Skip to content

Commit

Permalink
Move to ConfigDict. Rename ThrustEnv to AttitudeEnv.
Browse files Browse the repository at this point in the history
  • Loading branch information
amacati committed Jan 13, 2025
1 parent 82a70b6 commit 0822050
Show file tree
Hide file tree
Showing 16 changed files with 221 additions and 196 deletions.
16 changes: 8 additions & 8 deletions benchmarks/config/test.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[sim]
physics = "analytical"
camera_view = [5.0, -40.0, -40.0, 0.5, -1.0, 0.5]
sim_freq = 500 # Simulation frequency, in Hz
freq = 500 # Simulation frequency, in Hz
attitude_freq = 500 # Controller frequency, in Hz. This frequency is used to simulate the onboard controller, NOT for the environment's step function
gui = false # Enable/disable PyBullet's GUI

Expand Down Expand Up @@ -53,38 +53,38 @@ fn = "uniform"
minval = [-0.1, -0.1, -0.1]
maxval = [0.1, 0.1, 0.1]

[env.randomization.drone_pos]
[env.randomizations.drone_pos]
type = "uniform" # Everything that can be used as a distribution in numpy.random
# Kwargs that are permissable in the np random function
low = [-0.1, -0.1, 0.0]
high = [0.1, 0.1, 0.02]

[env.randomization.drone_rpy]
[env.randomizations.drone_rpy]
type = "uniform"
low = [-0.1, -0.1, -0.1]
high = [0.1, 0.1, 0.1]

[env.randomization.drone_mass]
[env.randomizations.drone_mass]
type = "uniform"
low = -0.01
high = 0.01

[env.randomization.drone_inertia]
[env.randomizations.drone_inertia]
type = "uniform"
low = [-0.000001, -0.000001, -0.000001]
high = [0.000001, 0.000001, 0.000001]

[env.randomization.gate_pos]
[env.randomizations.gate_pos]
type = "uniform"
low = [-0.1, -0.1, 0.0]
high = [0.1, 0.1, 0.0]

[env.randomization.gate_rpy]
[env.randomizations.gate_rpy]
type = "uniform"
low = [0.0, 0.0, -0.1]
high = [0.0, 0.0, 0.1]

[env.randomization.obstacle_pos]
[env.randomizations.obstacle_pos]
type = "uniform"
low = [-0.1, -0.1, 0.0]
high = [0.1, 0.1, 0.0]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import lsy_drone_racing
env = gymnasium.make('DroneRacingThrust-v0', config=config)
env = gymnasium.make('DroneRacingAttitude-v0', config=config)
env.reset()
env.step(env.action_space.sample()) # JIT compile
env.reset()
Expand Down
4 changes: 2 additions & 2 deletions config/level0.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ practice_without_track_objects = false
physics = "analytical"

camera_view = [5.0, -40.0, -40.0, 0.5, -1.0, 0.5]
sim_freq = 500 # Simulation frequency, in Hz
freq = 500 # Simulation frequency, in Hz
attitude_freq = 500 # Controller frequency, in Hz. This frequency is used to simulate the onboard controller, NOT for the environment's step function
gui = false # Enable/disable PyBullet's GUI

Expand All @@ -37,7 +37,7 @@ low = [-0.1, -0.1, -0.1]
high = [0.1, 0.1, 0.1]

[env]
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.
id = "DroneRacing-v0" # Either "DroneRacing-v0" or "DroneRacingAttitude-v0". If using "DroneRacingAttitude-v0", the drone will use the attitude controller instead of the position controller.
random_resets = false # Whether to re-seed the random number generator between episodes
seed = 1337 # Random seed
freq = 50 # Frequency of the environment's step function, in Hz
Expand Down
20 changes: 10 additions & 10 deletions config/level1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ practice_without_track_objects = false
# Physics options: analytical, sys_id, mujoco
physics = "analytical"
camera_view = [5.0, -40.0, -40.0, 0.5, -1.0, 0.5]
sim_freq = 500 # Simulation frequency, in Hz
freq = 500 # Simulation frequency, in Hz
attitude_freq = 500 # Controller frequency, in Hz. This frequency is used to simulate the onboard controller, NOT for the environment's step function
gui = false # Enable/disable PyBullet's GUI

[env]
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.
id = "DroneRacing-v0" # Either "DroneRacing-v0" or "DroneRacingAttitude-v0". If using "DroneRacingAttitude-v0", the drone will use the attitude controller instead of the position controller.
random_resets = false # Whether to re-seed the random number generator between episodes
seed = 1337 # Random seed
freq = 50 # Frequency of the environment's step function, in Hz
Expand Down Expand Up @@ -73,26 +73,26 @@ fn = "uniform"
minval = [-0.1, -0.1, -0.1]
maxval = [0.1, 0.1, 0.1]

[env.randomization.drone_pos]
[env.randomizations.drone_pos]
fn = "uniform"
[env.randomization.drone_pos.kwargs]
[env.randomizations.drone_pos.kwargs]
minval = [-0.1, -0.1, 0.0]
maxval = [0.1, 0.1, 0.02]

