From 35e206409adecbbf96357f327d0ccc9096007f70 Mon Sep 17 00:00:00 2001 From: Martin Schuck Date: Thu, 30 Jan 2025 23:36:11 +0100 Subject: [PATCH] Remove old dependencies. Prepare further removals --- .github/workflows/kaggle.yml | 4 +--- README.md | 2 +- docker/Deploy.Dockerfile | 4 ++-- docker/Sim.Dockerfile | 4 ++-- docs/getting_started/setup.rst | 4 ++-- lsy_drone_racing/envs/drone_racing_deploy_env.py | 6 +++--- lsy_drone_racing/utils/ros_utils.py | 10 +++++----- lsy_drone_racing/utils/utils.py | 2 +- lsy_drone_racing/vicon.py | 2 +- pyproject.toml | 12 ++++-------- scripts/deploy.py | 2 +- scripts/multi_sim.py | 4 ++-- scripts/sim.py | 4 ++-- 13 files changed, 27 insertions(+), 33 deletions(-) diff --git a/.github/workflows/kaggle.yml b/.github/workflows/kaggle.yml index 22903205..fe64b85c 100644 --- a/.github/workflows/kaggle.yml +++ b/.github/workflows/kaggle.yml @@ -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: | diff --git a/README.md b/README.md index 0d92957e..e6da75a7 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docker/Deploy.Dockerfile b/docker/Deploy.Dockerfile index 18006664..3de0ec77 100644 --- a/docker/Deploy.Dockerfile +++ b/docker/Deploy.Dockerfile @@ -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" diff --git a/docker/Sim.Dockerfile b/docker/Sim.Dockerfile index 154dc481..8e80657d 100644 --- a/docker/Sim.Dockerfile +++ b/docker/Sim.Dockerfile @@ -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"] \ No newline at end of file diff --git a/docs/getting_started/setup.rst b/docs/getting_started/setup.rst index 10b03dde..9fa0a586 100644 --- a/docs/getting_started/setup.rst +++ b/docs/getting_started/setup.rst @@ -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: diff --git a/lsy_drone_racing/envs/drone_racing_deploy_env.py b/lsy_drone_racing/envs/drone_racing_deploy_env.py index 93c41fa7..4658f6bf 100644 --- a/lsy_drone_racing/envs/drone_racing_deploy_env.py +++ b/lsy_drone_racing/envs/drone_racing_deploy_env.py @@ -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__) @@ -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: @@ -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: diff --git a/lsy_drone_racing/utils/ros_utils.py b/lsy_drone_racing/utils/ros_utils.py index 241ef9f7..4b637ae4 100644 --- a/lsy_drone_racing/utils/ros_utils.py +++ b/lsy_drone_racing/utils/ros_utils.py @@ -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: @@ -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]) @@ -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: diff --git a/lsy_drone_racing/utils/utils.py b/lsy_drone_racing/utils/utils.py index fa21f818..0d717042 100644 --- a/lsy_drone_racing/utils/utils.py +++ b/lsy_drone_racing/utils/utils.py @@ -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}" diff --git a/lsy_drone_racing/vicon.py b/lsy_drone_racing/vicon.py index 2fc8bd4d..66c5012e 100644 --- a/lsy_drone_racing/vicon.py +++ b/lsy_drone_racing/vicon.py @@ -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!" diff --git a/pyproject.toml b/pyproject.toml index a40ebcea..e3b46539 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = {} diff --git a/scripts/deploy.py b/scripts/deploy.py index eb12e9f5..cdf725f4 100644 --- a/scripts/deploy.py +++ b/scripts/deploy.py @@ -3,7 +3,7 @@ Usage: -python deploy.py +python deploy.py """ diff --git a/scripts/multi_sim.py b/scripts/multi_sim.py index 0ed8b22c..760cf08f 100644 --- a/scripts/multi_sim.py +++ b/scripts/multi_sim.py @@ -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 @@ -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 diff --git a/scripts/sim.py b/scripts/sim.py index 082e0044..945a0df7 100644 --- a/scripts/sim.py +++ b/scripts/sim.py @@ -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 @@ -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