Skip to content

ROS2 version of OCS2, refactor with modern-cmake

License

Notifications You must be signed in to change notification settings

wei-hsuan-cheng/ocs2_ros2

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7,678 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OCS2_ROS2 Toolbox

1. Summary

OCS2_ROS2 is developed based on OCS2, it was refactored to be compatible with ROS 2 and modern cmake. (Forked from legubiao/ocs2_ros2)

Version History

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)

Tested Platforms

  • 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

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 ROS 2 version:

  • Ubuntu 24.04 ROS 2 Jazzy
  • Ubuntu 22.04 ROS 2 Humble

2.2 Dependencies

  • 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-*

2.3 Clone Repositories

  • 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
  • rosdep

    cd ~/ros2_ws
    rosdep update
    rosdep install --from-paths src --ignore-src -r -y

3. Basic Examples

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
πŸ›’ 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
    # 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
🚁 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
πŸ• 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. Advanced Examples

perceptive_side

perceptive_hurdles

raisim

raisim_rviz

5. Related Projects

About

ROS2 version of OCS2, refactor with modern-cmake

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 93.3%
  • Python 4.4%
  • CMake 1.9%
  • C 0.4%