bipedal_control is an NMPC framework for bipedal robot depending on OCS2
Before installation, make sure you have ROS noetic installed in Ubuntu 20.04.
Install catkin tools to use catkin build
instead of catkin_make
.
sudo apt-get install python3-catkin-tools
Create a catkin workspace:
mkdir -p ~/bipedal_ws/src
cd ~/bipedal_ws/src
others:
sudo apt install ros-noetic-effort-controllers
OCS2 is a huge monorepo; DO NOT try to compile the whole repo. You only need to compile ocs2_legged_robot_ros
and
its dependencies following the step below.
-
You are supposed to clone the OCS2, pinocchio, and hpp-fcl as described in the documentation of OCS2.
# Under the src directory of your catkin workspace # Clone OCS2 git clone git@github.com:leggedrobotics/ocs2.git # Clone pinocchio git clone --recurse-submodules https://github.com/leggedrobotics/pinocchio.git # Clone hpp-fcl git clone --recurse-submodules https://github.com/leggedrobotics/hpp-fcl.git # Clone ocs2_robotic_assets git clone https://github.com/leggedrobotics/ocs2_robotic_assets.git # Install dependencies sudo apt install liburdfdom-dev liboctomap-dev libassimp-dev sudo apt install ros-noetic-grid-map-rviz-plugin
-
Compile the
ocs2_legged_robot_ros
package with catkin tools instead ofcatkin_make
. It will take you several minutes.# Under catkin workspace cd ~/bipedal_ws catkin config -DCMAKE_BUILD_TYPE=RelWithDebInfo catkin build ocs2_legged_robot_ros ocs2_self_collision_visualization
-
Launch the example to test whether ocs2 is installed correctly.
# Under catkin workspace # Source workspace source devel/setup.bash # Launch the example for DDP roslaunch ocs2_legged_robot_ros legged_robot_ddp.launch
Ensure you can command the ANYmal as shown in the document and below.
Clone the repository to the src
folder of your catkin workspace.
cd ~/bipedal_ws/src
git clone https://github.com/zitongbai/bipedal_control.git
Build the source code of bipedal_control
.
cd ~/bipedal_ws
catkin build ocs2_bipedal_robot_ros
For implementation of your own robot, here are some steps to follow:
-
Create a folder under
bipedal_robot_example
to store some ROS packages specific to your robot. (e.g.,bipedal_robot_example/unitree_h1
) -
Create a ROS package for the urdf model of your robot, or you can copy the out-of-the-box package containing the urdf model to here. (e.g.,
bipedal_robot_example/unitree_h1/h1_description
). Make sure the urdf model is correct (you can usecheck_urdf
) and can be visualized in RViz. -
Create a ROS package for the configuration of ocs2 for your robot. (e.g.,
bipedal_robot_example/unitree_h1/h1_ocs2_config
). It should contain the following contents:gait.info
: the gait information of the robot, including several mode templates and the corresponding mode sequences.reference.info
: the reference information of the robot, it would be used in your command.task.info
You can copy these files from
bipedal_robot_example/unitree_h1/h1_ocs2_config
and modify them according to your robot. Details would be explained later.You can also create the launch file in this package to start bipedal interface node and a dummy node to test the MPC trajectory planner. (you can refer to
bipedal_robot_example/unitree_h1/h1_ocs2_config/launch/bipedal_robot_sqp.launch
) -
If your robot does not have links in the sole, add virtual links to the urdf model of your robot. These links are used to construct contact constraints in MPC. You can refer to
right_sole_1_link
, etc. inbipedal_robot_example/unitree_h1/h1_description/urdf/h1_with_sole.urdf
for an example. -
Modify
jointNames
intask.info
to match ONLY the revolute legged joint names of your robot. Upper body joints should not be included. -
Modify
contactNames3DoF
intask.info
to match the contact points (links defined in 4) of your robot. -
Modify
initialState
intask.info
anddefaultJointState
inreference.info
to set the initial state of your robot. -
Create a launch file like
/bipedal_robot_example/unitree_h1/h1_ocs2_config/launch/bipedal_robot_sqp.launch
to launch the bipedal interface node and a dummy node to test the MPC trajectory planner. -
Modify
torqueLimitsTask
intask.info
- OCS2: a C++ toolbox tailored for Optimal Control for Switched Systems.
- legged_control:an NMPC-WBC legged robot control stack and framework.
- self collision avoidance and visualization
- Currently, the imu name in ros control must be
base_imu
. If you want to use another name, you should modify the following code:BipedalController.cpp
:imuSensorHandle_ = imuSensorInterface->getHandle("base_imu");
/bipedal_gazebo/config/default.yaml
:base_imu