Skip to content

Sepishoon/2DOF-Inverted-Pendulum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

2DOF Inverted Pendulum — Modern Control

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


Overview

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.


Project Structure

.
└── 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

Methods

Q1.1 — Equations of Motion & Linearization

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, ẋ]

Q1.2 — Controllability & Observability

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.

Q1.3 — State Feedback Controller (EESA & GCCF)

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.

Q1.4 — Observer Design

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.

Q1.5 — Servo Controller

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.


Simulink Models

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 θ₁

Requirements

  • MATLAB R2023b or later
  • Symbolic Math Toolbox
  • Control System Toolbox
  • Simulink

Usage

  1. Open MATLAB and navigate to the Codes/ directory
  2. Run 2DOF_Pendulum.mlx in the Live Editor to reproduce all symbolic derivations and numerical results
  3. Open the Simulink models (Servo.slx, Observer.slx, Controller.slx) to run closed-loop simulations

About

State-space modelling, controllability & observability analysis, EESA and GCCF state feedback design, and Luenberger observer synthesis for a 2-DOF inverted pendulum, implemented in MATLAB and Simulink.

Topics

Resources

Stars

Watchers

Forks

Contributors