Skip to content

Commit 60d92f8

Browse files
committed
Add time logging to deploy script
1 parent 381d47a commit 60d92f8

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

scripts/deploy.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@
3030

3131

3232
def create_init_info(
33-
env_info: dict, gate_poses: list, obstacle_poses: list, constraint_values: list, x_reference: list
33+
env_info: dict,
34+
gate_poses: list,
35+
obstacle_poses: list,
36+
constraint_values: list,
37+
x_reference: list,
3438
) -> dict:
3539
"""Create the initial information dictionary for the controller.
3640
@@ -39,6 +43,7 @@ def create_init_info(
3943
gate_poses: The list of gate poses.
4044
obstacle_poses: The list of obstacle poses.
4145
constraint_values: The values of the environment constraints evaluated at the start state.
46+
x_reference: The reference state for the controller to stabilize the drone after the race.
4247
"""
4348
gate_dimensions_low = {"shape": "square", "height": 0.525, "edge": 0.45}
4449
gate_dimensions_tall = {"shape": "square", "height": 1.0, "edge": 0.45}
@@ -138,7 +143,9 @@ def main(config: str = "config/getting_started.yaml", controller: str = "example
138143
constraint_values = env.constraints.get_values(env, only_state=True)
139144
x_reference = config.quadrotor_config.task_info.stabilization_goal
140145

141-
init_info = create_init_info(env_info, gate_poses, obstacle_poses, constraint_values, x_reference)
146+
init_info = create_init_info(
147+
env_info, gate_poses, obstacle_poses, constraint_values, x_reference
148+
)
142149

143150
CTRL_FREQ = init_info["ctrl_freq"]
144151

@@ -156,6 +163,7 @@ def main(config: str = "config/getting_started.yaml", controller: str = "example
156163
try:
157164
# Run the main control loop
158165
start_time = time.time()
166+
total_time = None
159167
while not time_helper.isShutdown():
160168
curr_time = time.time() - start_time
161169

@@ -193,10 +201,7 @@ def main(config: str = "config/getting_started.yaml", controller: str = "example
193201

194202
if target_gate_id == len(gate_poses): # Reached the end
195203
target_gate_id = -1
196-
at_goal_time = time.time()
197-
198-
if target_gate_id == -1:
199-
goal_pos = np.array([env.X_GOAL[0], env.X_GOAL[2], env.X_GOAL[4]])
204+
total_time = time.time() - start_time
200205

201206
# Get the latest vicon observation and call the controller
202207
p = vicon.pos["cf"]
@@ -214,6 +219,7 @@ def main(config: str = "config/getting_started.yaml", controller: str = "example
214219
if command_type == Command.FINISHED or completed:
215220
break
216221

222+
logger.info(f"Total time: {total_time:.3f}s" if total_time else "Task not completed")
217223
# Save the commands for logging
218224
save_dir = Path(__file__).resolve().parents[1] / "logs"
219225
save_dir.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)