AnyLearn
All lessons
Roboticsintermediate

State-Space Models and Pole Placement

Move beyond single-input PID to the state-space framework: the state vector, matrix dynamics, controllability, pole placement via state feedback, and LQR — the tool that scales to full robot arms and drones.

Not signed in — your progress and quiz score won't be saved.
Lesson progress1 / 8

Why transfer functions hit a wall

A single transfer function G(s)G(s) elegantly describes a single-input single-output (SISO) loop — one voltage in, one angle out. But a 6-DOF robot arm has six joint angles, six torque inputs, and every joint couples to every other through centripetal and Coriolis terms. Stacking six transfer functions doesn't capture this coupling.

State-space is the answer. It represents all dynamics in a compact matrix equation:

x˙=Ax+Bu,y=Cx\dot{x} = Ax + Bu, \qquad y = Cx

Here xRnx \in \mathbb{R}^n is the state vector (everything you need to predict the future), uRmu \in \mathbb{R}^m is the input, yRpy \in \mathbb{R}^p is the measured output, and AA, BB, CC are constant matrices. Multiple inputs and outputs? Just make BB have more columns and CC more rows. The framework scales effortlessly to MIMO systems.

Full lesson text

All 8 steps on one page — for reading, reference, and search.

Show

1. Why transfer functions hit a wall

A single transfer function G(s)G(s) elegantly describes a single-input single-output (SISO) loop — one voltage in, one angle out. But a 6-DOF robot arm has six joint angles, six torque inputs, and every joint couples to every other through centripetal and Coriolis terms. Stacking six transfer functions doesn't capture this coupling.

State-space is the answer. It represents all dynamics in a compact matrix equation:

x˙=Ax+Bu,y=Cx\dot{x} = Ax + Bu, \qquad y = Cx

Here xRnx \in \mathbb{R}^n is the state vector (everything you need to predict the future), uRmu \in \mathbb{R}^m is the input, yRpy \in \mathbb{R}^p is the measured output, and AA, BB, CC are constant matrices. Multiple inputs and outputs? Just make BB have more columns and CC more rows. The framework scales effortlessly to MIMO systems.

2. Choosing a state vector

The state vector xx must capture all information needed to predict future behavior. For a mechanical system, position and velocity are the natural choices — because Newton's law is second order.

For a robot joint (angle qq, velocity q˙\dot{q}):

x=[qq˙],x˙=[010b/m]x+[01/m]ux = \begin{bmatrix} q \\ \dot{q} \end{bmatrix}, \quad \dot{x} = \begin{bmatrix} 0 & 1 \\ 0 & -b/m \end{bmatrix} x + \begin{bmatrix} 0 \\ 1/m \end{bmatrix} u

where bb is damping and mm is effective inertia. This is the x˙=Ax+Bu\dot{x} = Ax + Bu form with A=[010b/m]A = \begin{bmatrix}0 & 1 \\ 0 & -b/m\end{bmatrix} and B=[01/m]B = \begin{bmatrix}0 \\ 1/m\end{bmatrix}.

The state-space model is just Newton's second law written in matrix form. No new physics — new notation that generalises to any number of coupled equations.

3. State-space vs transfer function: a comparison

Both representations describe the same linear dynamics, but they have different strengths:

FeatureTransfer function G(s)G(s)State-space (A,B,C)(A,B,C)
SISO systemsNatural, compactWorks but verbose
MIMO systemsHard (matrix of transfer functions)Natural — just bigger matrices
Internal stateHiddenExplicit
Stability analysisPoles of G(s)G(s)Eigenvalues of AA
Controller designClassical (PID, lead-lag)Pole placement, LQR, Kalman
Nonlinear extensionVery limitedLinearize around operating point
SimulationNeed partial fractionsDirect numerical integration

For a single joint with a PID controller, transfer functions are fine. For a quadrotor (12 states, 4 inputs) or a manipulator arm, state-space is the only practical framework.

4. Controllability: can you reach any state?

Before designing a state-feedback controller, you must answer: can the inputs uu actually steer xx anywhere you want? This is controllability.

Formally, a system is controllable if the controllability matrix

C=[BABA2BAn1B]\mathcal{C} = \begin{bmatrix} B & AB & A^2B & \cdots & A^{n-1}B \end{bmatrix}

has full row rank (rank=n\text{rank} = n).

Physical intuition: BB captures what states are directly driven by inputs. ABAB captures what states are driven one step later via dynamics. An1BA^{n-1}B covers states reachable after n1n-1 dynamic steps. If any state is unreachable, the rank drops below nn and no controller can drive the system to an arbitrary target.

In practice: an unactuated degree of freedom (a freely spinning wheel with no motor) is uncontrollable. Check with np.linalg.matrix_rank(np.hstack([B, A@B, ...])) before designing anything.

5. State feedback and pole placement

If the system is controllable, you can place the closed-loop poles anywhere by choosing a state feedback gain matrix KK:

u=Kxx˙=(ABK)xu = -Kx \quad \Rightarrow \quad \dot{x} = (A - BK)x

The closed-loop eigenvalues are the eigenvalues of (ABK)(A - BK). Choose desired poles λ1,,λn\lambda_1, \dots, \lambda_n (all in the left half-plane), and there exists a unique KK that achieves them — found by Ackermann's formula or SciPy's place_poles.

import numpy as np
from scipy.signal import place_poles

