← Work / Projects

Side project · 2017

Double inverted pendulum

A Simulink experiment that grew into a full estimation and control design: an LQR controller and Kalman filter that balance a double inverted pendulum using a realistic, noisy gyro model.

Role
Solo project
When
2017, after Embark
Tools
Simulink · Matlab
Methods
LQR · Kalman filter · sensor noise modeling
Simulink block diagram with PLANT, State Estimator and gain blocks, partly covered by the animation window showing the double pendulum balanced upright on its base
Simulink model and animation

Why

At Embark I had started designing software-in-the-loop and hardware-in-the-loop testing, and I wanted to keep learning how to model physical systems in Simulink. This began as a small experiment to model and animate a double pendulum, a classic demonstration of chaos.

Controller

Once the animation worked, I wanted to know how hard it would be to balance the pendulum inverted. A simple LQR controller did it, and was surprisingly robust, as long as it had perfect state information.

Realistic sensing

So I made the simulation realistic. I analysed the output of an off-the-shelf gyro in Matlab and reproduced its noise profile and bias in Simulink, then used that model for the angular-rate feedback of both pendulum stages.

To give the LQR controller a state estimate, I designed a Kalman filter using a model linearized about the balanced position and the modeled gyro feedback. With that observer, the controller balanced the pendulum comfortably, which was enough to conclude that a physical build with the same sensors would work.

Estimation and control loop

  1. Goal
    Upright reference
  2. Control
    LQR controller
  3. Plant
    Double pendulumNonlinear Simulink model
  4. Sensing
    Modeled gyrosNoise and bias fitted to a real sensor
  5. Estimation
    Kalman filterLinearized about upright

↺ state estimate

LQR on a Kalman-filtered state estimateSimplified

Related