Fix: Inertial Origin Resetting During Merge Links #4683
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.
Hello!
I noticed an issue where the center of mass of the parent object was ignored when a child was merged into it.
Take this example of a cube with an offset center of mass @ [0.5 0 0]
and a cube with the same offset center of mass and a (practically) massless child that is rigidly linked to it
If we call getDynamicsInfo on both of them with the following script:
we can see that the cube has the correct center of mass (0.5, 0.0, 0.0)
Cube Dynamics (1.0, 0.5, (1.0, 1.0, 1.0), (0.5, 0.0, 0.0), (0.0, 0.0, 0.0, 1.0), 0.0, 0.0, 0.0, -1.0, -1.0, 2, 0.001)
However, when the massless child is added:
Cube with Massless Child Dynamics (1.0, 0.5, (1.0, 1.0, 1.0), (0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 1.0), 0.0, 0.0, 0.0, -1.0, -1.0, 2, 0.001)
the center of mass is reset to the origin.
The root of the issue is these lines:
bullet3/examples/Importers/ImportURDFDemo/UrdfParser.cpp
Lines 2005 to 2012 in e9c461b
Nothing sets m_inertia.m_hasLinkLocalFrame to be true before this happens, so it is always reset.
I noticed that this Boolean doesn't do anything as the inertia properties are set to the identity on the creation of the object:
bullet3/examples/Importers/ImportURDFDemo/UrdfParser.h
Line 43 in e9c461b
And again in parse inertia:
bullet3/examples/Importers/ImportURDFDemo/UrdfParser.cpp
Line 236 in e9c461b
So may as well remove this extra logic.
If you want to keep it around as an extra check, the solution is to set the Boolean to true when the origin was loaded here:
bullet3/examples/Importers/ImportURDFDemo/UrdfParser.cpp
Line 254 in e9c461b