Skip to content

Commit

Permalink
PSM: keep references to scene_ valid upon receiving full scenes
Browse files Browse the repository at this point in the history
plan_execution-related modules rely on `plan.planning_scene_` in many places
to point to the currently monitored scene (or a diff on top of it).

Before this patch, if the PSM would receive full scenes during execution,
`plan.planning_scene_` would not include later incremental updates anymore
because the monitor created a new diff scene.
  • Loading branch information
v4hn committed Feb 8, 2024
1 parent 4191376 commit c174715
Showing 1 changed file with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,21 @@ bool PlanningSceneMonitor::newPlanningSceneMessage(const moveit_msgs::PlanningSc
"scene update " << fmod(last_update_time_.toSec(), 10.)
<< " robot stamp: " << fmod(last_robot_motion_time_.toSec(), 10.));
old_scene_name = scene_->getName();
result = scene_->usePlanningSceneMsg(scene);

if (!scene.is_diff && parent_scene_)
{
// clear maintained (diff) scene_ and set the full new scene in parent_scene_ instead
scene_->clearDiffs();
result = parent_scene_->setPlanningSceneMsg(scene);
// There were no callbacks for individual object changes, so rebuild the octree masks
excludeAttachedBodiesFromOctree();
excludeWorldObjectsFromOctree();
}
else
{
result = scene_->setPlanningSceneDiffMsg(scene);
}

if (octomap_monitor_)
{
if (!scene.is_diff && scene.world.octomap.octomap.data.empty())
Expand All @@ -592,23 +606,6 @@ bool PlanningSceneMonitor::newPlanningSceneMessage(const moveit_msgs::PlanningSc
}
robot_model_ = scene_->getRobotModel();

// if we just reset the scene completely but we were maintaining diffs, we need to fix that
if (!scene.is_diff && parent_scene_)
{
// the scene is now decoupled from the parent, since we just reset it
scene_->setAttachedBodyUpdateCallback(moveit::core::AttachedBodyCallback());
scene_->setCollisionObjectUpdateCallback(collision_detection::World::ObserverCallbackFn());
parent_scene_ = scene_;
scene_ = parent_scene_->diff();
scene_const_ = scene_;
scene_->setAttachedBodyUpdateCallback([this](moveit::core::AttachedBody* body, bool attached) {
currentStateAttachedBodyUpdateCallback(body, attached);
});
scene_->setCollisionObjectUpdateCallback(
[this](const collision_detection::World::ObjectConstPtr& object, collision_detection::World::Action action) {
currentWorldObjectUpdateCallback(object, action);
});
}
if (octomap_monitor_)
{
excludeAttachedBodiesFromOctree(); // in case updates have happened to the attached bodies, put them in
Expand Down

0 comments on commit c174715

Please sign in to comment.