⟿ INVERTED PENDULUM ON A CART // STATE FEEDBACK CONTROL

Inverted Pendulum

LQR · POLE PLACEMENT · REAL-TIME STABILIZATION
CONTROLLER
Q · POSITION (x)
Q · VELOCITY (ẋ)
Q · ANGLE (θ)
Q · ANGULAR VELOCITY (θ̇)
R · CONTROL PENALTY
SYSTEM PARAMETERS
REFERENCE & INITIAL STATE
PHYSICAL SYSTEM
TIME RESPONSE θ [°] x [m] u [N]
STATE
PENDULUM ANGLE θ
θ̇ = — °/s
CART POSITION x
ẋ = — m/s
CONTROL FORCE u
|u| ≤ 200 N
CLOSED-LOOP
mode: LQR
CONTROLLER ANALYSIS
FEEDBACK GAIN u = −K·(x − x*)
K = [ ]
state: x = [ x , ẋ , θ , θ̇ ]ᵀ
CLOSED-LOOP EIGENVALUES eig(A − B·K)
ⓘ Nonlinear model (integrated with RK4): ẍ = [u + m·sinθ·(l·θ̇² − g·cosθ)] / (M + m·sin²θ), θ̈ = [(M+m)·g·sinθ − cosθ·(u + m·l·θ̇²·sinθ)] / [l·(M + m·sin²θ)]. Controllers are designed using linearized A, B around the upright equilibrium (θ=0): LQR solves the continuous Algebraic Riccati Equation (CARE) using the Matrix Sign Function; pole placement assigns closed-loop poles based on damping ratio (ζ) and natural frequency (ωn) targets. The open-loop system is unstable — the pendulum falls in OFF mode. Eigenvalues are computed via Faddeev–LeVerrier + Durand–Kerner. All parameters can be modified live.