43 #include <rviz_common/transformation/transformation_manager.hpp> 
   44 #include <rviz_default_plugins/robot/robot.hpp> 
   45 #include <rviz_default_plugins/robot/robot_link.hpp> 
   47 #include <rviz_common/properties/property.hpp> 
   48 #include <rviz_common/properties/bool_property.hpp> 
   49 #include <rviz_common/properties/float_property.hpp> 
   50 #include <rviz_common/properties/color_property.hpp> 
   51 #include <rviz_common/properties/enum_property.hpp> 
   52 #include <rviz_common/display_context.hpp> 
   53 #include <tf2_ros/buffer.h> 
   55 #include <OgreSceneManager.h> 
   56 #include <OgreSceneNode.h> 
   62 static const rclcpp::Logger 
LOGGER = rclcpp::get_logger(
"moveit_ros_visualization.planning_scene_display");
 
   67   : Display(), planning_scene_needs_render_(true), current_scene_time_(0.0f)
 
   70                                                                         "The name of the ROS namespace in " 
   71                                                                         "which the move_group node is running",
 
   72                                                                         this, SLOT(changedMoveGroupNS()), 
this);
 
   74       "Robot Description", 
"robot_description", 
"The name of the ROS parameter where the URDF for the robot is loaded",
 
   75       this, SLOT(changedRobotDescription()), 
this);
 
   77   if (listen_to_planning_scene)
 
   79         "Planning Scene Topic", 
"/monitored_planning_scene",
 
   80         rosidl_generator_traits::data_type<moveit_msgs::msg::PlanningScene>(),
 
   81         "The topic on which the moveit_msgs::msg::PlanningScene messages are received", 
this,
 
   82         SLOT(changedPlanningSceneTopic()), 
this);
 
   87   scene_category_ = 
