You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BuiltinPdActuator applies swapped pos/vel targets when EntityCfg.sort_actuators=True #1170
When an entity uses EntityCfg(sort_actuators=True), Entity._add_actuators flattens each actuator config to per-target calls: edit_spec(spec, [name]) once per target. BuiltinPdActuator.edit_spec appends one <position> and one <velocity> element per call, so the elements end up interleaved in the compiled model:
But compute() still returns torch.cat((position_target, velocity_target)) (the [pos..., vel...] block layout), and ctrl_ids are derived from the appended order, so position targets are written to velocity actuators and vice versa. dr.pd_gains slices ctrl_ids[:n] / ctrl_ids[n:] under the same block assumption and randomizes the wrong elements too.
Repro (2-joint robot, kp=100, kd=10, pos target [0.1, 0.2], vel target [1.0, 2.0], joints at rest):
No test covers the combination: sort_actuators is only exercised with single-ctrl actuators, and the BuiltinPd layout test uses the default unsorted path.
I reproduced this on mjlab 1.6.1. With sort_actuators=True, the two joints produced [12, 120] N·m. I verified that main at d872bfd produces [20, 40] N·m with sorting both on and off.
I also checked dr.pd_gains. Scaling stiffness by 2 and damping by 3 produced [24, 360] N·m on unpatched 1.6.1 with sorting enabled, and the expected [50, 100] N·m on main. Backporting #1303 to 1.6.1 gave the expected results on both CPU and an RTX 3060 Laptop GPU.
Thanks @hadelan for the report and @saikishor for the fix. Can this issue be closed as resolved on main?
Activity
OrangeScript commentedon Nov 27, 2026
I reproduced this on mjlab 1.6.1. With sort_actuators=True, the two joints produced [12, 120] N·m. I verified that main at d872bfd produces [20, 40] N·m with sorting both on and off.
I also checked dr.pd_gains. Scaling stiffness by 2 and damping by 3 produced [24, 360] N·m on unpatched 1.6.1 with sorting enabled, and the expected [50, 100] N·m on main. Backporting #1303 to 1.6.1 gave the expected results on both CPU and an RTX 3060 Laptop GPU.
Thanks @hadelan for the report and @saikishor for the fix. Can this issue be closed as resolved on main?