This repo contains the following packages:
control-toolbox
(modified from upstream): from https://github.com/ethz-adrl/control-toolboxct
: meta packagect_core
: core libraryct_optcon
: optimal control library
kindr
: needed bycontrol-toolbox
invpend_experiment
: containing the necessary description of a inverted pendulum, I forked from https://github.com/linZHank/invpend_experimentacado
: containing ACADO source code. This folder will be ignored during catkin compilationcontrol_demo
: containing demo control programs using the two libraries written in C++ct_quad_circle_mpc.cpp
-> executablect_quad_circle_mpc_node
: (non-linear) model predictive control for quadrotor tracking a circle usingcontrol-toolbox
ct_invpend_pid.cpp
-> executablect_invpend_pid_node
: using one PID feedback controller to control the inverted pendulum stay stable, but not workingct_invpend_lqr.cpp
-> executablect_invpend_lqr_node
: using linear quadratic regulator feedback controller to control the inverted pendulum staying stable, working, but less robustct_invpend_mpc
.cpp -> executablect_invpend_mpc_node
: (non-linear) model predictive control for the inverted pendulum staying stable, workingacado_invpend_mpc.cpp
-> executableacado_invpend_mpc_node
: Linear MPC for the inverted pendulum staying stable, working
First, make a workspace folder, say demo_ws
$ mkdir demo_ws
Next clone this repo as src
folder
$ git clone https://github.com/zhangbaozhe/ControlLibraryDemo.git src
Then install the following dependencies:
- gflags:
$ sudo apt install libgflags-dev
- catkin tools:
$ sudo apt install python-catkin-tools or $ sudo apt install python3-catkin-tools
- Control Toolbox dependencies:
HPIPM & blasfeo
: Go tosrc/control-toolbox/ct
$ cd src/control-toolbox/ct $ bash install_hpipm.sh
- invpend_experiment dependencies:
$ sudo apt install ros-noetic-ros-control ros-noetic-ros-controllers ros-noetic-gazebo-ros ros-noetic-gazebo-ros-control
- mavros:
$ sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras $ wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh $ sudo bash ./install_geographiclib_datasets.sh
In the workspace folder:
$ catkin build -DCMAKE_BUILD_TYPE=Release -j2
If you have more than 8GB RAM or even 16GB, you can maybe drop -j2
option.
If you want compile the examples and tests in control toolbox you can type
$ catkin build -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=true -DBUILD_TESTS=true -j2
The compilation may take a while, since C++ templates compilation consumes huge resources.
(Optional) If you want to use the quadrotor demo, you need to use PX4-Autopilot simulation.
Run the inverted pendulum demo: In one terminal (in the workspace folder):
$ source devel/setup.bash
$ roslaunch invpend_control load_invpend.launch
In another terminal
$ source devel/setup.bash
$ rosrun control_demo ct_invpend_mpc_node