30
30
31
31
32
32
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 ,
34
38
) -> dict :
35
39
"""Create the initial information dictionary for the controller.
36
40
@@ -39,6 +43,7 @@ def create_init_info(
39
43
gate_poses: The list of gate poses.
40
44
obstacle_poses: The list of obstacle poses.
41
45
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.
42
47
"""
43
48
gate_dimensions_low = {"shape" : "square" , "height" : 0.525 , "edge" : 0.45 }
44
49
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
138
143
constraint_values = env .constraints .get_values (env , only_state = True )
139
144
x_reference = config .quadrotor_config .task_info .stabilization_goal
140
145
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
+ )
142
149
143
150
CTRL_FREQ = init_info ["ctrl_freq" ]
144
151
@@ -156,6 +163,7 @@ def main(config: str = "config/getting_started.yaml", controller: str = "example
156
163
try :
157
164
# Run the main control loop
158
165
start_time = time .time ()
166
+ total_time = None
159
167
while not time_helper .isShutdown ():
160
168
curr_time = time .time () - start_time
161
169
@@ -193,10 +201,7 @@ def main(config: str = "config/getting_started.yaml", controller: str = "example
193
201
194
202
if target_gate_id == len (gate_poses ): # Reached the end
195
203
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
200
205
201
206
# Get the latest vicon observation and call the controller
202
207
p = vicon .pos ["cf" ]
@@ -214,6 +219,7 @@ def main(config: str = "config/getting_started.yaml", controller: str = "example
214
219
if command_type == Command .FINISHED or completed :
215
220
break
216
221
222
+ logger .info (f"Total time: { total_time :.3f} s" if total_time else "Task not completed" )
217
223
# Save the commands for logging
218
224
save_dir = Path (__file__ ).resolve ().parents [1 ] / "logs"
219
225
save_dir .mkdir (parents = True , exist_ok = True )
0 commit comments