Skip to content
Physical AI
Chapter 06 28 min read

Understanding Asimov's Simulation Environment

A lower-body humanoid in MuJoCo: parallel ankles, passive toes, multi-rate timing and processor-in-the-loop validation.

Earlier chapters covered physics engines, MuJoCo, sensors and communication in general terms. This chapter applies them to one real platform: the lower body of Menlo's Asimov humanoid, as described in Menlo's guide Understanding Your Simulation Environment. The focus is on what makes a simulator useful for training a walking policy. Looking like the robot is not enough. The simulator has to behave like it: the same mechanics, the same software interfaces, and above all the same timing.

Facts marked like this come from Menlo's documentation. Everything else in this chapter is either general robotics knowledge or an illustrative example, and is labelled as such. Menlo does not publish joint names, link lengths, gains, torque limits, friction values, delay values, capsule sizes, CAN identifiers or bit rates on these pages, so none of those appear here as Asimov facts.

What the simulation environment is

A simulation environment for locomotion learning is more than a physics model. It is the whole chain that a policy experiences: a physics engine advancing the robot's body, a model of its sensors, a model of how sensor data reaches the policy, a model of how the policy's commands reach the motors, and the timing of all of it. The policy cannot tell which parts are real and which are simulated. It only sees numbers arriving at certain times and sends numbers back.

Menlo builds Asimov's environment in MuJoCo (Chapter 3) and organises it around a principle stated plainly in their guides: sim-to-real transfer depends mainly on matching the observation and actuation interface (what data the policy gets, when, and of what quality) rather than on clever network architecture.

The lower-body Asimov platform

  • The locomotion platform is legs only, with 12 actuated leg joints and 2 passive toe joints.
  • The ankle uses a parallel ankle mechanism rather than a directly driven serial ankle. The simulator maps ankle pitch and roll through that mechanism.
  • The toes are passive and compliant. Toe compliance and toe–ground interaction are modelled.
  • Actuator saturation, friction and delay are modelled.
  • Collision uses capsule-based foot and toe geometry with explicit foot and toe contact points and contact tuning. Explicit primitives are preferred over detailed mesh collision for conservative, repeatable contact.

Twelve actuated joints

Twelve actuated joints on two legs means six per leg. That is the classic layout for a walking leg: three rotations at the hip, one at the knee and two at the ankle, which together let the foot be placed at any nearby position and orientation. Menlo's pages do not publish Asimov's joint names, ordering or axis conventions.

Illustrative example

The 3D model on this site uses the generic names hip yaw, hip roll, hip pitch, knee, ankle pitch and ankle roll for each leg, in that order. These names, the link lengths and the joint limits are the site's own illustration, not Asimov's specification.

Six joints per leg is the minimum for full control of foot pose. It also means a policy outputs twelve numbers per step, and the observation contains twelve joint positions and twelve joint velocities. Menlo documents a 45-dimensional actor observation made of base angular velocity (3), projected gravity (3), velocity command (3), joint positions (12), joint velocities (12) and previous actions (12). Chapter 8 covers it in detail.

The parallel ankle mechanism

In a serial ankle, one motor rotates the foot in pitch (toes up and down), and a second motor, mounted on the pitching part, rotates it in roll (tilting the sole left and right). Each motor drives one joint directly. It is simple to model and control, but the roll motor and its housing sit low on the leg and move with the foot.

In a parallel ankle, two actuators are mounted higher up on the shank. Each drives a rod or linkage attached to the foot. Neither actuator corresponds to a single joint:

  • When both rods move the same way, the foot pitches.
  • When they move in opposite directions, the foot rolls.
  • Any other combination produces a mix of pitch and roll.

Why accept that complexity? Moving mass up the leg reduces the inertia that the knee and hip must swing on every step. Both actuators also share the load of pitching, which is the axis that carries most of the torque during push-off.

The relationship between actuator positions and joint angles is a kinematic mapping. Going from pitch and roll to rod lengths (inverse kinematics) usually has a closed form. Going from rod lengths to pitch and roll (forward kinematics) generally needs an iterative solve. Forces map through the Jacobian J=∂L/∂qJ = \partial \mathbf L / \partial \mathbf q, the matrix of how much each rod length changes per radian of each joint. By the principle of virtual work, joint torques and rod forces are related by

τ=J⊤f⟺f=J−⊤τ\boldsymbol\tau = J^\top \mathbf f \qquad\Longleftrightarrow\qquad \mathbf f = J^{-\top} \boldsymbol\tau

In the experiment below, try a pure pitch torque and see both rods share it equally. Then move into a corner of the range and watch the forces become unequal as the Jacobian changes.

Loading simulation…
▸How this works · equations · source · limitationsOpen in lab

What it demonstrates

How a parallel ankle maps two actuator positions to ankle pitch and roll and back, why both actuators move for either motion, and how the Jacobian converts joint torques into actuator forces.

How it works

The ankle is a 2-DoF universal joint. Two push-rods run from anchors on the shank, 0.2 m above and 4.5 cm behind the ankle, to anchors on the foot. Inverse kinematics is closed form: rotate each foot anchor by the foot orientation and take the distance to its shank anchor.

