Skip to content

Commit b6d367f

Browse files
committed
Fix ceiling error
1 parent 8ccf9c9 commit b6d367f

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.vscode/
22
**.egg-info/
33
**/__pycache__/
4-
submission.csv
4+
submission.csv
5+
logs

examples/controller.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,10 @@ def __init__(
124124

125125
tck, u = interpolate.splprep([waypoints[:, 0], waypoints[:, 1], waypoints[:, 2]], s=0.1)
126126
self.waypoints = waypoints
127-
duration = 16
127+
duration = 12
128128
t = np.linspace(0, 1, int(duration * self.CTRL_FREQ))
129129
self.ref_x, self.ref_y, self.ref_z = interpolate.splev(t, tck)
130+
assert max(self.ref_z) < 2.5, "Drone must stay below the ceiling"
130131

131132
if self.VERBOSE:
132133
# Draw the trajectory on PyBullet's GUI.

scripts/deploy.py

+5-17
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
def create_init_info(
33-
env_info: dict, gate_poses: list, obstacle_poses: list, constraint_values: list
33+
env_info: dict, gate_poses: list, obstacle_poses: list, constraint_values: list, x_reference: list
3434
) -> dict:
3535
"""Create the initial information dictionary for the controller.
3636
@@ -53,7 +53,7 @@ def create_init_info(
5353
init_info = {
5454
"symbolic_model": env_info["symbolic_model"],
5555
"nominal_physical_parameters": physical_params,
56-
"x_reference": [-0.5, 0.0, 2.9, 0.0, 0.75, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
56+
"x_reference": [x_reference[0], 0.0, x_reference[1], 0.0, x_reference[2], 0.0] + [0.0] * 6,
5757
"u_reference": [0.084623, 0.084623, 0.084623, 0.084623],
5858
"symbolic_constraints": env_info["symbolic_constraints"],
5959
"ctrl_timestep": 1 / 30,
@@ -136,8 +136,9 @@ def main(config: str = "config/getting_started.yaml", controller: str = "example
136136
drone_rot_and_agl_vel = [vicon.rpy["cf"][0], vicon.rpy["cf"][1], vicon.rpy["cf"][2], 0, 0, 0]
137137
env.state = drone_pos_and_vel + drone_rot_and_agl_vel
138138
constraint_values = env.constraints.get_values(env, only_state=True)
139+
x_reference = config.quadrotor_config.task_info.stabilization_goal
139140

140-
init_info = create_init_info(env_info, gate_poses, obstacle_poses, constraint_values)
141+
init_info = create_init_info(env_info, gate_poses, obstacle_poses, constraint_values, x_reference)
141142

142143
CTRL_FREQ = init_info["ctrl_freq"]
143144

@@ -194,17 +195,8 @@ def main(config: str = "config/getting_started.yaml", controller: str = "example
194195
target_gate_id = -1
195196
at_goal_time = time.time()
196197

197-
# TODO: Clean this up
198198
if target_gate_id == -1:
199199
goal_pos = np.array([env.X_GOAL[0], env.X_GOAL[2], env.X_GOAL[4]])
200-
goal_dist = np.linalg.norm(vicon.pos["cf"][0:3] - goal_pos)
201-
print(f"{time.time() - at_goal_time:.4}s and {goal_dist}m away")
202-
if goal_dist >= 0.15:
203-
print(f"First hit goal position in {curr_time:.4}s")
204-
at_goal_time = time.time()
205-
elif time.time() - at_goal_time > 2:
206-
print(f"Task Completed in {curr_time:.4}s")
207-
completed = True
208200

209201
# Get the latest vicon observation and call the controller
210202
p = vicon.pos["cf"]
@@ -219,13 +211,9 @@ def main(config: str = "config/getting_started.yaml", controller: str = "example
219211
apply_command(cf, command_type, args) # Send the command to the drone controller
220212
time_helper.sleepForRate(CTRL_FREQ)
221213

222-
if completed:
214+
if command_type == Command.FINISHED or completed:
223215
break
224216

225-
# Land does not wait for the drone to actually land, so we have to wait manually
226-
cf.land(0, 3)
227-
time_helper.sleep(3.5)
228-
229217
# Save the commands for logging
230218
save_dir = Path(__file__).resolve().parents[1] / "logs"
231219
save_dir.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)