Dynamic Model Based Control: State-Space Control of an Inverted Pendulum

An academic project focused on designing, implementing, and simulating a complete controller and observer system in MATLAB & Simulink to solve the classic unstable inverted pendulum problem.

Simulink Model of the Inverted Pendulum Control System

At a Glance

  • Situation: The inverted pendulum on a cart is a classic problem in dynamics and control theory. It is an inherently unstable, non-linear system that requires active control to maintain its upright equilibrium position.
  • Task: To model the system, design a stabilizing state feedback controller, and implement an observer to estimate the full state of the system from limited sensor outputs (pendulum angle and cart position only).
  • Action: I first derived the linearized state-space model of the system. Then, using MATLAB, I designed a full state feedback controller via pole placement and a Luenberger observer to estimate the unmeasurable states (the angular and linear velocities). The entire system was implemented and tested in Simulink on both the linearized and original non-linear models.
  • Result: The simulations were successful. The controller effectively stabilized the pendulum, driving its angle to zero from an initial offset. The observer accurately tracked the true states of the system, enabling the estimated state feedback to perform almost identically to a controller with full state information. The linear controller also proved robust enough to stabilize the non-linear model.

Technical Deep Dive

System Architecture & Design

The project followed a classic state-space control design methodology. The first step was to take the non-linear mechanical equations of the pendulum and cart and linearize them around the upright equilibrium point ($\theta=0$) to obtain a linear time-invariant (LTI) system of the form $\dot{x} = Ax + Bu$ and $y = Cx$.

The control architecture consists of two main components:

  1. State Feedback Controller: A controller of the form $u = -Fx$ (or $u = -F\hat{x}$ for estimated feedback) where the gain matrix F is calculated to move the eigenvalues (poles) of the closed-loop system matrix $(A-BF)$ to stable locations in the left-half of the complex plane.
  2. Luenberger Observer: Since only the angle ($\theta$) and cart position ($p$) were assumed to be measurable, an observer was designed to estimate the full state vector, including the velocities ($\dot{\theta}$ and $\dot{p}$). The observer dynamics are given by $\dot{\hat{x}} = A\hat{x} + Bu + K(y - C\hat{x})$, where K is the observer gain matrix.

This separation principle allows the controller and observer to be designed independently. The final implementation uses the estimated state for feedback, with the control law $u = -F\hat{x}$.

Core Implementation Details

The entire design and simulation was carried out in MATLAB and Simulink.

  • Controller & Observer Gain Calculation: I used MATLAB's place command to perform the pole placement. For the controller gain F, the desired poles were specified as [-1±i, -2±2i] to achieve a stable response. For the observer gain K, two sets of poles were tested: "slow" poles, and "fast" poles (e.g., [-100, -101, -102, -103]) to ensure the estimation error converged much more quickly than the system dynamics.
  • Simulink Modeling: I built Simulink models that included State-Space blocks for both the plant and the observer. The models were configured to switch between ideal full state feedback and the more realistic estimated state feedback for direct comparison.
  • Simulation and Visualization: A MATLAB script (utils.m) was used to automate the process of setting parameters, running the various simulation configurations, and generating plots to compare the true state ($x$), the estimated state ($\hat{x}$), the estimation error, and the control input ($u$) over time.

Challenges & Solutions

The primary challenge of this problem is that in any realistic scenario, it's impossible or impractical to measure every state variable directly. Specifically, measuring the angular and linear velocities accurately can be difficult and noisy.

The solution was the implementation of the Luenberger observer. By using only the reliable position and angle measurements, the observer successfully reconstructed the velocity states. The simulation results showed that when the observer poles were chosen to be "fast", the estimated states converged to the true states very rapidly. This allowed the estimated state feedback controller to perform nearly as well as an ideal controller with perfect information, demonstrating the practical power of observers in bridging the gap between control theory and real-world hardware limitations.

Project Information

Date: 2024

Type: Academic Course Project

Course: Dynamic Model Based Control

Technologies Used

  • MATLAB
  • Simulink
  • Control Theory
  • State-Space Models
  • Pole Placement
  • Luenberger Observer