Forward kinematics (rod lengths to angles) has no simple closed form, so it is solved by Newton's method on the inverse kinematics. The Jacobian J = ∂L/∂(pitch, roll) is computed by central differences. By virtual work, the joint torques are τ = Jᵀ f, so the rod forces for a desired torque are f = J⁻ᵀ τ.

Adjustable parameters

  • Mode: command joint angles (IK) or rod strokes (FK)
  • Pitch (±30°), roll (±20°)
  • Rod strokes (±30 mm)
  • Desired pitch and roll torque

Known limitations

  • The geometry (linear push-rods, anchor positions, foot shape) is illustrative. Menlo documents that Asimov uses a parallel ankle mechanism but not its geometry, and real designs often use rotary motors with cranks.
  • Statics only: no rod mass, friction, compliance or actuator dynamics.

Equations

Li(q)=∥ai−R(q) bi∥,R=Ry(−pitch) Rx(roll)L_i(\mathbf q) = \big\lVert \mathbf a_i - R(\mathbf q)\,\mathbf b_i \big\rVert,\quad R = R_y(-\text{pitch})\,R_x(\text{roll})
qn+1=qn+J−1(L∗−L(qn))\mathbf q_{n+1} = \mathbf q_n + J^{-1}\big(\mathbf L^* - \mathbf L(\mathbf q_n)\big)
τ=J⊤f  ⇒  f=J−⊤τ,J(0)=[csc−s]\boldsymbol\tau = J^\top \mathbf f \;\Rightarrow\; \mathbf f = J^{-\top}\boldsymbol\tau,\qquad J(\mathbf 0) = \begin{bmatrix} c & s \\ c & -s \end{bmatrix}

Core update rule

// IK: closed form
const L = [0, 1].map((i) => dist(upper[i], rotateFoot(foot[i], pitch, roll)));
// FK: Newton on the IK equations
for (let it = 0; it < 50; it++) {
  const e = sub(Lstar, ankleIK(q));
  q = add(q, solve(ankleJacobian(q), e));
}
// actuator forces for a joint torque
const f = solve(transpose(J), tau);

Explained in Chapter 6: Asimov Simulation

What the policy sees

Menlo states that the simulator maps ankle pitch and roll through the parallel mechanism. In other words, the mechanism is part of the simulated robot, not something the policy has to learn about directly. The pages do not say exactly where the mapping happens on hardware (in firmware or on the robot computer), so we do not claim either.

Passive toes, foot support and push-off

Human walking ends each stance phase with push-off: the heel rises, the body rolls over the ball of the foot, and the toes bend. A rigid, flat foot cannot do this smoothly. Once the heel lifts, it can only pivot on its front edge, so the support area collapses to a line and the contact point jumps.

A passive toe is a hinge near the front of the foot with no motor, only a spring and some damping. As the heel lifts, the ground pushes the toe up, the spring bends, and the toe stays flat on the ground. That gives three benefits:

  • A larger, longer-lasting support area during late stance, which makes balance easier.
  • Smoother transfer of load from heel to forefoot instead of a sudden pivot.
  • Elastic energy storage: the spring stores energy as it bends and returns it as the foot lifts off.

Because the toe is passive, its motion is entirely determined by physics: the spring, the damper, the foot's motion and contact with the ground. If the simulator gets the toe stiffness or the contact model wrong, the robot's push-off will be wrong too, and the policy will learn a gait for a foot that does not exist.

Loading simulation…
▸How this works · equations · source · limitationsOpen in lab

What it demonstrates

How a passive, spring-loaded toe deflects as the heel lifts during push-off, carries ground force without a motor, stores and returns elastic energy, and how the contact model's stiffness interacts with the toe spring.

How it works

The foot's motion is scripted: flat stance, then the heel lifts by up to the peak angle while rolling about the toe joint, then swing. The toe is a 5 cm link on a torsional spring and damper, integrated at 4 kHz. The ground pushes on the toe tip with a penalty force proportional to penetration (plus damping), as a soft-contact solver does.

With a held heel lift, the toe spring and the contact stiffness act in series: the toe bends by α·k_c r² / (k_c r² + k_t). A stiff toe bends less and transmits more force; soft contact steals deflection from the toe.

Adjustable parameters

  • Toe stiffness (0.5–40 N·m/rad)
  • Toe damping (0–0.2 N·m·s/rad)
  • Contact stiffness (5–100 kN/m)
  • Peak heel lift (5–40°)
  • Step period (0.6–3 s)
  • Playback speed

Known limitations

  • Foot motion is prescribed, not simulated; the body's weight is not modelled, only the toe's interaction with the ground.
  • All stiffness, damping and geometry values are illustrative. Menlo documents that the toes are passive and compliant but publishes no parameters.

Equations

Iβ¨=Frcos⁡(α−β)−ktβ−btβ˙I\ddot\beta = F r\cos(\alpha - \beta) - k_t\beta - b_t\dot\beta
F=max⁡ ⁣(0, kc p+bc p˙),p=max⁡ ⁣(0, rsin⁡(α−β)−h)F = \max\!\big(0,\ k_c\,p + b_c\,\dot p\big),\quad p = \max\!\big(0,\ r\sin(\alpha-\beta) - h\big)
βstatic=α kcr2kcr2+kt\beta_{static} = \alpha\,\frac{k_c r^2}{k_c r^2 + k_t}

Core update rule

const abs = alpha - beta;                       // toe angle below horizontal
const pen = Math.max(0, p.r * Math.sin(abs) - h);
const F = pen > 0 ? Math.max(0, kC * pen + bC * penDot) : 0;
const tau = F * p.r * Math.cos(abs) - kToe * beta - bToe * betaDot;
betaDot += (tau / inertia) * dt;
beta += betaDot * dt;

Explained in Chapter 6: Asimov Simulation

Notice the hint on the contact-stiffness slider. A penalty-style soft contact acts like a second spring in series with the toe. If the contact is too soft, the toe tip sinks into the ground instead of bending the toe. This is one concrete reason why contact tuning and toe modelling cannot be done separately.

Toe joint position and velocity are given only to the critic (privileged information during training), not to the actor. The deployed policy must infer what the toes are doing from ankle motion, the IMU and the body's response.

Visually accurate is not physically accurate

A robot model has two kinds of geometry:

  • Visual geometry: detailed meshes, usually exported from CAD, used for rendering.
  • Collision geometry: the shapes the physics engine uses to detect contact and compute contact forces.

They do not have to match, and for good simulation they usually should not. A visual mesh of a foot might have thousands of triangles, chamfers and screw heads. A contact solver that used it directly would find contacts on tiny features, get different contact points from one step to the next as the mesh rocks between triangles, and spend much more computation.

Loading simulation…
▸How this works · equations · source · limitationsOpen in lab

What it demonstrates

The difference between the geometry a robot model renders and the simpler geometry the physics engine uses for contact, such as capsules on feet and toes.

How it works

The site's procedural lower-body model (12 actuated joints, 2 passive toes) is drawn with visual bodies, with translucent collision capsules, or both. Joint angles come from a hand-written sinusoidal stepping pattern; it is an animation, not a simulation or a trained policy.

Adjustable parameters

  • Display: visual, collision or both
  • Stepping speed command

Known limitations

  • Dimensions, joint names and capsule sizes are illustrative, not Asimov's model.
  • The motion is scripted and kinematic; feet may slide or float.

Equations

capsule(p0,p1,r)={x:dist⁡(x,p0p1‾)≤r}\text{capsule}(\mathbf p_0, \mathbf p_1, r) = \{\mathbf x : \operatorname{dist}(\mathbf x, \overline{\mathbf p_0\mathbf p_1}) \le r\}

Pseudocode

<!-- MJCF pattern: render a mesh, collide with a capsule -->
<geom type="mesh" mesh="foot_visual" contype="0" conaffinity="0" group="1"/>
<geom type="capsule" fromto="-0.05 0 -0.04  0.10 0 -0.04" size="0.016" group="3"/>

Explained in Chapter 6: Asimov Simulation

A model can look perfect and still be physically wrong in every way that matters to a controller:

Looks rightBut physics depends on
Correct shape of every linkMass, centre of mass and inertia of each link, including batteries, cables and fasteners
Feet that touch the floor in rendersWhere contact points are, contact stiffness and damping, friction coefficients
Joints that bend the right wayJoint limits, friction, backlash, armature (reflected rotor inertia)
Motors drawn inside the legsTorque limits, speed limits, delay, how commands become torque
A smooth gait animationThe timing of sensing, computing and actuating

“If it looks like the robot, it simulates like the robot.”

Rendering and dynamics are computed from different data. A model's appearance tells you nothing about its masses, contact parameters or actuator behaviour, and nothing at all about timing. Chapter 2 discusses this separation in general.

Capsule collision primitives

A capsule is a cylinder with hemispherical ends: the set of all points within radius rr of a line segment. Capsules are popular for robot feet and limbs because:

  • Contact between a capsule and a plane (or another capsule) is cheap to compute exactly.
  • The surface is smooth and convex, so the contact point moves continuously as the foot rolls instead of jumping between mesh vertices.
  • A few capsules placed along the sole's edges give a small number of well-defined contact points, which makes contact repeatable from run to run.

Menlo describes exactly this choice for Asimov: explicit foot and toe contact points built from capsules, preferred over detailed mesh collision for conservative, repeatable contact. "Conservative" here is a design value. A simple, predictable contact model is easier to match to hardware and less likely to give the policy unrealistic contacts to exploit.

Illustrative example

A MuJoCo fragment for a foot with a visual-only mesh, capsule contact on the heel and a passive toe. The sizes, stiffness and damping values are made up for illustration; foot_visual would be a mesh declared in <asset>.

foot.xml (fragment, illustrative values)
<body name="foot" pos="0 0 -0.30">
  <!-- visual only: contype/conaffinity 0 means it never collides -->
  <geom type="mesh" mesh="foot_visual" contype="0" conaffinity="0" group="1"/>
  <!-- collision: a capsule across the heel -->
  <geom name="heel" type="capsule" fromto="-0.05 0.03 -0.04 -0.05 -0.03 -0.04" size="0.015" friction="1.0"/>
  <body name="toe" pos="0.10 0 -0.04">
    <!-- passive hinge: a spring and damper, no actuator -->
    <joint name="toe" type="hinge" axis="0 1 0" stiffness="6" damping="0.02" range="-0.05 0.8"/>
    <geom name="toe_pad" type="capsule" fromto="0.03 0.03 0 0.03 -0.03 0" size="0.014"/>
  </body>
</body>
xml

Contact tuning

MuJoCo's contact model is soft: contacts are allowed to penetrate slightly, with a stiffness and damping set by solver parameters such as solref and solimp (Chapter 3). These parameters, together with friction coefficients and the placement of contact geometry, decide how a foot lands, slips, rolls and pushes off. Contact tuning means adjusting them so that simulated contact matches measured behaviour: how far the robot sinks, how it bounces, when it slips. Menlo lists contact tuning as part of Asimov's model but does not publish the values.

Mechanical constraints

Real joints have hard stops, and linkages have their own limits. A parallel ankle may reach a pitch and roll that are each fine on their own but not together, because a rod hits its stroke limit or the linkage approaches a singular configuration where the Jacobian loses rank. Cables and covers limit motion too. A simulator that allows poses the hardware cannot reach lets the policy learn motions it can never perform. In the ankle experiment, try commanding both rods to extreme opposite strokes: some combinations have no solution.

Actuators: behaviour, friction, saturation and delay

An actuator turns a command into torque, but not ideally. Menlo documents that Asimov's simulation models three non-idealities. In general terms:

  • Saturation. Every motor has a maximum torque, set by current limits, thermal limits and the gearbox. Commands beyond it are clipped. A policy trained without saturation may rely on torques the hardware cannot produce, especially during recovery from pushes.
  • Joint friction. Gearboxes and bearings resist motion. Coulomb (dry) friction is a roughly constant torque opposing motion, plus stiction that must be overcome to start moving. Viscous friction grows with speed. Friction eats small corrective commands, so a policy trained on frictionless joints may expect fine adjustments that never happen. In MuJoCo, joint frictionloss and damping model these two effects.
  • Delay. A command does not become torque instantly. It must be transmitted, received by firmware, passed through control loops and turned into current. The torque arrives later than the policy assumes.

Other effects that matter in practice, though not listed on Menlo's page, include armature (the rotor's inertia, multiplied by the square of the gear ratio, which adds to the joint's apparent inertia), torque–speed limits, backlash and thermal derating.

What the policy actually outputs

Menlo documents that the policy produces commanded joint targets at 50 Hz. The pages do not say whether these are absolute positions or offsets from a default pose, what scaling is applied, or what control law turns them into motor torque. Many systems use a PD law in the actuator, τ=Kp(q∗−q)−Kdq˙\tau = K_p(q^* - q) - K_d \dot q, but that is a general pattern, not a documented Asimov detail.

Matching the simulation to the robot

