@@ -158,15 +158,20 @@ def navigate_to_pose(self, goal_handle: ServerGoalHandle) -> str:
158158 elif result == TaskResult .FAILED :
159159 reason = self .navigator .result_future .result ().result .error_code
160160 enum_name = decode_error_code (reason , Nav2NavigateToPose )
161- response = self .llm .invoke (
162- self .formulate_prompt (
163- f"Navigate to pose has failed with error code { enum_name } . Check the logs and provide a short summary." ,
164- str (feedback ),
165- request .pose ,
166- )
167- )
168161 action_result .success = False
169- action_result .report = response .content
162+ try :
163+ response = self .llm .invoke (
164+ self .formulate_prompt (
165+ f"Navigate to pose has failed with error code { enum_name } . Check the logs and provide a short summary." ,
166+ str (feedback ),
167+ request .pose ,
168+ )
169+ )
170+ action_result .report = response .content
171+ except Exception :
172+ action_result .report = (
173+ f"Navigate to pose has failed with error code { enum_name } "
174+ )
170175 return action_result
171176 else :
172177 action_result .success = False
@@ -213,15 +218,20 @@ def drive_on_heading(self, goal_handle: ServerGoalHandle):
213218 goal_handle .abort ()
214219 reason = self .navigator .result_future .result ().result .error_code
215220 enum_name = decode_error_code (reason , Nav2DriveOnHeading )
216- response = self .llm .invoke (
217- self .formulate_prompt (
218- f"Drive on heading has failed with error code { enum_name } . Check the logs and provide a short summary." ,
219- str (feedback ),
220- params ,
221- )
222- )
223221 action_result .success = False
224- action_result .report = response .content
222+ try :
223+ response = self .llm .invoke (
224+ self .formulate_prompt (
225+ f"Drive on heading has failed with error code { enum_name } . Check the logs and provide a short summary." ,
226+ str (feedback ),
227+ params ,
228+ )
229+ )
230+ action_result .report = response .content
231+ except Exception :
232+ action_result .report = (
233+ f"Drive on heading has failed with error code { enum_name } "
234+ )
225235 return action_result
226236 else :
227237 action_result .success = False
@@ -273,15 +283,18 @@ def spin(self, goal_handle: ServerGoalHandle):
273283 enum_name = decode_error_code (reason , Nav2Spin )
274284
275285 goal_handle .abort ()
276- response = self .llm .invoke (
277- self .formulate_prompt (
278- f"Turn (requested angle: { request .target_yaw } radians) has failed with error code { enum_name } . Check the logs and provide a short summary." ,
279- str (feedback ),
280- params ,
281- )
282- )
283286 action_result .success = False
284- action_result .report = response .content
287+ try :
288+ response = self .llm .invoke (
289+ self .formulate_prompt (
290+ f"Turn (requested angle: { request .target_yaw } radians) has failed with error code { enum_name } . Check the logs and provide a short summary." ,
291+ str (feedback ),
292+ params ,
293+ )
294+ )
295+ action_result .report = response .content
296+ except Exception :
297+ action_result .report = f"Turn (requested angle: { request .target_yaw } radians) has failed with error code { enum_name } ."
285298 return action_result
286299 else :
287300 action_result .success = False
@@ -317,15 +330,20 @@ def follow_waypoints(self, goal_handle: ServerGoalHandle):
317330 enum_name = decode_error_code (reason , Nav2Spin )
318331
319332 goal_handle .abort ()
320- response = self .llm .invoke (
321- self .formulate_prompt (
322- f"Followed waypoints has failed with error code { enum_name } . Check the logs and provide a short summary." ,
323- str (feedback ),
324- request .poses ,
325- )
326- )
327333 action_result .success = False
328- action_result .report = response .content
334+ try :
335+ response = self .llm .invoke (
336+ self .formulate_prompt (
337+ f"Followed waypoints has failed with error code { enum_name } . Check the logs and provide a short summary." ,
338+ str (feedback ),
339+ request .poses ,
340+ )
341+ )
342+ action_result .report = response .content
343+ except Exception :
344+ action_result .report = (
345+ f"Followed waypoints has failed with error code { enum_name } ."
346+ )
329347 return action_result
330348 else :
331349 action_result .success = False
0 commit comments