Skip to content
Physical AI
Chapter 08 30 min read

Reinforcement Learning for Asimov Locomotion

The 45-dimensional observation, the 45→512→256→128→12 actor, and how a neural network becomes a walking controller.

Fifty times a second, Asimov's walking controller receives a list of 45 numbers and returns 12. Everything the robot "knows" about its own balance, posture and recent behaviour is in those 45 numbers, and everything it does with its legs follows from those 12. This chapter takes the list apart one number at a time, then follows it through the neural network that turns it into joint commands.

The previous chapter explained reinforcement learning in general. Here we make it concrete: what the policy sees, why it sees exactly that and nothing more, how the network is built, and what happens to its output on the way to the motors.

What a locomotion policy is

A policy is a function that maps what the robot observes to what it should do next:

at=πθ(ot)a_t = \pi_\theta(o_t)

Here oto_t is the observation at control step tt, ata_t is the action, and θ\theta stands for all the adjustable numbers (the network's weights) that training tunes. A locomotion policy is a policy whose job is to keep a legged robot upright while it moves the way it is told to move.

Think of a person walking with their eyes closed. They still know which way is down (the inner ear), how fast they are turning, where their legs are (proprioception) and what they just did with their muscles a moment ago. They also know where they want to go. That is roughly what Asimov's policy gets, and it is enough to walk.

Three properties of the policy shape everything in this chapter:

  • It is reactive. The policy does not plan a trajectory. At each step it looks at the current observation and produces the next action. Walking emerges from repeating that mapping 50 times per second.
  • It is learned. Nobody wrote down the equations for when to lift a foot. The mapping was found by reinforcement learning in simulation (Chapter 7).
  • It is deployed on hardware. The same function must work on the physical robot, where it sees real sensor data with real noise and delays. This is the reason the observation is designed so carefully.

Asimov's policy runs at 50 Hz and produces commanded joint targets from the latest available IO state. Physics is simulated at 200 Hz and the observation/IO path is modelled at 200 Hz, which captures actuator-side state, timing and delay effects. The rates imply four physics steps per policy step.

Why the observation interface matters

It is tempting to think of the neural network as the interesting part and the observation as plumbing. For a robot that is trained in simulation and deployed on hardware, the reverse is closer to the truth.

A policy only ever learns the relationship between the inputs it was trained on and the rewards it received. If on the real robot one of those inputs is computed differently, arrives later, is noisier, or is simply unavailable, the policy is now running on data it has never seen. It may still work. It may also do something confident and wrong.

Menlo attributes Asimov's sim-to-real transfer mainly to matching the observation and actuation interface, meaning the type, timing and quality of the data, rather than to novelty in the network architecture.

So the guiding rule for the actor's observation is simple: include only what the real robot can measure, measured the way the real robot measures it. Every choice below follows from that rule.

The 45-dimensional actor observation

At every policy step the actor receives one vector of 45 numbers, built from six groups:

IndexGroupSizeComes fromUnit
0–2Base angular velocity3IMU gyroscoperad/s
3–5Projected gravity3IMU data, computed on the FusionX pathunit vector
6–8Movement command (vx,vy,ωzv_x, v_y, \omega_z)3operator or higher-level plannerm/s, m/s, rad/s
9–20Joint positions12actuator encoders over CANrad
21–32Joint velocities12actuator side over CANrad/s
33–44Previous actions12the policy's own recent outputsaction units

The actor observation has 45 values: base angular velocity (3), projected gravity (3), desired movement command (3), joint positions (12), joint velocities (12) and previous actions (12), described as a "smoothed control history". Base linear velocity is deliberately excluded.

The index ranges follow the order in which Menlo lists the groups. Inside each group, the order of elements (for example, which joint is index 9) is not documented, and neither is any per-term scaling applied before normalization. The site's shared layout file, lib/sim/ch08-observations.ts, records exactly this split between documented and assumed details.

Explore the vector below. Every cell is one input to the network; hover or select one to see where it comes from and what it means.

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

What it demonstrates

Exactly which 45 numbers Asimov's locomotion policy receives at each 50 Hz step, how they are grouped, where each comes from and what it means physically.

How it works

The layout (six groups: base angular velocity 3, projected gravity 3, command 3, joint positions 12, joint velocities 12, previous actions 12) and each group's source are taken from Menlo's documentation and stored in lib/sim/ch08-observations.ts.

The live values are synthetic. Every 20 ms the site's hand-written scripted gait produces joint angles, joint velocities are finite differences, a made-up torso sway produces roll and pitch, projected gravity is computed from them, and the previous-action block is an exponentially smoothed history of the scripted pose expressed as actions. No physics engine or trained policy is involved.

Adjustable parameters

  • Command v_x (−1 to 1 m/s)
  • Command v_y (−0.5 to 0.5 m/s)
  • Command w_z (−1 to 1 rad/s)
  • Selected element (0–44)

Known limitations

  • Values are generated by a scripted animation and a hand-made sway model, not by MuJoCo or a policy.
  • Per-element order inside groups, any per-term scaling and the exact smoothing used for previous actions are not documented by Menlo.
  • Joint names shown are the site's illustrative convention.

Equations

ot=[ ωt,  gtb,  ct,  qt,  q˙t,  aˉt−1 ]∈R3+3+3+12+12+12=45o_t = \big[\,\omega_t,\; g^{b}_t,\; c_t,\; q_t,\; \dot q_t,\; \bar a_{t-1}\,\big] \in \mathbb{R}^{3+3+3+12+12+12=45}
gb=R⊤[00−1]=[sin⁡θ−sin⁡ϕcos⁡θ−cos⁡ϕcos⁡θ]g^{b} = R^{\top} \begin{bmatrix}0\\0\\-1\end{bmatrix} = \begin{bmatrix}\sin\theta\\ -\sin\phi\cos\theta\\ -\cos\phi\cos\theta\end{bmatrix}
aˉt=β aˉt−1+(1−β) at(illustrative smoothing)\bar a_{t} = \beta\,\bar a_{t-1} + (1-\beta)\,a_{t}\quad(\text{illustrative smoothing})

Core update rule

// lib/sim/ch08-observation-frame.ts (values illustrative, layout documented)
const obs = concatObservation({
  base_ang_vel: s.angVel,                 // 3, IMU gyro
  projected_gravity: s.gravity,           // 3, FusionX path on hardware
  command: [cmd.vx, cmd.vy, cmd.wz],      // 3
  joint_pos: s.q,                         // 12, CAN timing groups 1-3
  joint_vel: s.qd,                        // 12
  prev_actions: s.prevActions,            // 12, smoothed control history
}); // Float32Array(45)

Explained in Chapter 8: Locomotion Policy

The rest of this section explains each group in turn: where it comes from, what it means physically, and why the policy needs it.

Base angular velocity (3 values)

What it is. The rate at which the robot's torso (the "base") is rotating about three axes fixed to the body: roll (tipping sideways, about the forward axis), pitch (tipping forward or back, about the sideways axis) and yaw (turning, about the vertical axis). Units are radians per second.

Where it comes from. A gyroscope inside the inertial measurement unit (IMU) mounted on the pelvis measures angular velocity directly (Chapter 4). In Asimov's processor-in-the-loop simulation, a MuJoCo bridge reads the simulated imu_ang_vel signal and sends it to the firmware over UDP, so the policy receives it through the same software path as on hardware.

Why it is useful. Angular velocity is the earliest warning of a fall. A robot that starts to tip shows a growing roll or pitch rate long before its tilt angle becomes large. It also closes the loop on turning: if the command asks for ωz=0.5\omega_z = 0.5 rad/s, the yaw-rate reading tells the policy whether it is actually turning that fast. A gyroscope measures rotation rate directly and with low latency, which makes it one of the most trustworthy signals a legged robot has.

Projected gravity (3 values)

What it is. The direction of gravity, expressed in the robot's own body frame. It is a unit vector. When the robot stands perfectly upright it reads approximately (0,0,−1)(0, 0, -1): gravity points straight down along the body's vertical axis. When the robot leans forward, part of gravity appears along the body's forward axis; when it leans sideways, part appears along the sideways axis.

If the robot's orientation is described by roll ϕ\phi and pitch θ\theta, the projected gravity is

gb=R⊤[00−1]=[sin⁡θ−sin⁡ϕcos⁡θ−cos⁡ϕcos⁡θ]g^{b} = R^{\top}\begin{bmatrix}0\\0\\-1\end{bmatrix} = \begin{bmatrix}\sin\theta\\ -\sin\phi\cos\theta\\ -\cos\phi\cos\theta\end{bmatrix}

where RR is the rotation from body to world frame. The heading (yaw) does not appear, which is exactly the point.

Where it comes from. No sensor measures gravity direction directly. It is estimated by fusing gyroscope and accelerometer data: the accelerometer tells you roughly which way is down when the robot is not accelerating hard, and the gyroscope tracks fast changes in between.

In Asimov's processor-in-the-loop setup, the MuJoCo bridge sends imu_ang_vel and imu_lin_acc to the firmware over UDP, and the hardware FusionX path computes projected gravity for the policy. Simulation and hardware therefore use the same estimator.

That design choice is a direct application of the data-matching rule. Reading the true orientation from the simulator would have been easier, but it would give the policy a perfect signal during training and an estimated one at deployment.

Why it is useful. Balance is about staying upright, and "upright" means "body axis aligned with gravity". Projected gravity gives the tilt in a form that does not depend on which way the robot faces, so the policy does not need to learn separate behaviour for every heading. Three numbers are used instead of two angles because a unit vector has no wrap-around or singularities.

Movement command (3 values)

What it is. The instruction the robot is following:

  • vxv_x: desired forward (positive) or backward (negative) velocity, in m/s.
  • vyv_y: desired sideways velocity, in m/s (positive to the robot's left under the usual convention).
  • ωz\omega_z: desired turning rate about the vertical axis, in rad/s.

Where it comes from. A joystick, a teleoperation interface, or a higher-level navigation planner. During training, commands are sampled randomly so the policy learns to follow the full range.

Why it is useful. Without the command, a policy could learn only one behaviour. Including the command as an input makes the policy conditional: the same network walks forward, sideways or turns depending on these three numbers. The reward during training measures how well the robot's actual motion matches the command, so the policy learns to read them. Note what the command is not: it is a request, not a measurement. The robot's actual velocity is a different quantity, and as we will see, the actor never receives it.

Joint positions (12 values)

What it is. The angle of each of the 12 actuated leg joints, six per leg. This is the robot's posture.

Where it comes from. Each actuator has a position encoder. The readings travel over the CAN bus (Chapter 5) to the computer running the policy.

Joint position and joint velocity observations are grouped by CAN timing (groups 1–3). Delay and timing skew are modelled in simulation, and bus jitter and stale observations are named as major sources of sim-to-real failure. Which joints are in which group, and the exact timing, are not published.

This detail matters more than it looks. On the real robot, the 12 joint readings are not captured at one instant. They arrive in groups at slightly different times, so the "posture" the policy sees is stitched together from slightly different moments. A policy trained on perfectly synchronised joint data has never seen this skew. Modelling the timing groups in simulation means the policy learns to cope with it.

Why it is useful. The policy has to know where its legs are to decide where to put them. Joint positions also implicitly encode where the feet are relative to the body (through the leg's kinematics), which matters for balance.

Joint velocities (12 values)

What it is. How fast each actuated joint is rotating, in rad/s.

Where it comes from. The actuator side, over CAN, in the same timing groups as positions. Whether the velocity is measured or differentiated from position inside the actuator is not specified in the reviewed documentation.

Why it is useful. Position says where a leg is; velocity says where it is going. A policy that knows only positions has to infer motion from changes between steps, which it cannot do from a single snapshot. Velocity also lets the policy damp oscillations, much as the KdK_d term does in a PD controller (Chapter 1). Joint velocities are noisier than positions, which is one reason the robot's simulated sensors include noise.

Previous actions (12 values)

What it is. A record of what the policy itself commanded recently, one value per joint.

Where it comes from. Software. The policy's own outputs are kept and fed back in at the next step. No sensor is involved.

Menlo describes the previous-action input as a "smoothed control history". The exact smoothing method is not described on the reviewed pages.

Why it is useful. A feedforward policy has no memory; each step it sees only the current observation. Previous actions give it a small, cheap form of memory:

  • Consistency. Knowing what it just commanded lets the policy produce smooth commands rather than jumping between unrelated targets. Jerky commands waste energy, excite vibrations and stress gearboxes.
  • Actuator lag. Motors do not reach a commanded target instantly. Comparing what was commanded with where the joint actually is (the joint positions) tells the policy how far behind the actuators are, which is information about actuator dynamics that is otherwise invisible.
  • Phase information. In a periodic gait, recent commands hint at where in the step cycle the robot is.

Previous actions are a limited history. They cover only the policy's own outputs over a short window, not past sensor readings. That limitation comes back in Chapter 9, where we discuss what a policy cannot infer from a single observation.

What is deliberately left out

The most interesting entry in Asimov's observation list is one that is missing.

Base linear velocity (how fast the torso is moving forwards, sideways and vertically) is obviously relevant to walking. A simulator can report it exactly. Yet Menlo excludes it from the actor on purpose.

The reason is that a real robot cannot measure it directly. An IMU measures acceleration, not velocity. Integrating acceleration to get velocity accumulates every small bias into a growing drift, so after a few seconds the estimate is useless. Estimating velocity well requires a dedicated state estimator that fuses leg kinematics, contact detection and IMU data, and its errors are very different from the simulator's perfect value. A policy trained with perfect velocity would come to rely on it and then receive something quite different on hardware.

The same logic excludes foot contact forces and the passive toe joints, which are available in simulation but not as reliable hardware signals for the policy. The critic receives all of these during training. That asymmetry is the subject of Chapter 9.

A policy that does not see force

Menlo notes that a policy without force input does not react to contact changes as aggressively as a force-rich system, but it is stable. This is a deliberate trade-off: less information, but information the policy can trust on hardware.

Where the data comes from, step by step

Putting the sources together, one policy step looks like this:

  1. IMUgyro + accelerometer
  2. FusionXprojected gravity
  3. Actuators over CANjoint pos/vel, timing groups 1–3
  4. Command + action historysoftware
  5. 45-D observationfloat32 vector
  6. Actor network50 Hz
  7. 12 joint targetsto low-level control
Signals from three hardware paths and two software sources are combined into one observation every 20 ms.

In simulation, MuJoCo replaces the physical robot but not the software path. Asimov's processor-in-the-loop setup uses a virtual CAN interface (SocketCAN) with the same software interface as the actuator stack, and can inject CAN delay and jitter to test how robust the policy is to timing (Chapter 6).

The experiment below lets you steer a lower-body humanoid with a command pad and watch the command values enter the observation, together with the IMU and joint signals. The robot here is driven by a hand-written stepping animation, not by a policy and not by physics. It shows what the signals look like, not how a trained policy produces them.

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

What it demonstrates

How the three command values enter the observation, and what base angular velocity, projected gravity and joint signals look like while a lower-body humanoid steps.

How it works

A 2-D pad sets v_x (up/down) and v_y (left/right); a slider sets w_z. These three numbers are copied straight into obs[6..8].

The 3D robot is driven by scriptedGait(), a hand-written sinusoidal stepping animation, so it is a picture of what the signals look like, not a policy responding to them. Roll and pitch come from a made-up torso sway; the gyro reading is their time derivative plus small Gaussian noise, and yaw rate follows w_z with a 0.25 s lag.

Adjustable parameters

  • v_x, v_y via the command pad
  • w_z (−1 to 1 rad/s)
  • Plotted joint (0–11)

Known limitations

  • The gait is scripted. It does not balance, does not react to the IMU and is not trained.
  • The robot stays in place (treadmill view); no base motion is simulated.
  • Kinematics, link lengths and joint names are illustrative, not Asimov's.

Equations

ct=(vx∗,  vy∗,  ωz∗)c_t = (v_x^{*},\; v_y^{*},\; \omega_z^{*})
ωx≈ϕ˙,ωy≈θ˙,ω˙z=(ωz∗−ωz)/0.25 s\omega_x \approx \dot\phi,\quad \omega_y \approx \dot\theta,\quad \dot\omega_z = (\omega_z^{*}-\omega_z)/0.25\,\text{s}

Core update rule

const { q, toes } = scriptedGait(t, cmd);       // hand-written animation
const roll  = 0.035 * speed * Math.sin(phase) - 0.12 * cmd.vy;
const pitch = 0.06 * cmd.vx + 0.015 * speed * Math.sin(2 * phase);
angVel  = [(roll - prevRoll) / dt, (pitch - prevPitch) / dt, yawRate];
gravity = projectedGravity(roll, pitch);

Explained in Chapter 8: Locomotion Policy

Things to notice:

  • The three command values are copied into indices 6–8 unchanged. They are the only part of the observation the operator controls directly.
  • Turning (ωz\omega_z) shows up in the yaw-rate reading after a short lag. The policy sees both what was asked and what is happening.
  • Leaning into a sideways command changes the projected gravity's yy component. Projected gravity changes only with tilt, never with heading.

Assembling the observation in code

Once the six groups are available, building the observation is a single concatenation. Here is a sketch in NumPy. The variable names are ours, and real code would read these values from the sensor and actuator interfaces rather than receive them as arguments.

build_observation.py
import numpy as np
 
def build_observation(
    base_ang_vel: np.ndarray,       # (3,)  rad/s, body frame, from the IMU gyro
    projected_gravity: np.ndarray,  # (3,)  unit vector, from the IMU fusion path
    command: np.ndarray,            # (3,)  [v_x, v_y, w_z]
    joint_pos: np.ndarray,          # (12,) rad
    joint_vel: np.ndarray,          # (12,) rad/s
    prev_actions: np.ndarray,       # (12,) the policy's recent (smoothed) outputs
) -> np.ndarray:
    obs = np.concatenate(
        [base_ang_vel, projected_gravity, command, joint_pos, joint_vel, prev_actions]
    ).astype(np.float32)
    assert obs.shape == (45,), obs.shape
    return obs
python

Three practical points:

  • Order is a contract. The network has no idea which number is which; it only knows positions in the vector. If deployment code swaps two groups, or orders joints differently from training, the policy receives nonsense with no error message. Freeze the layout in one shared definition and test it.
  • float32. Neural network weights are almost always stored as 32-bit floats, and inference libraries expect float32 inputs. Converting once, at assembly time, avoids silent upcasts and copies.
  • Shape (45,). For a single robot the observation is a flat vector. During training, thousands of simulated robots run in parallel and their observations are stacked into a matrix of shape (num_envs, 45). The network processes the whole batch at once.

Passing the vector to a PyTorch network then looks like this:

infer.py
import torch
 
obs_t = torch.from_numpy(obs).unsqueeze(0)   # shape (1, 45), float32
with torch.no_grad():
    action = actor(obs_t).squeeze(0).numpy()   # shape (12,)
python

The actor network

The function πθ\pi_\theta is a neural network. Asimov's is small by modern standards and very standard in shape.

Actor: multilayer perceptron 45 → 512 → 256 → 128 → 12. Activation: ELU. Observation normalization: enabled. Initial policy noise standard deviation: 1.0.

These choices match the defaults of the open-source legged_gym / rsl_rl training code that accompanied Rudin et al. (2022): [512, 256, 128] hidden layers, ELU, and an initial noise std of 1.0. Menlo does not say which training framework it uses, so treat that as context rather than a claim about Asimov.

Feedforward networks and multilayer perceptrons

A feedforward neural network passes information in one direction, from input to output, with no loops. Its output depends only on its current input. That makes it a pure function: the same observation always produces the same action mean.

A multilayer perceptron (MLP) is the simplest feedforward network. It is a stack of fully connected layers: every number in one layer influences every number in the next. Each layer does two things:

  1. A linear map: multiply the input vector by a weight matrix and add a bias vector, z=Wh+bz = W h + b.
  2. A nonlinearity (the activation function) applied to each element: h′=f(z)h' = f(z).

Without the nonlinearity, stacking layers would be pointless: a product of matrices is just another matrix, so the whole network would collapse into one linear function. The nonlinearity is what lets an MLP approximate complex, curved mappings like "if tilting left and the left foot is in the air, put it down further out".

Input, hidden and output layers

Asimov's actor has five layers of numbers and four layers of weights between them:

  • Input layer (45). The observation. No computation happens here; it is just the vector.
  • Hidden layer 1 (512). 512 units, each a weighted combination of all 45 inputs, passed through ELU.
  • Hidden layer 2 (256). Each unit combines all 512 outputs of layer 1.
  • Hidden layer 3 (128). Each unit combines all 256 outputs of layer 2.
  • Output layer (12). One number per actuated joint. This layer is linear (no activation), because the action can be any real number, positive or negative.

The tapering shape (512, 256, 128) is a common heuristic: a wide first layer extracts many features from the raw observation, and later layers combine them into progressively more compact representations of "what to do". Nothing about legs is built into the architecture; any structure is learned.

Written out, the forward pass is:

h1=ELU(W1x+b1),W1∈R512×45h2=ELU(W2h1+b2),W2∈R256×512h3=ELU(W3h2+b3),W3∈R128×256μ=W4h3+b4,W4∈R12×128\begin{aligned} h_1 &= \mathrm{ELU}(W_1 x + b_1), & W_1 &\in \mathbb{R}^{512\times45}\\ h_2 &= \mathrm{ELU}(W_2 h_1 + b_2), & W_2 &\in \mathbb{R}^{256\times512}\\ h_3 &= \mathrm{ELU}(W_3 h_2 + b_3), & W_3 &\in \mathbb{R}^{128\times256}\\ \mu &= W_4 h_3 + b_4, & W_4 &\in \mathbb{R}^{12\times128} \end{aligned}

Weights, biases and the parameter count

A weight WijW_{ij} says how strongly input jj influences unit ii. A bias bib_i shifts unit ii's pre-activation regardless of input, letting it be active or inactive by default. Training adjusts all of them.

A fully connected layer from nn inputs to mm outputs has n⋅mn \cdot m weights and mm biases. For Asimov's actor:

LayerWeightsBiasesTotal
45 → 51245 · 512 = 23,04051223,552
512 → 256512 · 256 = 131,072256131,328
256 → 128256 · 128 = 32,76812832,896
128 → 12128 · 12 = 1,536121,548
Total188,416908189,324

So the actor has 189,324 trainable parameters in its layers (a Gaussian policy adds a few more for the noise standard deviation; see below). Stored as float32, that is about 0.76 MB. One forward pass is roughly 189,000 multiply-adds, which takes microseconds on a modern CPU. At 50 Hz, the network itself is never the bottleneck; sensing and communication timing are.

The experiment below runs a real forward pass through a network of exactly this shape in your browser. The weights are randomly initialised and untrained, using PyTorch's default initialisation. The arithmetic is identical to the trained policy's; only the numbers differ.

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

What it demonstrates

What a forward pass through Asimov's documented actor shape computes, how activations flow through three ELU hidden layers to 12 outputs, and where the 189,324 parameters live.

How it works

A multilayer perceptron with layer sizes 45, 512, 256, 128, 12 is created in TypeScript with PyTorch's default nn.Linear initialisation (weights and biases uniform in ±1/√fan_in). The weights are random and never trained.

The input is either the illustrative live observation (optionally normalized by a running mean/std accumulated from the stream), a standard-normal vector, or zeros. Every frame the full forward pass runs: 189,324 multiply-adds and 896 ELU evaluations. The probe slider perturbs one input so you can see how far the output moves.

Adjustable parameters

  • Input: live / N(0,1) / zeros
  • Normalization on/off
  • Probe element (0–44)
  • Perturbation (−3 to 3)
  • Weight seed

Known limitations

  • The weights are random, so the outputs carry no meaning. A trained network has the same arithmetic but different numbers.
  • Only the mean head is shown. A Gaussian policy also has a standard deviation parameter (initially 1.0 for Asimov).
  • The output layer initialisation of the real policy is not documented.

Equations

h1=ELU(W1x+b1),  h2=ELU(W2h1+b2),  h3=ELU(W3h2+b3),  μ=W4h3+b4h_1 = \mathrm{ELU}(W_1 x + b_1),\; h_2 = \mathrm{ELU}(W_2 h_1 + b_2),\; h_3 = \mathrm{ELU}(W_3 h_2 + b_3),\; \mu = W_4 h_3 + b_4
N=(45⋅512+512)+(512⋅256+256)+(256⋅128+128)+(128⋅12+12)=189,324N = (45\cdot512+512) + (512\cdot256+256) + (256\cdot128+128) + (128\cdot12+12) = 189{,}324

Core update rule

for (let l = 0; l < L; l++) {
  for (let o = 0; o < fanOut; o++) {
    let z = b[l][o];
    for (let i = 0; i < fanIn; i++) z += W[l][o * fanIn + i] * h[i];
    next[o] = l === L - 1 ? z : elu(z);   // linear output layer
  }
  h = next;
}

Explained in Chapter 8: Locomotion Policy

Try perturbing one input with the probe. Even with random weights, every output moves: in a fully connected network every input influences every output. Training is what makes those influences sensible.

The ELU activation function

The exponential linear unit (ELU), introduced by Clevert, Unterthiner and Hochreiter (2015), is:

ELUα(x)={xif x>0α (ex−1)if x≤0\mathrm{ELU}_\alpha(x) = \begin{cases} x & \text{if } x > 0 \\ \alpha\,(e^{x} - 1) & \text{if } x \le 0 \end{cases}

For positive inputs it is the identity. For negative inputs it curves smoothly down towards −α-\alpha instead of jumping to zero. The usual choice is α=1\alpha = 1, which is PyTorch's default; the value Menlo uses is not stated on the reviewed pages.

Compare it with the popular ReLU, max⁡(0,x)\max(0, x):

  • No dead units. ReLU's gradient is exactly zero for negative inputs. A unit whose input is negative for every training sample never receives a learning signal and stays "dead". ELU's gradient for negative inputs is αex\alpha e^{x}: small, but never zero.
  • Mean activations closer to zero. ReLU outputs are never negative, so their average is positive, which shifts the input distribution of the next layer. ELU's negative outputs pull the mean towards zero. Clevert et al. argue this speeds up learning, similar in spirit to normalization.
  • Smoothness. With α=1\alpha = 1, ELU's slope is continuous at zero. A policy built from smooth pieces tends to produce smoother action changes as the observation changes, which is welcome on a physical robot. (This is an intuition, not a guarantee; smoothness of the learned policy also depends on training.)
  • Cost. ELU needs an exponential for negative inputs, so it is slightly more expensive than ReLU. For a network of this size that cost is irrelevant.
Loading simulation…
▸How this works · equations · source · limitationsOpen in lab

What it demonstrates

The shape of the ELU activation used in Asimov's actor and critic, how α sets its negative saturation, and how its gradient differs from ReLU's.

How it works

Both functions and (optionally) their derivatives are plotted analytically. The probe reads off values at one input.

Adjustable parameters

  • α (0.1–2)
  • Probe input x (−4 to 3)
  • Show ReLU
  • Show derivatives

Known limitations

  • Menlo documents that ELU is used; the α value is not stated on the reviewed pages (PyTorch's default is 1.0).

Equations

ELUα(x)={xx>0α (ex−1)x≤0\mathrm{ELU}_\alpha(x) = \begin{cases} x & x > 0 \\ \alpha\,(e^{x}-1) & x \le 0 \end{cases}
ELUα′(x)={1x>0αexx≤0\mathrm{ELU}'_\alpha(x) = \begin{cases} 1 & x > 0 \\ \alpha e^{x} & x \le 0 \end{cases}
ReLU(x)=max⁡(0,x)\mathrm{ReLU}(x) = \max(0, x)

Core update rule

const elu = (x: number, a = 1) => (x > 0 ? x : a * Math.expm1(x));

Explained in Chapter 8: Locomotion Policy

A PyTorch implementation

The documented architecture translates directly into PyTorch:

actor.py
import torch
from torch import nn
 
def mlp(sizes: list[int]) -> nn.Sequential:
    layers: list[nn.Module] = []
    for i in range(len(sizes) - 1):
        layers.append(nn.Linear(sizes[i], sizes[i + 1]))
        if i < len(sizes) - 2:          # no activation after the output layer
            layers.append(nn.ELU())
    return nn.Sequential(*layers)
 
actor_mean = mlp([45, 512, 256, 128, 12])
 
n_params = sum(p.numel() for p in actor_mean.parameters())
print(n_params)  # 189324
python

nn.Linear(45, 512) holds a weight matrix of shape (512, 45) and a bias of shape (512,), and computes x @ W.T + b. nn.ELU() uses α=1\alpha = 1 by default.

Observation normalization

The 45 inputs live on very different scales. Projected gravity's zz component sits near −1-1 and barely moves. Joint velocities swing by several radians per second. Commands are fractions of a metre per second. If these raw numbers went straight into the network, the large ones would dominate the first layer's weighted sums, and the learning rate that suits one input would be far too large or small for another.

Observation normalization fixes this by rescaling every input to have roughly zero mean and unit variance:

x~i=clip⁡ ⁣(xi−μiσi2+ε,  −c,  c)\tilde x_i = \operatorname{clip}\!\left(\frac{x_i - \mu_i}{\sqrt{\sigma_i^2 + \varepsilon}},\; -c,\; c\right)

Because the distribution of observations is not known in advance (it depends on what the policy does, and the policy changes during training), the mean μi\mu_i and variance σi2\sigma_i^2 are running estimates, updated from every batch of observations seen so far. The small ε\varepsilon avoids division by zero, and the clip at ±c\pm c (often 5 or 10) stops rare outliers from producing huge inputs.

Observation normalization is enabled for Asimov's policy training. The specific implementation, clip value and update schedule are not described on the reviewed pages.

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

What it demonstrates

How a running mean and variance turn observations with very different scales (a joint velocity of several rad/s, a gravity component near −0.98) into comparable, roughly zero-mean unit-variance inputs, and what happens if the data shift after the statistics are frozen.

How it works

Two synthetic channels are streamed at 50 Hz. Each new sample is merged into the running statistics with the parallel mean/variance update, then normalized as (x − mean)/√(var + ε) and clipped. Freezing the statistics mimics deployment, where the normalizer saved with the policy is applied unchanged.

Adjustable parameters

  • Raw offset (−8 to 8 rad/s)
  • Raw spread (0.2–10 rad/s)
  • Clip (±1 to ±10)
  • Freeze statistics
  • Reset statistics

Known limitations

  • Menlo documents that observation normalization is enabled; the exact implementation, clip value and whether statistics are frozen at deployment are not stated.
  • The input signals are synthetic.

Equations

δ=xˉB−μ,μ←μ+δ nBn+nB\delta = \bar x_B - \mu,\quad \mu \leftarrow \mu + \delta\,\frac{n_B}{n+n_B}
σ2←nσ2+nBσB2+δ2n nBn+nBn+nB\sigma^2 \leftarrow \frac{n\sigma^2 + n_B\sigma_B^2 + \delta^2\frac{n\,n_B}{n+n_B}}{n+n_B}
x~=clip⁡ ⁣(x−μσ2+ε, −c, c)\tilde x = \operatorname{clip}\!\left(\frac{x-\mu}{\sqrt{\sigma^2+\varepsilon}},\,-c,\,c\right)

Core update rule

updateRunningStats(stats, [raw]);          // skipped when frozen
const z = normalize(stats, raw, clip);     // (x - mean) / sqrt(var + 1e-8), clipped

Explained in Chapter 8: Locomotion Policy

The statistics become part of the policy. At deployment, the saved mean and variance must be applied to real observations exactly as during training. Forgetting the normalizer, or recomputing it from a few seconds of hardware data, is a classic deployment bug: the network receives inputs on a completely different scale. Freezing the statistics in the experiment above and then shifting the raw signal shows what that looks like.

A minimal PyTorch normalizer using the same parallel update as the experiment:

normalizer.py
import torch
from torch import nn
 
class RunningMeanStd(nn.Module):
    """Running mean/variance normalizer. Statistics are buffers, so they are
    saved with the model's state_dict and restored at deployment."""
 
    def __init__(self, dim: int, eps: float = 1e-8, clip: float = 5.0):
        super().__init__()
        self.register_buffer("mean", torch.zeros(dim))
        self.register_buffer("var", torch.ones(dim))
        self.register_buffer("count", torch.tensor(1e-4))
        self.eps, self.clip = eps, clip
 
    @torch.no_grad()
    def update(self, x: torch.Tensor) -> None:          # x: (batch, dim)
        b_mean = x.mean(dim=0)
        b_var = x.var(dim=0, unbiased=False)
        b_count = x.shape[0]
        delta = b_mean - self.mean
        total = self.count + b_count
        self.mean += delta * b_count / total
        m2 = self.var * self.count + b_var * b_count + delta**2 * self.count * b_count / total
        self.var = m2 / total
        self.count = total
 
    def forward(self, x: torch.Tensor) -> torch.Tensor:
        z = (x - self.mean) / torch.sqrt(self.var + self.eps)
        return z.clamp(-self.clip, self.clip)
python

During training, call update on each batch of rollout observations before normalizing them. At deployment, never call update.

A Gaussian policy: noise, exploration and the initial std of 1.0

The network above outputs 12 numbers. During training, those numbers are not the action directly. They are the mean of a probability distribution over actions, and the action is sampled from it:

at∼N(μθ(ot),  diag⁡(σ2))a_t \sim \mathcal{N}\big(\mu_\theta(o_t),\; \operatorname{diag}(\sigma^2)\big)

This is called a Gaussian policy. Each of the 12 action dimensions gets independent Gaussian noise with standard deviation σi\sigma_i. In most implementations of this kind, σ\sigma is a separate set of learnable parameters that does not depend on the observation (one per joint, typically stored as log⁡σ\log\sigma so it stays positive). Menlo documents only the initial value.

The initial policy noise standard deviation is 1.0.

Why sample at all? Reinforcement learning improves a policy by trying actions and seeing which lead to more reward. If the policy always did the same thing in the same situation, it would never discover anything better. The noise is exploration: small random variations around the current best guess. Over training, actions that happened to do better are made more likely (the mean moves towards them), and as the policy becomes confident the learned σ\sigma usually shrinks.

What does σ=1.0\sigma = 1.0 mean? The policy's action is in normalized units whose scale depends on how actions are mapped to joint targets (not documented for Asimov). With σ=1.0\sigma = 1.0, about 32% of samples land more than one unit from the mean. Early in training this produces very noisy, flailing motion, which is fine in simulation. It is one of the reasons such training only happens in simulation and never on the physical robot.

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

What it demonstrates

How a stochastic policy samples actions around the network's mean, how the standard deviation controls exploration, and what Asimov's documented initial noise std of 1.0 means in practice.

How it works

Samples a = μ + σ·ε with ε from a seeded standard normal are drawn at 50 Hz and binned; the analytical density is overlaid. A second panel draws one 12-D sample around a fixed, made-up mean and shows the joint target it would give under an illustrative mapping q* = q₀ + 0.25·a.

Adjustable parameters

  • Mean μ (−2 to 2)
  • Std σ (0–1.5, documented initial value 1.0)

Known limitations

  • The 12-D mean and the action-to-target mapping (scale 0.25 around a default pose) are illustrative; Menlo does not document how actions become joint targets.
  • Whether σ is learned per joint, state-independent, or scheduled is not documented; it is learned in many common implementations.

Equations

πθ(a∣o)=N(μθ(o), diag⁡(σ2))\pi_\theta(a\mid o) = \mathcal{N}\big(\mu_\theta(o),\, \operatorname{diag}(\sigma^2)\big)
log⁡πθ(a∣o)=−∑i=112[(ai−μi)22σi2+log⁡σi+12log⁡2π]\log \pi_\theta(a\mid o) = -\sum_{i=1}^{12} \left[ \frac{(a_i-\mu_i)^2}{2\sigma_i^2} + \log\sigma_i + \tfrac12\log 2\pi \right]
P(∣a−μ∣>σ)≈0.317P(|a-\mu| > \sigma) \approx 0.317

Core update rule

const a = mean.map((m, i) => m + std * gaussian(rng));   // reparameterised sample

Explained in Chapter 8: Locomotion Policy

Two consequences that are easy to miss:

  • Training and deployment behave differently. During training the robot executes noisy samples. At deployment the noise is normally switched off and the mean μθ(o)\mu_\theta(o) is used directly. The deployed policy is therefore smoother than anything seen in training rollouts.
  • The probability matters for learning. Policy-gradient methods need log⁡πθ(a∣o)\log \pi_\theta(a \mid o), the log-probability of the action that was actually taken. A diagonal Gaussian has a simple closed form for it, which is part of why Gaussian policies are the default for continuous control.

In PyTorch:

gaussian_policy.py
import torch
from torch import nn
from torch.distributions import Normal
 
class GaussianActor(nn.Module):
    def __init__(self, obs_dim: int = 45, act_dim: int = 12, init_std: float = 1.0):
        super().__init__()
        self.normalizer = RunningMeanStd(obs_dim)          # from normalizer.py
        self.mean_net = mlp([obs_dim, 512, 256, 128, act_dim])
        self.log_std = nn.Parameter(torch.full((act_dim,), float(torch.log(torch.tensor(init_std)))))
 
    def distribution(self, obs: torch.Tensor) -> Normal:
        mean = self.mean_net(self.normalizer(obs))
        return Normal(mean, self.log_std.exp().expand_as(mean))
 
    def act(self, obs: torch.Tensor, deterministic: bool = False):
        dist = self.distribution(obs)
        action = dist.mean if deterministic else dist.sample()
        log_prob = dist.log_prob(action).sum(dim=-1)       # sum over the 12 joints
        return action, log_prob
 
actor = GaussianActor()
obs = torch.zeros(4096, 45)                 # a batch of parallel environments
a, logp = actor.act(obs)                    # training: sampled actions
a_det, _ = actor.act(obs, deterministic=True)   # deployment: the mean
python

With init_std = 1.0, the extra 12 log_std parameters start at zero, bringing the total to 189,336. Whether Asimov's policy uses one σ\sigma per joint or another parameterisation is not documented.

From actions to motors

The actor outputs 12 numbers, one per actuated joint. What are they?

Menlo describes the policy as producing commanded joint targets at 50 Hz from the latest available IO state.

They are joint targets, not torques. That distinction matters: the policy says where each joint should go, and something else decides how much torque to apply to get it there. What Menlo's reviewed pages do not say is:

  • whether the targets are absolute angles or offsets from a default standing pose,
  • whether the raw network output is scaled before becoming a target, and by how much,
  • how the targets become motor commands (gains, rates, limits), or exactly where that conversion runs.

The simulator models actuator saturation, friction and delay, so whatever the conversion is, the policy is trained against realistic actuator behaviour.

Illustrative example

A widely used pattern in open-source legged RL (for example legged_gym) is a PD target: the action is scaled, added to a default joint pose, and tracked by a proportional-derivative controller that runs much faster than the policy:

q∗=qdefault+ka a,τ=Kp (q∗−q)−Kd q˙q^{*} = q_{\text{default}} + k_a\, a, \qquad \tau = K_p\,(q^{*} - q) - K_d\,\dot q

with an action scale kak_a such as 0.25 or 0.5, and the torque τ\tau clipped to the motor's limit. This is shown as an example of how joint targets can work. It is not a description of Asimov's controller.

pd_target_example.py (illustrative)
import numpy as np
 
ACTION_SCALE = 0.25                     # illustrative
KP, KD = 40.0, 1.0                      # illustrative gains, N·m/rad and N·m·s/rad
TAU_MAX = 30.0                          # illustrative torque limit, N·m
Q_DEFAULT = np.zeros(12, dtype=np.float32)   # illustrative default pose
 
def joint_targets(action: np.ndarray) -> np.ndarray:
    return Q_DEFAULT + ACTION_SCALE * action          # policy rate (50 Hz)
 
def pd_torque(q_target, q, qd) -> np.ndarray:         # actuator rate (much faster)
    return np.clip(KP * (q_target - q) - KD * qd, -TAU_MAX, TAU_MAX)
python

Why targets rather than torques? A position target with a stiff low-level loop gives the policy a well-behaved "spring" at every joint: if the policy is late or wrong by a little, the joint still holds its pose. Directly commanding torques at 50 Hz would leave the joints unregulated for 20 ms between decisions. That is a general argument, not a documented statement about Asimov.

The 3D explorer below shows the 12 actuated joints and how posture becomes the joint-position block of the observation. Joint names, axes and limits are the site's illustrative convention.

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

What it demonstrates

Where the 12 actuated joints sit on a lower-body humanoid, how each moves the leg, and how posture becomes the joint-position block obs[9..20]. Passive toes are shown but are not actor inputs.

How it works

A procedural 12-DoF lower body (6 joints per leg plus a passive toe) is rendered with React Three Fiber. In manual mode each slider sets one joint angle directly. In scripted mode the site's hand-written gait animates all joints and the velocities are finite differences at 50 Hz.

Adjustable parameters

  • Pose source: manual or scripted
  • Selected joint (0–11)
  • Joint angle (illustrative limits)

Known limitations

  • Joint names, order, axes, limits and dimensions are illustrative; Menlo documents the joint count (12 actuated, 2 passive toes), not these details.
  • Whether the observation stores absolute angles or offsets from a default pose is not documented.
  • No dynamics: the robot is posed kinematically and kept on the ground by a height correction.

Equations

q∈R12,q˙t≈(qt−qt−1)/Δt,  Δt=20 msq \in \mathbb{R}^{12},\quad \dot q_t \approx (q_t - q_{t-1})/\Delta t,\; \Delta t = 20\,\text{ms}

Core update rule

<LowerBodyRobot q={q} toes={toes} highlight={selected} />
// observation block: obs[9 + i] = q[i], obs[21 + i] = qd[i]

Explained in Chapter 8: Locomotion Policy

A practical example: one control step, end to end

Putting everything together, here is what happens in one 20 ms policy step on a robot like Asimov, written as a sketch. Everything marked illustrative is our assumption.

control_step.py
import numpy as np
import torch
 
prev_smoothed = np.zeros(12, dtype=np.float32)
BETA = 0.5   # illustrative smoothing factor for the action history
 
def control_step(robot, actor, command):
    global prev_smoothed
    # 1. Read the latest available state (some joints may be a few ms older: CAN timing groups)
    w = robot.imu_angular_velocity()          # (3,) gyro
    g = robot.projected_gravity()             # (3,) from the IMU fusion path
    q, qd = robot.joint_state()               # (12,), (12,)
 
    # 2. Assemble the 45-D observation in the training order
    obs = np.concatenate([w, g, command, q, qd, prev_smoothed]).astype(np.float32)
 
    # 3. Normalize with the frozen training statistics and run the actor (mean action)
    with torch.no_grad():
        action, _ = actor.act(torch.from_numpy(obs)[None], deterministic=True)
    action = action[0].numpy()
 
    # 4. Send 12 joint targets to the low-level controller (mapping illustrative)
    robot.send_joint_targets(joint_targets(action))
 
    # 5. Update the action history for the next step (smoothing illustrative)
    prev_smoothed = BETA * prev_smoothed + (1 - BETA) * action
python

Notice what is not in this loop: no reward, no critic, no simulator, no gradient. Those exist only during training (Chapter 9).

How this connects to the rest of the site

Limitations and common misconceptions

“The policy outputs motor torques.”

Menlo describes the outputs as commanded joint targets. How they become motor commands is not documented. A lower-level controller sits between the policy and the motors.

“More observations always help.”

Only if they are available, accurate and timed the same way on hardware. Asimov's actor deliberately omits base linear velocity, contact forces and toe state for exactly this reason. An input the policy cannot trust at deployment is worse than no input.

“The network architecture is the secret.”

Asimov's actor is a plain three-hidden-layer MLP with standard choices. Menlo credits transfer to the observation and actuation interface. The engineering is in the data, its timing and the actuator model.

“Previous actions give the policy memory.”

Only a little. The policy sees a smoothed record of its own recent commands, not past sensor readings. It still cannot, for example, integrate its velocity over the last second. Chapter 9 discusses what that means.

What this chapter cannot tell you

Menlo's reviewed pages do not document per-element ordering inside groups, observation scaling, the action scale or offset, the PD gains, the RL algorithm or the training framework. Where code on this page fills those gaps, it is labelled illustrative.

Other limitations of the approach itself:

  • No explicit state estimation. The policy has to infer quantities like body velocity implicitly from the history it has. That works for walking on flat ground but limits how aggressively the policy can react.
  • Fixed interface. The observation layout and normalizer are baked into the trained weights. Adding a sensor means retraining.
  • Feedforward. With no recurrent memory, behaviour that requires remembering more than a few steps must be encoded in the observation or the previous actions.

Key takeaways

Key takeaways

  • Asimov's actor receives 45 numbers at 50 Hz: base angular velocity (3), projected gravity (3), command vx,vy,ωzv_x, v_y, \omega_z (3), joint positions (12), joint velocities (12) and previous actions (12).
  • Every input is something the real robot can provide through the same path as in simulation: the IMU, the FusionX gravity estimate, actuators over CAN in timing groups 1–3, and software.
  • Base linear velocity is deliberately excluded because the hardware cannot measure it reliably.
  • The actor is an MLP 45 → 512 → 256 → 128 → 12 with ELU activations, 189,324 layer parameters, observation normalization and an initial Gaussian noise std of 1.0.
  • The 12 outputs are commanded joint targets, not torques. How they become motor commands is not documented. The PD pattern on this page is an example only.
  • Observation order and normalization statistics are part of the policy. Getting them wrong at deployment silently breaks it.

References and further reading