Skip to content

Refresh derived simulator quantities after final physics substep - #11

Open
M-Colley wants to merge 1 commit into
google-deepmind:mainfrom
M-Colley:fix/device-layer-post-step-forward
Open

M-Colley wants to merge 1 commit into
google-deepmind:mainfrom
M-Colley:fix/device-layer-post-step-forward

Conversation

@M-Colley

Copy link
Copy Markdown

DeviceLayer._substep() calls self.sim.step(), which executes mj_step / mjw.step (forward followed by state integration) and leaves position-, velocity-, actuation-, and sensor-dependent fields (site_xpos, site_xmat, cvel, subtree_com, actuator_force, ten_length, sensordata, and camera BVHs) at the pre-integration state of the final substep ($t + (N - 1)\Delta t$) while qpos, qvel, act, and time have already advanced to $t + N\Delta t$.

Call self.sim.forward() on is_last_substep immediately after self.sim.step() and before _substep_measurements() so control-step device measurements, on_step() hooks, and final-substep processors observe synchronized post-step kinematics, forces, and sensors while adding only a single forward() launch per control step.

Added DeviceLayerTest.test_step_refreshes_derived_quantities_on_final_substep across both Impl.CPP and Impl.WARP verifying single-forward() execution per multi-substep control step and exact post-step agreement for SiteDevice, ActuatorDevice (actuator_force), cvel, and sensordata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant