Print auto inertial values with gz sdf --print --expand-auto-inertials#1422
Merged
Print auto inertial values with gz sdf --print --expand-auto-inertials#1422
Conversation
This adds a SAVE_CALCULATION_IN_ELEMENT value to the ConfigureResolveAutoInertials enum, which is similar to the SAVE_CALCULATION value but also stores the resulting inertial data in the Link's Element so that it can be printed. Signed-off-by: Steve Peters <scpeters@openrobotics.org>
If the SAVE_CALCULATION_IN_ELEMENT value is set in ParserConfig, then store auto-computed inertial data in the Link's Element. Confirm with a test added to INTEGRATION_link_dom. Signed-off-by: Steve Peters <scpeters@openrobotics.org>
The --inertial-stats argument represents a command, so move its help string and change indentation to match other commands, so that it doesn't look like a sub-parameter of --print. Signed-off-by: Steve Peters <scpeters@openrobotics.org>
The `--expand-auto-inertials` option to `gz sdf --print` will print auto-computed inertial values. Signed-off-by: Steve Peters <scpeters@openrobotics.org>
ahcorde
approved these changes
May 21, 2024
azeey
reviewed
May 24, 2024
src/cmd/cmdsdformat.rb.in
Outdated
| " rotational part of poses and unit vectors will be normalized.\n" + | ||
| " -i [ --preserve-includes ] Preserve included tags when printing converted arg (does not preserve merge-includes).\n" + | ||
| " --degrees Pose rotation angles are printed in degrees.\n" + | ||
| " --expand-auto-inertials Prints auto-computed inertial values.\n" + |
Collaborator
There was a problem hiding this comment.
Can you mention that this won't work for meshes.
Member
Author
There was a problem hiding this comment.
in f32393b I've added a bit to the doc-string for gz sdf --print --expand-auto-inertials that mesh inertial data isn't computed. here's the output I see (with some adjusted whitespace):
$ gz sdf --print test/sdf/mesh_auto_inertial.sdf --expand-auto-inertials
Warning [Utils.cc:115] Collision is missing a <density> child element.
Using a default density value of 1000.000000 kg/m^3.
Warning [Utils.cc:115] Custom moment of inertia calculator for meshes
not set via sdf::ParserConfig::RegisterCustomInertiaCalc,
using default inertial values.
<sdf version='1.12'>
<model name='test_model'>
<link name='L1'>
<inertial auto='true'>
<pose>0 0 0 0 0 0</pose>
<mass>1</mass>
<inertia>
<ixx>1</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>1</iyy>
<iyz>0</iyz>
<izz>1</izz>
</inertia>
</inertial>
<collision name='collision'>
<geometry>
<mesh>
<uri>box.dae</uri>
</mesh>
</geometry>
</collision>
</link>
</model>
</sdf>
Update doc-string for `gz sdf --print --expand-auto-inertials` to clarify that mesh inertial data is not computed. Signed-off-by: Steve Peters <scpeters@openrobotics.org>
azeey
approved these changes
May 24, 2024
Contributor
|
@Mergifyio backport sdf14 |
Contributor
✅ Backports have been createdDetails
|
mergify bot
pushed a commit
that referenced
this pull request
Jan 14, 2025
#1422) The ability to automatically compute inertial values by setting the `//inertial/@auto` attribute to true is very convenient, but it is difficult to see what inertial values were computed. This adds an `--expand-auto-inertials` argument to `gz sdf --print` to show the auto-computed inertial values in the printed output. Note that it does not compute inertial values for mesh shapes. To enable this behavior, a new enum value SAVE_CALCULATION_IN_ELEMENT is added to ConfigureResolveAutoInertials in ParserConfig.hh, and the Link will store auto-computed inertial values directly in its sdf::Element when this configuration is set. Signed-off-by: Steve Peters <scpeters@openrobotics.org> (cherry picked from commit 3f84210)
Merged
9 tasks
iche033
pushed a commit
that referenced
this pull request
Jan 14, 2025
#1422) The ability to automatically compute inertial values by setting the `//inertial/@auto` attribute to true is very convenient, but it is difficult to see what inertial values were computed. This adds an `--expand-auto-inertials` argument to `gz sdf --print` to show the auto-computed inertial values in the printed output. Note that it does not compute inertial values for mesh shapes. To enable this behavior, a new enum value SAVE_CALCULATION_IN_ELEMENT is added to ConfigureResolveAutoInertials in ParserConfig.hh, and the Link will store auto-computed inertial values directly in its sdf::Element when this configuration is set. Signed-off-by: Steve Peters <scpeters@openrobotics.org> (cherry picked from commit 3f84210)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🎉 New feature
Closes #1348
Summary
The ability to automatically compute inertial values by setting the
//inertial/@autoattribute to true is very convenient, but it is difficult to see what inertial values were computed. This adds a--expand-auto-inertialsargument togz sdf --printto show the auto-computed inertial values in the printed output.To enable this behavior, a new enum value
SAVE_CALCULATION_IN_ELEMENTis added toConfigureResolveAutoInertialsinParserConfig.hh, and theLinkwill store auto-computed inertial values directly in itssdf::Elementwhen this configuration is set.I am seeing a failing test on macOS locally but want to see if it is an issue on other platforms. EDIT: fixed in 2ffda3d.
Test it
INTEGRATION_link_domto verify the functionality of theLinkclass withSAVE_CALCULATION_IN_ELEMENTUNIT_gz_TESTto verify the--expand-auto-inertialsparameter togz sdf --printcolconworkspace withgz-tools2, thengz sdf --print test/sdf/inertial_stats_auto.sdfwith and without--expand-auto-inertialsshould demonstrate the feature.Checklist
codecheckpassed (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-bymessages.