Skip to content

Commit 423979b

Browse files
committed
Update configs. Fix benchmark script
1 parent 48aae58 commit 423979b

File tree

11 files changed

+123
-123
lines changed

11 files changed

+123
-123
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ The config folder contains settings for progressively harder scenarios:
146146
| | | | | | |
147147
| sim2real | **Yes** | Real-life hardware | **Yes** | *No* | Sim2real transfer |
148148

149-
> **Note:** "Rand. Between Episodes" (governed by argument `reseed_on_reset`) states whether randomized properties and positions vary or are kept constant (by re-seeding the random number generator on each `env.reset()`) across episodes
149+
> **Note:** "Rand. Between Episodes" (governed by argument `random_resets`) states whether randomized properties and positions vary or are kept constant (by re-seeding the random number generator on each `env.reset()`) across episodes
150150
151151
### Switching between configurations
152152
You can choose which configuration to use by changing the `--config` command line option. To e.g. run the example controller on the hardest scenario, you can use the following command

benchmarks/config/test.toml

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
11
[sim]
2-
physics = "pyb"
2+
physics = "analytical"
33
camera_view = [5.0, -40.0, -40.0, 0.5, -1.0, 0.5]
44
sim_freq = 500 # Simulation frequency, in Hz
5-
ctrl_freq = 500 # Controller frequency, in Hz. This frequency is used to simulate the onboard controller, NOT for the environment's step function
5+
attitude_freq = 500 # Controller frequency, in Hz. This frequency is used to simulate the onboard controller, NOT for the environment's step function
66
gui = false # Enable/disable PyBullet's GUI
77

8-
[sim.disturbances.action]
9-
type = "GaussianNoise"
10-
std = 0.001
11-
12-
[sim.disturbances.dynamics]
13-
type = "UniformNoise"
14-
low = [-0.1, -0.1, -0.1]
15-
high = [0.1, 0.1, 0.1]
16-
178
[env]
18-
reseed = false # Whether to re-seed the random number generator between episodes
9+
random_resets = false # Whether to re-seed the random number generator between episodes
1910
seed = 1337 # Random seed
20-
freq = 60 # Frequency of the environment's step function, in Hz
11+
freq = 50 # Frequency of the environment's step function, in Hz
2112
symbolic = false # Whether to include symbolic expressions in the info dict. Note: This can interfere with multiprocessing! If you want to parallelize your training, set this to false.
2213

2314
[env.track]
@@ -50,7 +41,17 @@ pos = [0.0, 1.0, 1.05]
5041
pos = [1.0, 1.0, 0.05]
5142
rpy = [0, 0, 0]
5243
vel = [0, 0, 0]
53-
ang_vel = [0, 0, 0]
44+
rpy_rates = [0, 0, 0]
45+
46+
[env.disturbances.action]
47+
fn = "normal"
48+
scale = 0.001
49+
50+
[env.disturbances.dynamics]
51+
fn = "uniform"
52+
[env.disturbances.dynamics.kwargs]
53+
minval = [-0.1, -0.1, -0.1]
54+
maxval = [0.1, 0.1, 0.1]
5455

5556
[env.randomization.drone_pos]
5657
type = "uniform" # Everything that can be used as a distribution in numpy.random

benchmarks/main.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,9 @@ def print_benchmark_results(name: str, timings: list[float]):
1919
print_benchmark_results(name="Sim reset", timings=timings)
2020
timings = time_sim_step(n_tests=n_tests, sim_steps=sim_steps)
2121
print_benchmark_results(name="Sim steps", timings=timings / sim_steps)
22-
timings = time_sim_step(n_tests=n_tests, sim_steps=sim_steps, physics_mode="dyn")
23-
print_benchmark_results(name="Sim steps (dyn backend)", timings=timings / sim_steps)
24-
timings = time_sim_step(n_tests=n_tests, sim_steps=sim_steps, physics_mode="pyb_gnd")
25-
print_benchmark_results(name="Sim steps (pyb_gnd backend)", timings=timings / sim_steps)
26-
timings = time_sim_step(n_tests=n_tests, sim_steps=sim_steps, physics_mode="pyb_drag")
27-
print_benchmark_results(name="Sim steps (pyb_drag backend)", timings=timings / sim_steps)
28-
timings = time_sim_step(n_tests=n_tests, sim_steps=sim_steps, physics_mode="pyb_dw")
29-
print_benchmark_results(name="Sim steps (pyb_dw backend)", timings=timings / sim_steps)
30-
timings = time_sim_step(n_tests=n_tests, sim_steps=sim_steps, physics_mode="pyb_gnd_drag_dw")
31-
print_benchmark_results(name="Sim steps (pyb_gnd_drag_dw backend)", timings=timings / sim_steps)
22+
timings = time_sim_step(n_tests=n_tests, sim_steps=sim_steps, physics_mode="sys_id")
23+
print_benchmark_results(name="Sim steps (sys_id backend)", timings=timings / sim_steps)
24+
timings = time_sim_step(n_tests=n_tests, sim_steps=sim_steps, physics_mode="mujoco")
25+
print_benchmark_results(name="Sim steps (mujoco backend)", timings=timings / sim_steps)
3226
timings = time_sim_attitude_step(n_tests=n_tests, sim_steps=sim_steps)
3327
print_benchmark_results(name="Sim steps (sys_id backend)", timings=timings / sim_steps)

benchmarks/sim.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,19 @@
2323
import lsy_drone_racing
2424
2525
env = gymnasium.make('DroneRacing-v0', config=config)
26-
26+
env.reset()
27+
env.step(env.action_space.sample()) # JIT compile
28+
env.reset()
2729
"""
2830
attitude_env_setup_code = """
2931
import gymnasium
3032
3133
import lsy_drone_racing
3234
3335
env = gymnasium.make('DroneRacingThrust-v0', config=config)
36+
env.reset()
37+
env.step(env.action_space.sample()) # JIT compile
38+
env.reset()
3439
"""
3540

3641

@@ -41,7 +46,7 @@ def time_sim_reset(n_tests: int = 10) -> NDArray[np.floating]:
4146

4247

4348
def time_sim_step(
44-
n_tests: int = 10, sim_steps: int = 100, physics_mode: str = "pyb"
49+
n_tests: int = 10, sim_steps: int = 100, physics_mode: str = "analytical"
4550
) -> NDArray[np.floating]:
4651
modify_config_code = f"""config.sim.physics = '{physics_mode}'\n"""
4752
setup = load_config_code + modify_config_code + env_setup_code + "\nenv.reset()"

config/level0.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ high = [0.1, 0.1, 0.1]
3838

3939
[env]
4040
id = "DroneRacing-v0" # Either "DroneRacing-v0" or "DroneRacingThrust-v0". If using "DroneRacingThrust-v0", the drone will use the thrust controller instead of the position controller.
41-
reseed = true # Whether to re-seed the random number generator between episodes
41+
random_resets = true # Whether to re-seed the random number generator between episodes
4242
seed = 1337 # Random seed
4343
freq = 50 # Frequency of the environment's step function, in Hz
4444
symbolic = false # Whether to include symbolic expressions in the info dict. Note: This can interfere with multiprocessing! If you want to parallelize your training, set this to false.

config/level1.toml

+32-34
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,18 @@ check_drone_start_pos = true
1616
practice_without_track_objects = false
1717

1818
[sim]
19-
# Physics options:
20-
# "pyb": PyBullet
21-
# "dyn": Mathematical dynamics model
22-
# "pyb_gnd" PyBullet with ground effect
23-
# "pyb_drag": PyBullet with drag
24-
# "pyb_dw": PyBullet with downwash
25-
# "pyb_gnd_drag_dw": PyBullet with ground effect, drag, and downwash.
26-
physics = "pyb"
19+
# Physics options: analytical, sys_id, mujoco
20+
physics = "analytical"
2721
camera_view = [5.0, -40.0, -40.0, 0.5, -1.0, 0.5]
2822
sim_freq = 500 # Simulation frequency, in Hz
29-
ctrl_freq = 500 # Controller frequency, in Hz. This frequency is used to simulate the onboard controller, NOT for the environment's step function
23+
attitude_freq = 500 # Controller frequency, in Hz. This frequency is used to simulate the onboard controller, NOT for the environment's step function
3024
gui = false # Enable/disable PyBullet's GUI
3125

32-
[sim.disturbances.action]
33-
type = "GaussianNoise"
34-
std = 0.001
35-
36-
[sim.disturbances.dynamics]
37-
type = "UniformNoise"
38-
low = [-0.1, -0.1, -0.1]
39-
high = [0.1, 0.1, 0.1]
40-
4126
[env]
4227
id = "DroneRacing-v0" # Either "DroneRacing-v0" or "DroneRacingThrust-v0". If using "DroneRacingThrust-v0", the drone will use the thrust controller instead of the position controller.
43-
reseed = true # Whether to re-seed the random number generator between episodes
28+
random_resets = true # Whether to re-seed the random number generator between episodes
4429
seed = 1337 # Random seed
45-
freq = 60 # Frequency of the environment's step function, in Hz
30+
freq = 50 # Frequency of the environment's step function, in Hz
4631
symbolic = false # Whether to include symbolic expressions in the info dict. Note: This can interfere with multiprocessing! If you want to parallelize your training, set this to false.
4732
sensor_range = 0.45 # Range at which the exact location of gates and obstacles become visible to the drone. Objects that are not in the drone's sensor range report their nominal position.
4833

@@ -76,25 +61,38 @@ pos = [0.0, 1.0, 1.4]
7661
pos = [1.0, 1.0, 0.05]
7762
rpy = [0, 0, 0]
7863
vel = [0, 0, 0]
79-
ang_vel = [0, 0, 0]
64+
rpy_rates = [0, 0, 0]
65+
66+
[env.disturbances.action]
67+
fn = "normal"
68+
scale = 0.001
69+
70+
[env.disturbances.dynamics]
71+
fn = "uniform"
72+
[env.disturbances.dynamics.kwargs]
73+
minval = [-0.1, -0.1, -0.1]
74+
maxval = [0.1, 0.1, 0.1]
8075

8176
[env.randomization.drone_pos]
82-
type = "uniform" # Everything that can be used as a distribution in numpy.random
83-
# Kwargs that are permissable in the np random function
84-
low = [-0.1, -0.1, 0.0]
85-
high = [0.1, 0.1, 0.02]
77+
fn = "uniform"
78+
[env.randomization.drone_pos.kwargs]
79+
minval = [-0.1, -0.1, 0.0]
80+
maxval = [0.1, 0.1, 0.02]
8681

8782
[env.randomization.drone_rpy]
88-
type = "uniform"
89-
low = [-0.1, -0.1, -0.1]
90-
high = [0.1, 0.1, 0.1]
83+
fn = "uniform"
84+
[env.randomization.drone_rpy.kwargs]
85+
minval = [-0.1, -0.1, -0.1]
86+
maxval = [0.1, 0.1, 0.1]
9187

9288
[env.randomization.drone_mass]
93-
type = "uniform"
94-
low = -0.01
95-
high = 0.01
89+
fn = "uniform"
90+
[env.randomization.drone_mass.kwargs]
91+
minval = -0.01
92+
maxval = 0.01
9693

9794
[env.randomization.drone_inertia]
98-
type = "uniform"
99-
low = [-0.000001, -0.000001, -0.000001]
100-
high = [0.000001, 0.000001, 0.000001]
95+
fn = "uniform"
96+
[env.randomization.drone_inertia.kwargs]
97+
minval = [-0.000001, -0.000001, -0.000001]
98+
maxval = [0.000001, 0.000001, 0.000001]

config/level2.toml

+44-43
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,18 @@ check_drone_start_pos = true
1616
practice_without_track_objects = false
1717

1818
[sim]
19-
# Physics options:
20-
# "pyb": PyBullet
21-
# "dyn": Mathematical dynamics model
22-
# "pyb_gnd" PyBullet with ground effect
23-
# "pyb_drag": PyBullet with drag
24-
# "pyb_dw": PyBullet with downwash
25-
# "pyb_gnd_drag_dw": PyBullet with ground effect, drag, and downwash.
26-
physics = "pyb"
19+
# Physics options: analytical, sys_id, mujoco
20+
physics = "analytical"
2721
camera_view = [5.0, -40.0, -40.0, 0.5, -1.0, 0.5]
2822
sim_freq = 500 # Simulation frequency, in Hz
29-
ctrl_freq = 500 # Controller frequency, in Hz. This frequency is used to simulate the onboard controller, NOT for the environment's step function
23+
attitude_freq = 500 # Controller frequency, in Hz. This frequency is used to simulate the onboard controller, NOT for the environment's step function
3024
gui = false # Enable/disable PyBullet's GUI
3125

32-
[sim.disturbances.action]
33-
type = "GaussianNoise"
34-
std = 0.001
35-
36-
[sim.disturbances.dynamics]
37-
type = "UniformNoise"
38-
low = [-0.1, -0.1, -0.1]
39-
high = [0.1, 0.1, 0.1]
40-
4126
[env]
4227
id = "DroneRacing-v0" # Either "DroneRacing-v0" or "DroneRacingThrust-v0". If using "DroneRacingThrust-v0", the drone will use the thrust controller instead of the position controller.
43-
reseed = true # Whether to re-seed the random number generator between episodes
28+
random_resets = true # Whether to re-seed the random number generator between episodes
4429
seed = 1337 # Random seed
45-
freq = 60 # Frequency of the environment's step function, in Hz
30+
freq = 50 # Frequency of the environment's step function, in Hz
4631
symbolic = false # Whether to include symbolic expressions in the info dict. Note: This can interfere with multiprocessing! If you want to parallelize your training, set this to false.
4732
sensor_range = 0.45 # Range at which the exact location of gates and obstacles become visible to the drone. Objects that are not in the drone's sensor range report their nominal position.
4833

@@ -76,40 +61,56 @@ pos = [0.0, 1.0, 1.4]
7661
pos = [1.0, 1.0, 0.05]
7762
rpy = [0, 0, 0]
7863
vel = [0, 0, 0]
79-
ang_vel = [0, 0, 0]
64+
rpy_rates = [0, 0, 0]
65+
66+
[env.disturbances.action]
67+
fn = "normal"
68+
scale = 0.001
69+
70+
[env.disturbances.dynamics]
71+
fn = "uniform"
72+
[env.disturbances.dynamics.kwargs]
73+
minval = [-0.1, -0.1, -0.1]
74+
maxval = [0.1, 0.1, 0.1]
8075

8176
[env.randomization.drone_pos]
82-
type = "uniform" # Everything that can be used as a distribution in numpy.random
83-
# Kwargs that are permissable in the np random function
84-
low = [-0.1, -0.1, 0.0]
85-
high = [0.1, 0.1, 0.02]
77+
fn = "uniform"
78+
[env.randomization.drone_pos.kwargs]
79+
minval = [-0.1, -0.1, 0.0]
80+
maxval = [0.1, 0.1, 0.02]
8681

8782
[env.randomization.drone_rpy]
88-
type = "uniform"
89-
low = [-0.1, -0.1, -0.1]
90-
high = [0.1, 0.1, 0.1]
83+
fn = "uniform"
84+
[env.randomization.drone_rpy.kwargs]
85+
minval = [-0.1, -0.1, -0.1]
86+
maxval = [0.1, 0.1, 0.1]
9187

9288
[env.randomization.drone_mass]
93-
type = "uniform"
94-
low = -0.01
95-
high = 0.01
89+
fn = "uniform"
90+
[env.randomization.drone_mass.kwargs]
91+
minval = -0.01
92+
maxval = 0.01
9693

9794
[env.randomization.drone_inertia]
98-
type = "uniform"
99-
low = [-0.000001, -0.000001, -0.000001]
100-
high = [0.000001, 0.000001, 0.000001]
95+
fn = "uniform"
96+
[env.randomization.drone_inertia.kwargs]
97+
minval = [-0.000001, -0.000001, -0.000001]
98+
maxval = [0.000001, 0.000001, 0.000001]
10199

102100
[env.randomization.gate_pos]
103-
type = "uniform"
104-
low = [-0.15, -0.15, 0.0]
105-
high = [0.15, 0.15, 0.0]
101+
fn = "uniform"
102+
[env.randomization.gate_pos.kwargs]
103+
minval = [-0.15, -0.15, -0.1]
104+
maxval = [0.15, 0.15, 0.1]
106105

107106
[env.randomization.gate_rpy]
108-
type = "uniform"
109-
low = [0.0, 0.0, -0.1]
110-
high = [0.0, 0.0, 0.1]
107+
fn = "uniform"
108+
[env.randomization.gate_rpy.kwargs]
109+
minval = [0.0, 0.0, -0.1]
110+
maxval = [0.0, 0.0, 0.1]
111111

112112
[env.randomization.obstacle_pos]
113-
type = "uniform"
114-
low = -0.15
115-
high = 0.15
113+
fn = "uniform"
114+
[env.randomization.obstacle_pos.kwargs]
115+
minval = [-0.15, -0.15, -0.05]
116+
maxval = [0.15, 0.15, 0.05]

config/level3.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ check_drone_start_pos = true
1616
practice_without_track_objects = false
1717

1818
[sim]
19-
# Physics options:
19+
# Physics options: analytical, sys_id, mujoco
2020
physics = "analytical"
2121
camera_view = [5.0, -40.0, -40.0, 0.5, -1.0, 0.5]
2222
sim_freq = 500 # Simulation frequency, in Hz
@@ -25,7 +25,7 @@ gui = false # Enable/disable PyBullet's GU
2525

2626
[env]
2727
id = "DroneRacing-v0" # Either "DroneRacing-v0" or "DroneRacingThrust-v0". If using "DroneRacingThrust-v0", the drone will use the thrust controller instead of the position controller.
28-
reseed = false # Whether to re-seed the random number generator between episodes
28+
random_resets = false # Whether to re-seed the random number generator between episodes
2929
seed = 1337 # Random seed
3030
freq = 50 # Frequency of the environment's step function, in Hz
3131
symbolic = false # Whether to include symbolic expressions in the info dict. Note: This can interfere with multiprocessing! If you want to parallelize your training, set this to false.

docs/challenge/simulation.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ The challenge is divided into different difficulty levels, each specified by a T
5050
- Sim2real transfer
5151

5252
.. note::
53-
"Rand. Between Episodes" (governed by argument `reseed_on_reset`) determines whether randomized properties and positions vary or are kept constant (by re-seeding the random number generator on each `env.reset()`) across episodes.
53+
"Rand. Between Episodes" (governed by argument `random_resets`) determines whether randomized properties and positions vary or are kept constant (by re-seeding the random number generator on each `env.reset()`) across episodes.
5454

5555
You may use the easier scenarios to develop and debug your controller. However, the final evaluation will be on the hardest scenario (Level 3).
5656

0 commit comments

Comments
 (0)