Skip to content

mjcf parser not correctly parsing body mass #1521

@gyeomannvidia

Description

@gyeomannvidia

The following test creates a fixed root and a child link. The child link is given a mass of 1.5 but ModelBuilder reports a mass of 0.01.

I believe something is not right with inertia so this is worth looking at as well. I expect body_inertia to be a diagonal matrix with 0.02 on the diagonal but these values are not present in individual_builder.body_inertia[0]

The test may be added to test_import_mjcf.py.

    def test_mass(self):
        """Test that mass parameters can be parsed from mjcf"""
        mjcf = """<?xml version="1.0" ?>
<mujoco model="myart">
    <worldbody>
    <!-- Root body (fixed to world) -->
    <body name="root" pos="0 0 0">

      <!-- First child link with prismatic joint along x -->
      <body name="link1" pos="0.0 -0.5 0">
        <joint name="joint1" type="slide" axis="1 0 0" range="-50.5 50.5"/>
        <inertial pos="0 0 0" mass="1.5" diaginertia="0.02 0.02 0.02"/>
      </body>
    </body>
  </worldbody>
</mujoco>
"""
        individual_builder = newton.ModelBuilder()
        SolverMuJoCo.register_custom_attributes(individual_builder)
        individual_builder.add_mjcf(mjcf)

        # The mass should be 1.5 but it is reported as 0.01
        print(individual_builder.body_mass)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions