Skip to content

About

ROS2 version of OCS2, refactor with modern-cmake

Resources

Stars

181 stars

Watchers

2 watching

Forks

Β 
Β 

Latest commit

Β 

History

7,573 Commits

Folders and files

Repository files navigation

OCS2_ROS2 Toolbox

1. Summary

OCS2_ROS2 is developed based on OCS2, it was refactored to be compatible with ROS2 and modern cmake.

What's New (2026.08)

Omni-Wheel Mobile Manipulator Support

  • Add OmniWheelBasedMobileManipulator kinematics for planar holonomic bases (omni-wheel / mecanum).
  • Mobile manipulator MPC previously covered differential-drive bases; this model adds body-frame (vx, vy, omega) inputs so the planner can command true omnidirectional motion.
  • Wired through factory dimensions, Pinocchio mapping, and the mobile manipulator interface (modelType: omniWheelBasedMobileManipulator in the task .info file).

What's New (2026.05)

ROS 2 Lyrical Support

  • Add support for ROS 2 Lyrical on Ubuntu 26.04.
  • Modernize launch files for newer robot_state_publisher: URDF files are now parsed and passed through the robot_description parameter instead of the removed positional URDF path argument.
  • Replace deprecated tf2 / tf2_ros .h includes with .hpp headers for Jazzy and Lyrical compatibility.
  • Remove dependency on the removed urdf::exportURDF API by keeping the original URDF XML inside the Pinocchio interface.
  • Make RViz plugins select the matching Qt major version automatically (Qt5 on Jazzy, Qt6 on Lyrical).
  • Avoid OctoMap ABI conflicts by letting the collision backend own its native OctoMap linkage.
  • Default launch terminal prefix is now xterm -e, which works better in WSL and container environments such as distrobox. Override it with OCS2_TERMINAL_PREFIX if needed.

What's New (2026.01)

Environment Collision for Mobile Manipulator

  • Add basic geometry environment collision support.
  • See the Franka demo for more details.

Tested Platform

  • Intel Nuc X15 (i7-11800H):
    • Ubuntu 22.04 ROS2 Humble (WSL2 included)
    • Ubuntu 24.04 ROS2 Jazzy (WSL2 included)
    • Ubuntu 26.04 ROS2 Lyrical (distrobox)
  • Lenovo P16v (i7-13800H):
    • Ubuntu 24.04 ROS2 Jazzy
  • Jetson Orin Nano
    • Ubuntu 22.04 ROS2 Humble (JetPack 6.1)

2. Installation

2.1 Prerequisites

The OCS2 library is written in C++17. It is tested under Ubuntu with library versions as provided in the package sources.

Tested system and ROS2 version:

  • Ubuntu 26.04 ROS2 Lyrical
  • Ubuntu 24.04 ROS2 Jazzy
  • Ubuntu 22.04 ROS2 Humble

Note: Some demos open auxiliary nodes in a new terminal. The default terminal prefix is xterm -e for better compatibility with WSL and distrobox. Install it if necessary:

sudo apt install xterm

You can override the terminal prefix, for example:

export OCS2_TERMINAL_PREFIX="gnome-terminal --"

2.2 Dependencies

  • C++ compiler with C++17 support
  • Eigen (v3.4)
  • Boost C++ (v1.74)

Note: The latest version uses Pinocchio from the ROS distribution to simplify installation. If you previously installed Pinocchio from robotpkg, uninstall it with:

sudo apt remove robotpkg-*

2.3 Install from deb (try basic examples without building)

Prebuilt .deb packages bundle the OCS2 core stack and all basic examples listed in Section 3. This is the fastest way to run the demos if you do not need to modify the source code.

ROS 2 distro Ubuntu Debian package Install prefix
Jazzy 24.04 (Noble) ros-jazzy-ocs2 /opt/ros/jazzy
Lyrical 26.04 (Resolute) ros-lyrical-ocs2 /opt/ros/lyrical

Prerequisites

  1. Install the matching ROS 2 base from docs.ros.org (e.g. ros-jazzy-ros-base or ros-lyrical-ros-base).
  2. Install xterm (used by several example launch files to open MPC / dummy nodes in separate terminals):
    sudo apt install xterm

Download and install

Pick the asset that matches your distro and CPU architecture (amd64 or arm64) from the GitHub Releases page.

Trigger GitHub Release Notes
PR merged into ros2 rolling pre-release Overwrites assets each merge; deb Version is latest.patch+N~main.<sha>
Push v* tag / manual dispatch formal vX.Y.Z Stable installs

Example for pre-release (Jazzy amd64):

gh release download pre-release --repo legubiao/ocs2_ros2 --pattern 'ros-jazzy-ocs2_*_amd64.deb'
sudo dpkg -i ros-jazzy-ocs2_*_amd64.deb
sudo apt-get install -f

Example for ROS 2 Jazzy on amd64 (replace VERSION with the release tag, e.g. 1.0.0):

wget https://github.com/legubiao/ocs2_ros2/releases/download/vVERSION/ros-jazzy-ocs2_VERSION_amd64.deb
sudo dpkg -i ros-jazzy-ocs2_VERSION_amd64.deb
sudo apt-get install -f   # if apt reports missing dependencies

Example for ROS 2 Lyrical on amd64:

wget https://github.com/legubiao/ocs2_ros2/releases/download/vVERSION/ros-lyrical-ocs2_VERSION_amd64.deb
sudo dpkg -i ros-lyrical-ocs2_VERSION_amd64.deb
sudo apt-get install -f

Use the installed packages

# Jazzy:
source /opt/ros/jazzy/setup.bash

# Lyrical:
# source /opt/ros/lyrical/setup.bash

Then follow the run steps in Section 3 (skip the build steps). For example:

ros2 launch ocs2_double_integrator_ros double_integrator.launch.py

To confirm the install:

ros2 pkg list | grep ocs2_
dpkg -L ros-jazzy-ocs2    # or ros-lyrical-ocs2

Note: The deb installs into the same prefix as your system ROS packages. You only need to source /opt/ros/<distro>/setup.bash once per shell. Advanced examples under advance examples/ are not included in the deb; build those from source if needed (Section 2.4).

2.4 Clone Repositories

  • Create a new workspace or clone the project to your workspace
cd ~
mkdir -p ros2_ws/src
  • Clone the repository
cd ~/ros2_ws/src
git clone https://github.com/legubiao/ocs2_ros2
cd ocs2_ros2
git submodule update --init --recursive
  • rosdep
cd ~/ros2_ws
rosdep install --from-paths src --ignore-src -r -y

3. Basic Examples

This section contains basic examples for the OCS2 library.

If you installed the prebuilt deb (Section 2.3), skip the build steps in each example: source /opt/ros/<distro>/setup.bash and run the ros2 launch command directly. To build from source instead, use Section 2.4 and the build commands below.

🎯 Click to expand Double Integrator example
  • build
cd ~/ros2_ws
colcon build --packages-up-to ocs2_double_integrator_ros --symlink-install
  • run
source ~/ros2_ws/install/setup.bash
ros2 launch ocs2_double_integrator_ros double_integrator.launch.py
double_interger.webm
πŸ›’ Click to expand Cartpole example
  • build
cd ~/ros2_ws
colcon build --packages-up-to ocs2_cartpole_ros --symlink-install
  • run
source ~/ros2_ws/install/setup.bash
ros2 launch ocs2_cartpole_ros cartpole.launch.py
cart.pole.webm
πŸ€ Click to expand Ballbot example
  • build
cd ~/ros2_ws
colcon build --packages-up-to ocs2_ballbot_ros --symlink-install
  • run
source ~/ros2_ws/install/setup.bash
ros2 launch ocs2_ballbot_ros ballbot_ddp.launch.py
ballbot.webm
🚁 Click to expand Quadrotor example
  • build
cd ~/ros2_ws
colcon build --packages-up-to ocs2_quadrotor_ros --symlink-install
  • run
source ~/ros2_ws/install/setup.bash
ros2 launch ocs2_quadrotor_ros quadrotor.launch.py
quadrotor.webm

Supported base model types include fixed-base / floating-arm manipulators, differential-drive (wheelBasedMobileManipulator), and omni-wheel / mecanum (omniWheelBasedMobileManipulator). Set modelType in the task .info file accordingly.

🦾 Click to expand Mobile Manipulator example
  • build
cd ~/ros2_ws
colcon build --packages-up-to ocs2_mobile_manipulator_ros --symlink-install
  • run Mabi-Mobile
source ~/ros2_ws/install/setup.bash
ros2 launch ocs2_mobile_manipulator_ros manipulator_mabi_mobile.launch.py
mabi-mobile.webm
  • run Kinova Jaco2
source ~/ros2_ws/install/setup.bash
ros2 launch ocs2_mobile_manipulator_ros manipulator_kinova_j2n6.launch.py
  • run Franka Panda
source ~/ros2_ws/install/setup.bash
ros2 launch ocs2_mobile_manipulator_ros franka.launch.py
source ~/ros2_ws/install/setup.bash
ros2 launch ocs2_mobile_manipulator_ros franka_sqp.launch.py
franka.webm
  • run Willow Garage PR2
source ~/ros2_ws/install/setup.bash
ros2 launch ocs2_mobile_manipulator_ros pr2.launch.py
pr2.webm
  • run Clearpath Ridgeback with UR-5
source ~/ros2_ws/install/setup.bash
ros2 launch ocs2_mobile_manipulator_ros manipulator_ridgeback_ur5.launch.py 
πŸ• Click to expand Legged Robot example
  • build
cd ~/ros2_ws
colcon build --packages-up-to ocs2_legged_robot_ros --symlink-install
  • run
source ~/ros2_ws/install/setup.bash
ros2 launch ocs2_legged_robot_ros legged_robot_ddp.launch.py
trot.webm

4. Advanced Examples

perceptive_side

perceptive_hurdles

raisim

raisim_rviz

5. Related Projects

About

ROS2 version of OCS2, refactor with modern-cmake

Resources

Stars

181 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages