This repo contains controller support for our lab's research on MPC algorithms.
The goal is
1. Provide an easy to use docker installation environment
2. Implement a good low-level controller that can track any traj generated by any MPC algorithms
3. Provide mechanism to benchmark different MPC algorithms. Currently we have
- CIMPC
- Convex MPC
2022-11-21: Major update. An improved convex MPC controller; our CI-MPC controller can enable Go1 to trot, step on boxes, and lean against wall.
We build, develop and test controller in a docker container. We also recommend to use VSCode devcontainer feature.
!important: First thing you need to do after building the docker container: run "source ~/ocs2_ws/devel/setup.bash" in the container. (I don't know how to automate this yet )
Since LCI MPC uses Julia, we need to config Julia environment after building the docker container. After docker is built, we first
1. git submodule update. Make sure src/legged_ctrl/src/mpc_ctrl/ci_mpc/lib has EmbeddedLciMpc.jl lib
2. go into src/legged_ctrl/src/mpc_ctrl/ci_mpc/lib/EmbeddedLciMpc.jl
3. start julia
4. pkg> activate .
5. pkg> instantiate
6. @v1.7) pkg> status ContactImplicitMPC (must be the local dir)
7. julia> include("scripts/precompile_sysimage.jl")
The controller can control either a hardware Go1 robot or a simulation Go1/A1 robot. To start the gazebo simulation environment, we create another docker. On the host computer, build a second docker in "gazebo_docker" folder
docker build -t a1_unitree_gazebo_image .
Now we need to be careful about the graphics card of the host computer. If the host computer uses Nvidia graphics card. Then we need to install nvidia-docker2. Read this link for more information.
Assuming an Nvidia graphics card is used, and Nvidia driver is properly installed. First follow this link to add nvidia-docker repo to your host computer, then install the nvidia-docker2 follows the instruction.
bash run_gazebo_docker.bash
Then on host computer, type
xhost +
Then we run script run_gazebo_docker.bash once, later you can access the docker "a1_unitree_gazebo_docker" by
docker start a1_unitree_gazebo_docker
docker attach a1_unitree_gazebo_docker
If more terminals are needed, use the following command to add more terminals
docker exec -it a1_unitree_gazebo_docker bash
In the docker container, run the following command to start the gazebo environment
roslaunch unitree_gazebo normal.launch rname:=a1 wname:=earth
The gazebo window should be seen on the host computer. Check the list of worlds for different wname.
During the development, we can let the robot stand up by two Unitree testing scripts. The following two commands are very handy.
rosrun unitree_controller unitree_servo # let the robot stretch legs
rosrun unitree_controller unitree_move_kinetic # place the robot back to origin
We oftern running the two commands alternatively by running one and ctrl-C after a while to adjust the pose of the robot. After the robot properly stands up, it is ready to be controlled.
The MPC controllers can be run using following commands after sucessful installation. (Again be careful to run "source ~/ocs2_ws/devel/setup.bash" in the container first after docker build)
roslaunch legged_ctrl gazebo_a1_convex.launch # or
roslaunch legged_ctrl gazebo_go1_convex.launch