|
|
||
|
This tutorial visualizes a cart-pole control problem. The pendulum starts hanging downward at rest. The goal is to swing the pendulum up and then keep it upright. The final cart goal position is shown from the beginning. After the pendulum is caught near upright, the controller uses an active reference Sections Mathematical FoundationThe state vector packs cart position/velocity and pendulum angle/angular-velocity: state = [x, x', θ, θ']
Cart-Pole DynamicsThe simulator uses a standard nonlinear cart-pole model. With cart force temp = (F + m L (θ')2 sinθ) / (M + m)
θ'' = (g sinθ − cosθ · temp) / (L (4/3 − m cos2θ / (M + m))) x'' = temp − m L θ'' cosθ / (M + m) Euler integration advances the state each step Δt: x' ← x' + x'' Δt, x ← x + x' Δt
θ' ← θ' + θ'' Δt, θ ← θ + θ' Δt Hybrid Controller MechanismBecause the initial state is hanging downward, a simple upright stabilizer cannot work by itself. The simulator uses two modes:
Swing-up drives the pendulum energy toward the upright energy: E = 0.5 m (L θ')2 + m g L cosθ, Edesired = m g L
Fswing = KE (E − Edesired) θ' cosθ − Kxs x − Kvs x' Why the startup nudge: if the pendulum is exactly hanging down with zero angular velocity, that is a symmetric equilibrium — no controller can infer which direction to swing first, so the simulator adds a small startup nudge to break the symmetry.
Balance mode switches to state feedback once the pole is near upright: F = Kθ θerr + Kω θ' + Kx (x − xref) + Kv x'
Balance-mode interpretation:
Worked balance example. With θerr = 0.04 rad, θ' = −0.10 rad/s, x = 0.20 m, xref = 1.00 m, x' = 0.30 m/s:
What The Plots ShowThe animation shows the cart and pendulum. The plots show whether control is working:
SimulationThe interactive simulator is below. Use the controls to explore the concepts described above.
balanced
1.00 m
95
18
18
12
0.0 N
45 N
starts hanging down
Animated Cart And PendulumAngle error from uprightCart position x(t)Control force F(t)Live Calculation
Usage Instructions
Important SimplificationsThis is an educational control simulation. The model is deliberately idealized:
|
||