43#include <interactive_markers/tools.hpp>
45#include <rviz_common/display_context.hpp>
46#include <rviz_common/frame_manager_iface.hpp>
47#include <rviz_common/window_manager_interface.hpp>
49#include <tf2_eigen/tf2_eigen.hpp>
50#include <geometric_shapes/shape_operations.h>
53#include <QInputDialog>
56#include "ui_motion_planning_rviz_plugin_frame.h"
62 QString status_text =
"\nIt has the subframes '";
63 for (
const auto& subframe : subframes)
65 status_text += QString::fromStdString(subframe.first) +
"', '";
76void MotionPlanningFrame::shapesComboBoxChanged(
const QString& )
78 switch (
ui_->shapes_combo_box->currentData().toInt())
81 ui_->shape_size_x_spin_box->setEnabled(
true);
82 ui_->shape_size_y_spin_box->setEnabled(
true);
83 ui_->shape_size_z_spin_box->setEnabled(
true);
86 ui_->shape_size_x_spin_box->setEnabled(
true);
87 ui_->shape_size_y_spin_box->setEnabled(
false);
88 ui_->shape_size_z_spin_box->setEnabled(
false);
90 case shapes::CYLINDER:
92 ui_->shape_size_x_spin_box->setEnabled(
true);
93 ui_->shape_size_y_spin_box->setEnabled(
false);
94 ui_->shape_size_z_spin_box->setEnabled(
true);
97 ui_->shape_size_x_spin_box->setEnabled(
false);
98 ui_->shape_size_y_spin_box->setEnabled(
false);
99 ui_->shape_size_z_spin_box->setEnabled(
false);
106void MotionPlanningFrame::setLocalSceneEdited(
bool dirty)
108 ui_->publish_current_scene_button->setEnabled(dirty);
111bool MotionPlanningFrame::isLocalSceneDirty()
const
113 return ui_->publish_current_scene_button->isEnabled();
116void MotionPlanningFrame::publishScene()
121 moveit_msgs::msg::PlanningScene msg;
122 ps->getPlanningSceneMsg(msg);
123 planning_scene_publisher_->publish(msg);
124 setLocalSceneEdited(
false);
128void MotionPlanningFrame::publishSceneIfNeeded()
130 if (isLocalSceneDirty() &&
131 QMessageBox::question(
this,
"Update PlanningScene",
132 "You have local changes to your planning scene.\n"
133 "Publish them to the move_group node?",
134 QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes)
138void MotionPlanningFrame::clearScene()
143 ps->getWorldNonConst()->clearObjects();
144 ps->getCurrentStateNonConst().clearAttachedBodies();
145 moveit_msgs::msg::PlanningScene msg;
146 ps->getPlanningSceneMsg(msg);
147 planning_scene_publisher_->publish(msg);
148 setLocalSceneEdited(
false);
154void MotionPlanningFrame::sceneScaleChanged(
int value)
156 const double scaling_factor =
static_cast<double>(value) / 100.0;
162 if (ps->getWorld()->hasObject(scaled_object_->id_))
164 ps->getWorldNonConst()->removeObject(scaled_object_->id_);
165 for (std::size_t i = 0; i < scaled_object_->shapes_.size(); ++i)
167 shapes::Shape* s = scaled_object_->shapes_[i]->clone();
168 s->scale(scaling_factor);
170 Eigen::Isometry3d scaled_shape_pose = scaled_object_->shape_poses_[i];
171 scaled_shape_pose.translation() *= scaling_factor;
173 ps->getWorldNonConst()->addToObject(scaled_object_->id_, scaled_object_->pose_, shapes::ShapeConstPtr(s),
177 for (
auto& subframe_pair : scaled_subframes)
178 subframe_pair.second.translation() *= scaling_factor;
180 ps->getWorldNonConst()->setSubframesOfObject(scaled_object_->id_, scaled_subframes);
181 setLocalSceneEdited();
182 scene_marker_->processMessage(createObjectMarkerMsg(ps->getWorld()->getObject(scaled_object_->id_)));
186 scaled_object_.reset();
189 scaled_object_.reset();
193void MotionPlanningFrame::sceneScaleStartChange()
195 QList<QListWidgetItem*> sel =
ui_->collision_objects_list->selectedItems();
203 scaled_object_ = ps->getWorld()->getObject(sel[0]->
text().toStdString());
204 scaled_object_subframes_ = scaled_object_->subframe_poses_;
205 scaled_object_shape_poses_ = scaled_object_->shape_poses_;
210void MotionPlanningFrame::sceneScaleEndChange()
212 scaled_object_.reset();
213 ui_->scene_scale->setSliderPosition(100);
216void MotionPlanningFrame::removeSceneObject()
218 QList<QListWidgetItem*> sel =
ui_->collision_objects_list->selectedItems();
224 for (
int i = 0; i < sel.count(); ++i)
226 if (sel[i]->checkState() == Qt::Unchecked)
228 ps->getWorldNonConst()->removeObject(sel[i]->
text().toStdString());
232 ps->getCurrentStateNonConst().clearAttachedBody(sel[i]->
text().toStdString());
236 setLocalSceneEdited();
244 QString status_text =
"'" + QString::fromStdString(obj->id_) +
"' is a collision object with ";
245 if (obj->shapes_.empty())
247 status_text +=
"no geometry";
251 std::vector<QString> shape_names;
252 for (
const shapes::ShapeConstPtr& shape : obj->shapes_)
253 shape_names.push_back(QString::fromStdString(
shapes::shapeStringName(shape.get())));
254 if (shape_names.size() == 1)
256 status_text +=
"one " + shape_names[0];
260 status_text += QString::fromStdString(std::to_string(shape_names.size())) +
" shapes:";
261 for (
const QString& shape_name : shape_names)
262 status_text +=
" " + shape_name;
266 if (!obj->subframe_poses_.empty())
268 status_text += subframePosesToQstring(obj->subframe_poses_);
275 QString status_text =
"'" + QString::fromStdString(attached_body->
getName()) +
"' is attached to '" +
279 status_text += subframePosesToQstring(attached_body->
getSubframes());
284void MotionPlanningFrame::selectedCollisionObjectChanged()
286 QList<QListWidgetItem*> sel =
ui_->collision_objects_list->selectedItems();
289 bool old_state =
ui_->object_x->blockSignals(
true);
290 ui_->object_x->setValue(0.0);
291 ui_->object_x->blockSignals(old_state);
293 old_state =
ui_->object_y->blockSignals(
true);
294 ui_->object_y->setValue(0.0);
295 ui_->object_y->blockSignals(old_state);
297 old_state =
ui_->object_z->blockSignals(
true);
298 ui_->object_z->setValue(0.0);
299 ui_->object_z->blockSignals(old_state);
301 old_state =
ui_->object_rx->blockSignals(
true);
302 ui_->object_rx->setValue(0.0);
303 ui_->object_rx->blockSignals(old_state);
305 old_state =
ui_->object_ry->blockSignals(
true);
306 ui_->object_ry->setValue(0.0);
307 ui_->object_ry->blockSignals(old_state);
309 old_state =
ui_->object_rz->blockSignals(
true);
310 ui_->object_rz->setValue(0.0);
311 ui_->object_rz->blockSignals(old_state);
313 ui_->object_status->setText(
"");
315 ui_->pose_scale_group_box->setEnabled(
false);
320 if (sel[0]->checkState() == Qt::Unchecked)
322 ui_->pose_scale_group_box->setEnabled(
true);
323 bool update_scene_marker =
false;
324 Eigen::Isometry3d obj_pose;
328 ps->getWorld()->getObject(sel[0]->
text().toStdString());
331 ui_->object_status->setText(decideStatusText(obj));
333 if (obj->shapes_.size() == 1)
335 obj_pose = obj->pose_;
336 Eigen::Vector3d xyz = obj_pose.linear().eulerAngles(0, 1, 2);
337 update_scene_marker =
true;
339 bool old_state =
ui_->object_x->blockSignals(
true);
340 ui_->object_x->setValue(obj_pose.translation()[0]);
341 ui_->object_x->blockSignals(old_state);
343 old_state =
ui_->object_y->blockSignals(
true);
344 ui_->object_y->setValue(obj_pose.translation()[1]);
345 ui_->object_y->blockSignals(old_state);
347 old_state =
ui_->object_z->blockSignals(
true);
348 ui_->object_z->setValue(obj_pose.translation()[2]);
349 ui_->object_z->blockSignals(old_state);
351 old_state =
ui_->object_rx->blockSignals(
true);
352 ui_->object_rx->setValue(xyz[0]);
353 ui_->object_rx->blockSignals(old_state);
355 old_state =
ui_->object_ry->blockSignals(
true);
356 ui_->object_ry->setValue(xyz[1]);
357 ui_->object_ry->blockSignals(old_state);
359 old_state =
ui_->object_rz->blockSignals(
true);
360 ui_->object_rz->setValue(xyz[2]);
361 ui_->object_rz->blockSignals(old_state);
365 ui_->object_status->setText(
"ERROR: '" + sel[0]->
text() +
"' should be a collision object but it is not");
367 if (update_scene_marker &&
ui_->tabWidget->tabText(
ui_->tabWidget->currentIndex()).toStdString() == TAB_OBJECTS)
369 createSceneInteractiveMarker();
374 ui_->pose_scale_group_box->setEnabled(
false);
379 ps->getCurrentState().getAttachedBody(sel[0]->
text().toStdString());
382 ui_->object_status->setText(decideStatusText(attached_body));
386 ui_->object_status->setText(
"ERROR: '" + sel[0]->
text() +
"' should be an attached object but it is not");
392void MotionPlanningFrame::objectPoseValueChanged(
double )
394 updateCollisionObjectPose(
true);
397void MotionPlanningFrame::updateCollisionObjectPose(
bool update_marker_position)
399 QList<QListWidgetItem*> sel =
ui_->collision_objects_list->selectedItems();
409 p.translation()[0] =
ui_->object_x->value();
410 p.translation()[1] =
ui_->object_y->value();
411 p.translation()[2] =
ui_->object_z->value();
413 p = Eigen::Translation3d(p.translation()) *
414 (Eigen::AngleAxisd(
ui_->object_rx->value(), Eigen::Vector3d::UnitX()) *
415 Eigen::AngleAxisd(
ui_->object_ry->value(), Eigen::Vector3d::UnitY()) *
416 Eigen::AngleAxisd(
ui_->object_rz->value(), Eigen::Vector3d::UnitZ()));
418 ps->getWorldNonConst()->setObjectPose(obj->id_, p);
420 setLocalSceneEdited();
426 Eigen::Quaterniond eq(p.linear());
427 scene_marker_->setPose(Ogre::Vector3(
ui_->object_x->value(),
ui_->object_y->value(),
ui_->object_z->value()),
428 Ogre::Quaternion(eq.w(), eq.x(), eq.y(), eq.z()),
"");
434void MotionPlanningFrame::collisionObjectChanged(QListWidgetItem* item)
439 if (known_collision_objects_[item->type()].first != item->text().toStdString())
441 renameCollisionObject(item);
445 bool checked = item->checkState() == Qt::Checked;
446 if (known_collision_objects_[item->type()].second != checked)
447 attachDetachCollisionObject(item);
453void MotionPlanningFrame::imProcessFeedback(visualization_msgs::msg::InteractiveMarkerFeedback& feedback)
457 RCLCPP_ERROR_STREAM(logger_,
458 "Frame `" << feedback.header.frame_id <<
"` unknown doesn't exists in the planning scene");
460 Eigen::Isometry3d fixed_frame_t_scene_marker;
461 tf2::fromMsg(feedback.pose, fixed_frame_t_scene_marker);
462 Eigen::Isometry3d model_frame_t_scene_marker =
465 bool old_state =
ui_->object_x->blockSignals(
true);
466 ui_->object_x->setValue(model_frame_t_scene_marker.translation().x());
467 ui_->object_x->blockSignals(old_state);
469 old_state =
ui_->object_y->blockSignals(
true);
470 ui_->object_y->setValue(model_frame_t_scene_marker.translation().y());
471 ui_->object_y->blockSignals(old_state);
473 old_state =
ui_->object_z->blockSignals(
true);
474 ui_->object_z->setValue(model_frame_t_scene_marker.translation().z());
475 ui_->object_z->blockSignals(old_state);
477 Eigen::Vector3d xyz = model_frame_t_scene_marker.linear().eulerAngles(0, 1, 2);
479 old_state =
ui_->object_rx->blockSignals(
true);
480 ui_->object_rx->setValue(xyz[0]);
481 ui_->object_rx->blockSignals(old_state);
483 old_state =
ui_->object_ry->blockSignals(
true);
484 ui_->object_ry->setValue(xyz[1]);
485 ui_->object_ry->blockSignals(old_state);
487 old_state =
ui_->object_rz->blockSignals(
true);
488 ui_->object_rz->setValue(xyz[2]);
489 ui_->object_rz->blockSignals(old_state);
491 updateCollisionObjectPose(
false);
494void MotionPlanningFrame::copySelectedCollisionObject()
496 QList<QListWidgetItem*> sel =
ui_->collision_objects_list->selectedItems();
504 for (
const QListWidgetItem* item : sel)
506 std::string
name = item->text().toStdString();
512 name.insert(0,
"Copy of ");
513 if (ps->getWorld()->hasObject(name))
517 while (ps->getWorld()->hasObject(name + std::to_string(n)))
519 name += std::to_string(n);
521 ps->getWorldNonConst()->addToObject(name, obj->shapes_, obj->shape_poses_);
522 RCLCPP_DEBUG(logger_,
"Copied collision object to '%s'",
name.c_str());
524 setLocalSceneEdited();
528void MotionPlanningFrame::computeSaveSceneButtonClicked()
532 moveit_msgs::msg::PlanningScene msg;
539 catch (std::exception& ex)
541 RCLCPP_ERROR(logger_,
"%s", ex.what());
548void MotionPlanningFrame::computeSaveQueryButtonClicked(
const std::string& scene,
const std::string& query_name)
550 moveit_msgs::msg::MotionPlanRequest mreq;
556 if (!query_name.empty())
560 catch (std::exception& ex)
562 RCLCPP_ERROR(logger_,
"%s", ex.what());
569void MotionPlanningFrame::computeDeleteSceneButtonClicked()
573 QList<QTreeWidgetItem*> sel =
ui_->planning_scene_tree->selectedItems();
576 QTreeWidgetItem* s = sel.front();
579 std::string scene = s->text(0).toStdString();
584 catch (std::exception& ex)
586 RCLCPP_ERROR(logger_,
"%s", ex.what());
592 std::string scene = s->parent()->text(0).toStdString();
597 catch (std::exception& ex)
599 RCLCPP_ERROR(logger_,
"%s", ex.what());
607void MotionPlanningFrame::computeDeleteQueryButtonClicked()
611 QList<QTreeWidgetItem*> sel =
ui_->planning_scene_tree->selectedItems();
614 QTreeWidgetItem* s = sel.front();
617 std::string scene = s->parent()->text(0).toStdString();
618 std::string query_name = s->text(0).toStdString();
623 catch (std::exception& ex)
625 RCLCPP_ERROR(logger_,
"%s", ex.what());
633void MotionPlanningFrame::computeDeleteQueryButtonClickedHelper(QTreeWidgetItem* s)
635 ui_->planning_scene_tree->setUpdatesEnabled(
false);
636 s->parent()->removeChild(s);
637 ui_->planning_scene_tree->setUpdatesEnabled(
true);
640void MotionPlanningFrame::checkPlanningSceneTreeEnabledButtons()
642 QList<QTreeWidgetItem*> sel =
ui_->planning_scene_tree->selectedItems();
645 ui_->load_scene_button->setEnabled(
false);
646 ui_->load_query_button->setEnabled(
false);
647 ui_->save_query_button->setEnabled(
false);
648 ui_->delete_scene_button->setEnabled(
false);
652 ui_->save_query_button->setEnabled(
true);
654 QTreeWidgetItem* s = sel.front();
659 ui_->load_scene_button->setEnabled(
true);
660 ui_->load_query_button->setEnabled(
false);
661 ui_->delete_scene_button->setEnabled(
true);
662 ui_->delete_query_button->setEnabled(
false);
663 ui_->save_query_button->setEnabled(
true);
668 ui_->load_scene_button->setEnabled(
false);
669 ui_->load_query_button->setEnabled(
true);
670 ui_->delete_scene_button->setEnabled(
false);
671 ui_->delete_query_button->setEnabled(
true);
676void MotionPlanningFrame::computeLoadSceneButtonClicked()
680 QList<QTreeWidgetItem*> sel =
ui_->planning_scene_tree->selectedItems();
683 QTreeWidgetItem* s = sel.front();
686 std::string scene = s->text(0).toStdString();
687 RCLCPP_DEBUG(logger_,
"Attempting to load scene '%s'", scene.c_str());
695 catch (std::exception& ex)
697 RCLCPP_ERROR(logger_,
"%s", ex.what());
702 RCLCPP_INFO(logger_,
"Loaded scene '%s'", scene.c_str());
708 "Scene '%s' was saved for robot '%s' but we are using robot '%s'. Using scene geometry only",
709 scene.c_str(), scene_m->robot_model_name.c_str(),
711 planning_scene_world_publisher_->publish(scene_m->world);
713 moveit_msgs::msg::PlanningScene diff;
715 diff.name = scene_m->name;
716 planning_scene_publisher_->publish(diff);
719 planning_scene_publisher_->publish(
static_cast<const moveit_msgs::msg::PlanningScene&
>(*scene_m));
722 planning_scene_publisher_->publish(
static_cast<const moveit_msgs::msg::PlanningScene&
>(*scene_m));
726 RCLCPP_WARN(logger_,
"Failed to load scene '%s'. Has the message format changed since the scene was saved?",
734void MotionPlanningFrame::computeLoadQueryButtonClicked()
738 QList<QTreeWidgetItem*> sel =
ui_->planning_scene_tree->selectedItems();
741 QTreeWidgetItem* s = sel.front();
744 std::string scene = s->parent()->text(0).toStdString();
745 std::string query_name = s->text(0).toStdString();
753 catch (std::exception& ex)
755 RCLCPP_ERROR(logger_,
"%s", ex.what());
760 moveit::core::RobotStatePtr start_state(
763 mp->start_state, *start_state);
767 for (
const moveit_msgs::msg::Constraints& goal_constraint : mp->goal_constraints)
769 if (!goal_constraint.joint_constraints.empty())
771 std::map<std::string, double> vals;
772 for (
const moveit_msgs::msg::JointConstraint& joint_constraint : goal_constraint.joint_constraints)
773 vals[joint_constraint.joint_name] = joint_constraint.position;
774 goal_state->setVariablePositions(vals);
782 RCLCPP_ERROR(logger_,
783 "Failed to load planning query '%s'. Has the message format changed since the query was saved?",
791visualization_msgs::msg::InteractiveMarker
794 Eigen::Vector3d center;
796 shapes::computeShapeBoundingSphere(obj->shapes_[0].get(), center, scale);
797 geometry_msgs::msg::PoseStamped shape_pose = tf2::toMsg(tf2::Stamped<Eigen::Isometry3d>(
803 scale = (scale + center.cwiseAbs().maxCoeff()) * 2.0 * 1.2;
806 visualization_msgs::msg::InteractiveMarker imarker =
808 imarker.description = obj->id_;
809 interactive_markers::autoComplete(imarker);
813void MotionPlanningFrame::createSceneInteractiveMarker()
815 QList<QListWidgetItem*> sel =
ui_->collision_objects_list->selectedItems();
824 ps->getWorld()->getObject(sel[0]->
text().toStdString());
825 if (obj && obj->shapes_.size() == 1)
827 scene_marker_ = std::make_shared<rviz_default_plugins::displays::InteractiveMarker>(
833 connect(
scene_marker_.get(), SIGNAL(userFeedback(visualization_msgs::msg::InteractiveMarkerFeedback&)),
this,
834 SLOT(imProcessFeedback(visualization_msgs::msg::InteractiveMarkerFeedback&)));
842void MotionPlanningFrame::renameCollisionObject(QListWidgetItem* item)
844 long unsigned int version = known_collision_objects_version_;
845 if (item->text().isEmpty())
847 QMessageBox::warning(
this,
"Invalid object name",
"Cannot set an empty object name.");
848 if (version == known_collision_objects_version_)
849 item->setText(QString::fromStdString(known_collision_objects_[item->type()].first));
853 std::string item_text = item->text().toStdString();
859 QMessageBox::warning(
this,
"Duplicate object name",
860 QString(
"The name '")
862 .append(
"' already exists. Not renaming object ")
863 .append((known_collision_objects_[item->type()].first.c_str())));
864 if (version == known_collision_objects_version_)
865 item->setText(QString::fromStdString(known_collision_objects_[item->type()].first));
869 if (item->checkState() == Qt::Unchecked)
873 ps->getWorld()->getObject(known_collision_objects_[item->type()].first);
876 known_collision_objects_[item->type()].first = item_text;
877 ps->getWorldNonConst()->removeObject(obj->id_);
878 ps->getWorldNonConst()->addToObject(known_collision_objects_[item->type()].first, obj->pose_, obj->shapes_,
880 ps->getWorldNonConst()->setSubframesOfObject(obj->id_, obj->subframe_poses_);
896 known_collision_objects_[item->type()].first = item_text;
897 auto new_ab = std::make_unique<moveit::core::AttachedBody>(
904 setLocalSceneEdited();
907void MotionPlanningFrame::attachDetachCollisionObject(QListWidgetItem* item)
909 long unsigned int version = known_collision_objects_version_;
910 bool checked = item->checkState() == Qt::Checked;
911 std::pair<std::string, bool> data = known_collision_objects_[item->type()];
912 moveit_msgs::msg::AttachedCollisionObject aco;
918 for (
const std::string& link : links_std)
919 links.
append(QString::fromStdString(link));
922 QInputDialog::getItem(
this, tr(
"Select Link Name"), tr(
"Choose the link to attach to:"), links, 0,
false, &ok);
925 if (version == known_collision_objects_version_)
926 item->setCheckState(Qt::Unchecked);
929 aco.link_name = response.toStdString();
930 aco.object.id = data.first;
931 aco.object.operation = moveit_msgs::msg::CollisionObject::ADD;
940 aco.object.id = attached_body->
getName();
941 aco.object.operation = moveit_msgs::msg::CollisionObject::REMOVE;
949 for (std::pair<std::string, bool>& known_collision_object : known_collision_objects_)
951 if (known_collision_object.first == data.first)
953 known_collision_object.second = checked;
957 ps->processAttachedCollisionObjectMsg(aco);
958 rs = ps->getCurrentState();
961 selectedCollisionObjectChanged();
962 setLocalSceneEdited();
967void MotionPlanningFrame::populateCollisionObjectsList()
969 ui_->collision_objects_list->setUpdatesEnabled(
false);
970 bool old_state =
ui_->collision_objects_list->blockSignals(
true);
971 bool octomap_in_scene =
false;
974 QList<QListWidgetItem*> sel =
ui_->collision_objects_list->selectedItems();
975 std::set<std::string> to_select;
976 for (QListWidgetItem* item : sel)
977 to_select.insert(item->
text().toStdString());
978 ui_->collision_objects_list->clear();
979 known_collision_objects_.clear();
980 known_collision_objects_version_++;
985 const std::vector<std::string>& collision_object_names = ps->getWorld()->getObjectIds();
986 for (std::size_t i = 0; i < collision_object_names.size(); ++i)
990 octomap_in_scene =
true;
994 QListWidgetItem* item =
new QListWidgetItem(QString::fromStdString(collision_object_names[i]),
995 ui_->collision_objects_list,
static_cast<int>(i));
996 item->setFlags(item->flags() | Qt::ItemIsEditable);
997 item->setToolTip(item->text());
998 item->setCheckState(Qt::Unchecked);
999 if (to_select.find(collision_object_names[i]) != to_select.end())
1000 item->setSelected(
true);
1001 ui_->collision_objects_list->addItem(item);
1002 known_collision_objects_.push_back(std::make_pair(collision_object_names[i],
false));
1006 std::vector<const moveit::core::AttachedBody*> attached_bodies;
1008 for (std::size_t i = 0; i < attached_bodies.size(); ++i)
1010 QListWidgetItem* item =
1011 new QListWidgetItem(QString::fromStdString(attached_bodies[i]->getName()),
ui_->collision_objects_list,
1012 static_cast<int>(i + collision_object_names.size()));
1013 item->setFlags(item->flags() | Qt::ItemIsEditable);
1014 item->setToolTip(item->text());
1015 item->setCheckState(Qt::Checked);
1016 if (to_select.find(attached_bodies[i]->getName()) != to_select.end())
1017 item->setSelected(
true);
1018 ui_->collision_objects_list->addItem(item);
1019 known_collision_objects_.push_back(std::make_pair(attached_bodies[i]->getName(),
true));
1024 ui_->clear_octomap_button->setEnabled(octomap_in_scene);
1025 ui_->collision_objects_list->blockSignals(old_state);
1026 ui_->collision_objects_list->setUpdatesEnabled(
true);
1027 selectedCollisionObjectChanged();
1030void MotionPlanningFrame::exportGeometryAsTextButtonClicked()
1033 QFileDialog::getSaveFileName(
this, tr(
"Export Scene Geometry"), tr(
""), tr(
"Scene Geometry (*.scene)"));
1034 if (!path.isEmpty())
1041void MotionPlanningFrame::computeExportGeometryAsText(
const std::string& path)
1046 std::string p = (path.length() < 7 || path.substr(path.length() - 6) !=
".scene") ? path +
".scene" : path;
1047 std::ofstream fout(p.c_str());
1050 ps->saveGeometryToStream(fout);
1052 RCLCPP_INFO(logger_,
"Saved current scene geometry to '%s'", p.c_str());
1055 RCLCPP_WARN(logger_,
"Unable to save current scene geometry to '%s'", p.c_str());
1059void MotionPlanningFrame::computeImportGeometryFromText(
const std::string& path)
1064 std::ifstream fin(path.c_str());
1065 if (ps->loadGeometryFromStream(fin))
1067 RCLCPP_INFO(logger_,
"Loaded scene geometry from '%s'", path.c_str());
1070 setLocalSceneEdited();
1074 QMessageBox::warning(
nullptr,
"Loading scene geometry",
1075 "Failed to load scene geometry.\n"
1076 "See console output for more details.");
1081void MotionPlanningFrame::importGeometryFromTextButtonClicked()
1084 QFileDialog::getOpenFileName(
this, tr(
"Import Scene Geometry"), tr(
""), tr(
"Scene Geometry (*.scene)"));
1085 if (!path.isEmpty())
1088 "import from text");
World::ObjectConstPtr ObjectConstPtr
Object defining bodies that can be attached to robot links.
const Eigen::Isometry3d & getPose() const
Get the pose of the attached body relative to the parent link.
const LinkModel * getAttachedLink() const
Get the model of the link this body is attached to.
const moveit::core::FixedTransformsMap & getSubframes() const
Get subframes of this object (relative to the object pose). The returned transforms are guaranteed to...
const std::set< std::string > & getTouchLinks() const
Get the links that the attached body is allowed to touch.
const EigenSTL::vector_Isometry3d & getShapePoses() const
Get the shape poses (the transforms to the shapes of this body, relative to the pose)....
const std::string & getName() const
Get the name of the attached body.
const std::string & getAttachedLinkName() const
Get the name of the link this body is attached to.
const std::vector< shapes::ShapeConstPtr > & getShapes() const
Get the shapes that make up this attached body.
const trajectory_msgs::msg::JointTrajectory & getDetachPosture() const
Return the posture that is necessary for the object to be released, (if any). This is useful for exam...
Representation of a robot's state. This includes position, velocity, acceleration and effort.
void attachBody(std::unique_ptr< AttachedBody > attached_body)
Add an attached body to this state.
void getAttachedBodies(std::vector< const AttachedBody * > &attached_bodies) const
Get all bodies attached to the model corresponding to this state.
bool clearAttachedBody(const std::string &id)
Remove the attached body named id. Return false if the object was not found (and thus not removed)....
const AttachedBody * getAttachedBody(const std::string &name) const
Get the attached body named name. Return nullptr if not found.
void setQueryGoalState(const moveit::core::RobotState &goal)
void setQueryStartState(const moveit::core::RobotState &start)
void updateQueryStates(const moveit::core::RobotState ¤t_state)
moveit::core::RobotStateConstPtr getQueryStartState() const
moveit::core::RobotStateConstPtr getQueryGoalState() const
moveit_warehouse::PlanningSceneStoragePtr planning_scene_storage_
static const int ITEM_TYPE_SCENE
std::shared_ptr< rviz_default_plugins::displays::InteractiveMarker > scene_marker_
rviz_common::DisplayContext * context_
Ui::MotionPlanningUI * ui_
static const int ITEM_TYPE_QUERY
void constructPlanningRequest(moveit_msgs::msg::MotionPlanRequest &mreq)
MotionPlanningDisplay * planning_display_
planning_scene_monitor::LockedPlanningSceneRO getPlanningSceneRO() const
get read-only access to planning scene
planning_scene_monitor::LockedPlanningSceneRW getPlanningSceneRW()
get write access to planning scene
void addMainLoopJob(const std::function< void()> &job)
queue the execution of this function for the next time the main update() loop gets called
const moveit::core::RobotModelConstPtr & getRobotModel() const
void addBackgroundJob(const std::function< void()> &job, const std::string &name)
void queueRenderSceneGeometry()
const planning_scene_monitor::PlanningSceneMonitorPtr & getPlanningSceneMonitor()
static const std::string OCTOMAP_NS
This is a convenience class for obtaining access to an instance of a locked PlanningScene.
This is a convenience class for obtaining access to an instance of a locked PlanningScene.
std::map< std::string, Eigen::Isometry3d, std::less< std::string >, Eigen::aligned_allocator< std::pair< const std::string, Eigen::Isometry3d > > > FixedTransformsMap
Map frame names to the transformation matrix that can transform objects from the frame name to the pl...
bool robotStateMsgToRobotState(const Transforms &tf, const moveit_msgs::msg::RobotState &robot_state, RobotState &state, bool copy_attached_bodies=true)
Convert a robot state msg (with accompanying extra transforms) to a MoveIt robot state.
warehouse_ros::MessageWithMetadata< moveit_msgs::msg::PlanningScene >::ConstPtr PlanningSceneWithMetadata
warehouse_ros::MessageWithMetadata< moveit_msgs::msg::MotionPlanRequest >::ConstPtr MotionPlanRequestWithMetadata
std::string append(const std::string &left, const std::string &right)
visualization_msgs::msg::InteractiveMarker make6DOFMarker(const std::string &name, const geometry_msgs::msg::PoseStamped &stamped, double scale, bool orientation_fixed=false)