Three things have to match for a policy to transfer:

  1. Physical properties. Masses, inertias, joint friction, actuator limits, toe stiffness and contact parameters. These are found by measurement and system identification, and covered with domain randomisation where they are uncertain (later chapters in Menlo's guide).
  2. Software interfaces. The same observation vector, computed the same way, from the same sources. If the real robot computes projected gravity with a particular sensor-fusion algorithm, the simulator should feed the policy gravity computed the same way, not the simulator's exact ground truth.
  3. Timing. The same control rate, the same delays, the same skew between signals, and similar jitter.

The first is the most familiar. The second and third are the subject of the rest of this chapter, because Menlo identifies them as where many real-world failures come from.

Many real-world failures come from timing skew, stale observations, bus jitter, or signals computed differently in simulation and on hardware, rather than from large mismatches in physics.

The timing architecture

LoopRatePeriodRole
Physics integration200 Hz5 msMuJoCo advances the robot's dynamics
IO-side state handling200 Hz5 msActuator-side state, timing and delay effects (not policy inference)
Policy execution50 Hz20 msProduces commanded joint targets from the latest available IO state

Why the frequencies differ

Each loop runs as fast as its job needs, and no faster:

  • Physics must be fast enough to integrate contact and joint dynamics stably and accurately. Foot impacts and stiff contacts change quickly, so the integrator needs small steps.
  • The IO path models what the actuator side of the real robot does between policy decisions: sampling joint state, applying commands, and imposing realistic delays. It needs the same fine time resolution as physics so that delays and skews of a few milliseconds can be represented.
  • The policy is a neural network that decides what the legs should do. Walking dynamics (step frequency, body sway) evolve over tens to hundreds of milliseconds, so a decision every 20 ms is enough, while leaving time for observation construction and inference. Lower-level control inside the actuators handles the fast part of tracking each target.

Four physics steps per policy interval

The rates imply a fixed ratio:

ΔtpolicyΔtphysics=20 ms5 ms=200 Hz50 Hz=4\frac{\Delta t_{\text{policy}}}{\Delta t_{\text{physics}}} = \frac{20\ \text{ms}}{5\ \text{ms}} = \frac{200\ \text{Hz}}{50\ \text{Hz}} = 4

Each policy action is therefore applied over four physics steps. In reinforcement-learning code this ratio is often called the decimation or frame skip. Menlo's page states the rates, not a decimation value; the 4 follows from them.

During those four steps the commanded target is held (a zero-order hold) while physics and IO keep running. The policy's next decision is made from the IO state as it stands at the next 20 ms boundary.

Loading simulation…
▸How this works · equations · source · limitationsOpen in lab

What it demonstrates

How Asimov's documented rates fit together: physics and IO-side state handling every 5 ms, the policy every 20 ms, so each policy action is held for four physics steps.

How it works

A step counter advances in 5 ms physics steps. Physics and IO tasks run on every step. The policy task runs on the first physics step at or after each of its ideal release times, i / f_policy. For 50 Hz this is exactly every fourth step.

The bottom trace shows a joint target produced at each policy step and held constant (zero-order hold) until the next one. Choosing a rate that does not divide 200 Hz, such as 60 Hz, shows the uneven 4-3-3 pattern that results.

Adjustable parameters

  • Policy rate (50 Hz documented; 40, 60, 100 Hz hypothetical)
  • Playback speed

Known limitations

  • The relative order of IO, policy and physics inside one step is a modelling choice; Menlo does not document it.
  • Rates other than 50 Hz are hypothetical.

Equations

Δtphys=1200 Hz=5 ms,Δtpolicy=150 Hz=20 ms\Delta t_{phys} = \tfrac{1}{200\,\text{Hz}} = 5\,\text{ms},\qquad \Delta t_{policy} = \tfrac{1}{50\,\text{Hz}} = 20\,\text{ms}
N=Δtpolicy/Δtphys=4N = \Delta t_{policy} / \Delta t_{phys} = 4
policy runs on step k  ⟺  ⌊kfpolfphys⌋>⌊(k−1)fpolfphys⌋\text{policy runs on step } k \iff \left\lfloor \tfrac{k f_{pol}}{f_{phys}} \right\rfloor > \left\lfloor \tfrac{(k-1) f_{pol}}{f_{phys}} \right\rfloor

Core update rule

for (let k = 0; ; k++) {
  ioSample(state);                         // 200 Hz
  if (runsOnStep(k, 50, 200)) action = policy(observation()); // every 4th step
  applyHeld(action);                       // zero-order hold
  physicsStep(state, 0.005);               // 200 Hz
}

Explained in Chapter 6: Asimov Simulation

Try the hypothetical 60 Hz setting. 200/60 is not an integer, so the policy period alternates between 3 and 4 physics steps. Real systems avoid that irregular pattern by choosing rates that divide evenly, which Asimov's 200 Hz and 50 Hz do.

Observation timing

"The latest available IO state" is not the state of the robot at the moment the policy runs. It is the most recent state that has made it through sensing, communication and processing. Every observation therefore has an age. On a real robot that age comes from encoder sampling and filtering in firmware, CAN transmission, kernel and driver handling, and waiting for the next policy step. Chapter 5's latency experiment shows how these add up.

Actuator timing

Commands also take time to act. A target computed at time tt is sent over the bus, received by firmware, and fed into the actuator's control loop. On the simulated robot it should take effect at the physics step that corresponds to the real delay, not at the same step it was computed. In a 200 Hz simulation, delays are naturally represented in multiples of 5 ms, or with finer interpolation if needed.

CAN timing groups and timing skew

Joint position and velocity observations are grouped by CAN timing, in groups 1–3. Delay and timing skew are modelled. Menlo does not publish which joints belong to which group or what each group's timing is.

Chapter 5 showed why groups like this arise. On a shared CAN bus, frames are transmitted one at a time, so joints whose feedback is sent later in each cycle are measured, or at least delivered, later than others. If all twelve joints are copied into the observation vector at once, they describe slightly different moments. That difference is timing skew.

Skew matters most when joints move fast. A joint swinging at 6 rad/s moves 6 mrad per millisecond, so 2 ms of skew makes its reading 12 mrad out of step with the others. A policy that combines joint angles to estimate foot positions effectively sees a slightly distorted leg.

Observation delays, action delays and jitter

Three timing effects are worth naming separately, because they affect a controller differently:

  • Observation delay: the policy acts on old information. In control terms this is a phase lag in the feedback path.
  • Action delay: the policy's decision takes effect late. It is also a phase lag, but it appears after the decision. A policy that has learned to compensate for one does not automatically compensate for the other in the same way, particularly in contact-rich moments.
  • Jitter: delays that vary from step to step. A constant delay can be learned and anticipated; a varying one cannot be fully compensated and acts more like noise in timing.
Loading simulation…
▸How this works · equations · source · limitationsOpen in lab

What it demonstrates

Observation delay, timing skew between CAN timing groups, jitter and actuator delay on one timeline: how old each part of the policy's observation is, and when its command actually takes effect.

How it works

A joint swings at 2 Hz. At each 50 Hz policy step the observation for each of three CAN timing groups is the joint angle at an earlier time: the read time minus a common latency, minus the group index times a skew, minus a uniform random jitter. The policy in this demo simply commands the angle it observes for group 1.

The command is applied on the first 5 ms physics step at or after the read time plus the actuator delay, then held. The timeline shows the last policy step; the chart shows the true angle, what the policy saw for groups 1 and 3, and the command in effect.

Adjustable parameters

  • Sensor + bus latency (0–20 ms)
  • Skew between groups (0–5 ms)
  • Jitter (0–5 ms)
  • Actuator delay (0–20 ms)
  • Playback speed

Known limitations

  • Menlo documents CAN timing groups 1–3 but not their membership or timing; the 4/4/4 split and every delay value here are illustrative.
  • Observations are taken from a continuous signal; a real IO path samples at discrete instants.

Equations

tgsample=tread−L−g σ−J u,u∼U(0,1), g∈{0,1,2}t^{sample}_g = t_{read} - L - g\,\sigma - J\,u,\quad u \sim \mathcal{U}(0,1),\ g \in \{0,1,2\}
q^g=q(tgsample),skew=max⁡gtgsample−min⁡gtgsample\hat q_g = q\big(t^{sample}_g\big),\qquad \text{skew} = \max_g t^{sample}_g - \min_g t^{sample}_g
kapply=⌈(tread+dact)/Δtphys⌉k_{apply} = \left\lceil (t_{read} + d_{act}) / \Delta t_{phys} \right\rceil

Core update rule

if (runsOnStep(k, 50)) {
  const obs = [0, 1, 2].map((g) => q(t - latency - g * skew - jitter * rng()));
  pending.push({ step: Math.ceil((t + actDelay) / 0.005), u: obs[0] });
}
while (pending[0]?.step <= k) applied = pending.shift().u;

Explained in Chapter 6: Asimov Simulation

Why ideal observations produce unrealistic policies

A policy trained in a simulator with perfect, instantaneous, synchronised observations learns to rely on that perfection. It may use very high effective feedback gains, reacting sharply to small changes, because in simulation that works. On hardware, the same gains combined with delay can produce oscillation or instability, exactly as in the experiment below. It may also learn to depend on fine relationships between joint signals that skew destroys, or react to a contact event within one step when the real robot cannot even observe the event that quickly.

Loading simulation…
▸How this works · equations · source · limitationsOpen in lab

What it demonstrates

Why a controller that works with ideal, instantaneous observations can oscillate or fall when observations and actions are delayed, even with the same 200 Hz physics and 50 Hz control rates.

How it works

Two identical inverted pendulums (4 kg at 0.6 m, standing in for a robot balancing over its ankles) are integrated with semi-implicit Euler at 200 Hz. A PD controller runs every fourth physics step (50 Hz) and its torque is held between steps and clipped at 40 N·m.

The ideal copy sees the state of the current physics step and its torque applies immediately. The delayed copy samples the state into a timestamped buffer at 200 Hz; each sample becomes visible only after the observation delay plus jitter, and each command takes effect only after the action delay plus jitter. Both receive the same pushes.

Adjustable parameters

  • Observation delay (0–60 ms)
  • Action delay (0–60 ms)
  • Jitter (0–10 ms)
  • Kp (30–250 N·m/rad)
  • Kd (0–30 N·m·s/rad)
  • Periodic pushes / push button

Known limitations

  • A single-joint pendulum is far simpler than a legged robot; it shows the mechanism, not Asimov's numbers.
  • The controller is a hand-tuned PD law, not a learned policy.
  • Delays are quantised to 5 ms physics steps.

Equations

ml2θ¨=mglsin⁡θ−bθ˙+τ+τpushm l^2 \ddot\theta = m g l \sin\theta - b\dot\theta + \tau + \tau_{push}
τk=clip⁡(−Kp θ(tk−dobs)−Kd θ˙(tk−dobs), ±τmax) applied at tk+dact\tau_k = \operatorname{clip}\big(-K_p\,\theta(t_k - d_{obs}) - K_d\,\dot\theta(t_k - d_{obs}),\ \pm\tau_{max}\big) \text{ applied at } t_k + d_{act}
ϕlag(ω)≈ω (dobs+dact+12Δtpolicy)\phi_{lag}(\omega) \approx \omega\,(d_{obs} + d_{act} + \tfrac{1}{2}\Delta t_{policy})

Core update rule

obs.push(t, t + obsDelay + jitter * rng(), [theta, omega]);   // IO, 200 Hz
if (runsOnStep(k, 50)) {
  const o = obs.latest(t);                                   // newest visible sample
  actions.push({ tApply: t + actDelay + jitter * rng(), u: -kp * o[0] - kd * o[1] });
}
u = latestDue(actions, t);                                   // zero-order hold
omega += ((m * g * l * Math.sin(theta) - b * omega + clip(u)) / (m * l * l)) * dt;
theta += omega * dt;

Explained in Chapter 6: Asimov Simulation

Things to try:

  • With the defaults, the delayed pendulum is visibly less damped than the ideal one.
  • Increase both delays to about 40 ms. The delayed pendulum oscillates or falls, while the ideal one is unaffected.
  • Lower Kp and Kd. The delayed system becomes stable again, at the cost of slower recovery. A policy trained with delays makes a similar trade automatically, because aggressive behaviour gets punished during training.

This is why Asimov's simulator models delay and skew during training, and why Menlo uses CAN delay and jitter injection to test robustness: a policy should experience the hardware's timing before it meets the hardware.

Code: a multi-rate loop with delays in MuJoCo

Illustrative example

The following script reproduces the structure of the timing architecture on a single-joint model: physics at 200 Hz, IO sampling at 200 Hz, a controller at 50 Hz, and fixed observation and action delays implemented with buffers. The model, gains and delay values are made up for illustration and are not Asimov's.

multirate_delay.py
import collections
 
import mujoco
 
XML = """
<mujoco>
  <option timestep="0.005" gravity="0 0 -9.81"/>
  <worldbody>
    <body name="pole">
      <joint name="ankle" type="hinge" axis="0 1 0" damping="0.5" frictionloss="0.2" armature="0.01"/>
      <geom type="capsule" fromto="0 0 0 0 0 0.6" size="0.03" mass="4"/>
    </body>
  </worldbody>
  <actuator>
    <motor joint="ankle" ctrlrange="-40 40" ctrllimited="true"/>
  </actuator>
</mujoco>
"""
 
model = mujoco.MjModel.from_xml_string(XML)
data = mujoco.MjData(model)
data.qpos[0] = 0.08                      # start tilted by 0.08 rad
 
PHYSICS_HZ, POLICY_HZ = 200, 50
STEPS_PER_POLICY = PHYSICS_HZ // POLICY_HZ   # 4, implied by the rates
OBS_DELAY_STEPS = 3                      # 15 ms observation delay (illustrative)
ACT_DELAY_STEPS = 2                      # 10 ms action delay (illustrative)
KP, KD = 60.0, 6.0                       # illustrative PD gains
 
assert abs(model.opt.timestep - 1.0 / PHYSICS_HZ) < 1e-12
 
obs_buffer = collections.deque(maxlen=OBS_DELAY_STEPS + 1)
act_buffer = collections.deque([0.0] * ACT_DELAY_STEPS)
command = 0.0
 
for k in range(2000):                    # 10 s of simulated time
    # IO side, every physics step: sample joint state into the delay line
    obs_buffer.append((float(data.qpos[0]), float(data.qvel[0])))
 
    # Policy side, every 4th step: act on the oldest buffered sample
    if k % STEPS_PER_POLICY == 0:
        q, qd = obs_buffer[0]            # OBS_DELAY_STEPS old once the buffer is full
        command = -KP * q - KD * qd      # held until the next policy step
 
    # Actuator side: the command reaches the motor ACT_DELAY_STEPS later
    act_buffer.append(command)
    data.ctrl[0] = act_buffer.popleft()  # ctrlrange clips it to +-40 N*m
 
    mujoco.mj_step(model, data)          # advance physics by 5 ms
 
print(f"final angle {data.qpos[0]:+.5f} rad at t = {data.time:.2f} s")
python

Change OBS_DELAY_STEPS and ACT_DELAY_STEPS and rerun. With zero delay the pole settles quickly; as the delays grow, the same gains first ring and then fail. Training environments do the same thing at scale, often with delays randomised per episode.

Processor-in-the-loop

Training happens entirely in simulation. Before a policy goes onto the real robot, it is valuable to test it against the real software stack: the same firmware, drivers and observation code that will run on hardware, with only the physical robot replaced by the simulator. Menlo describes a processor-in-the-loop setup for exactly this.

  • Joint communication uses virtual CAN via SocketCAN, the same software interface as the real actuator stack.
  • A MuJoCo bridge reads the simulated IMU signals imu_ang_vel and imu_lin_acc and sends them to the firmware over UDP.
  • The hardware FusionX sensor-processing path computes the projected gravity that the policy observes.
  • CAN delay and jitter injection is used to test timing robustness.

The joint path

Joint feedback and command loop

  1. 1MuJoCo Physics Engine200 Hz dynamics
  2. 2Virtual CAN Joint FeedbackSocketCAN vcan, timing groups 1–3
  3. 3Firmware / IO Processingthe real actuator-side software
  4. 4Observation Constructionjoint pos/vel, previous actions
  5. 5Locomotion Policy50 Hz neural network
  6. 6Actuator Commandscommanded joint targets

Loops back: Actuator Commands → MuJoCo Physics Engine

The simulator plays the role of the motors on a virtual CAN bus. Everything from the firmware to the policy is the software that runs on the robot.
  1. MuJoCo computes joint positions and velocities.
  2. The bridge publishes them as CAN frames on a virtual CAN interface, the vcan device from Chapter 5. To the software above, it looks just like the actuators' real bus. Delay and jitter can be injected here.
  3. The firmware and IO processing receive the frames exactly as they would from real motor controllers.
  4. The observation is built from those values, with whatever timing and grouping the real path produces.
  5. The policy runs on that observation.
  6. Its actuator commands go back out over virtual CAN, and the bridge applies them to the simulated joints, closing the loop.

The IMU path

IMU to projected gravity

  1. MuJoCo IMU Sensorsimu_ang_vel, imu_lin_acc
  2. UDP Bridgedatagrams to the firmware
  3. Firmware Sensor FusionFusionX path
  4. Projected Gravitygravity direction in the body frame
  5. Policy Observationwith base angular velocity
The policy receives projected gravity computed by the same sensor-processing path as on hardware, not the simulator's exact orientation.

Projected gravity is the direction of gravity expressed in the robot's base frame. When the robot stands upright it is (0,0,−1)(0, 0, -1); when it tilts forward, the vector tips accordingly. It tells the policy which way is down without requiring a full orientation estimate. The simulator knows the robot's orientation exactly and could compute projected gravity perfectly. Sending raw IMU signals through the hardware's own fusion path instead means the policy sees projected gravity with the same filtering, lag and error characteristics it will have on the real robot. This is a direct application of the interface-matching principle. Menlo's pages do not describe FusionX's internals, so this chapter does not either.

Processor-, software- and hardware-in-the-loop

These terms describe how much of the real system takes part in a test:

Software-in-the-loop (SIL)Processor-in-the-loop (PIL)Hardware-in-the-loop (HIL)
Controller codeReal code, compiled for the development PCReal code on the target processor (or its exact build)Real code on the real controller hardware
Robot bodySimulatedSimulatedSimulated, often with real sensors, drives or electrical interfaces attached
InterfacesOften function calls or simplified messagesReal software interfaces (e.g. SocketCAN on vcan, UDP)Real electrical signals and buses
What it catchesLogic errors, policy behaviourInterface, timing, scheduling and computation differencesElectrical and real-time hardware issues
Cost and riskLowestLowHigher, needs dedicated rigs
General principle

These definitions vary between industries and companies; the table gives typical usage. The key idea is that each step replaces more of the simulation with the real thing while keeping the physical robot safely out of the loop.

Asimov's setup uses the real software interfaces and processing path with simulated physics, which is what makes it processor-in-the-loop in this taxonomy. It catches a class of problems that pure simulation cannot: a policy that only works when observations are perfectly synchronised, an observation computed slightly differently on the robot, or a firmware path that adds more delay than training assumed.

Limitations and common misconceptions

“A higher control rate always transfers better.”

A faster policy reduces one source of delay, but the transfer problem is about matching. A policy trained at 200 Hz with no delay and deployed on hardware that delivers 50 Hz observations with skew is worse off than one trained at 50 Hz with realistic timing.

“Delay can be fixed later with a faster computer.”

Much of the delay is in the sensing and actuation path (firmware filtering, bus scheduling, motor current response), not in inference. A faster computer does not remove it.

“Processor-in-the-loop proves the policy will work on the robot.”

It shows that the software and timing interfaces behave as expected with simulated physics. Contact, friction, toe behaviour and actuator dynamics still differ on hardware. PIL narrows the gap; it does not close it.

Limits of the experiments in this chapter

The browser experiments use simplified, illustrative models: a 2-D linkage, a scripted foot, a single-joint pendulum. They show mechanisms, not Asimov's actual numbers. Only the facts in the documented boxes come from Menlo, and the CAN timing-group membership, delay values and mechanical parameters remain unpublished.

Key takeaways

Key takeaways

  • Asimov's locomotion platform is legs only: 12 actuated joints and 2 passive, compliant toes, with a parallel ankle that couples pitch and roll through two actuators.
  • A parallel ankle maps actuator positions to pitch and roll through nonlinear kinematics; torques and actuator forces are related by τ = Jᵀf.
  • Passive toes extend support and smooth push-off with no motor; their behaviour depends on toe stiffness and on contact tuning together.
  • Visual meshes are for looking; capsule collision primitives give conservative, repeatable contact. A visually accurate model can be physically wrong.
  • Actuator saturation, friction and delay are modelled because policies exploit any idealisation they are trained on.
  • Physics and IO run at 200 Hz (5 ms) and the policy at 50 Hz (20 ms), so each action is held for four physics steps.
  • Joint observations arrive in CAN timing groups with skew; delays, jitter and stale data are major sources of sim-to-real failure, so they are modelled in training.
  • Processor-in-the-loop runs the real software path (virtual CAN via SocketCAN, a UDP IMU bridge, the FusionX projected-gravity path) against simulated physics.

References and further reading

  • Menlo, Understanding Your Simulation Environment, the primary source for this chapter.
  • Menlo, Reinforcement Learning for Locomotion, for observations, network structure and the sim-to-real framing.
  • Menlo, Asimov locomotion-training guide overview, including later chapters on system identification, domain randomisation and deployment.
  • MuJoCo documentation: Modeling (contact parameters solref/solimp, collision filtering with contype/conaffinity) and the XML reference (joint stiffness, damping, frictionloss, armature; actuator ctrlrange).
  • Linux kernel documentation, SocketCAN, including the virtual CAN driver.
  • J. Tan et al., "Sim-to-Real: Learning Agile Locomotion For Quadruped Robots," Robotics: Science and Systems, 2018, on modelling actuators and latency for transfer.
  • J. Hwangbo et al., "Learning agile and dynamic motor skills for legged robots," Science Robotics, 2019, on actuator networks and the role of actuator modelling.
  • K. J. Åström and R. M. Murray, Feedback Systems, 2nd ed. (Princeton, 2021), chapters on time delay and stability margins. Free online.