Skip to content

Commit e8aa697

Browse files
authored
Merge branch 'development' into kd/batch_spawning
2 parents 377d7a7 + 12fc9fa commit e8aa697

6 files changed

Lines changed: 92 additions & 47 deletions

File tree

pixi.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ depends-on = ["sync"]
358358
description = "Run all linters and formatters"
359359

360360
[feature.dev.tasks.test]
361-
cmd = "uv run pytest"
361+
cmd = "PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run python -m pytest"
362362
depends-on = ["sync"]
363363
description = "Run test suite"
364364

rai_app/agents/moveit2_agent.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,16 @@ def move_arm(self, request: MoveArm.Request, response: MoveArm.Response):
468468
)
469469
except Exception as e:
470470
response.success = False
471-
llm_response = self.llm.invoke(
472-
"The arm failed to move to the position. Check the logs and provide a short summary."
473-
+ str(e)
474-
)
475-
response.report = llm_response.content
471+
try:
472+
llm_response = self.llm.invoke(
473+
self.formulate_prompt(
474+
"The arm failed to move to the position. Check the logs and provide a short summary.",
475+
str(e),
476+
)
477+
)
478+
response.report = llm_response.content
479+
except Exception:
480+
response.report = f"The arm failed to move to the position: {e}"
476481
return response
477482

478483
if request.gripper_state == 0:
@@ -486,10 +491,15 @@ def move_arm(self, request: MoveArm.Request, response: MoveArm.Response):
486491
except Exception as e:
487492
self.logger.error(f"Failed to open gripper: {e}")
488493
response.success = False
489-
llm_response = self.llm.invoke(
490-
self.formulate_prompt("The arm failed to open the gripper.", str(e))
491-
)
492-
response.report = llm_response.content
494+
try:
495+
llm_response = self.llm.invoke(
496+
self.formulate_prompt(
497+
"The arm failed to open the gripper.", str(e)
498+
)
499+
)
500+
response.report = llm_response.content
501+
except Exception:
502+
response.report = f"The arm failed to open the gripper: {e}"
493503
return response
494504
elif request.gripper_state == 2:
495505
try:
@@ -499,12 +509,15 @@ def move_arm(self, request: MoveArm.Request, response: MoveArm.Response):
499509
except Exception as e:
500510
self.logger.error(f"Failed to close gripper: {e}")
501511
response.success = False
502-
llm_response = self.llm.invoke(
503-
self.formulate_prompt(
504-
"The arm failed to close the gripper.", str(e)
512+
try:
513+
llm_response = self.llm.invoke(
514+
self.formulate_prompt(
515+
"The arm failed to close the gripper.", str(e)
516+
)
505517
)
506-
)
507-
response.report = llm_response.content
518+
response.report = llm_response.content
519+
except Exception:
520+
response.report = f"The arm failed to open the gripper: {e}"
508521
return response
509522
else:
510523
response.success = False

rai_app/agents/nav2_agent.py

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -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

rai_app/agents/tools.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,10 @@ def housekeep(self, rack: str):
887887
pos, collection_name=rack, approach_distance=self.approach_distance
888888
)
889889
except RuntimeError as e:
890+
if "arm" in str(
891+
e
892+
): # don't count moveit related exceptions as "side not available"
893+
raise e
890894
sides_not_available += 1
891895
logging.warning(e)
892896
except Exception as e:

rai_app/environment/scene_manager.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,15 @@ def clear_scene(self):
361361
timeout_sec=3.0,
362362
)
363363

364+
def reset_simulation(self):
365+
wait_for_ros2_services(self.connector, ["/reset_simulation"])
366+
self.connector.call_service(
367+
ROS2Message(payload={}),
368+
target="/reset_simulation",
369+
msg_type="simulation_interfaces/srv/ResetSimulation",
370+
timeout_sec=10.0,
371+
)
372+
364373
def move_entity(
365374
self,
366375
entity_name,

tests/test_housekeep.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,5 @@ def test_single_box_housekeeping(
7979
result = housekeep_tool._run(rack)
8080
assert "successfully" in result, f"HouseKeepTool failed: {result}"
8181
except Exception as e:
82+
scene_manager.reset_simulation()
8283
pytest.fail(f"HouseKeepTool failed: {e}")

0 commit comments

Comments
 (0)