This is a repository for trying control algorithms, which is the content repository of the following article.
NonlinearMPCCasADi_.-180.0_0.0_dt-0.02-0.02_dead-0.0_f-0.0-0.0_n-False_e-False_q-False-72.mp4
I Implemented a double inverted pendulum simulator and tried the following algorithms.
- PID
- Pole Placement
- LQR
- iLQR
- Linear MPC
- Nonlinear MPC
Install rye according to the following.
https://rye.astral.sh/guide/installation/
curl -sSf https://rye.astral.sh/get | bash
Set up a virtual environment with rye.
source .rye/env
rye sync
source .venv/bin/activate
python control_double_inverted_pendulum.py
The default controller_model is LQR. You can change the controller_model by modifying the following line.
controller_mode = "LQR"
Also, if you set the following options to True
, the selected controller will run the simulation only once from the given initial angle state.
run_once = True
If you set this to False
, you can run control repeatedly from various initial values to find the ROA (Region of Attraction).
If matplotlib does not display properly in the virtual environment, run the following command.
sudo apt-get install python3-tk