Skip to content

Commit

Permalink
Remove old dependencies. Prepare further removals
Browse files Browse the repository at this point in the history
  • Loading branch information
amacati committed Jan 30, 2025
1 parent b371579 commit 35e2064
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 33 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/kaggle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ jobs:
init-shell: bash
create-args: python=3.8
cache-environment: true
- run: pip install .[rl,test]
shell: micromamba-shell {0}
- run: pip install kaggle
- run: pip install .[online_submission,test]
shell: micromamba-shell {0}
- name: Install cffirmware
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ You can also install the extended dependencies with
```bash
conda activate race
cd ~/repos/lsy_drone_racing
pip install -e .[rl, test]
pip install -e .[test]
```
and check if all tests complete with
```bash
Expand Down
4 changes: 2 additions & 2 deletions docker/Deploy.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ WORKDIR /home/lsy_drone_racing
COPY pyproject.toml ./
# Install dependencies and cache the build step (only rebuilds when pyproject.toml changes)
RUN pip install build
RUN pip install --no-cache-dir .[test,rl]
RUN pip install --no-cache-dir .[test]
# Copy the rest of the application
COPY . .
RUN pip install --no-cache-dir -e .[test,rl]
RUN pip install --no-cache-dir -e .[test]

CMD bash -c "source /home/crazyswarm/ros_ws/devel/setup.bash && python /home/lsy_drone_racing/scripts/deploy.py"
4 changes: 2 additions & 2 deletions docker/Sim.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ WORKDIR /home/lsy_drone_racing
COPY pyproject.toml ./
# Install dependencies and cache the build step (only rebuilds when pyproject.toml changes)
RUN pip install build
RUN pip install --no-cache-dir .[test,rl]
RUN pip install --no-cache-dir .[test]
# Copy the rest of the application
COPY . .
RUN pip install -e .[test,rl]
RUN pip install -e .[test]

ENTRYPOINT ["python", "/home/lsy_drone_racing/scripts/sim.py", "--gui", "False"]
4 changes: 2 additions & 2 deletions docs/getting_started/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ If everything is installed correctly, this will open the simulator and simulate
Extended Dependencies
---------------------

To install extended dependencies for reinforcement learning and testing:
To install extended dependencies for testing:

.. code-block:: bash
conda activate race
cd ~/repos/lsy_drone_racing
pip install -e .[rl, test]
pip install -e .[test]
You can then run the tests to ensure everything is working:

Expand Down
6 changes: 3 additions & 3 deletions lsy_drone_racing/envs/drone_racing_deploy_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from lsy_drone_racing.vicon import Vicon

if TYPE_CHECKING:
from munch import Munch
from ml_collections import ConfigDict
from numpy.typing import NDArray

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -70,7 +70,7 @@ class DroneRacingDeployEnv(gymnasium.Env):

CONTROLLER = "mellinger"

def __init__(self, config: dict | Munch):
def __init__(self, config: dict | ConfigDict):
"""Initialize the crazyflie drone and the motion capture system.
Args:
Expand Down Expand Up @@ -281,7 +281,7 @@ class DroneRacingAttitudeDeployEnv(DroneRacingDeployEnv):
real-world hardware (Crazyflie drone and Vicon motion capture system) instead of a simulation.
"""

def __init__(self, config: dict | Munch):
def __init__(self, config: dict | ConfigDict):
"""Initialize the crazyflie drone and the motion capture system.
Args:
Expand Down
10 changes: 5 additions & 5 deletions lsy_drone_racing/utils/ros_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
from lsy_drone_racing.vicon import Vicon

if TYPE_CHECKING:
from munch import Munch
from ml_collections import ConfigDict

logger = logging.getLogger("rosout." + __name__)


def check_race_track(config: Munch):
def check_race_track(config: ConfigDict):
"""Check if the race track's gates and obstacles are within tolerances.
Args:
Expand All @@ -33,13 +33,13 @@ def check_race_track(config: Munch):
assert rng_info.gate_pos.type == "uniform", "Race track checks expect uniform distributions"
assert rng_info.obstacle_pos.type == "uniform", "Race track checks expect uniform distributions"
for i, gate in enumerate(config.env.track.gates):
name = f"gate{i+1}"
name = f"gate{i + 1}"
gate_pos, gate_rot = vicon.pos[name], R.from_euler("xyz", vicon.rpy[name])
check_bounds(name, gate_pos, gate.pos, rng_info.gate_pos.low, rng_info.gate_pos.high)
check_rotation(name, gate_rot, R.from_euler("xyz", gate.rpy), ang_tol)

for i, obstacle in enumerate(config.env.track.obstacles):
name = f"obstacle{i+1}"
name = f"obstacle{i + 1}"
low, high = rng_info.obstacle_pos.low, rng_info.obstacle_pos.high
check_bounds(name, vicon.pos[name][:2], obstacle.pos[:2], low[:2], high[:2])

Expand All @@ -66,7 +66,7 @@ def check_rotation(name: str, actual_rot: R, desired_rot: R, ang_tol: float):
raise RuntimeError(f"{name} exceeds rotation tolerances ({ang_tol})")


def check_drone_start_pos(config: Munch):
def check_drone_start_pos(config: ConfigDict):
"""Check if the real drone start position matches the settings.
Args:
Expand Down
2 changes: 1 addition & 1 deletion lsy_drone_racing/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def load_config(path: Path) -> ConfigDict:
path: Path to the config file.
Returns:
The munchified config dict.
The configuration.
"""
assert path.exists(), f"Configuration file not found: {path}"
assert path.suffix == ".toml", f"Configuration file has to be a TOML file: {path}"
Expand Down
2 changes: 1 addition & 1 deletion lsy_drone_racing/vicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(
... # ROS node is already running which is fine for us
self.drone_name = None
self.auto_track_drone = auto_track_drone
if auto_track_drone:
if auto_track_drone: # TODO: Remove crazyswarm dependency
with open(get_ros_package_path("crazyswarm") / "launch/crazyflies.yaml", "r") as f:
config = yaml.load(f, yaml.SafeLoader)
assert len(config["crazyflies"]) == 1, "Only one crazyfly allowed at a time!"
Expand Down
12 changes: 4 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,18 @@ classifiers = [

dependencies = [
"fire >= 0.6.0",
"munch >= 4.0.0",
"numpy >= 1.24.1, < 2.0.0",
"pandas >= 2.0.3",
"pybullet >= 3.2.6",
"PyYAML >= 6.0.1",
"rospkg >= 1.5.1",
"PyYAML >= 6.0.1", # TODO: Remove after removing crazyswarm dependency
"rospkg >= 1.5.1", # TODO: Remove after moving to cflib
"scipy >= 1.10.1",
"gymnasium >= 1.0.0",
"toml >= 0.10.2",
"casadi >= 3.6.5",
"ml_collections >= 1.0",
]

[project.optional-dependencies]
test = ["pytest>=8.0.0"]
rl = ["stable-baselines3"]

online_submission = ["pandas", "kaggle"]

[tool.setuptools.packages]
find = {}
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Usage:
python deploy.py <path/to/controller.py> <path/to/config.yaml>
python deploy.py <path/to/controller.py> <path/to/config.toml>
"""

Expand Down
4 changes: 2 additions & 2 deletions scripts/multi_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from lsy_drone_racing.utils import load_config, load_controller

if TYPE_CHECKING:
from munch import Munch
from ml_collections import ConfigDict

from lsy_drone_racing.control.controller import BaseController
from lsy_drone_racing.envs.multi_drone_race import MultiDroneRacingEnv
Expand Down Expand Up @@ -105,7 +105,7 @@ def simulate(
env.close()


def log_episode_stats(obs: dict, info: dict, config: Munch, curr_time: float):
def log_episode_stats(obs: dict, info: dict, config: ConfigDict, curr_time: float):
"""Log the statistics of a single episode."""
gates_passed = obs["target_gate"]
finished = gates_passed == -1
Expand Down
4 changes: 2 additions & 2 deletions scripts/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from lsy_drone_racing.utils import load_config, load_controller

if TYPE_CHECKING:
from munch import Munch
from ml_collections import ConfigDict

from lsy_drone_racing.control.controller import BaseController
from lsy_drone_racing.envs.drone_race import DroneRaceEnv
Expand Down Expand Up @@ -103,7 +103,7 @@ def simulate(
return ep_times


def log_episode_stats(obs: dict, info: dict, config: Munch, curr_time: float):
def log_episode_stats(obs: dict, info: dict, config: ConfigDict, curr_time: float):
"""Log the statistics of a single episode."""
gates_passed = obs["target_gate"]
if gates_passed == -1: # The drone has passed the final gate
Expand Down

0 comments on commit 35e2064

Please sign in to comment.