Skip to content

Software

OCS2

By ETH Zurich Robotic Systems Lab, Switzerland (checked on github.com/leggedrobotics (opens in a new tab)), from github.com/leggedrobotics/ocs2 (opens in a new tab)

  • Humanoids and robot learning
  • Library
  • BSD-3-Clause

A C++ toolbox for formulating and solving nonlinear optimal control problems, aimed at real-time Model Predictive Control (MPC) for robotics.

Facts

GitHub stars
1,543read on 21 Nov 2026
Last update
16 Dec 2025Newest commit on main
Maintenance
Maintaineda commit in the last 12 months
Difficulty
Advanced
Hardware it needs, as the project states it
Designed for robotic platforms with limited onboard computation power; no specific hardware requirements are stated.

Checked on GitHub on 21 Nov 2026.

Licenses

Code
BSD-3-Clause (opens in a new tab)

Read by Robotheca from LICENCE.txt (opens in a new tab) (BSD-3-Clause) at commit 2638675 (opens in a new tab), on 16 Oct 2026.

Commercial use
Yes

At a glance

What it is
  • Provides several solvers: SLQ and iLQR (DDP family), SQP, SLP, and a multiple-shooting interior-point method.
  • Supports switched-system optimal control problems with mode schedules and jump maps.
  • Handles hard and soft path constraints via Augmented Lagrangian and relaxed barrier methods.
  • Offers analytic derivative interfaces plus automatic differentiation (CppAD) and optional code generation.
  • Includes robotics tooling built from URDF models: kinematics, centroidal models, and self-collision constraints.
  • Provides ROS interfaces, messages, and visualization/plotting tools for deploying MPC on robots, with example robots such as a legged robot, quadrotor, and cartpole.

Robotheca's summary of the project's documents, not the creator's words.

Robots on Robotheca
No robot on Robotheca uses it yet.
Licence
BSD-3-Clause. Commercial use: Yes. Where it was read
Install
In the creator's words: The project's website (opens in a new tab)
Maintenance
Maintained, last commit on 16 Dec 2025.

Use it

How to install it, in the creator's words: The project's website (opens in a new tab)

Robotheca doesn't review code. Read it before running it.

Files and versions

Facts read at commit 2638675

Robotheca never hosts the code: each link goes to the creator's own page.

The README

The creator's own README, copied as written: README.md by ETH Zurich Robotic Systems Lab, at commit 2638675, under BSD-3-Clause (opens in a new tab). The original on GitHub (opens in a new tab).

Read the README here

OCS2 Toolbox

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.

Image: legged-robot (opens in a new tab)

OCS2 handles general path constraints through Augmented Lagrangian or relaxed barrier methods. To facilitate the application of OCS2 in robotic tasks, it provides additional 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. The toolbox’s efficient and numerically stable implementations in conjunction with its user-friendly interface have paved the way for employing it on numerous robotic applications with limited onboard computation power.

ROS 2 port available: use branch ros2.

ROS branches
ROS versionBranch
ROS 1main
ROS 2ros2
Highlights
  • Multiple solvers
    • SLQ: continuous-time constrained DDP (SLQ/DDP family)
    • 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
  • Switched-system OCP support: mode schedules and jump maps (single- and multi-domain problems).
  • Constraints: hard/soft constraints with Augmented Lagrangian and relaxed barrier methods.
  • Derivatives: analytic derivative interfaces + automatic differentiation (CppAD) and optional code generation (CppADCodeGen).
  • Robotics tooling: URDF→model helpers (Pinocchio), kinematics, centroidal models, 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.
Repository structure (high level)
  • ocs2_core: core data types, math utilities, rollout interfaces, AD utilities.
  • ocs2_oc: optimal control problem building blocks (costs, constraints, dynamics, pre-computation, reference management).
  • ocs2_ddp, ocs2_mpc: DDP-family solvers + MPC infrastructure and runtime interfaces.
  • ocs2_sqp, ocs2_slp, ocs2_ipm: alternative solvers (SQP / SLP / IPM).
  • ocs2_pinocchio/*: URDF/Pinocchio tooling (centroidal model, kinematics, self-collision, visualization).
  • ocs2_ros_interfaces, ocs2_msgs: ROS interfaces and message definitions.
  • ocs2_robotic_examples/*: robotic examples and their ROS nodes.
  • ocs2_python_interface: Python bindings for selected components.
  • ocs2_mpcnet: MPC-Net tooling for learned policy deployment/training.
  • ocs2_doc: documentation sources (Sphinx/Doxygen).
Documentation
Installation
Citing OCS2
@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}
}
License

BSD 3-Clause, see LICENCE.txt.

Robotheca lists software as a reference: nothing is hosted or run here, and every fact links to where it was read.