Inverted Pendulum Simulator

Cart-pole (inverted pendulum) with PID control. Watch the pendulum balance upright on a moving cart, tune the controller, or destabilize it with a kick to see how the controller recovers.

RK4 integrator, substepped at 0.5 ms, runs entirely in the browser.

Cart-Pole Animation

Cart position x Reference (target x) Pole Control force F

Time-Series Response

Cart x (m) Setpoint (m) Pole angle (deg) Control F (N)

x

0.000

m

theta

0.0

deg

F

0.00

N

|theta|max

0.0

peak (deg)

Cart and Pole Parameters

2.0 kg
0.2 kg
0.5 m
0.1
0.01

PID Gains

50
0
10
20
30 N

Equations of Motion

The cart-pole has four state variables: cart position x, cart velocity v, pole angle theta (0 = straight up), and pole angular velocity omega. The PID controller drives the cart to a setpoint x_ref = 0.

Cite this tool: Li, H. (2026). Inverted Pendulum Simulator. https://hongbinli.ca/tools/inverted-pendulum-simulator