/ControlBootcamp

Python implementation of the inverted pendulum demo from: https://www.youtube.com/watch?v=Pi7l8mMjYVE&list=PLMrJAkhIeNNR20Mz-VpzgfQs5zrYi085m

Primary LanguagePython

Inverted Pendulum Control

A python version of inverted pendulum control code from control boot camp.

Dependencies

Python 3

  • numpy
  • taichi (0.6.8)
  • control
  • matplotlib
  • scipy

Maxima

  • wxmaxima (for gui)

Math part

a. Cart-pend system definition

definition

b. Dynamics equations

Use wxmaxima for lagrange euqation computation. Please refer to pyVersion/cartpend.wxmx

Result

cd pyVersion # for run all script

1. Cartpend Simulation

python sim_cartpend.py

sim_cartpend

2. Pole placement

python poleplace_cartpend.py

poleplace_cartpend

  • To visualize how linearizad model perfroms at place away from linearized point, run:
    python linearize_cartpend.py

3. LQR control

Here I add a periodical force to the cart to for more visual impact.

python lqr_cartpend.py

lqr_cartpend

  • To play with observability, run:
    python obsv_cartpend.py

4. Kalman estimator

python kf_cartpend.py

kf_cartpend

5. LQG control (Kalman estimator + LQR control)

Here the controller is move the cart-pend system from initial state (x, x_dot, theta, theta_dot): [0.0, 0.0, 0.0, 0.1] to [0.3, 0.0, 0.0, 0.0]

python lqg_cartpend.py

lqg_cartpend