# safe-control-gym puts safety constraints inside the simulation loop

> safe-control-gym is a PyBullet based Gym benchmark suite from the learnsyslab group, pairing CartPole and quadrotor environments with CasADi symbolic dynamics, explicit safety constraints and disturbance models. It is a research suite with a fast moving dependency stack, and the manifest version is ahead of the newest release tag.

**learnsyslab/safe-control-gym** — PyBullet CartPole and Quadrotor environments—with CasADi symbolic a priori dynamics—for learning-based control and RL

- Repository: https://github.com/learnsyslab/safe-control-gym
- Website: https://www.dynsyslab.org/safe-robot-learning/
- Stars: 928 · Forks: 168
- Language: Python
- License: MIT
- Published: 2026-10-20 · Updated: 2026-10-20 · Language: en
- Canonical page: https://hysenlabs.com/projects/learnsyslab-safe-control-gym

## A Gym suite where the safety constraints belong to the environment

safe-control-gym is a set of physics-based Gym environments for CartPole and Quadrotor, built on PyBullet and developed by the learnsyslab group, whose homepage is dynsyslab.org/safe-robot-learning/.

What separates it from a standard control benchmark is that the environments include and evaluate symbolic safety constraints. The constraints are not an optional layer bolted onto a controller after the fact, they are part of the environment definition and part of what gets evaluated.

The environments also implement input, parameter and dynamics disturbances. The README frames the purpose as testing control approaches under disturbances and for generalizability, which is a research question rather than a deployment one. A method that only works in a noiseless plant is not the kind of result this suite is built to produce.

The project publishes two references. The 2021 Annual Review of Control, Robotics, and Autonomous Systems article is Safe Learning in Robotics, and the 2022 IEEE Robotics and Automation Letters paper is Safe-Control-Gym: A Unified Benchmark Suite for Safe Learning-Based Control and Reinforcement Learning in Robotics. Each has a companion release branch for reproducing its results, the ar branch for the first and the submission branch for the second.

## Symbolic a priori dynamics from CasADi, simulated in PyBullet

The architecture is a two-layer stack. PyBullet provides the physics simulation for the CartPole and quadrotor systems, and CasADi provides the symbolic a priori dynamics, which is the model used for constraint handling and for the model-based controllers rather than a learned approximation.

Having both is the point. A model-free reinforcement learning agent works against the simulator, while a controller such as Linear MPC or GP-MPC works against the symbolic model of the same system. Putting them in one suite means a safe learning algorithm and a safe model-based controller are measured on the same plant with the same constraints and the same disturbances, which is the comparison the benchmark exists to support.

The repository layout shows the separation. The package lives in safe_control_gym/, with controllers/ subdirectories per algorithm and a safety_filters/ directory, and there is a separate examples/ tree with one folder per method plus a tutorial.md. The root also has pyproject.toml, setup.py, tests/, figures/ and a CITATION.cff.

The README's Architecture and Configuration sections are both images, block.png and config.png, so the API overview and the configuration story live in diagrams rather than in prose.

## Eleven controllers and three safety filters to compare against

The suite ships a catalogue of reference implementations, and that catalogue is the comparison set your own method has to beat.

The controllers are PID, LQR, iLQR, Linear MPC, GP-MPC, SAC, PPO, DDPG, the Safety Layer, RARL and RAP. That spans classical control at one end (PID and LQR), model-based control with a learned part in the middle (GP-MPC), model-free reinforcement learning (SAC, PPO, DDPG) and adversarial or safety-layer approaches at the other end.

The safety filters are separate and fewer: MPSC, CBF and a neural network CBF variant. The distinction matters. A filter takes a proposed action and projects it onto a safe set before it reaches the plant, which is a different mechanism from a controller that is aware of safety constraints while planning.

Two of the reinforcement learning entries are also worth a note for anyone reading the literature. RARL and RAP sit under a controllers/rarl/ directory, so they are implemented as controllers in the same sense as PID, which means they can be driven through the same experiment scripts and configuration overrides as the classical baselines.

## Installing on Ubuntu or macOS, including the gmp and acados side dependencies

The README's install instructions cover Ubuntu and macOS and start with a clone of the repository.

```bash
git clone https://github.com/learnsyslab/safe-control-gym.git
cd safe-control-gym
```

It then offers an optional conda environment with Python 3.10.

```bash
conda create -n safe python=3.10
conda activate safe
```

The package itself installs with pip in editable mode.

```bash
python -m pip install --upgrade pip
python -m pip install -e .
```

Two dependencies do not come with that install. The README notes that you may need to install gmp separately because pycddlib depends on it, and gives both a conda route and a system route.

```bash
conda install -c anaconda gmp
```

or

```bash
sudo apt-get install libgmp-dev
```

There is also an optional step for MPC: the README states you may need to install acados separately for fast MPC implementations, pointing at the acados installation guide and the python interface setup steps. If your study involves MPC, budget for that build before you start experimenting.

## Running a first experiment from the examples directory

The getting started section points you at the scripts in examples/, and the four documented runs cover the range of the suite. Each one takes the same shape: an algorithm, a task, and YAML overrides.

The PID example tracks a 3D quadrotor on a lemniscate trajectory.

```bash
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
```

The LQR example stabilises the cartpole and passes two override files, one for the task and one for the controller.

```bash
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
```

The PPO example runs 2D quadrotor trajectory tracking with training switched off via a key value override, and the verbose API example runs the cartpole task with no controller to inspect the API surface. The overrides mechanism is the configuration story in practice: every experiment is a YAML file layered onto the defaults, so a result can be reproduced by reusing the same override set.

## What the README says about performance, and what it does not

The Performance section compares the sample efficiency of safe-control-gym with the original OpenAI Cartpole, with PyBullet Gym's Inverted Pendulum, and with gym-pybullet-drones. The method is stated: the default physics simulation integration step of each project is chosen, and results are reported for open-loop, random action inputs. The README also notes that the Bullet engine frequency reported for safe-control-gym is typically much finer grained for improved fidelity.

That last point is the detail to keep in mind when reading the comparison, because a finer integration step changes both the simulation cost and the behaviour of the plant. It is a fidelity choice, and it is stated openly.

The comparison with gym-pybullet-drones is the honest alternative here, and the README concedes the trade-off: the safe-control-gym quadrotor environment is not as light-weight as gym-pybullet-drones, but it provides the same order of magnitude speed-up and more, in a sentence the README truncates. The difference in approach between the two is exactly the point of this project: a plain drone simulator gives you a plant to fly, while safe-control-gym gives you a plant with symbolic constraints and disturbance models attached, at a heavier cost.

No wall-clock timings or sample-efficiency numbers appear in the README itself, so the performance claim has to be read from the papers rather than from the repository.

## A 2.0.0 manifest sitting next to a v1.0.0 release tag

The version situation is the thing to check before you build anything on this package. The pyproject.toml declares version 2.0.0 under tool.poetry, and setup.py also declares version 2.0.0 for the safe_control_gym distribution, while the newest release tag listed is v1.0.0 from 2024-10-21, alongside v1.0.0-alpha from 2023-05-08 and v0.6.0, tagged for the IEEE Robotics and Automation Letters paper, also dated 2024-10-21.

So the default branch carries a 2.0.0 version that has not been tagged. The poetry dependency list makes the other half of the picture clear: python = ^3.10, gymnasium = ^0.28, casadi = ^3.7, pybullet = ^3.2, torch = ^2.8, cvxpy = ^1.7, Mosek = ^11.0, plus gpytorch, scikit-learn, pytope, pycddlib, optuna and tensorboard. The Mosek entry in particular means the solver stack assumes a commercial licence path for the convex programs the filters rely on.

The build backend is poetry-core, with pre-commit configured through .pre-commit-config.yaml.

The licence field on the repository says MIT, so the code is reusable under permissive terms, while the Mosek dependency carries its own licensing for anyone running the optimisation problems at scale.

On maintenance, the repository is not archived and the last push was on 2026-04-29. The releases are anchored to the papers rather than to a rolling schedule, so treat the default branch as the moving target and the tagged branches as the reproducible ones.

## Conclusion

safe-control-gym fits research groups that need to compare a safety filter or a safe reinforcement learning algorithm against PID, LQR and MPC baselines on the same physics, and who can absorb a Python 3.10 environment with CasADi, PyBullet and Mosek installed. It does not fit a team that wants a lightweight drone simulator, since the README states its quadrotor environment is heavier than gym-pybullet-drones, and it is a poor fit for reproducing the published baselines on demand, because those live on separate release branches. Before installing it, check the gmp and acados side dependencies on your machine, and pin the version you intend to use against the pyproject.toml manifest rather than the v1.0.0 tag.

## FAQ

### What does safe-control-gym add to a standard PyBullet environment?

The environments include and evaluate symbolic safety constraints and implement input, parameter and dynamics disturbances, so a control approach is tested for behaviour under disturbances and for generalizability rather than only on a noiseless plant.

### How do I install safe-control-gym on Ubuntu or macOS?

Clone the repository, optionally create a conda environment with Python 3.10, then run python -m pip install -e . after upgrading pip. You may also need gmp, which pycddlib depends on, and acados for fast MPC implementations.

### Which safety filters does safe-control-gym implement?

The README lists three: MPSC, CBF and a neural network CBF variant, all under safe_control_gym/safety_filters/. Controllers shipped alongside them include PID, LQR, iLQR, Linear MPC, GP-MPC, SAC, PPO, DDPG, a Safety Layer, RARL and RAP.

## Sources

- [learnsyslab/safe-control-gym on GitHub](https://github.com/learnsyslab/safe-control-gym)
- [License: MIT](https://github.com/learnsyslab/safe-control-gym/blob/main/LICENSE)
- [Project website](https://www.dynsyslab.org/safe-robot-learning/)
- [README](https://github.com/learnsyslab/safe-control-gym/blob/main/README.md)
- [Releases](https://github.com/learnsyslab/safe-control-gym/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/learnsyslab-safe-control-gym
