86 UPDATE_TRANSFORMS = 2,
93 UPDATE_SCENE = 8 + UPDATE_STATE + UPDATE_TRANSFORMS + UPDATE_GEOMETRY
124 const std::string& name =
"");
130 PlanningSceneMonitor(
const rclcpp::Node::SharedPtr& node,
const robot_model_loader::RobotModelLoaderPtr& rml,
131 const std::string& name =
"");
138 PlanningSceneMonitor(
const rclcpp::Node::SharedPtr& node,
const planning_scene::PlanningScenePtr& scene,
139 const std::string& robot_description,
const std::string& name =
"");
146 PlanningSceneMonitor(
const rclcpp::Node::SharedPtr& node,
const planning_scene::PlanningScenePtr& scene,
147 const robot_model_loader::RobotModelLoaderPtr& rml,
const std::string& name =
"");
154 return monitor_name_;
199 bool updatesScene(
const planning_scene::PlanningSceneConstPtr& scene)
const;
205 bool updatesScene(
const planning_scene::PlanningScenePtr& scene)
const;
211 return robot_description_;
217 return default_robot_padd_;
223 return default_robot_scale_;
229 return default_object_padd_;
235 return default_attached_padd_;
249 void monitorDiffs(
bool flag);
254 void startPublishingPlanningScene(SceneUpdateType event,
255 const std::string& planning_scene_topic = MONITORED_PLANNING_SCENE_TOPIC);
258 void stopPublishingPlanningScene();
261 void setPlanningScenePublishingFrequency(
double hz);
266 return publish_planning_scene_frequency_;
273 return current_state_monitor_;
278 return current_state_monitor_;
286 void updateFrameTransforms();
291 void startStateMonitor(
const std::string& joint_states_topic = DEFAULT_JOINT_STATES_TOPIC,
292 const std::string& attached_objects_topic = DEFAULT_ATTACHED_COLLISION_OBJECT_TOPIC);
295 void stopStateMonitor();
300 void updateSceneWithCurrentState();
307 void setStateUpdateFrequency(
double hz);
312 if (dt_state_update_.count() > 0.0)
314 return 1.0 / dt_state_update_.count();
325 void startSceneMonitor(
const std::string& scene_topic = DEFAULT_PLANNING_SCENE_TOPIC);
334 bool requestPlanningSceneState(
const std::string& service_name = DEFAULT_PLANNING_SCENE_SERVICE);
343 void providePlanningSceneService(
const std::string& service_name = DEFAULT_PLANNING_SCENE_SERVICE);
346 void stopSceneMonitor();
356 void startWorldGeometryMonitor(
const std::string& collision_objects_topic = DEFAULT_COLLISION_OBJECT_TOPIC,
357 const std::string& planning_scene_world_topic = DEFAULT_PLANNING_SCENE_WORLD_TOPIC,
358 const bool load_octomap_monitor =
true);
361 void stopWorldGeometryMonitor();
364 void addUpdateCallback(
const std::function<
void(SceneUpdateType)>& fn);
367 void clearUpdateCallbacks();
370 void getMonitoredTopics(std::vector<std::string>& topics)
const;
375 return last_update_time_;
378 void publishDebugInformation(
bool flag);
381 void triggerSceneUpdateEvent(SceneUpdateType update_type);
388 bool waitForCurrentRobotState(
const rclcpp::Time& t,
double wait_time = 1.);
393 bool newPlanningSceneMessage(
const moveit_msgs::msg::PlanningScene& scene);
396 bool processCollisionObjectMsg(
const moveit_msgs::msg::CollisionObject::ConstSharedPtr& collision_object_msg,
397 const std::optional<moveit_msgs::msg::ObjectColor>& color_msg = std::nullopt);
400 bool processAttachedCollisionObjectMsg(
401 const moveit_msgs::msg::AttachedCollisionObject::ConstSharedPtr& attached_collision_object_msg);
407 void initialize(
const planning_scene::PlanningScenePtr& scene);
410 void lockSceneRead();
413 void unlockSceneRead();
417 void lockSceneWrite();
421 void unlockSceneWrite();
424 void configureCollisionMatrix(
const planning_scene::PlanningScenePtr& scene);
427 void configureDefaultPadding();
430 void newPlanningSceneWorldCallback(
const moveit_msgs::msg::PlanningSceneWorld::ConstSharedPtr& world);
433 void octomapUpdateCallback();
439 void currentWorldObjectUpdateCallback(
const collision_detection::World::ObjectConstPtr&
object,
442 void includeRobotLinksInOctree();
443 void excludeRobotLinksFromOctree();
445 void excludeWorldObjectsFromOctree();
446 void includeWorldObjectsInOctree();
447 void excludeWorldObjectFromOctree(
const collision_detection::World::ObjectConstPtr& obj);
448 void includeWorldObjectInOctree(
const collision_detection::World::ObjectConstPtr& obj);
450 void excludeAttachedBodiesFromOctree();
451 void includeAttachedBodiesInOctree();
455 bool getShapeTransformCache(
const std::string& target_frame,
const rclcpp::Time& target_time,
468 std::shared_ptr<rclcpp::Node>
node_;
521 std::vector<std::pair<occupancy_map_monitor::ShapeHandle, std::size_t> > >
524 std::vector<std::pair<occupancy_map_monitor::ShapeHandle, std::size_t> > >;
526 std::map<std::string, std::vector<std::pair<occupancy_map_monitor::ShapeHandle, const Eigen::Isometry3d*> > >;
539 void getUpdatedFrameTransforms(std::vector<geometry_msgs::msg::TransformStamped>& transforms);
542 void scenePublishingThread();
545 void onStateUpdate(
const sensor_msgs::msg::JointState::ConstSharedPtr& joint_state);
548 void stateUpdateTimerCallback();
551 void newPlanningSceneCallback(
const moveit_msgs::msg::PlanningScene::ConstSharedPtr& scene);
554 void getPlanningSceneServiceCallback(
const moveit_msgs::srv::GetPlanningScene::Request::SharedPtr& req,
555 const moveit_msgs::srv::GetPlanningScene::Response::SharedPtr& res);
557 void updatePublishSettings(
bool publish_geom_updates,
bool publish_state_updates,
bool publish_transform_updates,
558 bool publish_planning_scene,
double publish_planning_scene_hz);
561 std::mutex state_pending_mutex_;
565 volatile bool state_update_pending_;
569 std::chrono::duration<double> dt_state_update_;
574 rclcpp::Duration shape_transform_cache_lookup_wait_time_;
580 rclcpp::TimerBase::SharedPtr state_update_timer_;
584 std::chrono::system_clock::time_point last_robot_state_update_wall_time_;
586 robot_model_loader::RobotModelLoaderPtr rm_loader_;
587 moveit::core::RobotModelConstPtr robot_model_;
591 rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr callback_handler_;
598 rclcpp::Logger logger_;