-
Notifications
You must be signed in to change notification settings - Fork 276
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
Bugfix: Fixed Centre of Mass and Inertia Matrix Calculation Bug MeshInertiaCalculator::CalculateMassProperties()
function
#2182
Bugfix: Fixed Centre of Mass and Inertia Matrix Calculation Bug MeshInertiaCalculator::CalculateMassProperties()
function
#2182
Conversation
… theorem Signed-off-by: Jasmeet Singh <[email protected]>
Signed-off-by: Jasmeet Singh <[email protected]>
Signed-off-by: Jasmeet Singh <[email protected]>
…ormation Signed-off-by: Jasmeet Singh <[email protected]>
Signed-off-by: Jasmeet Singh <[email protected]>
9c0eed4
to
fcda45f
Compare
Codecov Report
@@ Coverage Diff @@
## gz-sim8 #2182 +/- ##
===========================================
- Coverage 66.00% 65.81% -0.19%
===========================================
Files 323 323
Lines 30719 30740 +21
===========================================
- Hits 20275 20233 -42
- Misses 10444 10507 +63
|
@jasmeet0915 would it be possible to add a test for this? |
Signed-off-by: Jasmeet Singh <[email protected]>
Signed-off-by: Jasmeet Singh <[email protected]>
… to 0, added TODO comment Signed-off-by: Jasmeet Singh <[email protected]>
…perties() Signed-off-by: Jasmeet Singh <[email protected]>
Signed-off-by: Jasmeet Singh <[email protected]>
MeshInertiaCalculator
MeshInertiaCalculator::CalculateMassProperties()
function
Signed-off-by: Jasmeet Singh <[email protected]>
Signed-off-by: Jasmeet Singh <[email protected]>
src/MeshInertiaCalculator.hh
Outdated
gz::math::Pose3d &_centreOfMass, | ||
gz::math::Pose3d &_inertiaOrigin); |
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.
can these be const ref?
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.
Done in 01aa539
Signed-off-by: Jasmeet Singh <[email protected]>
Signed-off-by: Jasmeet Singh <[email protected]>
code looks good to me. Maybe @azeey can take a one final look before merging. |
is there documentation of the algorithm / integrals used in |
@scpeters The method used was referred from this doc: https://www.geometrictools.com/Documentation/PolyhedralMassProperties.pdf |
src/MeshInertiaCalculator.cc
Outdated
@@ -101,12 +107,61 @@ void MeshInertiaCalculator::CalculateMeshCentroid( | |||
_centreOfMass.SetZ(centroid.Z()); | |||
} | |||
|
|||
////////////////////////////////////////////////// | |||
void MeshInertiaCalculator::TransformInertiaMatrixToCOM( |
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.
Since CalculateMeshCentroid
and TransformInertiaMatrixToCOM
are unused and untested, I think we should remove them. I'd be in favor of adding TransformInertiaMatrixToCOM
to gz::math::Inertial
with tests.
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.
Removed the unused functions in 7424bab. Would create a PR over at gz-math as soon as possible for the TransformInertiaMatrixToCOM()
function.
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.
Looks good! Thanks for the fix. My only suggestion is we remove unused code.
Signed-off-by: Jasmeet Singh <[email protected]>
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 @jasmeet0915!!
🦟 Bug fix
Previous Understanding:
The
MeshInertiaCalculator.cc
computes the inertia w.r.t the mesh origin. This can lead to incorrect inertia values in case the Mesh Origin was not at the Center of Mass as mentioned here.Since many times users may tend to use meshes with origins, not at the center, this PR adds and uses a function to transform the Inertia Matrix to the COM in such cases.
Actual Scenario:
There was a bug in the center of mass and inertia matrix calculation. This PR fixes bugs in a moment of inertia matrix calculation and adds a test for the inertia calculation of a cylinder model with the origin set not at the center of mass.
Some extra functions were also added according to the previous understanding but are not needed after the bugfix:
CalculateMeshCentroid()
TransformInertiaMatrixToCOM()
Below you can see multiple cylinder meshes with origins set at different places inside or outside the mesh getting similar inertia values:
Test it
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.