Skip to content

Commit 4bd48da

Browse files
committed
Merge branch 'main' into mujoco
2 parents 0df29e2 + b178145 commit 4bd48da

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

.github/workflows/kaggle.yml

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ on:
1010

1111
jobs:
1212
online-competition:
13+
# Skip this job if running on the main repo to prevent failing CI/CD. Only run on student forks.
14+
if: ${{ github.repository != 'utiasDSL/lsy_drone_racing' }}
1315

1416
runs-on: ubuntu-latest
1517
env: # Or as an environment variable

lsy_drone_racing/envs/drone_racing_deploy_env.py

+19-17
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,8 @@ def close(self):
184184
)
185185
return_pos[2] = RETURN_HEIGHT
186186
self.cf.goTo(goal=return_pos, yaw=0, duration=BREAKING_DURATION)
187-
time.sleep(
188-
BREAKING_DURATION - 1
189-
) # Smoothly transition to next position by setting the next goal earlier
187+
# Smoothly transition to next position by setting the next goal earlier
188+
time.sleep(BREAKING_DURATION - 1)
190189

191190
return_pos[:2] = self.config.env.track.drone.pos[:2]
192191
self.cf.goTo(goal=return_pos, yaw=0, duration=RETURN_DURATION)
@@ -223,27 +222,30 @@ def obs(self) -> dict:
223222
obstacles_pos = np.array([o.pos for o in self.config.env.track.obstacles])
224223
obstacle_names = [f"obstacle{g}" for g in range(1, len(obstacles_pos) + 1)]
225224

225+
real_gates_pos = gates_pos
226+
real_gates_rpy = gates_rpy
227+
real_obstacles_pos = obstacles_pos
226228
# Update objects position with vicon data if not in practice mode and object
227229
# either is in range or was in range previously.
228230
if not self.config.deploy.practice_without_track_objects:
229231
real_gates_pos = np.array([self.vicon.pos[g] for g in gate_names])
230232
real_gates_rpy = np.array([self.vicon.rpy[g] for g in gate_names])
231233
real_obstacles_pos = np.array([self.vicon.pos[o] for o in obstacle_names])
232234

233-
# Use x-y distance to calucate sensor range, otherwise it would depend on the height of the drone
234-
# and obstacle how early the obstacle is in range.
235-
in_range = np.linalg.norm(real_gates_pos[:, :2] - drone_pos[:2], axis=1) < sensor_range
236-
self.gates_visited = np.logical_or(self.gates_visited, in_range)
237-
gates_pos[self.gates_visited] = real_gates_pos[self.gates_visited]
238-
gates_rpy[self.gates_visited] = real_gates_rpy[self.gates_visited]
239-
obs["gates_visited"] = in_range
240-
241-
in_range = (
242-
np.linalg.norm(real_obstacles_pos[:, :2] - drone_pos[:2], axis=1) < sensor_range
243-
)
244-
self.obstacles_visited = np.logical_or(self.obstacles_visited, in_range)
245-
obstacles_pos[self.obstacles_visited] = real_obstacles_pos[self.obstacles_visited]
246-
obs["obstacles_visited"] = in_range
235+
# Use x-y distance to calucate sensor range, otherwise it would depend on the height of the
236+
# drone and obstacle how early the obstacle is in range.
237+
in_range = np.linalg.norm(real_gates_pos[:, :2] - drone_pos[:2], axis=1) < sensor_range
238+
self.gates_visited = np.logical_or(self.gates_visited, in_range)
239+
gates_pos[self.gates_visited] = real_gates_pos[self.gates_visited]
240+
gates_rpy[self.gates_visited] = real_gates_rpy[self.gates_visited]
241+
obs["gates_visited"] = self.gates_visited
242+
print(f"gates visited: {self.gates_visited}")
243+
244+
in_range = np.linalg.norm(real_obstacles_pos[:, :2] - drone_pos[:2], axis=1) < sensor_range
245+
self.obstacles_visited = np.logical_or(self.obstacles_visited, in_range)
246+
obstacles_pos[self.obstacles_visited] = real_obstacles_pos[self.obstacles_visited]
247+
obs["obstacles_visited"] = self.obstacles_visited
248+
print(f"obs visited: {self.obstacles_visited}")
247249

248250
obs["gates_pos"] = gates_pos.astype(np.float32)
249251
obs["gates_rpy"] = gates_rpy.astype(np.float32)

0 commit comments

Comments
 (0)