OCS2_ROS2 is developed based on OCS2, it was refactored to be compatible with ROS 2 and modern cmake. (Forked from legubiao/ocs2_ros2)
2025.11 (forked repo wei-hsuan-cheng/ocs2_ros2)
Multiple Target Mode for Mobile Manipulator
- Marker target mode: interactive marker for end-effector pose tracking.
- Twist target mode: end-effector twist tracking via pose forward propagation.
- Trajectory target mode: end-effector trajectory tracking (time-parameterized path).
Fixed small bugs
2025.08 (original repo legubiao/ocs2_ros2)
- Intel Nuc X15 (i7-11800H):
- Ubuntu 22.04 ROS 2 Humble (WSL2 included)
- Ubuntu 24.04 ROS 2 Jazzy (WSL2 included)
- Lenovo P16v (i7-13800H):
- Ubuntu 24.04 ROS 2 Jazzy
- Jetson Orin Nano
- Ubuntu 22.04 ROS 2 Humble (JetPack 6.1)
- VM on MacBook Pro with M2 (arm64)
- Ubuntu 22.04 ROS 2 Humble
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 ROS 2 version:
- Ubuntu 24.04 ROS 2 Jazzy
- Ubuntu 22.04 ROS 2 Humble
- C++ compiler with C++17 support
- Eigen (v3.4)
- Boost C++ (v1.74)
Note: Latest version used pinocchio from ros source to simplified install steps. If you install pinocchio from robot-pkgs, you can uninstall it by
sudo apt remove robotpkg-*
-
Create a new workspace or clone the project to your workspace
cd ~ mkdir -p ros2_ws/src
-
Clone the repository (with all submodules in
.gitmodules)cd ~/ros2_ws/src git clone --recursive https://github.com/wei-hsuan-cheng/ocs2_ros2.git -b humble
If you forgot
--recursive, you can run:cd ~/ros2_ws/src/ocs2_ros2 git submodule update --init --recursive
-
rosdepcd ~/ros2_ws rosdep update rosdep install --from-paths src --ignore-src -r -y
This section contains basic examples for the OCS2 library.
π― 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
3.2 Cartpole
π 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
3.3 Ballbot
π 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 # Launch demo ros2 launch ocs2_ballbot_ros ballbot_ddp.launch.py # Send target pose to ballbot [x, y, yaw] [m, deg] ros2 run ocs2_ballbot_ros ballbot_target
ballbot.webm
3.4 Quadrotor
π 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
π¦Ύ Click to expand Mobile Manipulator example
-
build
cd ~/ros2_ws colcon build --packages-up-to \ ocs2_mobile_manipulator_ros \ --parallel-workers 1 --executor sequential\ --symlink-install \ && . install/setup.bash
-
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
source ~/ros2_ws/install/setup.bash # Jaco2 ros2 launch ocs2_mobile_manipulator_ros manipulator_kinova_j2n6.launch.py ros2 launch ocs2_mobile_manipulator_ros manipulator_kinova_j2n7.launch.py # Gen3 Lite ros2 launch ocs2_mobile_manipulator_ros manipulator_kinova_gen3_lite.launch.py
-
run Franka Panda
source ~/ros2_ws/install/setup.bash ros2 launch ocs2_mobile_manipulator_ros franka.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 UR-5
source ~/ros2_ws/install/setup.bash # Marker/Twist/Trajecoty target modes ros2 launch ocs2_mobile_manipulator_ros ur5_marker.launch.py solver:=ddp ros2 launch ocs2_mobile_manipulator_ros ur5_twist.launch.py solver:=ddp ros2 launch ocs2_mobile_manipulator_ros ur5_trajectory.launch.py solver:=ddp # solver:=ddp, sqp
-
run Clearpath Ridgeback with UR-5
source ~/ros2_ws/install/setup.bash # Marker/Twist/Trajecoty target modes ros2 launch ocs2_mobile_manipulator_ros manipulator_ridgeback_ur5_marker.launch.py solver:=ddp ros2 launch ocs2_mobile_manipulator_ros manipulator_ridgeback_ur5_twist.launch.py solver:=ddp ros2 launch ocs2_mobile_manipulator_ros manipulator_ridgeback_ur5_trajectory.launch.py solver:=ddp # solver:=ddp, sqp
3.6 Legged Robot
π Click to expand Legged Robot example
-
build
cd ~/ros2_ws colcon build --packages-up-to \ ocs2_legged_robot_ros \ --parallel-workers 1 --executor sequential\ --symlink-install \ && . install/setup.bash
-
run legged robot mpc
source ~/ros2_ws/install/setup.bash ros2 launch ocs2_legged_robot_ros legged_robot_ddp.launch.py # Solvers: _ddp, _sqp, _ipm
-
Set gait command and reference motion
source ~/ros2_ws/install/setup.bash # Gai command ros2 run ocs2_legged_robot_ros legged_robot_gait_command --ros-args \ -p gaitCommandFile:=/home/whcheng/ocs2_ros2_ws/install/ocs2_legged_robot/share/ocs2_legged_robot/config/command/gait.info # Reference motion ros2 run ocs2_legged_robot_ros legged_robot_target --ros-args \ -p referenceFile:=/home/whcheng/ocs2_ros2_ws/install/ocs2_legged_robot/share/ocs2_legged_robot/config/command/reference.info
ros2 run ocs2_legged_robot_ros legged_robot_gait_command --ros-args
-p gaitCommandFile:=/home/whcheng/ocs2_ros2_ws/install/ocs2_legged_robot/share/ocs2_legged_robot/config/command/gait.info
ros2 run ocs2_legged_robot_ros legged_robot_target --ros-args
-p referenceFile:=/home/whcheng/ocs2_ros2_ws/install/ocs2_legged_robot/share/ocs2_legged_robot/config/command/reference.info
trot.webm
4.3 MPC-Net
fiveages-sim/robot_descriptions: More robot configs for OCS2_ROS2fiveages-sim/arms_ros2_control: Mobile manipulator controller based on OCS2_ROS2legubiao/quadruped_ros2_control: Quadruped controller based on OCS2_ROS2




