@@ -40,7 +40,7 @@ git clone https://github.com/utiasDSL/safe-control-gym.git
40
40
cd safe-control-gym
41
41
```
42
42
43
- ### Option A (recommended): using ` conda `
43
+ ### (optional) Create a ` conda ` environment
44
44
45
45
Create and access a Python 3.10 environment using
46
46
[ ` conda ` ] ( https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html )
@@ -50,29 +50,15 @@ conda create -n safe python=3.10
50
50
conda activate safe
51
51
```
52
52
53
+ ### Install
54
+
53
55
Install the ` safe-control-gym ` repository
54
56
55
57
``` bash
56
58
pip install --upgrade pip
57
59
pip install -e .
58
60
```
59
61
60
- ### Option B: using venv and poetry
61
-
62
- Create and access a Python 3.10 virtual environment using
63
- [ ` pyenv ` ] ( https://github.com/pyenv/pyenv ) and
64
- [ ` venv ` ] ( https://docs.python.org/3/library/venv.html )
65
-
66
- ``` bash
67
- pyenv install 3.10
68
- pyenv local 3.10
69
- python3 -m venv safe
70
- source safe/bin/activate
71
- pip install --upgrade pip
72
- pip install poetry
73
- poetry install
74
- ```
75
-
76
62
#### Note
77
63
78
64
You may need to separately install ` gmp ` , a dependency of ` pycddlib ` :
@@ -97,6 +83,80 @@ Overview of [`safe-control-gym`](https://arxiv.org/abs/2109.06325)'s API:
97
83
98
84
<img src =" figures/config.png " alt =" config " width =" 800 " >
99
85
86
+ ## Getting Started
87
+
88
+ Familiarize with APIs and environments with the scripts in [ ` examples/ ` ] ( https://github.com/utiasDSL/safe-control-gym/tree/main/examples )
89
+
90
+ ### 3D Quadrotor Lemniscate Trajectory Tracking with PID
91
+
92
+ ``` bash
93
+ cd ./examples/ # Navigate to the examples folder
94
+ python3 pid/pid_experiment.py \
95
+ --algo pid \
96
+ --task quadrotor \
97
+ --overrides \
98
+ ./pid/config_overrides/quadrotor_3D/quadrotor_3D_tracking.yaml
99
+ ```
100
+
101
+ <img src =" figures/systems.png " alt =" systems " width =" 450 " > <img src =" figures/figure8.gif " alt =" trajectory " width =" 350 " >
102
+
103
+ ### Cartpole Stabilization with LQR
104
+
105
+ ``` bash
106
+ cd ./examples/ # Navigate to the examples folder
107
+ python3 lqr/lqr_experiment.py \
108
+ --algo lqr \
109
+ --task cartpole \
110
+ --overrides \
111
+ ./lqr/config_overrides/cartpole/cartpole_stabilization.yaml \
112
+ ./lqr/config_overrides/cartpole/lqr_cartpole_stabilization.yaml
113
+ ```
114
+
115
+ ### 2D Quadrotor Trajectory Tracking with PPO
116
+
117
+ ``` bash
118
+ cd ./examples/rl/ # Navigate to the RL examples folder
119
+ python3 rl_experiment.py \
120
+ --algo ppo \
121
+ --task quadrotor \
122
+ --overrides \
123
+ ./config_overrides/quadrotor_2D/quadrotor_2D_track.yaml \
124
+ ./config_overrides/quadrotor_2D/ppo_quadrotor_2D.yaml \
125
+ --kv_overrides \
126
+ algo_config.training=False
127
+ ```
128
+
129
+ ### Verbose API Example
130
+
131
+ ``` bash
132
+ cd ./examples/ # Navigate to the examples folder
133
+ python3 no_controller/verbose_api.py \
134
+ --task cartpole \
135
+ --overrides no_controller/verbose_api.yaml
136
+ ```
137
+
138
+ <img src =" figures/prints.png " al =" prints " width =" 800 " >
139
+
140
+ ## List of Implemented Controllers
141
+
142
+ - [ PID] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/pid/pid.py )
143
+ - [ LQR] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/lqr/lqr.py )
144
+ - [ iLQR] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/lqr/ilqr.py )
145
+ - [ Linear MPC] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/mpc/linear_mpc.py )
146
+ - [ GP-MPC] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/mpc/gp_mpc.py )
147
+ - [ SAC] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/sac/sac.py )
148
+ - [ PPO] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/ppo/ppo.py )
149
+ - [ DDPG] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/ddpg/ddpg.py )
150
+ - [ Safety Layer] ( https://github.com/utiasDSL/safe-control-gym/tree/main/safe_control_gym/controllers/safe_explorer )
151
+ - [ RARL] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/rarl/rarl.py )
152
+ - [ RAP] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/rarl/rap.py )
153
+
154
+ ## List of Implemented Safety Filters
155
+
156
+ - [ MPSC] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/safety_filters/mpsc/linear_mpsc.py )
157
+ - [ CBF] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/safety_filters/cbf/cbf.py )
158
+ - [ Neural Network CBF] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/safety_filters/cbf/cbf_nn.py )
159
+
100
160
## Performance
101
161
102
162
We compare the sample efficiency of ` safe-control-gym ` with the original [ OpenAI Cartpole] [ 001 ] and [ PyBullet Gym's Inverted Pendulum] [ 002 ] , as well as [ ` gym-pybullet-drones ` ] [ 003 ] .
@@ -130,43 +190,18 @@ Note that the Bullet engine frequency reported for `safe-control-gym` is typical
130
190
[ 004 ] : https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/envs/gym_control/cartpole.py
131
191
[ 005 ] : https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/envs/gym_pybullet_drones/quadrotor.py
132
192
133
- ## Getting Started
134
-
135
- Familiarize with APIs and environments with the scripts in [ ` examples/ ` ] ( https://github.com/utiasDSL/safe-control-gym/tree/main/examples )
136
-
193
+ ## Run Tests and Linting
194
+ Tests can be run locally by executing:
137
195
``` bash
138
- cd ./examples/ # Navigate to the examples folder
139
- python3 pid/pid_experiment.py --algo pid --task quadrotor --overrides ./pid/config_overrides/quadrotor_3D/quadrotor_3D_tracking.yaml # PID trajectory tracking with the 3D quadcopter
140
- python3 no_controller/verbose_api.py --task cartpole --overrides no_controller/verbose_api.yaml # Printout of the extended safe-control-gym APIs
196
+ python3 -m pytest ./tests/ # Run all tests
141
197
```
142
198
143
- ## Systems Variables and 2D Quadrotor Lemniscate Trajectory Tracking
144
-
145
- <img src =" figures/systems.png " alt =" systems " width =" 450 " > <img src =" figures/figure8.gif " alt =" trajectory " width =" 350 " >
146
-
147
- ## Verbose API Example
148
-
149
- <img src =" figures/prints.png " al =" prints " width =" 800 " >
150
-
151
- ## List of Implemented Controllers
152
-
153
- - [ PID] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/pid/pid.py )
154
- - [ LQR] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/lqr/lqr.py )
155
- - [ iLQR] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/lqr/ilqr.py )
156
- - [ Linear MPC] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/mpc/linear_mpc.py )
157
- - [ GP-MPC] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/mpc/gp_mpc.py )
158
- - [ SAC] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/sac/sac.py )
159
- - [ PPO] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/ppo/ppo.py )
160
- - [ DDPG] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/ddpg/ddpg.py )
161
- - [ Safety Layer] ( https://github.com/utiasDSL/safe-control-gym/tree/main/safe_control_gym/controllers/safe_explorer )
162
- - [ RARL] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/rarl/rarl.py )
163
- - [ RAP] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/controllers/rarl/rap.py )
164
-
165
- ## List of Implemented Safety Filters
166
-
167
- - [ MPSC] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/safety_filters/mpsc/linear_mpsc.py )
168
- - [ CBF] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/safety_filters/cbf/cbf.py )
169
- - [ Neural Network CBF] ( https://github.com/utiasDSL/safe-control-gym/blob/main/safe_control_gym/safety_filters/cbf/cbf_nn.py )
199
+ Linting can be run locally with:
200
+ ``` bash
201
+ pre-commit install # Install the pre-commit hooks
202
+ pre-commit autoupdate # Auto-update the version of the hooks
203
+ pre-commit run --all # Run the hooks on all files
204
+ ```
170
205
171
206
## References
172
207
0 commit comments