-
Notifications
You must be signed in to change notification settings - Fork 92
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
scaleAndPadd does not keep the object centered #148
Comments
In bodies, there is an explicit mesh center read from the mesh file. Did you try scaling the body instead of the shape? |
I'm not sure what you mean by body. In the section of code I am editing I only see a mesh and a ShapeConstPtr to it. The |
Hmm... geometric_shapes differentiate between shapes and bodies. Shapes describe just the shape. Bodies describe items in a world which have their pose attached, allow point containment tests, raycasting etc. But as I quickly skimmed through the code you're referencing, it only uses shapes and never makes a body out of them. The definition of padding for shapes and bodies is different as of now (see #127). Also, shapes support general meshes, while bodies support only convex meshes. See #76 which might also be related - you're not the first one who wonders about the results of applying scaling/padding on meshes. However, I always had the idea that scaling is more or less what everyone expects, but padding is problematic. Could you share the mesh file? |
Sure, should have done it right away. |
Do you have an idea about how to solve this or work around it? |
Felix, I'm now convinced that the scaling works as it should. The mesh you provided has vertices from I guess you'd get what you expect if the mesh had its centroid in If you agree, I think this issue can be closed and it should be treated as an issue in the rviz plugin - you could e.g. say that after adding the mesh, rviz should translate its centroid towards zero. Here's a test that succeeds and tests the behavior:
|
Thanks for looking into it! I understood the problem better. I see two ways to solve this:
One could add either or both of them to the |
I only read your comments here, but why isn't it an option to simply "scale" the origin as well w.r.t. the centroid?
That doesn't sound too complicated and would not break intuitive behavior.
|
@v4hn Do you mean first figuring out the centroid, "scaling it", and then scaling all vertices and moving them to match the computed centroid? |
@v4hn Do you mean first figuring out the centroid, "scaling it", and then scaling all vertices and moving them to match the computed centroid?
Either that, or extend the interactive marker side to allow for an offset position that represents the scaling.
Moving the Marker might not be a nice move when the user deliberately put the mesh origin somewhere else...
|
And isn't the method you propose, @v4hn, equivalent to scaling towards zero? I mean, I think (hope) there was a reason for implementing scaling towards the centroid rather than towards zero. Honestly, I don't think it's possible to change the default scaling behavior without silently breaking lots of downstream code. But we could add methods like |
isn't the method you propose, @v4hn, equivalent to scaling towards zero?
Probably true. I proposed to do it like that in the context of the RViz GUI in order not to break user interaction, while not changing anything in the general geometric_shapes classes or the datastructures behind the GUI.
Honestly, I don't think it's possible to change the default scaling behavior without silently breaking lots of downstream code.
No, that's not an option.
But we could add methods like `scaleAndPaddTowardsZero()` or similar for `shapes::Mesh`.
Reasonable auxiliary methods.
I'm not sure that would help with the current problem, because scale and padding are represented by two numbers in MoveIt.
If we add a conditional mode for meshes, we would also have to add the information throughout the representation.
I don't think that's worth it.
|
I agree. Solving this issue on the rviz side seems like the best option to me. |
As is, scaling CollisionObjects in Rviz won't cause issues unless multiple shapes are defined and/or a mesh is not centered on the object. The current scaling behavior is safe for padding and probably mainly meant for that, so it should remain the default. I will close this. |
I tried loading an object and scaling down the mesh with
scaleAndPadd
(the file is in mm instead of m), but the vertices move to a location that's not the center.Here is the resulting location of the object after scaling by a factor of 0.1 (the grey slate in the middle of the image is the robot and the map grid):
It looks like the function doesn't calculate the center of the mesh, but rather the center of the vertices. I don't know if that's the cause of this issue, but it seems like a bounding box would be the more appropriate operation here.
I could also imagine a
center()
function that moves the object to the center according to this measure. That might solve my problem at least.The text was updated successfully, but these errors were encountered: