Skip to content

Commit 5d1d942

Browse files
committed
Add thrust deploy interface. Fix kaggle deploy script
1 parent b4b5691 commit 5d1d942

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

lsy_drone_racing/envs/drone_racing_deploy_env.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,14 @@ def step(
222222
) -> tuple[dict[str, NDArray[np.floating]], float, bool, bool, dict]:
223223
"""Take a step in the environment.
224224
225-
Todo:
226-
Implement the hardware interface for collective thrust and attitude control.
227-
228225
Note:
229226
Sleeps for the remaining time if the step took less than the control period. This
230227
ensures that the environment is running at the correct frequency during deployment.
231228
"""
232-
raise NotImplementedError("Hardware interface for thrust control not yet implemented.")
233229
tstart = time.perf_counter()
234-
collective_thrust, attitude = action
235-
self.cf.cmdAttitudeThrust(collective_thrust, attitude)
230+
collective_thrust, rpy = action
231+
rpy_deg = np.rad2deg(rpy)
232+
self.cf.cmdVel(*rpy_deg, collective_thrust)
236233
if (dt := time.perf_counter() - tstart) < 1 / self.config.env.freq:
237234
rospy.sleep(1 / self.config.env.freq - dt)
238235
return self.obs, -1.0, False, False, self.info

scripts/kaggle.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,25 @@
44
Please do not alter this script or ask the course supervisors first!
55
"""
66

7+
78
import logging
9+
from pathlib import Path
810

911
import pandas as pd
1012
from sim import simulate
1113

14+
from lsy_drone_racing.utils import load_config
15+
1216
logger = logging.getLogger(__name__)
1317

1418

1519
def main():
1620
"""Run the simulation N times and save the results as 'submission.csv'."""
1721
n_runs = 10
18-
ctrl_path = "lsy_drone_racing/control/" + "trajectory_controller.py" # TODO: Load dynamically
19-
ep_times = simulate(config="config/level3.toml", controller=ctrl_path, n_runs=n_runs, gui=False)
22+
config = load_config(Path(__file__).parents[1] / "config/level3.toml")
23+
ep_times = simulate(
24+
config="level3.toml", controller=config.controller.file, n_runs=n_runs, gui=False
25+
)
2026

2127
# Log the number of failed runs if any
2228
if failed := [x for x in ep_times if x is None]:

0 commit comments

Comments
 (0)