Control
How robots turn a desired motion into motor commands. Cascaded PID loops, state-space design with LQR and MPC, impedance, admittance and force control for contact, and whole-body control for robots with many tasks.
Overview
A controller compares what the robot is doing with what it should be doing and changes the motor commands to close the gap. Planning decides where to go. Control makes the hardware actually go there, at the rate the physics demands, despite friction, payload changes, contact and model error.
Robot control spans a wide range. At one end are the PID loops in every motor drive, tuned once and forgotten. At the other are model-predictive and whole-body controllers that solve an optimisation problem every few milliseconds to keep a humanoid balanced while it reaches. This hub maps that range for engineers who need to choose, tune or debug a controller and want to know which tool fits which problem.
Key ideas
PID and the cascade
A PID controller sums three terms: one proportional to the error, one to its integral and one to its derivative. On a robot joint it almost never runs alone. Joints use a cascade: an outer position loop produces a velocity setpoint, a velocity loop produces a current (torque) setpoint, and the current loop inside the motor drive sets the phase voltages. Each inner loop must be several times faster than the loop around it, so the outer loop can treat it as ideal.
Most practical PID problems are not about the three gains. They are integrator windup when the motor saturates, derivative kick on setpoint steps, noise amplified by the derivative term, and loops tuned on an unloaded joint. A feedforward term from the dynamics model in /topics/dynamics/ removes most of the work the feedback has to do. See /reference/pid-tuning/ for a tuning procedure.
State space, LQR and MPC
State-space control writes the system as a state vector x, an input u, and linear (or linearised) equations for how x changes. It handles many coupled inputs and outputs in one design, which PID loops tuned one at a time cannot. The linear quadratic regulator (LQR) picks the feedback gain that minimises a weighted sum of state error and control effort over an infinite horizon. You choose the weights, and a Riccati equation gives the gain. It is the standard first controller for balancing systems such as a cart-pole or a wheeled inverted pendulum.
Model predictive control (MPC) solves a finite-horizon optimisation at every control step, applies the first input and then solves again from the new state. Its strength is constraints: torque limits, joint limits, friction cones and obstacle margins go straight into the problem. Its cost is computation and the need for a good model. It is common on legged robots and drones, often with a simplified model inside the optimiser and a faster tracking controller underneath.
Impedance, admittance and force control
Position control is wrong for contact. A stiff position loop pushing a tool into a table will build up force until something gives. Impedance control, introduced by Hogan in 1985, controls the relation between motion and force instead: the robot behaves like a chosen spring and damper around its target. It needs a robot whose joint torques can be commanded and that can be back-driven.
Admittance control is the dual. It measures the contact force, usually with a wrist force/torque sensor, and moves the position setpoint in response. It suits stiff, high-ratio industrial arms that accept only position commands. Explicit force control regulates the contact force itself along chosen directions while position is controlled along the others. Khatib’s operational space formulation puts motion and force control into the same task-space framework.
Whole-body control
Humanoids, quadrupeds and mobile manipulators have many joints and many simultaneous goals: keep balance, keep the feet from slipping, move the hand, hold a posture. Whole-body control expresses each goal as a task with a priority, then solves for joint torques or accelerations that satisfy them in order, subject to contact and torque limits. Sentis and Khatib (2005) is an early description of the prioritised approach. Current implementations usually solve one or a stack of quadratic programs every control cycle. See /topics/legged-and-humanoid/.
Where to start
Begin with /learn/beginner/05-pid-control/, then tune a real loop using /reference/pid-tuning/. /learn/beginner/09-simulate-an-arm-in-mujoco/ gives you an arm to try gravity feedforward on.
Tools and platforms
| Tool | What it is for | Licence | Platform |
|---|---|---|---|
| ros2_control | Hardware interfaces, controller manager and standard controllers for ROS 2 | Apache-2.0 | /platforms/ros/ |
| python-control | Transfer functions, state space, LQR and frequency-domain analysis in Python | BSD-3-Clause | /platforms/opensource/ |
| acados | Fast embedded solvers for nonlinear MPC | BSD-2-Clause | /platforms/opensource/ |
| CasADi | Symbolic modelling and automatic differentiation for optimal control | LGPL-3.0 | /platforms/opensource/ |
| OSQP | Quadratic program solver used inside linear MPC and whole-body controllers | Apache-2.0 | /platforms/opensource/ |
Common mistakes
- Tuning the outer loop before the inner one is stable and fast.
- No anti-windup. The integrator charges while the motor is saturated and overshoots when it recovers.
- Differentiating a quantised encoder signal without filtering, then blaming the derivative gain.
- Running a controller in a non-real-time process and wondering why it jitters. Measure the loop period, not only the gains.
- Using impedance control on a robot whose joints cannot be back-driven. Use admittance control with a force sensor instead.
Going deeper
- Karl J. Åström and Richard M. Murray, Feedback Systems: An Introduction for Scientists and Engineers, 2nd edition, Princeton University Press. Free PDF on the book’s wiki.
- James B. Rawlings, David Q. Mayne and Moritz M. Diehl, Model Predictive Control: Theory, Computation, and Design, 2nd edition, Nob Hill Publishing. Free PDF from the authors.
- Neville Hogan, Impedance control: an approach to manipulation, Part I: Theory, Journal of Dynamic Systems, Measurement, and Control 107(1), 1985.
- Oussama Khatib, A unified approach for motion and force control of robot manipulators: the operational space formulation, IEEE Journal on Robotics and Automation 3(1), 1987.
- Luis Sentis and Oussama Khatib, Synthesis of whole-body behaviors through hierarchical control of behavioral primitives, International Journal of Humanoid Robotics 2(4), 2005.
- ros2_control documentation, for wiring a controller to real hardware in ROS 2.
- Motor-control loops on FPGAs are built from fixed-point arithmetic, digital filters and CORDIC. The FPGA Guide covers those building blocks in its DSP on FPGA hub.