Search

Search papers and lessons

Actuator Network

Level 4 · 12 min read

An actuator network is a small neural network trained on logged data to predict the torque a real joint delivers, so that a simulator can include the motor's delay and lag.

On this page

  • Colour = topic mix
  • Calculus
  • Linear algebra
  • Probability
  • Classical mechanics
  • Discrete math
  • Kinematics and dynamics
  • ReadReady to readNot yet

TL;DR

An actuator network is a small neural network trained on logged data to predict the torque a real joint delivers, given the recent history of its position errors and velocities. A simulator that assumes motors respond instantly predicts the wrong torques, and a learned actuator model closes that gap without anyone writing down the motor's physics. It was introduced for the ANYmal quadruped robot in 2019.

Builds on: Robot Dynamics, PD Control, Feedforward Neural Network, Supervised Learning · Leads to: learning agile legged locomotion in simulation

Where it's used

Legged locomotion on ANYmal (2019). ANYmal is a medium-dog-sized quadruped robot. Its control policies were trained entirely in simulation, with an actuator network inside the simulator, and then run on the physical robot without tuning on hardware. The paper reports that the robot ran 25 percent faster than the previous speed record, and that it could recover from falls, including by rolling its body over. The network is the piece that made the simulator faithful enough for this transfer. Learning agile and dynamic motor skills for legged robots is the paper that introduced it.

The alternative it replaced. An analytical model of a series elastic actuator, following Gehring and colleagues, contains nearly one hundred parameters that must be estimated from experiments or read from datasheets, and many manufacturers do not publish enough detail to fill them in. The ANYmal authors estimate that building such a model would take at least three weeks, even with a similar model in the literature. Collecting data for an actuator network took under four minutes, and tuning its input window often took less than a day.

Where it may fail. Some actuators are not independent. Hydraulic actuators that share a single accumulator have coupled dynamics, and learning each one separately may not reach enough accuracy. For those systems one larger network that sees several actuators at once is the more likely fit.

How it works

Here is the idea on one joint, traced from logged data to the torque the simulator applies.

flowchart LR
  A["Log position error, velocity and torque at 400 Hz"] --> B["Stack current and two past samples"]
  B --> C["Actuator net: 3 hidden layers of 32 units"]
  C --> D["Predicted torque for the simulator"]
  D --> E["Compare with measured torque and adjust weights"]
  E --> C
  1. Measure what the joint does. Drive the joint with a simple repeating foot motion while logging three things: the position error (the commanded position minus the actual position), the joint velocity, and the Torque measured by a sensor. The paper logs at 400 samples per second. Check: one sample every 2.5 milliseconds, so 400 samples per second.
  2. Build the input window. For each sample, take the current reading and the readings from 0.01 and 0.02 seconds earlier. At 400 Hz those are 4 and 8 samples back. Check: three times two values gives 6 numbers per joint.
  3. Pass the window through the network. Each of the 6 numbers feeds a layer of 32 neurons. Each neuron takes a weighted sum of its inputs and bends it with softsign, a smooth S-shaped function. That repeats for three hidden layers, and a final output gives one torque. Check: the shape is 6 inputs, then 32, 32 and 32 hidden units, then 1 output.
  4. Compare with the measurement. Take the gap between predicted and measured torque for each sample, square it, and average over the data. Toy numbers: measured torques of 1.0, 2.0 and 3.0 Nm, predicted 1.2, 1.7 and 3.5 Nm. The gaps (predicted minus measured) are +0.2, −0.3 and +0.5. Check: the squares sum to 0.04 + 0.09 + 0.25 = 0.38, and 0.38 divided by 3 is about 0.127 Nm².
  5. Adjust the weights. Gradient descent nudges every weight in the direction that lowers the average error, and the loop repeats over the dataset. Check: after many passes the error on the training data stops falling.
  6. Test on data it has not seen. About 10 percent of the samples are held back. The paper's average error on these is 0.740 Nm, against a torque sensor resolution of 0.2 Nm. Check: 0.740 divided by 0.2 is 3.7, so the average error is a few sensor steps wide, against 17.8 steps for the ideal model (3.55 divided by 0.2).
  7. Put it in the simulator. At each simulated step the network takes the joint's recent history and returns the torque applied to the simulated body. This replaces an ideal actuator, which would produce whatever torque is commanded at once. Check: the paper reports about 12 microseconds to evaluate the network for all 12 joints, which matters because training a complicated policy needs hundreds of millions of simulated samples.

The learned torque includes effects the ideal model leaves out: communication delay, friction, and the motor's own internal feedback loops. All of them leave a trace in the history window, and that is why a window of past samples matters. A single snapshot of error and velocity cannot show lag.

The math

For one joint, let ete_t be the position error at time tt (target minus actual) and vtv_t the joint velocity. Write Δ=0.01\Delta = 0.01 s for the spacing of the history. The input window is six numbers:

xt=(et,  et−Δ,  et−2Δ,  vt,  vt−Δ,  vt−2Δ)\mathbf{x}_t = \bigl(e_t,\; e_{t-\Delta},\; e_{t-2\Delta},\; v_t,\; v_{t-\Delta},\; v_{t-2\Delta}\bigr)

