Skip to content

Commit ce40e08

Browse files
authored
Shut down PSM publishing before starting to publish on a potentially new topic (#2680)
1 parent 78d6e1f commit ce40e08

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

moveit_ros/planning/planning_scene_monitor/src/planning_scene_monitor.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,24 @@ void PlanningSceneMonitor::startPublishingPlanningScene(SceneUpdateType update_t
416416
const std::string& planning_scene_topic)
417417
{
418418
publish_update_types_ = update_type;
419-
if (!publish_planning_scene_ && scene_)
419+
420+
if (publish_planning_scene_)
421+
{
422+
RCLCPP_INFO(logger_, "Stopping existing planning scene publisher.");
423+
stopPublishingPlanningScene();
424+
}
425+
426+
if (scene_)
420427
{
421428
planning_scene_publisher_ = pnode_->create_publisher<moveit_msgs::msg::PlanningScene>(planning_scene_topic, 100);
422429
RCLCPP_INFO(logger_, "Publishing maintained planning scene on '%s'", planning_scene_topic.c_str());
423430
monitorDiffs(true);
424431
publish_planning_scene_ = std::make_unique<std::thread>([this] { scenePublishingThread(); });
425432
}
433+
else
434+
{
435+
RCLCPP_WARN(logger_, "Did not find a planning scene, so cannot publish it.");
436+
}
426437
}
427438

428439
void PlanningSceneMonitor::scenePublishingThread()

0 commit comments

Comments
 (0)