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 pose-not-set-bug #2852

Merged
merged 3 commits into from
Aug 28, 2021
Merged

Fix pose-not-set-bug #2852

merged 3 commits into from
Aug 28, 2021

Conversation

mechwiz
Copy link
Contributor

@mechwiz mechwiz commented Aug 27, 2021

Description

In #2816 , there was a fix for backwards compatibility for specifying a pose for a single collision shape. In that fix, I think there may be a bug. There is a check here to determine if an object's pose has been set:
if (object_pose.isApprox(Eigen::Isometry3d::Identity()))

I think this check is problematic because if the pose is not set, all pose fields are zero. Checking if the pose is Identity assumes the unit quaternion which means that the "w" component is equal to 1. The way the code is currently, even if the object pose is set to identity, the shape pose will be used instead (which may not be aligned the same way as the object pose intended). This PR fixes this by explicitly checking that all fields of the object pose are zero.

Checklist

  • Required by CI: Code is auto formatted using clang-format
  • Extend the tutorials / documentation reference
  • Document API changes relevant to the user in the MIGRATION.md notes
  • Create tests, which fail without this PR reference
  • Include a screenshot if changing a GUI
  • While waiting for someone to review your request, please help review another open pull request to support the maintainers

@welcome
Copy link

welcome bot commented Aug 27, 2021

Thanks for helping in improving MoveIt and open source robotics!

@mechwiz mechwiz requested a review from mlautman as a code owner August 27, 2021 22:14
Copy link
Contributor

@v4hn v4hn left a comment

Choose a reason for hiding this comment

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

I think this check is problematic because if the pose is not set, all pose fields are zero.

Yes, but object_pose is obtained through PlanningScene::poseMsgToEigen(object.pose, object_pose); and this message prints a warning and assumes identity when the pose is empty. So that case works as expected.

even if the object pose is set to identity, the shape pose will be used instead

That is an actual bug in a (probably not uncommon) edge-case! Thank you for pointing it out and providing a patch.

I added some simplification.

@codecov
Copy link

codecov bot commented Aug 27, 2021

Codecov Report

Merging #2852 (a465501) into master (ee528ea) will increase coverage by 0.03%.
The diff coverage is 83.34%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2852      +/-   ##
==========================================
+ Coverage   60.84%   60.87%   +0.03%     
==========================================
  Files         366      366              
  Lines       31709    31710       +1     
==========================================
+ Hits        19290    19299       +9     
+ Misses      12419    12411       -8     
Impacted Files Coverage Δ
moveit_core/planning_scene/src/planning_scene.cpp 63.31% <50.00%> (+0.17%) ⬆️
moveit_core/utils/src/message_checks.cpp 100.00% <100.00%> (ø)
...meterization/work_space/pose_model_state_space.cpp 81.14% <0.00%> (+0.63%) ⬆️
...ipulation/pick_place/src/manipulation_pipeline.cpp 72.23% <0.00%> (+0.93%) ⬆️
...eit_ros/manipulation/pick_place/src/pick_place.cpp 92.64% <0.00%> (+3.16%) ⬆️

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 ee528ea...a465501. Read the comment docs.

Copy link
Contributor

@felixvd felixvd left a comment

Choose a reason for hiding this comment

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

Great catch, thanks!

@@ -1718,9 +1715,11 @@ bool PlanningScene::shapesAndPosesFromCollisionObjectMessage(const moveit_msgs::

bool switch_object_pose_and_shape_pose = false;
if (num_shapes == 1)
if (object_pose.isApprox(Eigen::Isometry3d::Identity()))
if (moveit::core::isEmpty(object.pose))
Copy link
Contributor

Choose a reason for hiding this comment

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

I had just accepted that identity object poses will always be overwritten by shape poses, but it's true that you might want to e.g. shift your mesh without changing the object pose itself. Nice!

object.object.pose.position.z == 0 && object.object.pose.orientation.x == 0 &&
object.object.pose.orientation.y == 0 && object.object.pose.orientation.z == 0 &&
object.object.pose.orientation.w == 0)
if (moveit::core::isEmpty(object.object.pose))
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks a lot prettier now.

@felixvd felixvd merged commit f91869b into moveit:master Aug 28, 2021
@welcome
Copy link

welcome bot commented Aug 28, 2021

Congrats on getting your first MoveIt pull request merged and improving open source robotics!

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

3 participants