A = np.array([[0, 1], [0, -2.0]])   # joint dynamics
B = np.array([[0], [10.0]])          # input matrix

# Desired poles: fast, well-damped
desired_poles = [-5 + 2j, -5 - 2j]
result = place_poles(A, B, desired_poles)
K = result.gain_matrix               # 1x2 gain vector
print("K =", K)  # e.g., [[2.9  0.8]]

With u=Kxu = -Kx, the actuator applies a weighted combination of position and velocity — exactly the P and D terms of a PID, now systematically chosen to achieve target dynamics.

6. LQR: optimal state feedback

Pole placement requires you to specify exact pole locations, which is non-trivial in high dimensions. Linear Quadratic Regulator (LQR) replaces pole specifications with a more intuitive trade-off: how much do you care about state error vs. control effort?

LQR minimises the cost:

J=0(xQx+uRu)dtJ = \int_0^\infty \bigl( x^\top Q x + u^\top R u \bigr)\,dt

Q0Q \succeq 0 penalises state error; R0R \succ 0 penalises control effort. A large Q/RQ/R ratio → aggressive controller (high bandwidth, lots of actuator effort). A small Q/RQ/R ratio → gentle controller (low effort, slower correction).

The optimal gain is K=R1BPK^* = R^{-1} B^\top P, where PP solves the algebraic Riccati equation. SciPy computes it in one line: from scipy.linalg import solve_continuous_are.

LQR is the workhorse of aerospace and robotics: it handles MIMO coupling automatically, guarantees stability margins (6\geq 6 dB gain margin, 60°\geq 60° phase margin for SISO), and requires only physical intuition about weights rather than pole arithmetic.

7. Observers: state estimation when you can't measure everything

State feedback needs all of xx. But sensors measure only y=Cxy = Cx. A robot joint might have a position encoder but no velocity sensor — so q˙\dot{q} must be estimated.

A Luenberger observer (state estimator) runs a model of the plant in parallel with the real plant:

x^˙=Ax^+Bu+L(yCx^)\dot{\hat{x}} = A\hat{x} + Bu + L(y - C\hat{x})

The term L(yCx^)L(y - C\hat{x}) is a correction proportional to how much the predicted output Cx^C\hat{x} differs from the measured yy. Choose LL so that (ALC)(A - LC) has fast, stable eigenvalues and x^x\hat{x} \to x quickly.

The Kalman filter is the LQR-optimal observer: it picks LL to minimise estimation error variance given process and measurement noise covariances. LQR + Kalman = LQG (Linear Quadratic Gaussian), the backbone of modern spacecraft and autonomous vehicle control.

8. PID vs state-space: which to use

Both tools are valid — choose based on what you're controlling:

SituationRecommendation
Single joint, simple dynamicsPID — simple to implement, easy to tune
Multi-joint arm with couplingState-space + LQR — coupling is handled naturally
No velocity sensorState-space + Kalman filter for estimation
Plant is well-understood, fast loopPID with feedforward
Tight performance specs (aerospace)LQR / LQG — guaranteed margins
Nonlinear plantLinearize, then state-space; or nonlinear MPC
Embedded microcontroller (tiny RAM)PID — minimal memory, one multiply-add loop

In practice, a 6-DOF industrial arm uses: per-joint PID for motor current (inner loop), state-space with LQR for position/velocity (outer loop), and feedforward from a dynamics model. The layers cooperate, not compete.

Check your understanding

The lesson ends with a 5-question quiz. Take it in the player above to see your score.

  1. The state-space model $\dot{x} = Ax + Bu$ for a robot joint uses $x = [q,\, \dot{q}]^\top$. What physical principle determines the structure of $A$ and $B$?
    • The Laplace transform of the transfer function $G(s)$.
    • Newton's second law, written as a first-order system in position and velocity.
    • The Ziegler-Nichols tuning rules applied to the joint torque.
    • The controllability matrix rank condition.
  2. The controllability matrix $\mathcal{C} = [B\; AB\; A^2B\; \cdots]$ does NOT have full row rank. What does this mean for controller design?
    • The system is unstable and requires a stabilizing gain.
    • At least one state mode cannot be driven by the inputs, so arbitrary pole placement is impossible.
    • The LQR cost is infinite regardless of the Q and R matrices chosen.
    • The transfer function from $u$ to $y$ has a right-half-plane zero.
  3. With state feedback $u = -Kx$, the closed-loop dynamics become $\dot{x} = (A - BK)x$. Where do the closed-loop poles come from?
    • The eigenvalues of $A$ alone, since $B$ only scales the input.
    • The eigenvalues of $(A - BK)$, which depend on the chosen $K$.
    • The roots of $\det(B - K) = 0$.
    • The poles of the transfer function $C(sI - A)^{-1}B$.
  4. In an LQR design, you double the $Q$ matrix while keeping $R$ fixed. What is the expected effect?
    • The controller becomes more conservative, using less actuator effort.
    • The controller becomes more aggressive, reducing state error faster at the cost of higher control effort.
    • The optimal gain $K^*$ becomes zero since $Q$ penalises the state.
    • The phase margin decreases below 45 degrees.
  5. A robot has a position encoder but no velocity sensor. Which approach correctly estimates velocity for state feedback?
    • Set the velocity state to zero and rely on the P term only.
    • Use a Luenberger observer or Kalman filter to estimate velocity from position measurements.
    • Add a D term to the position error to approximate velocity.
    • Differentiate the encoder signal directly without any filtering.

Related lessons