Skip to content

Commit 381d47a

Browse files
committed
Fix early drone crashes. Add lap termination flag
1 parent b6d367f commit 381d47a

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

config/getting_started.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ quadrotor_config:
3434
init_x_dot: 0
3535
init_y: 1.0
3636
init_y_dot: 0
37-
init_z: 0.03
37+
init_z: 0.05
3838
init_z_dot: 0
3939
init_phi: 0
4040
init_theta: 0
@@ -46,8 +46,8 @@ quadrotor_config:
4646
# Nominal (pre-randomization) positions of gates and obstacles
4747
gates:
4848
[ # x, y, z, r, p, y, type (0: `tall` obstacle, 1: `low` obstacle)
49-
[0.5, -1.0, 0, 0, 0, 2.35, 1],
50-
[1.0, -1.5, 0, 0, 0, -0.78, 0],
49+
[0.45, -1.0, 0, 0, 0, 2.35, 1],
50+
[1.0, -1.55, 0, 0, 0, -0.78, 0],
5151
[0.0, 0.5, 0, 0, 0, 0, 1],
5252
[-0.5, -0.5, 0, 0, 0, 3.14, 0]
5353
]

config/level0.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ quadrotor_config:
4040
init_x_dot: 0
4141
init_y: 1.0
4242
init_y_dot: 0
43-
init_z: 0.03
43+
init_z: 0.05
4444
init_z_dot: 0
4545
init_phi: 0
4646
init_theta: 0
@@ -52,8 +52,8 @@ quadrotor_config:
5252
# Nominal (pre-randomization) positions of gates and obstacles
5353
gates:
5454
[ # x, y, z, r, p, y, type (0: `tall` obstacle, 1: `low` obstacle)
55-
[0.5, -1.0, 0, 0, 0, 2.35, 1],
56-
[1.0, -1.5, 0, 0, 0, -0.78, 0],
55+
[0.45, -1.0, 0, 0, 0, 2.35, 1],
56+
[1.0, -1.55, 0, 0, 0, -0.78, 0],
5757
[0.0, 0.5, 0, 0, 0, 0, 1],
5858
[-0.5, -0.5, 0, 0, 0, 3.14, 0]
5959
]

config/level1.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ quadrotor_config:
4040
init_x_dot: 0
4141
init_y: 1.0
4242
init_y_dot: 0
43-
init_z: 0.03
43+
init_z: 0.05
4444
init_z_dot: 0
4545
init_phi: 0
4646
init_theta: 0
@@ -52,8 +52,8 @@ quadrotor_config:
5252
# Nominal (pre-randomization) positions of gates and obstacles
5353
gates:
5454
[ # x, y, z, r, p, y, type (0: `tall` obstacle, 1: `low` obstacle)
55-
[0.5, -1.0, 0, 0, 0, 2.35, 1],
56-
[1.0, -1.5, 0, 0, 0, -0.78, 0],
55+
[0.45, -1.0, 0, 0, 0, 2.35, 1],
56+
[1.0, -1.55, 0, 0, 0, -0.78, 0],
5757
[0.0, 0.5, 0, 0, 0, 0, 1],
5858
[-0.5, -0.5, 0, 0, 0, 3.14, 0]
5959
]

config/level2.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ quadrotor_config:
4040
init_x_dot: 0
4141
init_y: 1.0
4242
init_y_dot: 0
43-
init_z: 0.03
43+
init_z: 0.05
4444
init_z_dot: 0
4545
init_phi: 0
4646
init_theta: 0
@@ -52,8 +52,8 @@ quadrotor_config:
5252
# Nominal (pre-randomization) positions of gates and obstacles
5353
gates:
5454
[ # x, y, z, r, p, y, type (0: `tall` obstacle, 1: `low` obstacle)
55-
[0.5, -1.0, 0, 0, 0, 2.35, 1],
56-
[1.0, -1.5, 0, 0, 0, -0.78, 0],
55+
[0.45, -1.0, 0, 0, 0, 2.35, 1],
56+
[1.0, -1.55, 0, 0, 0, -0.78, 0],
5757
[0.0, 0.5, 0, 0, 0, 0, 1],
5858
[-0.5, -0.5, 0, 0, 0, 3.14, 0]
5959
]

config/level3.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ quadrotor_config:
4040
init_x_dot: 0
4141
init_y: 1.0
4242
init_y_dot: 0
43-
init_z: 0.03
43+
init_z: 0.05
4444
init_z_dot: 0
4545
init_phi: 0
4646
init_theta: 0
@@ -52,8 +52,8 @@ quadrotor_config:
5252
# Nominal (pre-randomization) positions of gates and obstacles
5353
gates:
5454
[ # x, y, z, r, p, y, type (0: `tall` obstacle, 1: `low` obstacle)
55-
[0.5, -1.0, 0, 0, 0, 2.35, 1],
56-
[1.0, -1.5, 0, 0, 0, -0.78, 0],
55+
[0.45, -1.0, 0, 0, 0, 2.35, 1],
56+
[1.0, -1.55, 0, 0, 0, -0.78, 0],
5757
[0.0, 0.5, 0, 0, 0, 0, 1],
5858
[-0.5, -0.5, 0, 0, 0, 3.14, 0]
5959
]

scripts/sim.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def simulate(
9393
obs, info = wrapped_env.reset()
9494
info["ctrl_timestep"] = CTRL_DT
9595
info["ctrl_freq"] = CTRL_FREQ
96+
lap_finished = False
9697
# obs = [x, x_dot, y, y_dot, z, z_dot, phi, theta, psi, p, q, r]
9798
vicon_obs = [obs[0], 0, obs[2], 0, obs[4], 0, obs[6], obs[7], obs[8], 0, 0, 0]
9899
ctrl = ctrl_class(vicon_obs, info, verbose=config.verbose)
@@ -135,13 +136,13 @@ def simulate(
135136
i += 1
136137
# Break early after passing the last gate (=> gate -1) or task completion
137138
if terminate_on_lap and info["current_target_gate_id"] == -1:
138-
info["task_completed"] = True
139+
info["task_completed"], lap_finished = True, True
139140
if info["task_completed"]:
140141
done = True
141142

142143
# Learn after the episode if the controller supports it
143144
ctrl.episode_learn() # Update the controller internal state and models.
144-
log_episode_stats(stats, info, config, curr_time)
145+
log_episode_stats(stats, info, config, curr_time, lap_finished)
145146
ctrl.episode_reset()
146147
# Reset the statistics
147148
stats["ep_reward"] = 0
@@ -155,14 +156,14 @@ def simulate(
155156
return ep_times
156157

157158

158-
def log_episode_stats(stats: dict, info: dict, config: Munch, curr_time: float):
159+
def log_episode_stats(stats: dict, info: dict, config: Munch, curr_time: float, lap_finished: bool):
159160
"""Log the statistics of a single episode."""
160161
stats["gates_passed"] = info["current_target_gate_id"]
161162
if stats["gates_passed"] == -1: # The drone has passed the final gate
162163
stats["gates_passed"] = len(config.quadrotor_config.gates)
163164
if config.quadrotor_config.done_on_collision and info["collision"][1]:
164165
termination = "COLLISION"
165-
elif config.quadrotor_config.done_on_completion and info["task_completed"]:
166+
elif config.quadrotor_config.done_on_completion and info["task_completed"] or lap_finished:
166167
termination = "TASK COMPLETION"
167168
elif config.quadrotor_config.done_on_violation and info["constraint_violation"]:
168169
termination = "CONSTRAINT VIOLATION"

0 commit comments

Comments
 (0)