new rviz_common::properties::Property(
"Scene Geometry", QVariant(), 
"", 
this);
 
   90       new rviz_common::properties::StringProperty(
"Scene Name", 
"(noname)", 
"Shows the name of the planning scene",
 
   94       new rviz_common::properties::BoolProperty(
"Show Scene Geometry", 
true,
 
   95                                                 "Indicates whether planning scenes should be displayed",
 
   99       new rviz_common::properties::FloatProperty(
"Scene Alpha", 0.9f, 
"Specifies the alpha for the scene geometry",
 
  105       "Scene Color", QColor(50, 230, 50), 
"The color for the planning scene obstacles (if a color is not defined)",
 
  109       new rviz_common::properties::EnumProperty(
"Voxel Rendering", 
"Occupied Voxels", 
"Select voxel type.",
 
  118       "Voxel Coloring", 
"Z-Axis", 
"Select voxel coloring mode", 
scene_category_, SLOT(changedOctreeColorMode()), 
this);
 
  124       new rviz_common::properties::FloatProperty(
"Scene Display Time", 0.01f,
 
  125                                                  "The amount of wall-time to wait in between rendering " 
  126                                                  "updates to the planning scene (if any)",
 
  130   if (show_scene_robot)
 
  132     robot_category_ = 
new rviz_common::properties::Property(
"Scene Robot", QVariant(), 
"", 
this);
 
  135         "Show Robot Visual", 
true,
 
  136         "Indicates whether the robot state specified by the planning scene should be " 
  137         "displayed as defined for visualisation purposes.",
 
  141         "Show Robot Collision", 
false,
 
  142         "Indicates whether the robot state specified by the planning scene should be " 
  143         "displayed as defined for collision detection purposes.",
 
  147         new rviz_common::properties::FloatProperty(
"Robot Alpha", 1.0f, 
"Specifies the alpha for the robot links",
 
  153         new rviz_common::properties::ColorProperty(
"Attached Body Color", QColor(150, 50, 150),
 
  192   Display::onInitialize();
 
  193   auto ros_node_abstraction = context_->getRosNodeAbstraction().lock();
 
  194   if (!ros_node_abstraction)
 
  196     RVIZ_COMMON_LOG_WARNING(
"Unable to lock weak_ptr from DisplayContext in PlanningSceneDisplay constructor");
 
  199   node_ = ros_node_abstraction->get_raw_node();
 
  212     changedRobotSceneAlpha();
 
  270     catch (std::exception& ex)
 
  272       RCLCPP_ERROR(LOGGER, 
"Exception caught executing main loop job: %s", ex.what());
 
  296     static moveit::core::RobotModelConstPtr empty;
 
  323 void PlanningSceneDisplay::changedSceneColor()
 
  328 void PlanningSceneDisplay::changedMoveGroupNS()
 
  334 void PlanningSceneDisplay::changedRobotDescription()
 
  340 void PlanningSceneDisplay::changedSceneName()
 
  350   Ogre::ColourValue env_color(color.redF(), color.greenF(), color.blueF(), 
scene_alpha_property_->getFloat());
 
  353   Ogre::ColourValue attached_color(color.redF(), color.greenF(), color.blueF(), 
robot_alpha_property_->getFloat());
 
  370   catch (std::exception& ex)
 
  372     RCLCPP_ERROR(LOGGER, 
"Caught %s while rendering planning scene", ex.what());
 
  377 void PlanningSceneDisplay::changedSceneAlpha()
 
  382 void PlanningSceneDisplay::changedRobotSceneAlpha()
 
  391 void PlanningSceneDisplay::changedPlanningSceneTopic()
 
  399     auto bg_func = [=]() {
 
  403         setStatus(rviz_common::properties::StatusProperty::Warn, 
"PlanningScene", 
"Requesting initial scene failed");
 
  409 void PlanningSceneDisplay::changedSceneDisplayTime()
 
  413 void PlanningSceneDisplay::changedOctreeRenderMode()
 
  417 void PlanningSceneDisplay::changedOctreeColorMode()
 
  421 void PlanningSceneDisplay::changedSceneRobotVisualEnabled()
 
  431 void PlanningSceneDisplay::changedSceneRobotCollisionEnabled()
 
  441 void PlanningSceneDisplay::changedSceneEnabled()
 
  456       for (
const std::string& link : links)
 
  466     const std::vector<std::string>& links = 
getRobotModel()->getLinkModelNamesWithCollisionGeometry();
 
  467     for (
const std::string& link : links)
 
  480       for (
const std::string& link : links)
 
  501   rviz_default_plugins::robot::RobotLink* link = 
robot->getLink(link_name);
 
  505     link->setColor(color.redF(), color.greenF(), color.blueF());
 
  510   rviz_default_plugins::robot::RobotLink* link = 
robot->getLink(link_name);
 
  522   return std::make_shared<planning_scene_monitor::PlanningSceneMonitor>(
node_, rml,
 
  523                                                                         getNameStd() + 
"_planning_scene_monitor");
 
  546   if (psm->getPlanningScene())
 
  559       setStatus(rviz_common::properties::StatusProperty::Error, 
"PlanningScene", 
"No Planning Scene Loaded");
 
  567   changedPlanningSceneTopic();
 
  584   setStatus(rviz_common::properties::StatusProperty::Ok, 
"PlanningScene", 
"Planning Scene Loaded Successfully");
 
  601   QMetaObject::invokeMethod(
this, 
"setSceneName", Qt::QueuedConnection,
 
  606 void PlanningSceneDisplay::setSceneName(
const QString& 
name)
 
  643   Display::onDisable();
 
  653   Display::update(wall_dt, ros_dt);
 
  679   Display::load(config);
 
  684   Display::save(config);
 
  695   Ogre::Vector3 position;
 
  696   Ogre::Quaternion orientation;
 
  698   context_->getFrameManager()->getTransform(
getRobotModel()->getModelFrame(), rclcpp::Time(0, 0, RCL_ROS_TIME),
 
  699                                             position, orientation);
 
  707   Display::fixedFrameChanged();
 
const std::vector< std::string > & getLinkModelNamesWithCollisionGeometry() const
Get the names of the links that are part of this joint group and also have geometry associated with t...
 
Representation of a robot's state. This includes position, velocity, acceleration and effort.
 
void update(bool force=false)
Update all transforms.
 
rviz_common::properties::Property * scene_category_
 
rviz_common::properties::EnumProperty * octree_coloring_property_
 
planning_scene_monitor::LockedPlanningSceneRO getPlanningSceneRO() const
get read-only access to planning scene
 
rviz_common::properties::StringProperty * robot_description_property_
 
void unsetGroupColor(rviz_default_plugins::robot::Robot *robot, const std::string &group_name)
 
rviz_common::properties::BoolProperty * scene_robot_collision_enabled_property_
 
rclcpp::Node::SharedPtr node_
 
void fixedFrameChanged() override
 
rviz_common::properties::ColorProperty * attached_body_color_property_
 
void setLinkColor(const std::string &link_name, const QColor &color)
 
const std::string getMoveGroupNS() const
 
rviz_common::properties::EnumProperty * octree_render_property_
 
void onInitialize() override
 
void sceneMonitorReceivedUpdate(planning_scene_monitor::PlanningSceneMonitor::SceneUpdateType update_type)
 
planning_scene_monitor::LockedPlanningSceneRW getPlanningSceneRW()
get write access to planning scene
 
void renderPlanningScene()
 
void save(rviz_common::Config config) const override
 
virtual void clearRobotModel()
 
void waitForAllMainLoopJobs()
 
PlanningSceneRenderPtr planning_scene_render_
 
void unsetLinkColor(const std::string &link_name)
 
void spawnBackgroundJob(const std::function< void()> &job)
 
std::deque< std::function< void()> > main_loop_jobs_
 
std::mutex main_loop_jobs_lock_
 
void onDisable() override
 
virtual void onRobotModelLoaded()
This is an event called by loadRobotModel() in the MainLoop; do not call directly.
 
rviz_common::properties::FloatProperty * scene_alpha_property_
 
bool planning_scene_needs_render_
 
void setGroupColor(rviz_default_plugins::robot::Robot *robot, const std::string &group_name, const QColor &color)
 
void calculateOffsetPosition()
Set the scene node's position, given the target frame and the planning frame.
 
virtual void updateInternal(float wall_dt, float ros_dt)
 
void executeMainLoopJobs()
 
~PlanningSceneDisplay() override
 
RobotStateVisualizationPtr planning_scene_robot_
 
float current_scene_time_
 
virtual void onSceneMonitorReceivedUpdate(planning_scene_monitor::PlanningSceneMonitor::SceneUpdateType update_type)
 
void addMainLoopJob(const std::function< void()> &job)
queue the execution of this function for the next time the main update() loop gets called
 
virtual planning_scene_monitor::PlanningSceneMonitorPtr createPlanningSceneMonitor()
 
rviz_common::properties::FloatProperty * robot_alpha_property_
 
planning_scene_monitor::PlanningSceneMonitorPtr planning_scene_monitor_
 
const moveit::core::RobotModelConstPtr & getRobotModel() const
 
void addBackgroundJob(const std::function< void()> &job, const std::string &name)
 
rviz_common::properties::StringProperty * move_group_ns_property_
 
void queueRenderSceneGeometry()
 
rviz_common::properties::StringProperty * scene_name_property_
 
void update(float wall_dt, float ros_dt) override
 
PlanningSceneDisplay(bool listen_to_planning_scene=true, bool show_scene_robot=true)
 
rviz_common::properties::FloatProperty * scene_display_time_property_
 
virtual void onNewPlanningSceneState()
This is called upon successful retrieval of the (initial) planning scene state.
 
void clearJobs()
remove all queued jobs
 
rviz_common::properties::BoolProperty * scene_robot_visual_enabled_property_
 
rviz_common::properties::Property * robot_category_
 
void unsetAllColors(rviz_default_plugins::robot::Robot *robot)
 
rviz_common::properties::RosTopicProperty * planning_scene_topic_property_
 
Ogre::SceneNode * planning_scene_node_
displays planning scene with everything in it
 
rviz_common::properties::BoolProperty * scene_enabled_property_
 
bool waitForCurrentRobotState(const rclcpp::Time &t)
wait for robot state more recent than t
 
const planning_scene_monitor::PlanningSceneMonitorPtr & getPlanningSceneMonitor()
 
std::mutex robot_model_loading_lock_
 
rviz_common::properties::ColorProperty * scene_color_property_
 
bool robot_state_needs_render_
 
moveit::tools::BackgroundProcessing background_process_
 
std::condition_variable main_loop_jobs_empty_condition_
 
virtual void changedAttachedBodyColor()
 
void load(const rviz_common::Config &config) override
 
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.
 
static const std::string DEFAULT_PLANNING_SCENE_SERVICE
The name of the service used by default for requesting full planning scene state.
 
robot_model_loader::RobotModelLoaderPtr getSharedRobotModelLoader(const rclcpp::Node::SharedPtr &node, const std::string &robot_description)
 
@ OCTOMAP_PROBABLILTY_COLOR
 
@ OCTOMAP_OCCUPIED_VOXELS
 
std::string append(const std::string &left, const std::string &right)
 
const rclcpp::Logger LOGGER