Skip to content

Commit

Permalink
nav2_simple_commander: use error_code and error_msg (#4341)
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Wake <[email protected]>
  • Loading branch information
aosmw committed Jun 23, 2024
1 parent da5e15a commit face00d
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def main():
elif result == TaskResult.CANCELED:
print('Inspection of shelving was canceled. Returning to start...')
elif result == TaskResult.FAILED:
print('Inspection of shelving failed! Returning to start...')
(error_code, error_msg) = navigator.getLastError()
print(f'Inspection of shelving failed!:{error_code}:{error_msg}')
print('Returning to start...')

# go back to start
initial_pose.header.stamp = navigator.get_clock().now().to_msg()
Expand Down
4 changes: 3 additions & 1 deletion nav2_simple_commander/nav2_simple_commander/demo_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ def main():
navigator.goToPose(initial_pose)

elif result == TaskResult.FAILED:
print(f'Task at {request_item_location} failed!')
(error_code, error_msg) = navigator.getLastError()
print(f'Task at {request_item_location} failed!:'
f'{error_code}:{error_msg}')
exit(-1)

while not navigator.isTaskComplete():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ def main():
elif result == TaskResult.CANCELED:
print('Recovery was canceled. Returning to start...')
elif result == TaskResult.FAILED:
print('Recovering from dead end failed! Returning to start...')
(error_code, error_msg) = navigator.getLastError()
print(f'Recovering from dead end failed!:{error_code}:{error_msg}')
print('Returning to start...')

initial_pose.header.stamp = navigator.get_clock().now().to_msg()
navigator.goToPose(initial_pose)
Expand Down
4 changes: 3 additions & 1 deletion nav2_simple_commander/nav2_simple_commander/demo_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ def main():
print('Security route was canceled, exiting.')
exit(1)
elif result == TaskResult.FAILED:
print('Security route failed! Restarting from other side...')
(error_code, error_msg) = navigator.getLastError()
print(f'Security route failed!:{error_code}:{error_msg}')
print('Restarting from other side...')

exit(0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def main():
elif result == TaskResult.CANCELED:
print('Goal was canceled!')
elif result == TaskResult.FAILED:
print('Goal failed!')
(error_code, error_msg) = navigator.getLastError()
print('Goal failed!{error_code}:{error_msg}')
else:
print('Goal has an invalid return status!')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def main():
elif result == TaskResult.CANCELED:
print('Goal was canceled!')
elif result == TaskResult.FAILED:
print('Goal failed!')
(error_code, error_msg) = navigator.getLastError()
print('Goal failed!{error_code}:{error_msg}')
else:
print('Goal has an invalid return status!')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def main():
elif result == TaskResult.CANCELED:
print('Goal was canceled!')
elif result == TaskResult.FAILED:
print('Goal failed!')
(error_code, error_msg) = navigator.getLastError()
print('Goal failed!{error_code}:{error_msg}')
else:
print('Goal has an invalid return status!')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ def main():
elif result == TaskResult.CANCELED:
print('Goal was canceled!')
elif result == TaskResult.FAILED:
print('Goal failed!')
(error_code, error_msg) = navigator.getLastError()
print('Goal failed!{error_code}:{error_msg}')
else:
print('Goal has an invalid return status!')

Expand Down
Loading

0 comments on commit face00d

Please sign in to comment.