Skip to content

Commit

Permalink
Shut down PSM publishing before starting to publish on a potentially …
Browse files Browse the repository at this point in the history
…new topic (#2680)
  • Loading branch information
sea-bass authored Feb 9, 2024
1 parent 78d6e1f commit ce40e08
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,24 @@ void PlanningSceneMonitor::startPublishingPlanningScene(SceneUpdateType update_t
const std::string& planning_scene_topic)
{
publish_update_types_ = update_type;
if (!publish_planning_scene_ && scene_)

if (publish_planning_scene_)
{
RCLCPP_INFO(logger_, "Stopping existing planning scene publisher.");
stopPublishingPlanningScene();
}

if (scene_)
{
planning_scene_publisher_ = pnode_->create_publisher<moveit_msgs::msg::PlanningScene>(planning_scene_topic, 100);
RCLCPP_INFO(logger_, "Publishing maintained planning scene on '%s'", planning_scene_topic.c_str());
monitorDiffs(true);
publish_planning_scene_ = std::make_unique<std::thread>([this] { scenePublishingThread(); });
}
else
{
RCLCPP_WARN(logger_, "Did not find a planning scene, so cannot publish it.");
}
}

void PlanningSceneMonitor::scenePublishingThread()
Expand Down

0 comments on commit ce40e08

Please sign in to comment.