30
30
31
31
32
32
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
34
34
) -> dict :
35
35
"""Create the initial information dictionary for the controller.
36
36
@@ -53,7 +53,7 @@ def create_init_info(
53
53
init_info = {
54
54
"symbolic_model" : env_info ["symbolic_model" ],
55
55
"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 ,
57
57
"u_reference" : [0.084623 , 0.084623 , 0.084623 , 0.084623 ],
58
58
"symbolic_constraints" : env_info ["symbolic_constraints" ],
59
59
"ctrl_timestep" : 1 / 30 ,
@@ -136,8 +136,9 @@ def main(config: str = "config/getting_started.yaml", controller: str = "example
136
136
drone_rot_and_agl_vel = [vicon .rpy ["cf" ][0 ], vicon .rpy ["cf" ][1 ], vicon .rpy ["cf" ][2 ], 0 , 0 , 0 ]
137
137
env .state = drone_pos_and_vel + drone_rot_and_agl_vel
138
138
constraint_values = env .constraints .get_values (env , only_state = True )
139
+ x_reference = config .quadrotor_config .task_info .stabilization_goal
139
140
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 )
141
142
142
143
CTRL_FREQ = init_info ["ctrl_freq" ]
143
144
@@ -194,17 +195,8 @@ def main(config: str = "config/getting_started.yaml", controller: str = "example
194
195
target_gate_id = - 1
195
196
at_goal_time = time .time ()
196
197
197
- # TODO: Clean this up
198
198
if target_gate_id == - 1 :
199
199
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
208
200
209
201
# Get the latest vicon observation and call the controller
210
202
p = vicon .pos ["cf" ]
@@ -219,13 +211,9 @@ def main(config: str = "config/getting_started.yaml", controller: str = "example
219
211
apply_command (cf , command_type , args ) # Send the command to the drone controller
220
212
time_helper .sleepForRate (CTRL_FREQ )
221
213
222
- if completed :
214
+ if command_type == Command . FINISHED or completed :
223
215
break
224
216
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
-
229
217
# Save the commands for logging
230
218
save_dir = Path (__file__ ).resolve ().parents [1 ] / "logs"
231
219
save_dir .mkdir (parents = True , exist_ok = True )
0 commit comments