Step 3 in symbols: the network

The bend used at each hidden neuron is softsign:

σ(z)=z1+∣z∣\sigma(z) = \frac{z}{1 + |z|}

Its output always lies between −1-1 and 11, it is nearly a straight line for small zz, and it flattens for large zz. The paper chose it over tanh because it is cheaper to compute, with about the same validation error.

Three hidden layers and a linear output give the prediction:

h1=σ(W1xt+b1),h2=σ(W2h1+b2),h3=σ(W3h2+b3)\mathbf{h}_1 = \sigma(W_1 \mathbf{x}_t + \mathbf{b}_1), \qquad \mathbf{h}_2 = \sigma(W_2 \mathbf{h}_1 + \mathbf{b}_2), \qquad \mathbf{h}_3 = \sigma(W_3 \mathbf{h}_2 + \mathbf{b}_3)

τ^t=w⊤h3+b\hat{\tau}_t = \mathbf{w}^{\top} \mathbf{h}_3 + b

Here W1W_1 is a 32×632 \times 6 matrix, W2W_2 and W3W_3 are 32×3232 \times 32, and w\mathbf{w} has 32 entries. Counting weights and biases gives 224+2112+33=2369224 + 2112 + 33 = 2369, so the whole network has roughly 2,400 parameters.

Step 4 in symbols: the loss

With nn samples and measured torques τi\tau_i, the training loss is the mean squared error (Mean Squared Error):

L=1n∑i=1n(τ^i−τi)2L = \frac{1}{n} \sum_{i=1}^{n} \left(\hat{\tau}_i - \tau_i\right)^2

For the toy numbers in step 4, n=3n = 3 and ∑i(τ^i−τi)2=0.38\sum_i (\hat{\tau}_i - \tau_i)^2 = 0.38, so L≈0.127L \approx 0.127.

Step 5 in symbols: the update

Let θ\theta stand for all the weights and biases, and η>0\eta > 0 for the step size. Each pass updates

θ←θ−η ∇θL\theta \leftarrow \theta - \eta \, \nabla_{\theta} L

which is one step of Gradient Descent. The gradient points uphill in the loss, so subtracting it moves downhill.

Step 6 in symbols: validation

The same loss is computed on the held-out samples, LvalL_{\text{val}}. The paper reports an average validation error of 0.740 Nm for the learned model and 3.55 Nm for the ideal model, which is the comparison that shows what the learned model adds.

Worked examples

Example
1. Tiny: one neuron, one input
  1. Position error e=0.5e = 0.5 rad and weight w=2w = 2. Weighted sum: z=2×0.5=1.0z = 2 \times 0.5 = 1.0. Check: no bias term in this toy.
  2. Softsign of zz: σ(1.0)=1.0/(1+1.0)=0.5\sigma(1.0) = 1.0 / (1 + 1.0) = 0.5. Check: the result lies between −1-1 and 11.
  3. Output weight 44: torque =4×0.5=2.0= 4 \times 0.5 = 2.0 Nm. Check: a positive error gives a positive torque.
  4. Interpretation: a straight-line model with the same weights would give 4 Nm. The bend halves the response to a large error, and it does so smoothly.
Example
2. Standard: building the input window

Suppose the log of position errors at 400 Hz reads, at samples 0 to 8: 0.00, 0.02, 0.04, 0.05, 0.06, 0.06, 0.05, 0.04, 0.03 rad.

  1. Sample spacing: 1 divided by 400 is 0.0025 s. Check: 0.01 s divided by 0.0025 s is 4 samples, and 0.02 s is 8 samples.
  2. Current sample, index 8: e8=0.03e_8 = 0.03 rad.
  3. One step back, index 4: e4=0.06e_4 = 0.06 rad. This is t−0.01t - 0.01 s.
  4. Two steps back, index 0: e0=0.00e_0 = 0.00 rad. This is t−0.02t - 0.02 s.
  5. The window is (0.03, 0.06, 0.00)(0.03,\ 0.06,\ 0.00). The most recent change is (0.03−0.06)/0.01=−3.0(0.03 - 0.06) / 0.01 = -3.0 rad/s, and the earlier change was (0.06−0.00)/0.01=+6.0(0.06 - 0.00) / 0.01 = +6.0 rad/s.
  6. Interpretation: the error rose and then fell, so the joint has turned around. A single reading of 0.03 rad could not tell the network this, but the window can.
Example
3. Realistic: how good is the learned model?
  1. Data volume: about 4 minutes at 400 Hz is roughly 96,000 samples per actuator, and 12 actuators give about 1.15 million. Check: the paper reports more than a million samples.
  2. Validation: the learned model's average error is 0.740 Nm and the ideal model's is 3.55 Nm. Check: 3.55 divided by 0.740 is about 4.8, so the ideal model is almost five times as wrong.
  3. Test on locomotion data, which is harder: the learned model reports 0.966 Nm, and the ideal model 5.74 Nm. Check: 5.74 divided by 0.966 is about 5.9.
  4. Interpretation: the ideal model's error is large because it ignores delay and lag. The learned error is about a fifth of the ideal error on validation data and about a sixth on the harder locomotion data, though it is still several sensor steps wide.
  5. Try it: the torque sensor resolves steps of 0.2 Nm. How many sensor steps is the learned model's test error of 0.966 Nm?

