Skip to content

MJScene reports body position pinned at the reference pose when a body's mass changes #1476

Description

@juan-g-bonilla

Description

In MJScene, when a body's mass changes during propagation (e.g. a depleting fuel tank), the
body's reported position stays pinned at the model reference pose for the whole maneuver,
even though its velocity and mass state integrate correctly.

Steps to reproduce

  1. Build a scene with a single translating body (free joint or three slide joints) and an
    on-axis thrust actuator.
  2. Make the body mass a state that decreases each step (e.g. drive the
    body mass rate directly).
  3. Propagate and record the body/site output message.

Expected

The recorded position integrates with the velocity (for a constant-thrust burn it should
follow the analytic Tsiolkovsky trajectory).

Actual

v_BN_N and the mass state are correct, but r_BN_N remains at the initial/reference pose —
off by the full displacement of the burn.

Cause

MJScene::equationsOfMotion calls mj_setConst on each step the mass changes, to refresh
MuJoCo's cached "constant" quantities. mj_setConst runs its internal computations at the model
reference pose: it overwrites data->qpos with qpos0/qpos_spring and leaves it there. Every
position-dependent quantity evaluated afterward in the same call — forward kinematics,
spring/gravity forces, and the site state-output messages — is therefore computed at the
reference pose instead of the current configuration. Since the branch fires every step of a
burn, the reported position never leaves the reference pose.

Metadata

Metadata

Labels

bugSomething isn't working

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions