# leggedrobotics/ocs2

Optimal Control for Switched Systems

Repository: https://github.com/leggedrobotics/ocs2
Canonical: https://ross.abutalabs.com/products/ocs2
Homepage: https://leggedrobotics.github.io/ocs2
Language: C++
License: BSD-3-Clause
License Family: permissive
Topics: optimal-control, mpc, robotics, control
Last push: 2026-07-20T14:29:24+00:00

## Health v2 (maintenance only)
Score: 65/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 93, release rhythm 8, longevity 100
- inputs: {"age_days": 1882, "days_push": 44, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1501, forks 329 (observed 2026-08-28T04:04:54.370103+00:00)

## What it is
OCS2 is a C++ toolbox for formulating and solving nonlinear optimal control problems, with an emphasis on real-time Model Predictive Control (MPC) for robotics. It provides multiple solvers (SLQ, iLQR, SQP, SLP, IPM), switched-system support, automatic differentiation, URDF-based robot modeling tools, and ROS interfaces.

## Use cases
- implement real-time model predictive control for a legged robot
- solve nonlinear optimal control problems with switched-system dynamics
- build MPC controllers from a URDF robot model with self-collision avoidance
- generate derivatives of system dynamics and costs via automatic differentiation
- deploy MPC on robots with limited onboard computation using ROS
- run cartpole, quadrotor, or mobile manipulator MPC examples

## When to choose
- you need real-time nonlinear MPC for robotic platforms
- your problem involves switched systems with mode schedules and jump maps
- you want URDF-based modeling, Pinocchio integration, and ROS deployment tooling
- you need a choice of solvers (SLQ, iLQR, SQP, SLP, IPM) with constraint handling

## When to avoid
- you need a lightweight general-purpose optimizer without robotics focus
- your project does not use C++ or ROS and you only need simple scripting
- you require a mature Python-first control library instead

## Facets
- artifact type: library
- maturity: active
- function: simulation, machine-learning, robotics, math, developer-tools
- domain: robotics, simulation, autonomous-vehicles
- platform: cpp, python
- tags: optimal-control, mpc, model-predictive-control, switched-systems, slq, ilqr, sqp, automatic-differentiation, urdf, pinocchio, legged-robots, algorithms, linux, ros

## Member repositories
- leggedrobotics/ocs2 (main) score 65

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:04:54.370103+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T04:32:56.728751+00:00, confidence not recorded.
  - readme: https://github.com/leggedrobotics/ocs2 (fetched 2026-08-28T04:04:54.370103+00:00, sha 6afe7fe7dd8e)
  - homepage: https://leggedrobotics.github.io/ocs2 (fetched 2026-08-29T11:37:49.285359+00:00, sha 2efe08fbe5e6)
- Data as of 2026-08-30T08:39:29.467469+00:00.
