Skip to content

max-assel/legged_software

Repository files navigation

Legged Software

empty empty empty

Introduction

This repo is built upon the legged_control codebase with some quality of life upgrades. Right now, this repository only supports the Unitree Go2 and ANYmal-C quadruped platforms.

Dependencies

Git Dependencies

This repository uses Git Large File Storage to maintain robot meshes. Follow the directions here to install Git LFS.

ROS Dependencies

  1. Install the following ROS2 Humble packages:
    sudo apt-get install ros-humble-controller-manager ros-humble-control-toolbox ros-humble-realtime-tools ros-humble-joint-state-broadcaster ros-humble-gazebo-ros ros-humble-angles ros-humble-rmw-cyclonedds-cpp ros-humble-rosidl-generator-dds-idl ros-humble-gazebo-ros2-control ros-humble-xacro ros-humble-robot-localization ros-humble-ros2-controllers ros-humble-ros2-control ros-humble-velodyne ros-humble-velodyne-gazebo-plugins ros-humble-velodyne-description ros-humble-gazebo-plugins

Colcon Dependencies

We use some colcon mixin commands when compiling our packages.

  1. To set up these CLI mixins, do the following:

    sudo apt-get install python3-colcon-mixin
    
    colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
    
    colcon mixin update default
    

OCS2 Dependencies

To run legged_software, you need to compile the OCS2 toolbox.

  1. Follow the OCS2 installation instructions on the ros2_humble branch, here.

Perception Dependencies

  1. Clone in the realsense gazebo plugin repository (yes, the foxy-devel branch is right):
    git clone --branch foxy-devel https://github.com/pal-robotics/realsense_gazebo_plugin.git
    

Installation

  1. Install proxsuite as a QP solver for WBC:

    cd /any/path/outside/ws
    git clone --recurse-submodules https://github.com/GTLIDAR/proxsuite.git
    cd proxsuite
    mkdir build && cd build
    cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBUILD_WITH_VECTORIZATION_SUPPORT=OFF
    make
    sudo make install
    
  2. To use the Go2, we follow the communication protocol of unitree_ros2 which uses cyclonedds. For simulation, you do not need to install any additional packages. For hardware, compile cyclonedds inside your ROS2 workspace according to the unitree_ros2 README.

  3. If you have not already, clone the legged_software repository

    git clone --branch ros2_humble https://github.com/max-assel/legged_software.git
    
  4. Then, pull from Git LFS to retrieve the URDF meshes

    git lfs pull
    
  5. Now you can build the go2_interface package.

    MAKEFLAGS="-j 4" colcon build --symlink-install --executor sequential --mixin rel-with-deb-info --packages-up-to go2_interface
    

Building ocs2 can be quite computationally expensive, so MAKEFLAGS="-j 4" limits the number (4) of cores used during build, and --executor sequential makes sure packages are build sequentially, not in parallel. --mixin rel-with-deb-info builds the release version of the code, not the debugging version in order to get better performance, though this needs colcon mixin to be set up. Feel free to adjust these to your liking. I would also recommend that you export this alias into your bashrc so that you do not have to copy this in every time

echo "alias buildros2='cd ~/ros2_ws && MAKEFLAGS="-j 4" colcon build --symlink-install --executor sequential --mixin rel-with-deb-info --packages-up-to'" >> ~/.bashrc  

Run GO2 examples

Teleop

First, build our teleop node:

MAKEFLAGS="-j 4" colcon build --symlink-install --executor sequential --mixin rel-with-deb-info --packages-up-to legged_twist_publisher

To run gazebo simulation:

ros2 launch go2_interface run_gazebo.launch.py

To bring up the robot, including state estimators, controllers, and visualizers:

ros2 launch go2_interface bringup_gazebo.launch.py

Note that it will take some time to compile the CppAD files depending on the capabilities of your PC.

You can either use the Invariant Extended Kalman filter from our codebase for base odometry estimation, or enable "Cheater Mode" which uses ground truth odometry estimation from the simulation API:

ros2 service call /CheaterMode go2_interface_msgs/srv/CheaterMode "{cmd: 1}"

Once the CppAd files are done compiling, the robot will then enter the passive mode. You need to manually send ROS services to change the mode:

ros2 service call /ControlMode go2_interface_msgs/srv/GO2Cmd "{cmd: 0}" // 0 passive; 1 standup; 2 balancestand; 3 locomotion Convex MPC; 4 perception nonlinear MPC from OCS2

