This branch (ros2) ports OCS2 from ROS 1/catkin to ROS 2 (colcon/ament) and currently targets Ubuntu 24.04 + ROS 2 Jazzy.
For the ROS 1 version, see branch main.
OCS2 (Optimal Control for Switched Systems) is a C++ toolbox for formulating and solving nonlinear optimal control problems, with an emphasis on real-time Model Predictive Control (MPC) for robotics.
OCS2 handles general path constraints through Augmented Lagrangian or relaxed barrier methods. To facilitate the application of OCS2 in robotic tasks, it provides tools to set up the system dynamics (such as kinematic or dynamic models) and cost/constraints (such as self-collision avoidance and end-effector tracking) from a URDF model. The library also provides an automatic differentiation tool to calculate derivatives of the system dynamics, constraints, and cost. To facilitate deployment on robotic platforms, OCS2 provides tools for ROS interfaces.
- Optimal control solvers
- SLQ: continuous-time constrained DDP
- iLQR: discrete-time constrained DDP
- SQP: multiple-shooting SQP (QP subproblems via HPIPM/BLASFEO)
- SLP: sequential linear programming (PIPG)
- IPM: multiple-shooting nonlinear interior-point method
- Robotics tooling: URDF/Pinocchio integration, kinematics, centroidal models, and self-collision constraints (HPP-FCL).
- ROS integration: messages, nodes, and visualization/plotting tools for deploying MPC on robots.
- Robotic examples: end-to-end MPC examples (and ROS wrappers) for double integrator, cartpole, ballbot, quadrotor, mobile manipulator, legged robot, and more.
- This branch replaces catkin with ament/colcon across the workspace.
blasfeo_catkin/hpipm_catkinkeep their names but are ROS 2ament_cmakepackages.ocs2_mpcnetandocs2_raisimare currently not ported and are ignored viaCOLCON_IGNORE.rqt_multiplotis not released for Jazzy on Ubuntu 24.04; multiplot launch files are optional.
Follow the branch-specific instructions in installation.md (dependencies, Pinocchio on Jazzy, and colcon build):
Optional Docker environment:
After building and sourcing your workspace:
ros2 launch ocs2_ballbot_ros ballbot_mpc_mrt.launch.pyProject documentation is hosted at:
Note: the online docs still describe the ROS 1/catkin workflow; the solver concepts and APIs are largely identical, but build/launch instructions differ on this branch.
@misc{OCS2,
title = {{OCS2}: An open source library for Optimal Control of Switched Systems},
note = {[Online]. Available: \url{https://github.com/leggedrobotics/ocs2}},
author = {Farbod Farshidian and others}
}BSD 3-Clause, see LICENCE.txt.
