remote_task_model.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2017, Bielefeld University
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Bielefeld University nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Robert Haschke */
36 
37 #include <stdio.h>
38 
39 #include "remote_task_model.h"
42 #include <moveit/task_constructor/properties.h>
44 #include <moveit_task_constructor_msgs/GetSolution.h>
47 #include <ros/console.h>
48 
49 #include <QApplication>
50 #include <QPalette>
51 #include <qglobal.h>
52 
53 using namespace moveit::task_constructor;
54 
55 namespace moveit_rviz_plugin {
56 
58 {
59  WAS_VISITED = 0x01, // indicate that model should emit change notifications
60  NAME_CHANGED = 0x02, // indicate that name was manually changed
61 };
62 using NodeFlags = QFlags<NodeFlag>;
63 
65 {
67  std::vector<std::unique_ptr<Node>> children_;
68  QString name_;
71  std::unique_ptr<RemoteSolutionModel> solutions_;
72  std::unique_ptr<rviz::PropertyTreeModel> property_tree_;
73  std::map<std::string, Property> properties_;
74 
75  inline Node(Node* parent) : parent_(parent) {
76  solutions_.reset(new RemoteSolutionModel());
77  property_tree_.reset(new rviz::PropertyTreeModel(new rviz::Property()));
78  }
79 
80  bool setName(const QString& name) {
81  if (name == name_)
82  return false;
83  name_ = name;
84  return true;
85  }
86 
87  void setProperties(const std::vector<moveit_task_constructor_msgs::Property>& props,
88  const planning_scene::PlanningSceneConstPtr& scene_, rviz::DisplayContext* display_context_);
89  rviz::Property* createProperty(const moveit_task_constructor_msgs::Property& prop, rviz::Property* old,
90  const planning_scene::PlanningSceneConstPtr& scene_,
91  rviz::DisplayContext* display_context_);
92 };
93 
94 void RemoteTaskModel::Node::setProperties(const std::vector<moveit_task_constructor_msgs::Property>& props,
95  const planning_scene::PlanningSceneConstPtr& scene_,
96  rviz::DisplayContext* display_context_) {
97  // insert properties in same order as reported in description
98  rviz::Property* root = property_tree_->getRoot();
99  int index = 0; // current child index in root
100  for (const auto& prop : props) {
101  int num = root->numChildren();
102  // find first child with name >= it->name
103  int next = index;
104  while (next < num && root->childAt(next)->getName().toStdString() < prop.name)
105  ++next;
106  // and remove all children in range [index, next) at once
107  root->removeChildren(index, next - index);
108  num = root->numChildren();
109 
110  // if names differ, insert a new child, otherwise reuse existing
111  rviz::Property* old_child = index < num ? root->childAt(index) : nullptr;
112  if (old_child && old_child->getName().toStdString() != prop.name)
113  old_child = nullptr;
114 
115  rviz::Property* new_child = createProperty(prop, old_child, scene_, display_context_);
116  if (new_child != old_child)
117  root->addChild(new_child, index);
118  ++index;
119  }
120  // remove remaining children
121  root->removeChildren(index, root->numChildren() - index);
122 }
123 
124 rviz::Property* RemoteTaskModel::Node::createProperty(const moveit_task_constructor_msgs::Property& prop,
125  rviz::Property* old,
126  const planning_scene::PlanningSceneConstPtr& scene_,
127  rviz::DisplayContext* display_context_) {
128  auto& factory = PropertyFactory::instance();
129  // try to deserialize from msg (using registered functions)
130  boost::any value = Property::deserialize(prop.type, prop.value);
131  if (!value.empty()) { // if successful, create rviz::Property from mtc::Property using factory methods
132  auto it = properties_.insert(std::make_pair(prop.name, Property())).first;
133  it->second.setDescription(prop.description);
134  it->second.setValue(value);
135  if (rviz::Property* rviz_prop = factory.create(prop.name, it->second, scene_.get(), display_context_)) {
136  rviz_prop->setReadOnly(true);
137  return rviz_prop;
138  } else
139  properties_.erase(it);
140  }
141 
142  // otherwise create default, read-only rviz::Property by parsing serialized YAML
143  return factory.createDefault(prop.name, prop.type, prop.description, prop.value, old);
144 }
145 
146 // return Node* corresponding to index
147 RemoteTaskModel::Node* RemoteTaskModel::node(const QModelIndex& index) const {
148  if (!index.isValid())
149  return root_;
150 
151  if (index.model() != this) {
152  ROS_ERROR_NAMED("TaskModel", "invalid model in QModelIndex");
153  return nullptr;
154  }
155 
156  // internal pointer refers to parent node
157  Node* parent = static_cast<Node*>(index.internalPointer());
158  Q_ASSERT(index.row() >= 0 && static_cast<size_t>(index.row()) < parent->children_.size());
159  return parent->children_.at(index.row()).get();
160 }
161 
162 // return Node* corresponding to stage_id
163 RemoteTaskModel::Node* RemoteTaskModel::node(uint32_t stage_id) const {
164  auto it = id_to_stage_.find(stage_id);
165  return (it == id_to_stage_.end()) ? nullptr : it->second;
166 }
167 
168 // return QModelIndex corresponding to Node*
169 QModelIndex RemoteTaskModel::index(const Node* n) const {
170  if (n == root_)
171  return QModelIndex();
172 
173  Node* parent = n->parent_;
174 
175  // the internal pointer refers to the parent node of n
176  for (int row = 0, end = parent->children_.size(); row != end; ++row)
177  if (parent->children_.at(row).get() == n)
178  return createIndex(row, 0, parent);
179  Q_ASSERT(false);
180  return QModelIndex();
181 }
182 
183 RemoteTaskModel::RemoteTaskModel(ros::NodeHandle& nh, const std::string& service_name,
184  const planning_scene::PlanningSceneConstPtr& scene,
185  rviz::DisplayContext* display_context, QObject* parent)
186  : BaseTaskModel(scene, display_context, parent), root_(new Node(nullptr)) {
187  id_to_stage_[0] = root_; // root node has ID 0
188  // service to request solutions
189  get_solution_client_ = nh.serviceClient<moveit_task_constructor_msgs::GetSolution>(service_name);
190 }
191 
193  delete root_;
194 }
195 
196 int RemoteTaskModel::rowCount(const QModelIndex& parent) const {
197  if (parent.column() > 0)
198  return 0;
199 
200  Node* n = node(parent);
201  if (!n)
202  return 0; // invalid model in parent
203 
204  return n->children_.size();
205 }
206 
207 QModelIndex RemoteTaskModel::index(int row, int column, const QModelIndex& parent) const {
208  if (column < 0 || column >= columnCount())
209  return QModelIndex();
210 
211  Node* p = node(parent);
212  if (!p || row < 0 || static_cast<size_t>(row) >= p->children_.size())
213  return QModelIndex();
214 
215  p->children_[row]->node_flags_ |= WAS_VISITED;
216  // the internal pointer refers to the parent node
217  return createIndex(row, column, p);
218 }
219 
220 QModelIndex RemoteTaskModel::parent(const QModelIndex& child) const {
221  if (!child.isValid())
222  return QModelIndex();
223 
224  // the internal pointer refers to the parent node
225  Node* p = static_cast<Node*>(child.internalPointer());
226  Q_ASSERT(p);
227  if (child.model() != this || p == root_)
228  return QModelIndex();
229 
230  return this->index(p);
231 }
232 
233 QVariant RemoteTaskModel::data(const QModelIndex& index, int role) const {
234  Node* n = node(index);
235  if (!n)
236  return QVariant(); // invalid model in index
237 
238  switch (role) {
239  case Qt::EditRole:
240  case Qt::DisplayRole:
241  switch (index.column()) {
242  case 0:
243  return n->name_;
244  case 1:
245  return n->solutions_->numSuccessful();
246  case 2:
247  return n->solutions_->numFailed();
248  case 3:
249  return QLocale().toString(n->solutions_->totalComputeTime(), 'f', 4);
250  }
251  break;
252  case Qt::ForegroundRole:
253  if (index.column() == 0 && !index.parent().isValid())
254  return (flags_ & IS_DESTROYED) ? QColor(Qt::red) : QApplication::palette().text().color();
255  break;
256  case Qt::DecorationRole:
257  if (index.column() == 0 && index.parent().isValid())
258  return flowIcon(n->interface_flags_);
259  break;
260  }
261 
262  return BaseTaskModel::data(index, role);
263 }
264 
265 bool RemoteTaskModel::setData(const QModelIndex& index, const QVariant& value, int role) {
266  Node* n = node(index);
267  if (!n || index.column() != 0 || role != Qt::EditRole)
268  return false;
269  n->setName(value.toString());
271  dataChanged(index, index);
272  return true;
273 }
274 
275 QModelIndex RemoteTaskModel::indexFromStageId(size_t id) const {
276  Node* n = node(id);
277  return n ? index(n) : QModelIndex();
278 }
279 
280 void RemoteTaskModel::processStageDescriptions(const moveit_task_constructor_msgs::TaskDescription::_stages_type& msg) {
281  // iterate over descriptions and create new / update existing nodes where needed
282  for (const auto& s : msg) {
283  // find parent node for stage s, this should always exist
284  auto parent_it = id_to_stage_.find(s.parent_id);
285  if (parent_it == id_to_stage_.end()) {
286  ROS_ERROR_NAMED("TaskListModel", "No parent found for stage %d (%s)", s.id, s.name.c_str());
287  continue;
288  }
289  Node* parent = parent_it->second;
290 
291  Node*& n = id_to_stage_[s.id];
292  if (!n) { // create a new Node if neccessary
293  // only emit notify signal if parent node was ever visited
294  bool notify = parent->node_flags_ & WAS_VISITED;
295  QModelIndex parent_idx = index(parent);
296  int row = parent->children_.size();
297 
298  if (notify)
299  beginInsertRows(parent_idx, row, row);
300  parent->children_.push_back(std::make_unique<Node>(parent));
301  if (notify)
302  endInsertRows();
303 
304  // store Node* in id_to_stage_
305  n = parent->children_.back().get();
306  }
307  Q_ASSERT(n->parent_ == parent);
308 
309  // set content of stage
310  bool changed = false;
311  if (!(n->node_flags_ & NAME_CHANGED)) // avoid overwriting a manually changed name
312  changed |= n->setName(QString::fromStdString(s.name));
313 
314  n->setProperties(s.properties, scene_, display_context_);
315 
316  InterfaceFlags old_flags = n->interface_flags_;
319  if (s.flags & f)
320  n->interface_flags_ |= f;
321  else
322  n->interface_flags_ &= ~f;
323  }
324  changed |= (n->interface_flags_ != old_flags);
325 
326  // emit notify about model changes when node was already visited
327  if (changed && (n->node_flags_ & WAS_VISITED)) {
328  QModelIndex idx = index(n);
329  dataChanged(idx, idx.sibling(idx.row(), 2));
330  }
331  }
332 
333  if (msg.empty()) {
334  flags_ |= IS_DESTROYED;
335  dataChanged(index(0, 0), index(0, 2));
336  }
337 }
338 
339 void RemoteTaskModel::processStageStatistics(const moveit_task_constructor_msgs::TaskStatistics::_stages_type& msg) {
340  // iterate over statistics and update node's solutions where needed
341  for (const auto& s : msg) {
342  // find node for stage s, this should always exist
343  auto it = id_to_stage_.find(s.id);
344  if (it == id_to_stage_.end()) {
345  ROS_ERROR_NAMED("TaskListModel", "No stage %d", s.id);
346  continue;
347  }
348  Node* n = it->second;
349  n->solutions_->processSolutionIDs(s.solved, s.failed, s.num_failed, s.total_compute_time);
350 
351  // emit notify about model changes when node was already visited
352  if (n->node_flags_ & WAS_VISITED) {
353  QModelIndex idx = index(n);
354  dataChanged(idx.sibling(idx.row(), 1), idx.sibling(idx.row(), 3));
355  }
356  }
357 }
358 
359 void RemoteTaskModel::setSolutionData(const moveit_task_constructor_msgs::SolutionInfo& info) {
360  if (info.id == 0)
361  return;
362  if (RemoteSolutionModel* m = getSolutionModel(info.stage_id))
363  m->setSolutionData(info.id, info.cost, QString::fromStdString(info.comment));
364 }
365 
366 DisplaySolutionPtr RemoteTaskModel::processSolutionMessage(const moveit_task_constructor_msgs::Solution& msg) {
367  DisplaySolutionPtr s(new DisplaySolution);
368  s->setFromMessage(scene_->diff(), msg);
369 
370  // store sub solution data in model
371  for (const auto& sub : msg.sub_solution)
372  setSolutionData(sub.info);
373  for (const auto& sub : msg.sub_trajectory)
374  setSolutionData(sub.info);
375 
376  // caching is only enabled for top-level solutions (stage_id == 1)
377  // otherwise we would store PlanningScenes over and over
378  if (!msg.sub_solution.empty() && msg.sub_solution.front().info.stage_id == 1 &&
379  msg.sub_solution.front().info.id != 0) {
380  // cache solution for future use
381  id_to_solution_[msg.sub_solution.front().info.id] = s;
382 
383  // cache DisplaySolutions for all individual sub trajectories
384  uint i = 0;
385  for (const auto& t : msg.sub_trajectory) {
386  if (t.info.id == 0)
387  continue; // invalid id
388  DisplaySolutionPtr& sub =
389  id_to_solution_.insert(std::make_pair(t.info.id, DisplaySolutionPtr())).first->second;
390  if (!sub)
391  sub.reset(new DisplaySolution(*s, i));
392  i++;
393  }
394  }
395 
396  return s;
397 }
398 
400  Node* n = node(stage_id);
401  return n ? n->solutions_.get() : nullptr;
402 }
403 
404 QAbstractItemModel* RemoteTaskModel::getSolutionModel(const QModelIndex& index) {
405  Node* n = node(index);
406  if (!n)
407  return nullptr;
408  return n->solutions_.get();
409 }
410 
411 DisplaySolutionPtr RemoteTaskModel::getSolution(const QModelIndex& index) {
412  Q_ASSERT(index.isValid());
413 
414  uint32_t id = index.sibling(index.row(), 0).data(Qt::UserRole).toUInt();
415  auto it = id_to_solution_.find(id);
416  if (it == id_to_solution_.cend()) {
417  // TODO: try to assemble (and cache) the solution from known leaves
418  // to avoid some communication overhead
419 
420  DisplaySolutionPtr result;
421  if (!(flags_ & IS_DESTROYED)) {
422  // request solution via service
423  moveit_task_constructor_msgs::GetSolution srv;
424  srv.request.solution_id = id;
425  if (get_solution_client_.call(srv)) {
426  id_to_solution_[id] = result = processSolutionMessage(srv.response.solution);
427  return result;
428  }
429  // on failure mark remote task as destroyed: don't retrieve more solutions
431  flags_ |= IS_DESTROYED;
432  }
433  return result;
434  }
435  return it->second;
436 }
437 
439  Node* n = node(index);
440  if (!n)
441  return nullptr;
442  return n->property_tree_.get();
443 }
444 
445 namespace detail {
446 // method used by sorted_ container (requiring an additional dereference to access id)
447 template <class T>
448 typename T::iterator findById(T& c, decltype((*c.cbegin())->id) id) {
449  return std::find_if(c.begin(), c.end(), [id](const typename T::value_type& item) { return item->id == id; });
450 }
451 
452 // insert new Data item into data_ container
453 template <class T>
454 typename T::iterator insert(T& c, typename T::value_type&& item) {
455  auto p = std::equal_range(c.begin(), c.end(), item);
456  if (p.first == p.second) // new item
457  return c.insert(p.second, std::move(item));
458  else
459  return p.first;
460 }
461 } // namespace detail
462 
463 RemoteSolutionModel::RemoteSolutionModel(QObject* parent) : QAbstractTableModel(parent) {}
464 
465 int RemoteSolutionModel::rowCount(const QModelIndex& /*parent*/) const {
466  return sorted_.size();
467 }
468 
469 int RemoteSolutionModel::columnCount(const QModelIndex& /*parent*/) const {
470  return 3;
471 }
472 
473 QVariant RemoteSolutionModel::headerData(int section, Qt::Orientation orientation, int role) const {
474  if (orientation == Qt::Horizontal) {
475  switch (role) {
476  case Qt::DisplayRole:
477  switch (section) {
478  case 0:
479  return tr("#");
480  case 1:
481  return tr("cost");
482  case 2:
483  return tr("comment");
484  }
485  break;
486  case Qt::TextAlignmentRole:
487  return Qt::AlignLeft;
488  }
489  }
490  return QAbstractItemModel::headerData(section, orientation, role);
491 }
492 
493 QVariant RemoteSolutionModel::data(const QModelIndex& index, int role) const {
494  Q_ASSERT(index.isValid());
495  Q_ASSERT(!index.parent().isValid());
496 
497  const Data& item = *sorted_[index.row()];
498 
499  switch (role) {
500  case Qt::UserRole:
501  return item.id;
502 
503  case Qt::ToolTipRole:
504 #if 0 // show internal solution id in first column
505  if (index.column() == 0)
506  return item.id;
507 #endif
508  // usually just show the comment
509  return item.comment;
510  break;
511 
512  case Qt::DisplayRole:
513  switch (index.column()) {
514  case 0:
515  return item.creation_rank;
516  case 1:
517  if (std::isinf(item.cost))
518  return tr(u8"∞");
519  if (std::isnan(item.cost))
520  return QVariant();
521  return QLocale().toString(item.cost, 'f', 4);
522  case 2:
523  return item.comment;
524  }
525  break;
526 
527  case Qt::ForegroundRole:
528  if (std::isinf(item.cost))
529  return QColor(Qt::red);
530  break;
531 
532  case Qt::TextAlignmentRole:
533  return index.column() == 2 ? Qt::AlignLeft : Qt::AlignRight;
534  }
535  return QVariant();
536 }
537 
538 void RemoteSolutionModel::setSolutionData(uint32_t id, float cost, const QString& comment) {
539  // retrieve iterator and row corresponding to id
540  auto sit = detail::findById(sorted_, id);
541  int row = (sit != sorted_.end()) ? sit - sorted_.begin() : -1;
542  auto it = (sit != sorted_.end()) ? *sit : detail::insert(data_, Data(id, cost, 0, comment));
543 
544  QModelIndex tl, br;
545  Data& item = *it;
546  if (item.cost != cost) {
547  item.cost = cost;
548  tl = br = index(row, 1);
549  }
550  if (item.comment != comment) {
551  item.comment = comment;
552  br = index(row, 2);
553  if (!tl.isValid())
554  tl = br;
555  }
556  if (tl.isValid())
557  Q_EMIT dataChanged(tl, br);
558 
559  if (row < 0 && isVisible(*it)) // item was newly created: inform views
560  sortInternal();
561 }
562 
563 void RemoteSolutionModel::sort(int column, Qt::SortOrder order) {
564  if (sort_column_ == column && sort_order_ == order)
565  return; // nothing to do
566 
567  sort_column_ = column;
568  sort_order_ = order;
569 
570  sortInternal();
571 }
572 
574  Q_EMIT layoutAboutToBeChanged();
575  QModelIndexList old_indexes = persistentIndexList();
576  std::vector<DataList::iterator> old_sorted;
577  std::swap(sorted_, old_sorted);
578 
579  // create new order in sorted_
580  for (auto it = data_.begin(), end = data_.end(); it != end; ++it)
581  if (isVisible(*it))
582  sorted_.push_back(it);
583 
584  if (sort_column_ >= 0) {
585  std::sort(sorted_.begin(), sorted_.end(),
586  [this](const DataList::iterator& left, const DataList::iterator& right) {
587  int comp = 0;
588  switch (sort_column_) {
589  case 1: // cost order
590  if (left->cost_rank < right->cost_rank)
591  comp = -1;
592  else if (left->cost_rank > right->cost_rank)
593  comp = 1;
594  break;
595  case 2: // comment
596  comp = left->comment.compare(right->comment);
597  break;
598  }
599  if (comp == 0) // if still undecided, id decides
600  comp = (left->id < right->id ? -1 : 1);
601  return (sort_order_ == Qt::AscendingOrder) ? (comp < 0) : (comp >= 0);
602  });
603  }
604 
605  // map old indexes to new ones
606  std::map<int, int> old_to_new_row;
607  QModelIndexList new_indexes;
608  for (int i = 0, end = old_indexes.count(); i != end; ++i) {
609  int old_row = old_indexes[i].row();
610  auto it_inserted = old_to_new_row.insert(std::make_pair(old_row, -1));
611  if (it_inserted.second) { // newly inserted: find new row index
612  auto it = detail::findById(sorted_, old_sorted[old_row]->id);
613  if (it != sorted_.cend())
614  it_inserted.first->second = it - sorted_.begin();
615  }
616  new_indexes.append(index(it_inserted.first->second, old_indexes[i].column()));
617  }
618 
619  changePersistentIndexList(old_indexes, new_indexes);
620  Q_EMIT layoutChanged();
621 }
622 
623 // process solution ids received in stage statistics
624 void RemoteSolutionModel::processSolutionIDs(const std::vector<uint32_t>& successful,
625  const std::vector<uint32_t>& failed, size_t num_failed,
626  double total_compute_time) {
627  // append new items to the end of data_
628  processSolutionIDs(successful, true);
629  processSolutionIDs(failed, false);
630 
631  // assign consecutive creation ranks
632  uint32_t rank = 0;
633  for (auto& item : data_)
634  item.creation_rank = ++rank;
635 
636  // the task may not report failure ids (in failed),
637  // but it may report the overall number of failures
638  num_failed_data_ = failed.size(); // needed to compute number of successes
639  num_failed_ = std::max(num_failed, num_failed_data_);
640  total_compute_time_ = total_compute_time;
641 
642  sortInternal();
643 }
644 
645 void RemoteSolutionModel::processSolutionIDs(const std::vector<uint32_t>& ids, bool successful) {
646  // Interface axiom: ids are sorted by cost
647  // insert them into data_ list sorted by id
648  double default_cost =
649  successful ? std::numeric_limits<double>::quiet_NaN() : std::numeric_limits<double>::infinity();
650  uint32_t cost_rank = 0;
651  for (const uint32_t id : ids) {
652  uint32_t rank = successful ? ++cost_rank : std::numeric_limits<uint32_t>::max();
653  auto it = detail::insert(data_, Data(id, default_cost, rank));
654  Q_ASSERT(it->id == id);
655  it->cost_rank = rank;
656  }
657 }
658 
659 bool RemoteSolutionModel::isVisible(const RemoteSolutionModel::Data& item) const {
660  return std::isnan(item.cost) || item.cost <= max_cost_;
661 }
662 } // namespace moveit_rviz_plugin
WRITES_NEXT_START
WRITES_NEXT_START
moveit_rviz_plugin::RemoteSolutionModel::setSolutionData
void setSolutionData(uint32_t id, float cost, const QString &comment)
Definition: remote_task_model.cpp:538
moveit_rviz_plugin::RemoteSolutionModel::Data
Definition: remote_task_model.h:130
remote_task_model.h
moveit_rviz_plugin::RemoteTaskModel::Node::children_
std::vector< std::unique_ptr< Node > > children_
Definition: remote_task_model.cpp:67
moveit_rviz_plugin::RemoteTaskModel::Node::Node
Node(Node *parent)
Definition: remote_task_model.cpp:75
moveit_rviz_plugin::RemoteSolutionModel::sortInternal
void sortInternal()
Definition: remote_task_model.cpp:573
moveit_rviz_plugin::detail::findById
T::iterator findById(T &c, decltype((*c.cbegin()) ->id) id)
Definition: remote_task_model.cpp:448
rviz::PropertyTreeModel
s
XmlRpcServer s
moveit_rviz_plugin::RemoteTaskModel::Node::setProperties
void setProperties(const std::vector< moveit_task_constructor_msgs::Property > &props, const planning_scene::PlanningSceneConstPtr &scene_, rviz::DisplayContext *display_context_)
Definition: remote_task_model.cpp:94
moveit_rviz_plugin::RemoteTaskModel::Node::node_flags_
NodeFlags node_flags_
Definition: remote_task_model.cpp:70
moveit_rviz_plugin::detail::insert
T::iterator insert(T &c, typename T::value_type &&item)
Definition: remote_task_model.cpp:454
getName
ROSCONSOLE_CONSOLE_IMPL_DECL std::string getName(void *handle)
moveit_rviz_plugin::RemoteTaskModel::data
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: remote_task_model.cpp:233
moveit_rviz_plugin::RemoteSolutionModel::sort_order_
Qt::SortOrder sort_order_
Definition: remote_task_model.h:152
moveit::task_constructor::Property::deserialize
static boost::any deserialize(const std::string &type_name, const std::string &wire)
moveit_rviz_plugin::RemoteTaskModel::node
Node * node(const QModelIndex &index) const
Definition: remote_task_model.cpp:147
moveit_rviz_plugin::RemoteSolutionModel::sorted_
std::vector< DataList::iterator > sorted_
Definition: remote_task_model.h:154
moveit_rviz_plugin::RemoteTaskModel::Node::solutions_
std::unique_ptr< RemoteSolutionModel > solutions_
Definition: remote_task_model.cpp:71
ros::NodeHandle::serviceClient
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
moveit_rviz_plugin::RemoteTaskModel::Node::parent_
Node * parent_
Definition: remote_task_model.cpp:66
uint32_t
uint32_t
detail
moveit_rviz_plugin::RemoteTaskModel::get_solution_client_
ros::ServiceClient get_solution_client_
Definition: remote_task_model.h:89
moveit_rviz_plugin::DisplaySolution
Definition: display_solution.h:66
ROS_ERROR_NAMED
#define ROS_ERROR_NAMED(name,...)
moveit_rviz_plugin::BaseTaskModel::IS_DESTROYED
@ IS_DESTROYED
Definition: task_list_model.h:83
moveit_rviz_plugin::RemoteTaskModel::~RemoteTaskModel
~RemoteTaskModel() override
Definition: remote_task_model.cpp:192
moveit_rviz_plugin::BaseTaskModel
Definition: task_list_model.h:71
property_factory.h
moveit_rviz_plugin::RemoteSolutionModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: remote_task_model.cpp:465
moveit_rviz_plugin::RemoteTaskModel::Node::name_
QString name_
Definition: remote_task_model.cpp:68
moveit_rviz_plugin::WAS_VISITED
@ WAS_VISITED
Definition: remote_task_model.cpp:59
container.h
moveit_rviz_plugin::RemoteSolutionModel::Data::creation_rank
uint32_t creation_rank
Definition: remote_task_model.h:135
rviz::Property
moveit_rviz_plugin::RemoteSolutionModel::data_
DataList data_
Definition: remote_task_model.h:145
moveit_rviz_plugin::RemoteTaskModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: remote_task_model.cpp:196
moveit_rviz_plugin::RemoteTaskModel::getSolution
DisplaySolutionPtr getSolution(const QModelIndex &index) override
get solution for given solution index
Definition: remote_task_model.cpp:411
console.h
moveit_rviz_plugin::RemoteSolutionModel::Data::comment
QString comment
Definition: remote_task_model.h:134
moveit_rviz_plugin::NodeFlags
QFlags< NodeFlag > NodeFlags
Definition: remote_task_model.cpp:62
moveit_rviz_plugin::RemoteSolutionModel::RemoteSolutionModel
RemoteSolutionModel(QObject *parent=nullptr)
Definition: remote_task_model.cpp:463
moveit_rviz_plugin::BaseTaskModel::flowIcon
static QVariant flowIcon(moveit::task_constructor::InterfaceFlags f)
Definition: task_list_model.cpp:117
moveit_rviz_plugin::RemoteTaskModel::getPropertyModel
rviz::PropertyTreeModel * getPropertyModel(const QModelIndex &index) override
get property model for given stage index
Definition: remote_task_model.cpp:438
moveit_rviz_plugin::RemoteSolutionModel::Data::cost
double cost
Definition: remote_task_model.h:133
property_tree_model.h
c
c
moveit::task_constructor
WRITES_PREV_END
WRITES_PREV_END
ros::ServiceClient::shutdown
void shutdown()
value
float value
moveit_rviz_plugin::RemoteTaskModel::index
QModelIndex index(const Node *n) const
Definition: remote_task_model.cpp:169
next
EndPoint * next[3]
rviz::DisplayContext
moveit_rviz_plugin::BaseTaskModel::scene_
planning_scene::PlanningSceneConstPtr scene_
Definition: task_list_model.h:76
name
name
moveit::task_constructor::utils::Flags< InterfaceFlag >
moveit_rviz_plugin::RemoteTaskModel::Node::setName
bool setName(const QString &name)
Definition: remote_task_model.cpp:80
moveit_rviz_plugin::NAME_CHANGED
@ NAME_CHANGED
Definition: remote_task_model.cpp:60
moveit_rviz_plugin::RemoteSolutionModel::sort_column_
int sort_column_
Definition: remote_task_model.h:151
READS_START
READS_START
moveit_rviz_plugin
moveit_rviz_plugin::RemoteTaskModel::getSolutionModel
RemoteSolutionModel * getSolutionModel(uint32_t stage_id) const
Definition: remote_task_model.cpp:399
uint8_t
uint8_t
moveit_rviz_plugin::RemoteTaskModel::processStageDescriptions
void processStageDescriptions(const moveit_task_constructor_msgs::TaskDescription::_stages_type &msg)
Definition: remote_task_model.cpp:280
m
m
rviz::Property::getName
virtual QString getName() const
planning_scene.h
f
f
moveit_rviz_plugin::BaseTaskModel::display_context_
rviz::DisplayContext * display_context_
Definition: task_list_model.h:77
READS_END
READS_END
ros::ServiceClient::call
bool call(const MReq &req, MRes &resp, const std::string &service_md5sum)
moveit_rviz_plugin::RemoteTaskModel::indexFromStageId
QModelIndex indexFromStageId(size_t id) const override
retrieve model index associated with given stage id
Definition: remote_task_model.cpp:275
moveit_rviz_plugin::NodeFlag
NodeFlag
Definition: remote_task_model.cpp:57
moveit_rviz_plugin::BaseTaskModel::flags_
unsigned int flags_
Definition: task_list_model.h:75
moveit_rviz_plugin::RemoteTaskModel::id_to_solution_
std::map< uint32_t, DisplaySolutionPtr > id_to_solution_
Definition: remote_task_model.h:92
moveit_rviz_plugin::RemoteSolutionModel::isVisible
bool isVisible(const Data &item) const
Definition: remote_task_model.cpp:659
index
unsigned int index
moveit_rviz_plugin::RemoteTaskModel::root_
Node *const root_
Definition: remote_task_model.h:87
moveit::task_constructor::Property
moveit_rviz_plugin::RemoteTaskModel::Node::property_tree_
std::unique_ptr< rviz::PropertyTreeModel > property_tree_
Definition: remote_task_model.cpp:72
moveit_rviz_plugin::RemoteTaskModel::Node::interface_flags_
InterfaceFlags interface_flags_
Definition: remote_task_model.cpp:69
moveit_rviz_plugin::RemoteSolutionModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: remote_task_model.cpp:469
root
root
moveit_rviz_plugin::RemoteSolutionModel::sort
void sort(int column, Qt::SortOrder order) override
Definition: remote_task_model.cpp:563
string_property.h
moveit_rviz_plugin::RemoteSolutionModel::Data::id
uint32_t id
Definition: remote_task_model.h:132
moveit_rviz_plugin::RemoteTaskModel::Node
Definition: remote_task_model.cpp:64
moveit_rviz_plugin::RemoteTaskModel::setData
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition: remote_task_model.cpp:265
moveit_rviz_plugin::RemoteTaskModel::Node::properties_
std::map< std::string, Property > properties_
Definition: remote_task_model.cpp:73
t
dictionary t
moveit_rviz_plugin::RemoteTaskModel::processStageStatistics
void processStageStatistics(const moveit_task_constructor_msgs::TaskStatistics::_stages_type &msg)
Definition: remote_task_model.cpp:339
moveit_rviz_plugin::RemoteSolutionModel::data
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: remote_task_model.cpp:493
moveit_rviz_plugin::RemoteTaskModel::id_to_stage_
std::map< uint32_t, Node * > id_to_stage_
Definition: remote_task_model.h:91
moveit_rviz_plugin::RemoteTaskModel::processSolutionMessage
DisplaySolutionPtr processSolutionMessage(const moveit_task_constructor_msgs::Solution &msg)
Definition: remote_task_model.cpp:366
moveit_rviz_plugin::BaseTaskModel::columnCount
int columnCount(const QModelIndex &=QModelIndex()) const override
Definition: task_list_model.h:92
moveit_rviz_plugin::RemoteTaskModel::setSolutionData
void setSolutionData(const moveit_task_constructor_msgs::SolutionInfo &info)
Definition: remote_task_model.cpp:359
ros::NodeHandle
moveit_rviz_plugin::RemoteTaskModel::parent
QModelIndex parent(const QModelIndex &index) const override
Definition: remote_task_model.cpp:220
moveit_rviz_plugin::RemoteSolutionModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Definition: remote_task_model.cpp:473
moveit_rviz_plugin::RemoteSolutionModel
Definition: remote_task_model.h:127
moveit_rviz_plugin::BaseTaskModel::data
QVariant data(const QModelIndex &index, int role) const override
Definition: task_list_model.cpp:109


visualization
Author(s): Robert Haschke
autogenerated on Thu Feb 27 2025 03:39:51