Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in applying planning scene diffs that have attached collision objects #3124

Merged
merged 7 commits into from
May 16, 2022

Conversation

JafarAbdi
Copy link
Contributor

Description

This fixes a bug we had while executing an MTC task where having two different planning scenes diffs that add a collision object to the scene, the first commit is just a test that trigger the bug, the second commit sets robot_state.is_diff to true when calling getPlanningSceneDiffMsg which prevent conversions.cpp#L369-L372 from deleting the aco from the robot state when applying the diffs, but now when calling PlanningScene::setCurrentState while detaching an object that object is staying in the scene so the last commit fixes it by explicitly removing the aco in the case of scene diff

This work is sponsored by RE2 Robotics

@codecov
Copy link

codecov bot commented Apr 28, 2022

Codecov Report

Merging #3124 (fed689b) into master (c88f6fb) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3124      +/-   ##
==========================================
+ Coverage   61.55%   61.60%   +0.05%     
==========================================
  Files         376      376              
  Lines       33308    33314       +6     
==========================================
+ Hits        20501    20521      +20     
+ Misses      12807    12793      -14     
Impacted Files Coverage Δ
moveit_core/planning_scene/src/planning_scene.cpp 64.89% <100.00%> (+0.76%) ⬆️
...meterization/work_space/pose_model_state_space.cpp 80.00% <0.00%> (-1.17%) ⬇️
moveit_core/robot_state/src/robot_state.cpp 51.85% <0.00%> (-0.16%) ⬇️
...raint_samplers/src/default_constraint_samplers.cpp 80.06% <0.00%> (+0.29%) ⬆️
...dl_kinematics_plugin/src/kdl_kinematics_plugin.cpp 78.28% <0.00%> (+0.38%) ⬆️
...on/pick_place/src/approach_and_translate_stage.cpp 75.76% <0.00%> (+0.61%) ⬆️
...g_scene_interface/src/planning_scene_interface.cpp 52.20% <0.00%> (+1.10%) ⬆️
...ma_kinematics_plugin/src/lma_kinematics_plugin.cpp 76.48% <0.00%> (+3.93%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c88f6fb...fed689b. Read the comment docs.

Copy link
Member

@AndyZe AndyZe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this now with the Panda tutorial and clearing collision scene objects. It seems to work great! But, I still think you need to check if parent_ is a nullptr.

Copy link
Contributor

@tahsinkose tahsinkose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there. Wanted to give a little review, which is just a nit 🙂

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being late on this PR. I have some more suggestions and comments. Please see #3142.

}
scene_msg.robot_state.is_diff = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, this is correct. However, @v4hn explicitly had a different opinion, when he introduced this code line: #939 (comment)

@@ -345,6 +345,129 @@ TEST_P(CollisionDetectorTests, ClearDiff)
parent.reset();
}

// Returns a planning scene diff message
moveit_msgs::PlanningScene create_planning_scene_diff(planning_scene::PlanningScene& ps, const std::string& object_name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here PlanningScene should be a const reference, shouldn't it?

@@ -711,6 +711,18 @@ void PlanningScene::getPlanningSceneDiffMsg(moveit_msgs::PlanningScene& scene_ms
if (do_omap)
getOctomapMsg(scene_msg.world.octomap);
}

// Ensure any detached collision objects get detached from the parent planning scene, too
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is misleading: The parent planning scene is not (and should not get) modified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I had a to-do to update the comment, but it got resolved somehow

JafarAbdi pushed a commit that referenced this pull request May 18, 2022
sjahr pushed a commit to sjahr/moveit that referenced this pull request Jun 21, 2024
… objects (moveit#3124) (moveit#1251)

* Add test that trigger the bug in applying scene that have robot state
diffs

* Fix a bug in planning scene diffs where having applying two diffs would cause them to override the aco

* Fix a bug where removing an attached collision object would keep it in the scene

* Update moveit_core/planning_scene/test/test_planning_scene.cpp

Co-authored-by: AndyZe <andyz@utexas.edu>

* Update moveit_core/planning_scene/test/test_planning_scene.cpp

Co-authored-by: AndyZe <andyz@utexas.edu>

* Update moveit_core/planning_scene/src/planning_scene.cpp

Co-authored-by: AndyZe <andyz@utexas.edu>

* Check parent pointer

Co-authored-by: AndyZe <andyz@utexas.edu>

Co-authored-by: AndyZe <andyz@utexas.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants