Skip to content

Software

safe-control-gym

By Learning Systems and Robotics Lab (LSY), Germany (checked on github.com/learnsyslab (opens in a new tab)), from github.com/learnsyslab/safe-control-gym (opens in a new tab)

  • Drones and boats
  • Simulator
  • MIT

A benchmark suite of physics-based CartPole and Quadrotor Gym environments built on PyBullet, with symbolic CasADi dynamics, for learning-based control and reinforcement learning research.

Facts

GitHub stars
938read on 29 Nov 2026
Last update
29 Apr 2026Newest commit on main
Maintenance
Maintaineda commit in the last 12 months
Difficulty
Intermediate
Hardware it needs, as the project states it
Installing the MPC interface requires acados, and PyBullet and Python 3.10 are used.

Checked on GitHub on 29 Nov 2026.

Licenses

Code
MIT (opens in a new tab)

Read by Robotheca from LICENSE (opens in a new tab) (MIT) at commit 6b5391d (opens in a new tab), on 16 Oct 2026.

Commercial use
Yes

At a glance

What it is
  • Provides CartPole and Quadrotor environments simulated with PyBullet, using symbolic a priori dynamics from CasADi.
  • Includes symbolic safety constraints and input, parameter, and dynamics disturbances to test robustness and generalizability.
  • Implements controllers including PID, LQR, iLQR, linear MPC, GP-MPC, and model-free RL methods SAC, PPO, and DDPG.
  • Offers safety filters such as MPSC, control barrier functions, and a neural network CBF.
  • Runnable example scripts cover quadrotor trajectory tracking, cartpole stabilization, and RL training, configured through YAML overrides.
  • Ships tests and pre-commit linting, and the project is maintained by the University of Toronto's Dynamic Systems Lab.

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

Robots on Robotheca
No robot on Robotheca uses it yet.
Licence
MIT. 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 29 Apr 2026.

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 6b5391d

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 Learning Systems and Robotics Lab (LSY), at commit 6b5391d, under MIT (opens in a new tab). The original on GitHub (opens in a new tab).

Read the README here

safe-control-gym

Physics-based CartPole and Quadrotor Gym (opens in a new tab) environments (using PyBullet (opens in a new tab)) with symbolic a priori dynamics (using CasADi (opens in a new tab)) for learning-based control, and model-free and model-based reinforcement learning (RL).

These environments include (and evaluate) symbolic safety constraints and implement input, parameter, and dynamics disturbances to test the robustness and generalizability of control approaches. [PDF] (opens in a new tab)

problem illustration

@article{brunke2021safe,
         title={Safe Learning in Robotics: From Learning-Based Control to Safe Reinforcement Learning},
         author={Lukas Brunke and Melissa Greeff and Adam W. Hall and Zhaocong Yuan and Siqi Zhou and Jacopo Panerati and Angela P. Schoellig},
         journal = {Annual Review of Control, Robotics, and Autonomous Systems},
         year={2021},
         url = {https://arxiv.org/abs/2108.06266}}

To reproduce the results in the article, see branch ar (opens in a new tab).

@article{yuan2021safecontrolgym,
  author={Yuan, Zhaocong and Hall, Adam W. and Zhou, Siqi and Brunke, Lukas and Greeff, Melissa and Panerati, Jacopo and Schoellig, Angela P.},
  journal={IEEE Robotics and Automation Letters},
  title={Safe-Control-Gym: A Unified Benchmark Suite for Safe Learning-Based Control and Reinforcement Learning in Robotics},
  year={2022},
  volume={7},
  number={4},
  pages={11142-11149},
  doi={10.1109/LRA.2022.3196132}}

To reproduce the results in the article, see branch submission (opens in a new tab).

Install on Ubuntu/macOS
Clone repo
git clone https://github.com/learnsyslab/safe-control-gym.git
cd safe-control-gym
(optional) Create a conda environment

Create and access a Python 3.10 environment using conda (opens in a new tab)

conda create -n safe python=3.10
conda activate safe
Install

Install the safe-control-gym repository

python -m pip install --upgrade pip
python -m pip install -e .
Note

You may need to separately install gmp, a dependency of pycddlib:

conda install -c anaconda gmp

or

sudo apt-get install libgmp-dev
(optional) Additional requirements for MPC

You may need to separately install acados (opens in a new tab) for fast MPC implementations.

Architecture

Overview of safe-control-gym (opens in a new tab)'s API:

block diagram

Configuration

config

Getting Started

Familiarize with APIs and environments with the scripts in examples/ (opens in a new tab)

3D Quadrotor Lemniscate Trajectory Tracking with PID
cd ./examples/   # Navigate to the examples folder
python3 pid/pid_experiment.py \
    --algo pid \
    --task quadrotor \
    --overrides \
        ./pid/config_overrides/quadrotor_3D/quadrotor_3D_track.yaml

systems trajectory

Cartpole Stabilization with LQR
cd ./examples/   # Navigate to the examples folder
python3 lqr/lqr_experiment.py \
    --algo lqr \
    --task cartpole \
    --overrides \
        ./lqr/config_overrides/cartpole/cartpole_stab.yaml \
        ./lqr/config_overrides/cartpole/lqr_cartpole_stab.yaml
2D Quadrotor Trajectory Tracking with PPO
cd ./examples/rl/   # Navigate to the RL examples folder
python3 rl_experiment.py \
    --algo ppo \
    --task quadrotor \
    --overrides \
        ./config_overrides/quadrotor_2D/quadrotor_2D_track.yaml \
        ./config_overrides/quadrotor_2D/ppo_quadrotor_2D.yaml \
    --kv_overrides \
        algo_config.training=False
Verbose API Example
cd ./examples/   # Navigate to the examples folder
python3 no_controller/verbose_api.py \
    --task cartpole \
    --overrides no_controller/verbose_api.yaml

Picture: prints.png

List of Implemented Controllers
List of Implemented Safety Filters
Performance

We compare the sample efficiency of safe-control-gym with the original OpenAI Cartpole (opens in a new tab) and PyBullet Gym's Inverted Pendulum (opens in a new tab), as well as gym-pybullet-drones (opens in a new tab). We choose the default physic simulation integration step of each project. We report performance results for open-loop, random action inputs. Note that the Bullet engine frequency reported for safe-control-gym is typically much finer grained for improved fidelity. safe-control-gym quadrotor environment is not as light-weight as gym-pybullet-drones (opens in a new tab) but provides the same order of magnitude speed-up and several more safety features/symbolic models.

EnvironmentGUIControl Freq.PyBullet Freq.Constraints & Disturbances^Speed-Up^^
Gym cartpole (opens in a new tab)True50HzN/ANo1.16x
InvPenPyBulletEnv (opens in a new tab)False60Hz60HzNo158.29x
cartpole (opens in a new tab)True50Hz50HzNo0.85x
cartpole (opens in a new tab)False50Hz1000HzNo24.73x
cartpole (opens in a new tab)False50Hz1000HzYes22.39x
gym-pyb-drones (opens in a new tab)True48Hz240HzNo2.43x
gym-pyb-drones (opens in a new tab)False50Hz1000HzNo21.50x
quadrotor (opens in a new tab)True60Hz240HzNo0.74x
quadrotor (opens in a new tab)False50Hz1000HzNo9.28x
quadrotor (opens in a new tab)False50Hz1000HzYes7.62x

^ Whether the environment includes a default set of constraints and disturbances

^^ Speed-up = Elapsed Simulation Time / Elapsed Wall Clock Time; on a 2.30GHz Quad-Core i7-1068NG7 with 32GB 3733MHz LPDDR4X; no GPU

Run Tests and Linting

Tests can be run locally by executing:

python3 -m pytest ./tests/  # Run all tests

Linting can be run locally with:

pre-commit install  # Install the pre-commit hooks
pre-commit autoupdate  # Auto-update the version of the hooks
pre-commit run --all  # Run the hooks on all files
References
Related Open-source Projects

University of Toronto's Dynamic Systems Lab (opens in a new tab) / Vector Institute for Artificial Intelligence (opens in a new tab)

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