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:
Here is the observation at control step , is the action, and 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:
| Index | Group | Size | Comes from | Unit |
|---|---|---|---|---|
| 0–2 | Base angular velocity | 3 | IMU gyroscope | rad/s |
| 3–5 | Projected gravity | 3 | IMU data, computed on the FusionX path | unit vector |
| 6–8 | Movement command () | 3 | operator or higher-level planner | m/s, m/s, rad/s |
| 9–20 | Joint positions | 12 | actuator encoders over CAN | rad |
| 21–32 | Joint velocities | 12 | actuator side over CAN | rad/s |
| 33–44 | Previous actions | 12 | the policy's own recent outputs | action 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.
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 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 : 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 and pitch , the projected gravity is
where 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:
- : desired forward (positive) or backward (negative) velocity, in m/s.
- : desired sideways velocity, in m/s (positive to the robot's left under the usual convention).
- : 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 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:
- IMUgyro + accelerometer
- FusionXprojected gravity
- Actuators over CANjoint pos/vel, timing groups 1–3
- Command + action historysoftware
- 45-D observationfloat32 vector
- Actor network50 Hz
- 12 joint targetsto low-level control
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.
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 () 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 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.
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 obsThree 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:
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,)The actor network
The function 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:
- A linear map: multiply the input vector by a weight matrix and add a bias vector, .
- A nonlinearity (the activation function) applied to each element: .
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:
Weights, biases and the parameter count
A weight says how strongly input influences unit . A bias shifts unit 's pre-activation regardless of input, letting it be active or inactive by default. Training adjusts all of them.
A fully connected layer from inputs to outputs has weights and biases. For Asimov's actor:
| Layer | Weights | Biases | Total |
|---|---|---|---|
| 45 → 512 | 45 · 512 = 23,040 | 512 | 23,552 |
| 512 → 256 | 512 · 256 = 131,072 | 256 | 131,328 |
| 256 → 128 | 256 · 128 = 32,768 | 128 | 32,896 |
| 128 → 12 | 128 · 12 = 1,536 | 12 | 1,548 |
| Total | 188,416 | 908 | 189,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.
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:
For positive inputs it is the identity. For negative inputs it curves smoothly down towards instead of jumping to zero. The usual choice is , which is PyTorch's default; the value Menlo uses is not stated on the reviewed pages.
Compare it with the popular ReLU, :
- 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 : 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 , 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.
A PyTorch implementation
The documented architecture translates directly into PyTorch:
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) # 189324nn.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 by default.
Observation normalization
The 45 inputs live on very different scales. Projected gravity's component sits near 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:
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 and variance are running estimates, updated from every batch of observations seen so far. The small avoids division by zero, and the clip at (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.
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:
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)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:
This is called a Gaussian policy. Each of the 12 action dimensions gets independent Gaussian noise with standard deviation . In most implementations of this kind, is a separate set of learnable parameters that does not depend on the observation (one per joint, typically stored as 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 usually shrinks.
What does 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 , 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.
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 is used directly. The deployed policy is therefore smoother than anything seen in training rollouts.
- The probability matters for learning. Policy-gradient methods need , 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:
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 meanWith 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 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.
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:
with an action scale such as 0.25 or 0.5, and the torque 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.
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)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.
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.
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) * actionNotice 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
- Chapter 4: Sensors explains the IMU and encoders that produce the angular velocity, gravity estimate and joint state.
- Chapter 5: Communication explains the CAN bus whose timing groups shape the joint observations.
- Chapter 6: Asimov simulation covers the 200 Hz physics and IO model, processor-in-the-loop testing and the FusionX path.
- Chapter 7: Reinforcement learning covers how the actor's weights are trained.
- Chapter 9: Actor-critic adds the critic and its 19 privileged observations.
- Research explores what information a policy like this should see during training.
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 (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
- Menlo, Reinforcement Learning for Locomotion: observation lists, network architecture, ELU, normalization and initial noise std.
- Menlo, Understanding Your Simulation Environment: timing, CAN timing groups, processor-in-the-loop and the FusionX path.
- Menlo, Asimov locomotion-training guide: overview and the sequence of later guides.
- D.-A. Clevert, T. Unterthiner and S. Hochreiter, "Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs)," arXiv:1511.07289, 2015.
- N. Rudin, D. Hoeller, P. Reist and M. Hutter, "Learning to Walk in Minutes Using Massively Parallel Deep Reinforcement Learning," Proceedings of the 5th Conference on Robot Learning, PMLR 164, 2022. arXiv:2109.11978.
- J. Schulman, F. Wolski, P. Dhariwal, A. Radford and O. Klimov, "Proximal Policy Optimization Algorithms," arXiv:1707.06347, 2017.
- PyTorch documentation:
torch.nn.Linear,torch.nn.ELU,torch.distributions.Normal.