Control design and analysis for a 2-DOF Inverted Pendulum system, covering linearization, state feedback, observer design, and servo control implemented in MATLAB and Simulink.
Course: Advanced Automatic Control (Modern Control)
Department: Aerospace Engineering, Sharif University of Technology
Author: Sepehr Mahfar
This project applies modern control theory to a 2-DOF inverted pendulum. The system is nonlinear, and the workflow proceeds from symbolic derivation of the equations of motion through linearization, controllability/observability analysis, and finally full state feedback and observer-based controller design.
All implementation details, derivations, and numerical results are provided in the MATLAB Live Script 2DOF_Pendulum.mlx.
.
└── Codes/
├── 2DOF_Pendulum.mlx # MATLAB Live Script — full analysis & design
├── Servo.slx # Simulink — Servo controller simulation
├── Observer.slx # Simulink — Observer (1-output & 2-output) simulation
└── Controller.slx # Simulink — EESA1, EESA2, and GCCF controller simulation
Symbolic derivation of the full nonlinear dynamics using Lagrangian mechanics. The inertia matrix, Coriolis terms, and gravitational forces are computed symbolically. The system is then linearized around the upright equilibrium to obtain the standard state-space form:
ẋ = Ax + Bu
y = Cx + Du
State vector: x = [θ₁, θ̇₁, θ₂, θ̇₂, x, ẋ]
Controllability and observability matrices are computed for different output configurations. The system is controllable for all tested input configurations. Observability depends on the choice of outputs — measuring only θ₁ or only θ₂ renders the system unobservable, while measuring both restores full observability.
Two state feedback controllers are designed:
- EESA1 / EESA2: Pole placement via extended state space approach, with two different desired pole locations tested
- GCCF: Generalized Canonical Controllable Form controller, providing an alternative placement strategy
All three are implemented and compared in Controller.slx.
A Luenberger observer is designed to estimate the full state from partial measurements. Two configurations are implemented in Observer.slx:
- 1-output observer: State estimation from a single measured output
- 2-output observer: Improved estimation using two measured outputs
The observer gain K_obs is designed so that observer poles are placed faster than the closed-loop controller poles.
A servo controller is designed to track a reference input for θ₁. Since only one input is available, the servo is designed for θ₁ as the output. Three output matrix configurations (C) are tested to assess servo feasibility, and the final servo gain is incorporated into the full closed-loop simulation in Servo.slx.
| File | Description |
|---|---|
Controller.slx |
Compares EESA1, EESA2, and GCCF state feedback controllers |
Observer.slx |
Luenberger observer with 1-output and 2-output configurations |
Servo.slx |
Full servo control loop with reference tracking for θ₁ |
- MATLAB R2023b or later
- Symbolic Math Toolbox
- Control System Toolbox
- Simulink
- Open MATLAB and navigate to the
Codes/directory - Run
2DOF_Pendulum.mlxin the Live Editor to reproduce all symbolic derivations and numerical results - Open the Simulink models (
Servo.slx,Observer.slx,Controller.slx) to run closed-loop simulations