Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
actuator and sensor delays
MuJoCo vs MuJoCo Warp: Delay Implementation Differences
API Signature Differences
All shape changes are driven by GPU batching over
nworldparallel worlds.values(nsample,)(nworld, nsample)phasefloat(nworld,)timefloat(nworld,)result(nworld,)or(nworld, dim)interp-1Sensor Computation: Conditional vs Always-Compute
MuJoCo C: Conditional Computation
Each sensor goes through
compute_or_read_sensor(), which skips computation for delayed sensors:delay > 0: reads directly from history buffer, never callsmj_computeSensorinterval > 0, condition not met: reads stale value from bufferinterval > 0, condition met: computes fresh valueMuJoCo Warp: Always Compute, Then Overwrite
All sensors are computed unconditionally via a single kernel launch, then
apply_sensor_delay()runs as a second pass:sensordatawith delayed values from historyJustification
GPU kernels execute uniformly across all threads — per-sensor branching (compute vs skip) creates warp divergence and is inefficient. Computing everything then overwriting is the standard GPU tradeoff: redundant computation is cheaper than divergent control flow. The final result is identical.
Public API Functions
mj_readCtrl(m, d, id, time, interp)read_ctrl(m, d, ctrlid, time, interp, result)mj_readSensor(m, d, id, time, buf, interp)read_sensor(m, d, sensorid, time, interp, result)mj_initCtrlHistory(m, d, id, times, values)init_ctrl_history(m, d, ctrlid, times, values)mj_initSensorHistory(m, d, id, times, values, phase)init_sensor_history(m, d, sensorid, times, values, phase)