Quick note: the ControlMode 3 uses the convex MPC, whereas ControlMode 4 uses a nonlinear MPC based on OCS2. The latter requires more computational power but leverages the full-body kinematics plus centroidal dynamics.

Manually define the gait you want the quadruped to perform in the pop-up terminal, and then:

ros2 run legged_twist_publisher legged_twist_publisher

Then, you can use WASD to translate, Q/E to rotate, and X to send a zero velocity commands. Z will exit the node, so only press this when you are done.

Nav2

First, clone and compile the QuadGap planner repository

git clone -b ros2_humble https://github.com/ivaROS/quad_gap
MAKEFLAGS="-j 4" colcon build --symlink-install --executor sequential --mixin rel-with-deb-info --packages-up-to quad_gap

Then, build our nav2 node:

MAKEFLAGS="-j 4" colcon build --symlink-install --executor sequential --mixin rel-with-deb-info --packages-up-to legged_nav2

Make sure you launch the quadruped with the laser scanner equipped. This can be adjusted through perception_mode in go2_description/description.launch.py

Perform the previous steps to put the desired quadruped into ControlMode 1 (stand up). Then, put the robot in MPC and assign a gait.

ros2 service call /ControlMode go2_interface_msgs/srv/GO2Cmd "{cmd: 4}" // change to 4 for nonlinear MPC

If you do not have a map of the environment already, you can run

ros2 launch legged_nav2 go2_sim_nav2_plus_slam_toolbox.launch.py

This will run the Nav2 stack alongside SLAM toolbox which will build a map as you go. Then you can save the map locally if you want to run future navigation trials with:

ros2 run nav2_map_server map_saver_cli -f ~/map

If you already have a map, you can run

ros2 launch legged_nav2 go2_sim_nav2.launch.py

Now, you can use the "Set Nav Goal" feature in Rviz, and the Go2 will navigate to it.

TODO:

  • Key parameters like map/env name
  • Change planners

Egocylinder

To run egocylinder demos, you must first clone and compile our depth image terrain normal estimation package:

git clone -b ros2_humble https://github.com/max-assel/depth_img_normal_estimation.git
MAKEFLAGS="-j 4" colcon build --symlink-install --executor sequential --mixin rel-with-deb-info --packages-up-to depth_img_normal_estimation

Install ROS2 Point Cloud Library

sudo apt-get install ros-humble-perception-pcl

Clone and compile the egocylindrical, egocylindrical_msgs, egocylindrical_image_to_laserscan, and egocircle packages:

git clone -b ros2_humble https://github.com/ivaROS/egocylindrical.git
git clone -b ros2_humble https://github.com/ivaROS/egocylindrical_msgs.git
git clone -b ros2_humble https://github.com/ivaROS/egocylindrical_image_to_laserscan.git
git clone -b ros2_humble https://github.com/ivaROS/egocircle.git

Build!

MAKEFLAGS="-j 4" colcon build --symlink-install --executor sequential --mixin rel-with-deb-info --packages-up-to egocylindrical
MAKEFLAGS="-j 4" colcon build --symlink-install --executor sequential --mixin rel-with-deb-info --packages-up-to egocylindrical_msgs
MAKEFLAGS="-j 4" colcon build --symlink-install --executor sequential --mixin rel-with-deb-info --packages-up-to egocylindrical_image_to_laserscan

To run the gazebo simulation:

ros2 launch go2_interface run_gazebo.launch.py

To bring up the robot, including state estimators, controllers, and visualizers:

ros2 launch go2_interface bringup_gazebo.launch.py

Make sure you launch the quadruped with the camera equipped. This can be adjusted through perception_mode in go2_description/description.launch.py

Stand up the Go2 with control mode 1

ros2 service call /ControlMode go2_interface_msgs/srv/GO2Cmd "{cmd: 1}"

Start up the depth image normal estimation:

ros2 launch depth_img_normal_estimation normal_estimation_sim.launch.py

Start up the egocan:

ros2 launch egocylindrical semantic_egocan.launch.py

Now, you can teleoperate the robot around and see the egocan capture the local environment

Egocircle

ros2 launch egocylindrical_image_to_laserscan test.launch.py

ToDo list

  • Add OCS2 modules.
  • Replace the rigid body dynamics utilities with pinocchio.
  • Add rosdep step for installation
  • Add navigation planner such as gap based planners.
  • Add elevation mapping and terrain segmentation.
  • Add submodules.

About

Quadrupedal autonomy codebase

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 9