Swing-Up & LQR Control of Inverted Pendulum on Cart in MATLAB (with Animation + Energy-Based Strategy)
🧠 Short Description:
This project demonstrates energy-based swing-up control combined with LQR stabilization of an inverted pendulum mounted on a cart, simulated entirely in MATLAB using custom OOP class definitions and realistic animation.
Ideal for students, control engineers, and researchers interested in non-linear control, dynamics, and advanced control strategies in action.
📦 What’s Inside the Download Bundle:
✅ Main simulation script (.m)
✅ RK4 integrator function
✅ Custom MATLAB class InvPendOnCart.m
✅ High-quality pendulum animation with rotating wheels
✅ Plot for swing-up control input vs time
✅ Fully commented code for all sections
✅ PDF Documentation/Guide included
💡 Key Concepts Covered:
- Lagrangian dynamics modeling
- Nonlinear control design
- Swing-up control via energy shaping
- LQR feedback control design
- RK4 numerical integration
- State-space linearization
- MATLAB OOP and modular design
- 2D animation with trail, wheels, and pendulum movement
🎯 Simulation Features:
- Randomized initial pendulum angle (±180°)
- Automatic swing-up using energy-based logic
- Seamless transition to LQR controller when upright
- Real-time animated cart and pendulum
- Rotating wheels synced with cart motion
- Visual display of time and angle during simulation
- Plot of control input used during swing-up
🛠️ System Requirements:
- MATLAB any version
- No external toolboxes required
- Compatible with all major OS (Windows/Mac/Linux)
📣 Social + Store Links:
📷 Instagram: @engrprogrammer2494
▶️ YouTube: @engrprogrammer