Answer: 0.966 divided by 0.2 is 4.83, so the test error is about 4.8 sensor steps.

Common mistakes and tradeoffs

  • It is tempting to think an actuator network is a physics model with a neural network bolted on. In fact it has no physical parameters to read off. It learns the whole chain from command to torque, including delay and internal feedback, and its individual weights do not mean anything on their own.
  • It is tempting to think a learned actuator model works everywhere. In fact the training data came from foot motions at 1 to 25 Hz with 5 to 10 cm amplitude, plus manual pushes. Motions outside that range are extrapolation, and the paper stresses that the excitation has to cover a wide range of frequencies or the model produces unnatural oscillation.
  • It is tempting to think a longer history always helps. In fact a window that is too sparse misses high-frequency dynamics, above about 100 Hz in the paper's account, and a window that is too dense overfits and costs compute. The window length is tuned against validation error.
  • It is tempting to think a model trained for one robot transfers to another. In fact the paper trains one network per actuator because it assumes independence, and it warns that coupled actuators may need a single larger network.
ApproachWhat it needsAccuracy on the jointWhere it fits
Ideal actuator (torque at once)NothingPoor: 3.55 Nm average error in the paperQuick prototypes and first simulations
Analytical actuator modelMany parameters, measured or read from datasheetsGood if the parameters are rightWell-documented actuators with known physics
Learned actuator networkLogged data at a high rate and some tuningClose to sensor resolution in the paperBlack-box motors with independent joints

History

The idea that a neural network can stand in for actuator dynamics is older than legged robots. Nikzad, Ghaboussi and Paul published "Actuator dynamics and delay compensation using neurocontrollers" in 1996, and Nguyen-Tuong and Peters used local Gaussian process regression to learn robot dynamics in 2008, both cited by the ANYmal paper.

The hardware that made modelling hard had a long history of its own. Series elastic actuators, which add a spring between motor and load, were described by Pratt and Williamson in 1995. The analytical model that the ANYmal paper sets against its network follows the SEA modelling work of Gehring and colleagues.

The 2019 ANYmal work brought the pieces together. Hwangbo and colleagues trained controllers in a fast simulator, used a small learned actuator model inside it, and transferred the policies to the robot. It caught on because the expensive step, training, could run on ordinary computers in simulation rather than on the robot, and because learning the actuator replaced weeks of manual modelling.

Recap

  • A real joint is a chain of delays, friction and internal feedback loops, and a simulator that ignores them predicts the wrong torque.
  • Logged data at 400 Hz gives input and output pairs. A window of current and past position errors and velocities holds the information the network needs.
  • A small multi-layer network with softsign, trained by mean squared error and gradient descent, learns torque as a function of that window.
  • Checked on held-out data, the model sits within a few times the sensor's resolution and is cheap enough to run inside the simulator.
  • Read next: Learning agile and dynamic motor skills for legged robots, which introduced the network, and Domain Randomization, because a simulator with an accurate actuator still differs from the real world in other ways. For the alternative of fitting a physical model, see System Identification.

Check yourself

QuestionWhat is the input to the actuator network for one joint, and why does it include past samples?Show answer
Six numbers: the current position error and velocity, plus the same two values 0.01 and 0.02 seconds earlier. A single snapshot cannot show lag or delay, but the history can, so the network can infer the motor's hidden internal states.
QuestionCompute softsign at z = 3 and at z = −3. Why does this bend keep the output bounded?Show answer
Softsign of 3 is 3 divided by (1 + 3), which is 0.75. Softsign of −3 is −3 divided by 4, which is −0.75. The denominator grows with the size of the input, so the output never leaves the range from −1 to 1, and one very large error cannot produce an unbounded signal inside the network.
QuestionWhy does the validation check compare the learned model with the ideal model as well as with the sensor's resolution?Show answer
The ideal model is what a simulator would use without learning, so it is the baseline. The learned error of 0.740 Nm against the ideal model's 3.55 Nm shows the learned model captures delay and lag. The comparison with the 0.2 Nm sensor resolution shows how far the learned model still is from the limit of measurement. Both are needed to judge whether it is good enough.
QuestionA team wants an actuator network for a new robot, but their data covers only slow motions at 1 to 2 Hz. What should they expect, and what would they do?Show answer
The network has seen only slow motions, so it has not learned the faster dynamics it will meet in quick locomotion, and its predictions there should be expected to be poor. They should collect data across a wide range of frequencies and amplitudes, as the paper's sweep from 1 to 25 Hz did, and validate on held-out motions that resemble the task.

Sources

  • Hwangbo J, Lee J, Dosovitskiy A, et al. (2019). Learning agile and dynamic motor skills for legged robots. arXiv. https://arxiv.org/abs/1901.08652
  • Tobin J, Fong R, Ray A, et al. (2017). Domain Randomization for Transferring Deep Neural Networks from Simulation to the Real World. arXiv. https://arxiv.org/abs/1703.06907