[env.randomization.drone_rpy]
[env.randomizations.drone_rpy]
fn = "uniform"
[env.randomization.drone_rpy.kwargs]
[env.randomizations.drone_rpy.kwargs]
minval = [-0.1, -0.1, -0.1]
maxval = [0.1, 0.1, 0.1]

[env.randomization.drone_mass]
[env.randomizations.drone_mass]
fn = "uniform"
[env.randomization.drone_mass.kwargs]
[env.randomizations.drone_mass.kwargs]
minval = -0.01
maxval = 0.01

[env.randomization.drone_inertia]
[env.randomizations.drone_inertia]
fn = "uniform"
[env.randomization.drone_inertia.kwargs]
[env.randomizations.drone_inertia.kwargs]
minval = [-0.000001, -0.000001, -0.000001]
maxval = [0.000001, 0.000001, 0.000001]
32 changes: 16 additions & 16 deletions config/level2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ practice_without_track_objects = false
# Physics options: analytical, sys_id, mujoco
physics = "analytical"
camera_view = [5.0, -40.0, -40.0, 0.5, -1.0, 0.5]
sim_freq = 500 # Simulation frequency, in Hz
freq = 500 # Simulation frequency, in Hz
attitude_freq = 500 # Controller frequency, in Hz. This frequency is used to simulate the onboard controller, NOT for the environment's step function
gui = false # Enable/disable PyBullet's GUI

[env]
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.
id = "DroneRacing-v0" # Either "DroneRacing-v0" or "DroneRacingAttitude-v0". If using "DroneRacingAttitude-v0", the drone will use the attitude controller instead of the position controller.
random_resets = false # Whether to re-seed the random number generator between episodes
seed = 1337 # Random seed
freq = 50 # Frequency of the environment's step function, in Hz
Expand Down Expand Up @@ -73,44 +73,44 @@ fn = "uniform"
minval = [-0.1, -0.1, -0.1]
maxval = [0.1, 0.1, 0.1]

[env.randomization.drone_pos]
[env.randomizations.drone_pos]
fn = "uniform"
[env.randomization.drone_pos.kwargs]
[env.randomizations.drone_pos.kwargs]
minval = [-0.1, -0.1, 0.0]
maxval = [0.1, 0.1, 0.02]

[env.randomization.drone_rpy]
[env.randomizations.drone_rpy]
fn = "uniform"
[env.randomization.drone_rpy.kwargs]
[env.randomizations.drone_rpy.kwargs]
minval = [-0.1, -0.1, -0.1]
maxval = [0.1, 0.1, 0.1]

[env.randomization.drone_mass]
[env.randomizations.drone_mass]
fn = "uniform"
[env.randomization.drone_mass.kwargs]
[env.randomizations.drone_mass.kwargs]
minval = -0.01
maxval = 0.01

[env.randomization.drone_inertia]
[env.randomizations.drone_inertia]
fn = "uniform"
[env.randomization.drone_inertia.kwargs]
[env.randomizations.drone_inertia.kwargs]
minval = [-0.000001, -0.000001, -0.000001]
maxval = [0.000001, 0.000001, 0.000001]

[env.randomization.gate_pos]
[env.randomizations.gate_pos]
fn = "uniform"
[env.randomization.gate_pos.kwargs]
[env.randomizations.gate_pos.kwargs]
minval = [-0.15, -0.15, -0.1]
maxval = [0.15, 0.15, 0.1]

[env.randomization.gate_rpy]
[env.randomizations.gate_rpy]
fn = "uniform"
[env.randomization.gate_rpy.kwargs]
[env.randomizations.gate_rpy.kwargs]
minval = [0.0, 0.0, -0.1]
maxval = [0.0, 0.0, 0.1]

[env.randomization.obstacle_pos]
[env.randomizations.obstacle_pos]
fn = "uniform"
[env.randomization.obstacle_pos.kwargs]
[env.randomizations.obstacle_pos.kwargs]
minval = [-0.15, -0.15, -0.05]
maxval = [0.15, 0.15, 0.05]
32 changes: 16 additions & 16 deletions config/level3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ practice_without_track_objects = false
# Physics options: analytical, sys_id, mujoco
physics = "analytical"
camera_view = [5.0, -40.0, -40.0, 0.5, -1.0, 0.5]
sim_freq = 500 # Simulation frequency, in Hz
freq = 500 # Simulation frequency, in Hz
attitude_freq = 500 # Controller frequency, in Hz. This frequency is used to simulate the onboard controller, NOT for the environment's step function
gui = false # Enable/disable PyBullet's GUI

[env]
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.
id = "DroneRacing-v0" # Either "DroneRacing-v0" or "DroneRacingAttitude-v0". If using "DroneRacingAttitude-v0", the drone will use the attitude controller instead of the position controller.
random_resets = true # Whether to re-seed the random number generator between episodes
seed = 1337 # Random seed
freq = 50 # Frequency of the environment's step function, in Hz
Expand Down Expand Up @@ -73,44 +73,44 @@ fn = "uniform"
minval = [-0.1, -0.1, -0.1]
maxval = [0.1, 0.1, 0.1]

