Balancing an inverted pendulum with delayed feedback

A homogeneous rod on a cart, stabilised by delayed PD control. Past the critical delay τc the upright position loses stability in a Hopf bifurcation and the cart starts to rock. For larger derivative gain Kd the oscillation then breaks its left–right symmetry before the pendulum falls.

angle x(t) [rad] mean tilt x̄ over one Hopf period cart position y(t) [m] scene: delayed state seen by the controller
Statestable
critical delay τc–
Hopf period 2π/ωc–
amplitude of x (last 3 s)–
mean tilt x̄–
cart speed ẏ–
time0.0 s
Scenarios
–
Feedback gains

M = 1 kg, m = 0.3 kg, L = 1 m, g = 9.81 m/s². τc is recomputed from the linearisation whenever the gains change.

Equations of motion

Rod of length L and mass m (centre of mass at l = L/2, moment of inertia mL²/12 about it), cart of mass M driven by a horizontal force F. x is the tilt from upright, y the cart position.

(M+m)y¨+ml(x¨cos⁡x−x˙2sin⁡x)=F(t)
43lx¨+y¨cos⁡x−gsin⁡x=0,l=L2

Delayed PD feedback

All four states are measured τ seconds late. The cart gains are much smaller than the angle gains. For an inverted pendulum they carry the same sign as the angle gains: the cart briefly moves away from the origin to lean the rod back towards it.

F(t)=Kpx(t−τ)+Kdx˙(t−τ)+kpy(t−τ)+kdy˙(t−τ)

Hopf bifurcation

Linearising about x = y = 0 gives the characteristic equation

λ4−aλ2+e−λτD[(K(λ)−43lk(λ))λ2+gk(λ)]=0

with K(λ) = Kp + Kdλ, k(λ) = kp + kdλ, D = l(4M+m)/3, a = (M+m)g/D.

A pair of roots crosses the imaginary axis at λ = ±iωc when τ = τc. With Kd = 7 the bifurcation is supercritical: the amplitude grows like √(τ − τc) until, about 10 % above τc, the pendulum falls.

Symmetry breaking

The equations are invariant under (x, y) ↦ (−x, −y), and the Hopf orbit inherits that symmetry: its mean tilt x̄ is zero. The fall corresponds to a connecting orbit. For larger Kd the orbit first loses its symmetry. In simulations without cart feedback, the pendulum falls from the symmetric orbit for Kd = 4. Symmetry breaking comes first at about 1.18 τc for Kd = 5.5, 1.13 τc for Kd = 7 and 1.03 τc for Kd = 13. In each case the fall follows only at 1.26–1.28 τc. The pendulum then oscillates about a tilted mean x̄ ≠ 0. Averaging the cart equation over one period gives the balance

Kpx‾+kpy‾+kdy˙‾=0

Without cart feedback (kp = kd = 0) the leaning oscillation is a stable periodic orbit of the angle equation, and the cart accelerates steadily towards the lean. With the small cart gains the balance cannot hold for long. The cart runs off, its own feedback pushes the tilt over to the other side, and the cart runs back. You see a fast oscillation with a slowly flipping mean tilt, and large, slow cart sweeps.