sdf_tutorials icon indicating copy to clipboard operation
sdf_tutorials copied to clipboard

//inertial/@auto: allow specifying mass instead of density

Open scpeters opened this issue 1 year ago • 7 comments

Desired behavior

Currently the //inertial/@auto attribute enables automatic computation of inertial properties assuming uniform density based on the shape and a density parameter. Since it can be more straightforward to measure mass by weighing an object than measuring density, center of mass, and moment of inertia, we should consider allowing the user to specify the mass and auto-compute the remaining inertial properties without using the density parameter.

Alternatives considered

Implementation suggestion

Currently automatic inertial calculations can be enabled by setting //inertial/@auto == 'true' and specifying collision geometries in a link:

<link name="link_with_collision_density">
  <inertial auto="true"/>
  <collision name="collision1">
    <density>...</density>
    <geometry>...</geometry>
  </collision>
  <collision name="collision2">
    <density>...</density>
    <geometry>...</geometry>
  </collision>
</link>

Note that when https://github.com/gazebosim/sdformat/pull/1335 is merged, density may also be specified in the //inertial instead of //collision (see the pull request for details on precedence if it is specified in both places):

<link name="link_with_inertial_density">
  <inertial auto="true">
    <density>...</density>
  </inertial>
  <collision name="collision1">
    <geometry>...</geometry>
  </collision>
  <collision name="collision2">
    <geometry>...</geometry>
  </collision>
</link>

If a user sets //inertial/@auto == 'true' and also specifies mass, inertial pose, or moment of inertia values, a warning is thrown and the user specified values are not used.

<link name="link_with_ignored_user_inertial_values">
  <inertial auto="true">
    <mass>...</mass>
    <pose>...</pose>
    <inertia>...</inertia>
  </inertial>
  <collision name="collision1">
    <geometry>...</geometry>
  </collision>
  <collision name="collision2">
    <geometry>...</geometry>
  </collision>
</link>

This feature request is proposing that if a user sets //inertial/@auto == 'true' and specifies //inertial/mass, that the density values should be ignored, and the inertial values calculated according to the density that would result in the user-specified mass:

<link name="link_with_auto_inertial_from_mass_not_density">
  <inertial auto="true">
    <mass>...</mass>
  </inertial>
  <collision name="collision1">
    <geometry>...</geometry>
  </collision>
  <collision name="collision2">
    <geometry>...</geometry>
  </collision>
</link>

Additional context

scpeters avatar Dec 18 '23 18:12 scpeters