Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions rai_app/agents/moveit2_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,16 @@ def move_arm(self, request: MoveArm.Request, response: MoveArm.Response):
)
except Exception as e:
response.success = False
llm_response = self.llm.invoke(
"The arm failed to move to the position. Check the logs and provide a short summary."
+ str(e)
)
response.report = llm_response.content
try:
llm_response = self.llm.invoke(
Comment thread
knicked marked this conversation as resolved.
self.formulate_prompt(
"The arm failed to move to the position. Check the logs and provide a short summary.",
str(e),
)
)
response.report = llm_response.content
except Exception:
response.report = f"The arm failed to move to the position: {e}"
return response

if request.gripper_state == 0:
Expand All @@ -486,10 +491,15 @@ def move_arm(self, request: MoveArm.Request, response: MoveArm.Response):
except Exception as e:
self.logger.error(f"Failed to open gripper: {e}")
response.success = False
llm_response = self.llm.invoke(
self.formulate_prompt("The arm failed to open the gripper.", str(e))
)
response.report = llm_response.content
try:
llm_response = self.llm.invoke(
self.formulate_prompt(
"The arm failed to open the gripper.", str(e)
)
)
response.report = llm_response.content
except Exception:
response.report = f"The arm failed to open the gripper: {e}"
return response
elif request.gripper_state == 2:
try:
Expand All @@ -499,12 +509,15 @@ def move_arm(self, request: MoveArm.Request, response: MoveArm.Response):
except Exception as e:
self.logger.error(f"Failed to close gripper: {e}")
response.success = False
llm_response = self.llm.invoke(
self.formulate_prompt(
"The arm failed to close the gripper.", str(e)
try:
llm_response = self.llm.invoke(
self.formulate_prompt(
"The arm failed to close the gripper.", str(e)
)
)
)
response.report = llm_response.content
response.report = llm_response.content
except Exception:
response.report = f"The arm failed to open the gripper: {e}"
return response
else:
response.success = False
Expand Down
82 changes: 50 additions & 32 deletions rai_app/agents/nav2_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,20 @@ def navigate_to_pose(self, goal_handle: ServerGoalHandle) -> str:
elif result == TaskResult.FAILED:
reason = self.navigator.result_future.result().result.error_code
enum_name = decode_error_code(reason, Nav2NavigateToPose)
response = self.llm.invoke(
self.formulate_prompt(
f"Navigate to pose has failed with error code {enum_name}. Check the logs and provide a short summary.",
str(feedback),
request.pose,
)
)
action_result.success = False
action_result.report = response.content
try:
response = self.llm.invoke(
self.formulate_prompt(
f"Navigate to pose has failed with error code {enum_name}. Check the logs and provide a short summary.",
str(feedback),
request.pose,
)
)
action_result.report = response.content
except Exception:
action_result.report = (
f"Navigate to pose has failed with error code {enum_name}"
)
return action_result
else:
action_result.success = False
Expand Down Expand Up @@ -213,15 +218,20 @@ def drive_on_heading(self, goal_handle: ServerGoalHandle):
goal_handle.abort()
reason = self.navigator.result_future.result().result.error_code
enum_name = decode_error_code(reason, Nav2DriveOnHeading)
response = self.llm.invoke(
self.formulate_prompt(
f"Drive on heading has failed with error code {enum_name}. Check the logs and provide a short summary.",
str(feedback),
params,
)
)
action_result.success = False
action_result.report = response.content
try:
response = self.llm.invoke(
self.formulate_prompt(
f"Drive on heading has failed with error code {enum_name}. Check the logs and provide a short summary.",
str(feedback),
params,
)
)
action_result.report = response.content
except Exception:
action_result.report = (
f"Drive on heading has failed with error code {enum_name}"
)
return action_result
else:
action_result.success = False
Expand Down Expand Up @@ -273,15 +283,18 @@ def spin(self, goal_handle: ServerGoalHandle):
enum_name = decode_error_code(reason, Nav2Spin)

goal_handle.abort()
response = self.llm.invoke(
self.formulate_prompt(
f"Turn (requested angle: {request.target_yaw} radians) has failed with error code {enum_name}. Check the logs and provide a short summary.",
str(feedback),
params,
)
)
action_result.success = False
action_result.report = response.content
try:
response = self.llm.invoke(
self.formulate_prompt(
f"Turn (requested angle: {request.target_yaw} radians) has failed with error code {enum_name}. Check the logs and provide a short summary.",
str(feedback),
params,
)
)
action_result.report = response.content
except Exception:
action_result.report = f"Turn (requested angle: {request.target_yaw} radians) has failed with error code {enum_name}."
return action_result
else:
action_result.success = False
Expand Down Expand Up @@ -317,15 +330,20 @@ def follow_waypoints(self, goal_handle: ServerGoalHandle):
enum_name = decode_error_code(reason, Nav2Spin)

goal_handle.abort()
response = self.llm.invoke(
self.formulate_prompt(
f"Followed waypoints has failed with error code {enum_name}. Check the logs and provide a short summary.",
str(feedback),
request.poses,
)
)
action_result.success = False
action_result.report = response.content
try:
response = self.llm.invoke(
self.formulate_prompt(
f"Followed waypoints has failed with error code {enum_name}. Check the logs and provide a short summary.",
str(feedback),
request.poses,
)
)
action_result.report = response.content
except Exception:
action_result.report = (
f"Followed waypoints has failed with error code {enum_name}."
)
return action_result
else:
action_result.success = False
Expand Down
Loading