[env.randomization.drone_pos]
[env.randomizations.drone_pos]
fn = "uniform"
[env.randomization.drone_pos.kwargs]
[env.randomizations.drone_pos.kwargs]
minval = [-0.1, -0.1, 0.0]
maxval = [0.1, 0.1, 0.02]

[env.randomization.drone_rpy]
[env.randomizations.drone_rpy]
fn = "uniform"
[env.randomization.drone_rpy.kwargs]
[env.randomizations.drone_rpy.kwargs]
minval = [-0.1, -0.1, -0.1]
maxval = [0.1, 0.1, 0.1]

[env.randomization.drone_mass]
[env.randomizations.drone_mass]
fn = "uniform"
[env.randomization.drone_mass.kwargs]
[env.randomizations.drone_mass.kwargs]
minval = -0.01
maxval = 0.01

[env.randomization.drone_inertia]
[env.randomizations.drone_inertia]
fn = "uniform"
[env.randomization.drone_inertia.kwargs]
[env.randomizations.drone_inertia.kwargs]
minval = [-0.000001, -0.000001, -0.000001]
maxval = [0.000001, 0.000001, 0.000001]

[env.randomization.gate_pos]
[env.randomizations.gate_pos]
fn = "uniform"
[env.randomization.gate_pos.kwargs]
[env.randomizations.gate_pos.kwargs]
minval = [-0.15, -0.15, -0.1]
maxval = [0.15, 0.15, 0.1]

[env.randomization.gate_rpy]
[env.randomizations.gate_rpy]
fn = "uniform"
[env.randomization.gate_rpy.kwargs]
[env.randomizations.gate_rpy.kwargs]
minval = [0.0, 0.0, -0.1]
maxval = [0.0, 0.0, 0.1]

[env.randomization.obstacle_pos]
[env.randomizations.obstacle_pos]
fn = "uniform"
[env.randomization.obstacle_pos.kwargs]
[env.randomizations.obstacle_pos.kwargs]
minval = [-0.15, -0.15, -0.05]
maxval = [0.15, 0.15, 0.05]
8 changes: 4 additions & 4 deletions lsy_drone_racing/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
)

register(
id="DroneRacingThrust-v0",
entry_point="lsy_drone_racing.envs.drone_racing_env:DroneRacingThrustEnv",
id="DroneRacingAttitude-v0",
entry_point="lsy_drone_racing.envs.drone_racing_env:DroneRacingAttitudeEnv",
max_episode_steps=1800,
disable_env_checker=True,
)
Expand All @@ -41,8 +41,8 @@
)

register(
id="DroneRacingThrustDeploy-v0",
entry_point="lsy_drone_racing.envs.drone_racing_deploy_env:DroneRacingThrustDeployEnv",
id="DroneRacingAttitudeDeploy-v0",
entry_point="lsy_drone_racing.envs.drone_racing_deploy_env:DroneRacingAttitudeDeployEnv",
max_episode_steps=1800,
disable_env_checker=True,
)
8 changes: 4 additions & 4 deletions lsy_drone_racing/envs/drone_racing_deploy_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
* :class:`~.DroneRacingDeployEnv`: A Gymnasium environment for controlling a real Crazyflie drone in
a physical race track, using Vicon motion capture for positioning.
* :class:`~.DroneRacingThrustDeployEnv`: A variant of :class:`~.DroneRacingDeployEnv` that uses
* :class:`~.DroneRacingAttitudeDeployEnv`: A variant of :class:`~.DroneRacingDeployEnv` that uses
collective thrust and attitude commands for control.
These environments maintain consistent interfaces with their simulation counterparts
(:class:`~.DroneRacingEnv` and :class:`~.DroneRacingThrustEnv`), allowing for seamless transition
(:class:`~.DroneRacingEnv` and :class:`~.DroneRacingAttitudeEnv`), allowing for seamless transition
from simulation to real-world deployment. They handle the complexities of interfacing with physical
hardware while providing the same observation and action spaces as the simulation environments.
Expand Down Expand Up @@ -273,11 +273,11 @@ def gate_passed(self, pos: NDArray[np.floating], prev_pos: NDArray[np.floating])
return False


class DroneRacingThrustDeployEnv(DroneRacingDeployEnv):
class DroneRacingAttitudeDeployEnv(DroneRacingDeployEnv):
"""A Gymnasium environment for deploying drone racing algorithms on real hardware.
This environment mirrors the functionality of the
class:~lsy_drone_racing.envs.drone_racing_thrust_env.DroneRacingThrustEnv, but interfaces with
class:~lsy_drone_racing.envs.drone_racing_thrust_env.DroneRacingAttitudeEnv, but interfaces with
real-world hardware (Crazyflie drone and Vicon motion capture system) instead of a simulation.
"""

Expand Down
Loading

0 comments on commit 0822050

Please sign in to comment.