Do not switch object and shape poses of attached objects with subframes #3145
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
moveit/moveit#2816 (comment) said
Namely, if an attached object has exactly one shape (primitive or mesh) and the pose of the attached object is "empty" (that is, the origin of the attached object coincides with the origin of the link it is attached to), then the code would "swap" the poses, moving the origin of the attached object to the origin of the shape/mesh.
Unfortunately this change had some IMHO very unfortunate side-effects. In my use case, the pose is not "empty", it is correctly set to identity, as the URDF was intentionally structured to have the origin of the robot link and attached object coincide, to make the whole thing simpler to set up. Whereas in my case the mesh origin is a completely "random" location (the URDF is created by exporting from Fusion using https://github.com/jaredgonzales/fusion360descriptor/ and Fusion has all meshes originate at global origin of the design, regardless of the local origin of the specific bodies). The issue is than two-fold:
This means that using the attached object or its subframe as a frame id or tip name in IK/motion planning results in things failing in completely unpredictable and seemingly incomprehensible ways (I just happened to have the scene returned by move_group's get_planning_scene logged and happened to see that the mesh origin was 0, which clued me to where to look in source code, otherwise I would have likely spent hours trying to understand why things work correctly for some attached objects, and completely bogus for others).
I see the following options:
IMHO option 3 is the right way, but I do not have bandwidth or understanding to implement it, and I do not know how much may be relying on the current behavior by now. This PR implements option 2 - it is the simplest fix for my use case and although I would expect to leave plenty of opportunities to trip people, it would hopefully avoid the worst side-effects.
Checklist