-
Notifications
You must be signed in to change notification settings - Fork 938
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
collision world: check for empty shapes vector before access #2026
collision world: check for empty shapes vector before access #2026
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. There is another unguarded check like this in moveShapeInObject
, but I suppose users who want to move empty shapes deserve the error.
I also think that method can be deleted, but that's just me.
@@ -186,6 +191,7 @@ const Eigen::Isometry3d& World::getTransform(const std::string& name, bool& fram | |||
} | |||
} | |||
|
|||
// we need a persisting isometry for the API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// we need a persisting isometry for the API | |
// Return an identity transform so there is a persisting isometry object for the API |
nit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't like the suggestion because we return a reference, not the transform.
I believe you are talking about this access operator? This is actually guarded by ensuring there exists a shape for this index. Edit:
No they don't. A framework should not segfault for bad input (Eigen possibly excluded....) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
@@ -174,7 +174,7 @@ const Eigen::Isometry3d& World::getTransform(const std::string& name, bool& fram | |||
std::map<std::string, ObjectPtr>::const_iterator it = objects_.find(name); | |||
if (it != objects_.end()) | |||
{ | |||
if (!it->second->shape_poses_.empty()) | |||
if (it->second->shape_poses_.size() == 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check for size == 1
, because of this:
https://github.com/ros-planning/moveit/blob/4d3062164bf03ebb74c57d5eba0e3e50438481ba/moveit_core/collision_detection/src/world.cpp#L146
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually back when we last discussed this, we kept the case with multiple shape_poses_
a gray area on purpose. If you ask for the frame you get the first one, if you ask whether the frame exists, it says no.
I don't have a use-case for objects with multiple shapes, so I don't care too much.
It does seem uncalled for to change this semantic in a segfault fix though. ;)
The proper way to fix this is @felixvd proposal to have a global pose for the object...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot believe we agreed on inconsistent behavior on purpose. As both fixes are strongly related, I'm fine to have them in a single PR. IMHO it doesn't make sense to split this tiny PR up into even smaller ones.
Codecov Report
@@ Coverage Diff @@
## master #2026 +/- ##
==========================================
+ Coverage 54.04% 54.08% +0.03%
==========================================
Files 319 319
Lines 24997 24997
==========================================
+ Hits 13509 13519 +10
+ Misses 11488 11478 -10
Continue to review full report at Codecov.
|
I cannot believe we agreed on inconsistent behavior on purpose.
I would be very surprised if you were involved in that discussion.
As far as I remember the rationale was to avoid breaking code that silently relied on the Transforms of objects with multiple shapes and never checked `knowsTransform` - which is quite a common thing to do if you just added the object a few lines above.
After all, it is an arbitrary and restrictive decision to stop treating the first transform of an object as its frame.
|
I agree. We should change both checks to |
I agree. We should change both checks to `!it->second->shape_poses_.empty()` then.
My key point was to make it consistent 😉
I believe the current behavior was present in the `PlanningScene` at least since 2013 (fc1a7e6).
There has been a warning since then if you access the transform of an object with multiple shapes, but it still works.
We discussed changing it at some point, but did not back then.
I'm fine with clearing up the semantics to define the pose as the pose *of the first shape* altogether.
One reason why I did not do that before is that the user does not always have full control over which shape is the first,
e.g., shapes are generated in the planning scene by type array, so one shape type will always go first.
|
If @felixvd is going to change the semantics anyway, I think we don't need to further discuss this topic here... |
By convention, the first pose of the object has been the objects frame for a looong time (though with warning output).
72dc527
to
64d6789
Compare
If @felixvd is going to change the semantics anyway, I think we don't need to further discuss this topic here...
I adjusted knowsTransform (which by the way makes it consistent with `RobotState`s code.
Feel free to merge once CI finished.
|
See #2025 (comment)