Giter Site home page Giter Site logo

jackqin007 / legged_mpc_control Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zha0ming1e/legged_mpc_control

0.0 0.0 0.0 29.61 MB

A legged robot controller for Unitree A1 and Go1 robot using different MPC algorithms

License: GNU General Public License v3.0

Shell 0.16% C++ 88.82% Python 3.83% C 0.18% CMake 2.65% Dockerfile 4.36%

legged_mpc_control's Introduction

Introduction

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

Update Log

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.

Installation

Controller Setup

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 )

Julia setup

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") 

Gazebo Setup

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.

Adjust the robot in the Gazebo

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.

Run controllers

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.