MPC Pendulum Swing-Up (MPPI)

This interactive simulator explores MPC Pendulum Swing-Up (MPPI) in Engineering. Sampling-based Model Predictive Control: K candidate torque rollouts over horizon H, MPPI cost-weighted update, bounded torque |u|≤u_max — swing up an inverted pendulum live and watch the planner replan. Use the controls to change the scenario; watch the visualization and any graphs or readouts to connect the model with lectures, labs, and homework.

Who it's for: For learners comfortable with heavier math or second-level detail. Typical context: Engineering.

Key terms

  • mpc
  • pendulum
  • swing
  • mppi
  • mpc pendulum
  • engineering

How it works

**Sampling-based Model Predictive Control (MPPI)** drives a damped pendulum from hanging (θ = 0) to the upright fixed point (θ = π) under a **bounded torque** |u| ≤ u_max. Every Δt the controller samples **K** candidate torque sequences over a horizon **H**, simulates each forward with RK4, and re-fits the mean by an exponentially weighted average of the costs (MPPI update with temperature **λ**). The first action is applied; the plan is shifted and warm-started for the next step. Try the **Swing-up** preset where u_max < m·g·L: the controller has to *pump* energy by swinging back and forth before catching the inverted equilibrium. Purple lines are the K candidate rollouts; green is the best one.

Key equations

Iθ̈ = − m g L sinθ − bθ̇ + u, |u| ≤ u_max
min J = Σ [q_θ(1+cosθ) + q_ω ω² + r_u u²] + q_term · (1+cosθ_T)²
MPPI: μ_t ← Σ w_k u_t^k / Σ w_k, w_k = exp(−(J_k − J_min)/λ)