Skip to content

Commit 66e0677

Browse files
committed
Fix logic for planning scene publishing from MoveItCpp
1 parent 78d6e1f commit 66e0677

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

moveit_ros/planning/moveit_cpp/src/moveit_cpp.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ bool MoveItCpp::loadPlanningSceneMonitor(const PlanningSceneMonitorOptions& opti
9999
RCLCPP_INFO(logger_, "Listening to '%s' for joint states", options.joint_state_topic.c_str());
100100
// Subscribe to JointState sensor messages
101101
planning_scene_monitor_->startStateMonitor(options.joint_state_topic, options.attached_collision_object_topic);
102-
// Publish planning scene updates to remote monitors like RViz
102+
// Publish planning scene updates to remote monitors like RViz, ensuring first that any active publisher is stopped.
103+
planning_scene_monitor_->stopPublishingPlanningScene();
103104
planning_scene_monitor_->startPublishingPlanningScene(planning_scene_monitor::PlanningSceneMonitor::UPDATE_SCENE,
104105
options.monitored_planning_scene_topic);
105106
// Monitor and apply planning scene updates from remote publishers like the PlanningSceneInterface

moveit_ros/planning/planning_scene_monitor/src/planning_scene_monitor.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,15 @@ void PlanningSceneMonitor::startPublishingPlanningScene(SceneUpdateType update_t
423423
monitorDiffs(true);
424424
publish_planning_scene_ = std::make_unique<std::thread>([this] { scenePublishingThread(); });
425425
}
426+
else if (publish_planning_scene_)
427+
{
428+
RCLCPP_WARN(logger_, "Did not start publishing planning scene as it is already publishing. Ensure to call "
429+
"stopPublishingPlanningScene() first.");
430+
}
431+
else
432+
{
433+
RCLCPP_WARN(logger_, "Did not find a planning scene, so cannot publish it.");
434+
}
426435
}
427436

428437
void PlanningSceneMonitor::scenePublishingThread()

0 commit comments

Comments
 (0)