Skip to content

Commit

Permalink
Fix format with black
Browse files Browse the repository at this point in the history
  • Loading branch information
sktometometo committed Jun 29, 2023
1 parent 64d1123 commit 8ea1d4d
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions spot_wrapper/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1696,8 +1696,7 @@ def set_localization_waypoint(self, waypoint_id: str) -> typing.Tuple[bool, str]
return False, f"Error: {e}"

def cancel_navigation(self) -> None:
"""Cancel navigation of a robot from start_navigation()
"""
"""Cancel navigation of a robot from start_navigation()"""
self._cancel_navigate_to()

@try_claim
Expand Down Expand Up @@ -2483,10 +2482,16 @@ def _start_navigation(self, target_waypoint_id):
)

if not destination_waypoint:
self.logger.error('Failed to find waypoint %s in current graph.', target_waypoint_id)
return False, f'Failed to find waypoint {target_waypoint_id} in current graph.', "aborted"
self.logger.error(
"Failed to find waypoint %s in current graph.", target_waypoint_id
)
return (
False,
f"Failed to find waypoint {target_waypoint_id} in current graph.",
"aborted",
)

self.logger.info('Starting navigation to %s', destination_waypoint)
self.logger.info("Starting navigation to %s", destination_waypoint)

self._lease = self._lease_wallet.advance()
sublease = self._lease.create_sublease()
Expand All @@ -2501,11 +2506,11 @@ def _start_navigation(self, target_waypoint_id):
destination_waypoint,
1.0,
leases=[sublease.lease_proto],
command_id=nav_to_cmd_id
command_id=nav_to_cmd_id,
)
self._last_navigate_to_command = nav_to_cmd_id
except ResponseError as e:
self._logger.error('Error while navitation: %s', e)
self._logger.error("Error while navitation: %s", e)
break

if self._check_success(nav_to_cmd_id):
Expand All @@ -2519,13 +2524,19 @@ def _start_navigation(self, target_waypoint_id):
return False, "Navigation is canceled", "preempted"

status = self._graph_nav_client.navigation_feedback(nav_to_cmd_id)
if status.status == graph_nav_pb2.NavigationFeedbackResponse.STATUS_REACHED_GOAL:
if (
status.status
== graph_nav_pb2.NavigationFeedbackResponse.STATUS_REACHED_GOAL
):
return True, "Successfully completed the navigation commands!", "succeeded"
elif status.status == graph_nav_pb2.NavigationFeedbackResponse.STATUS_LOST:
return False, "Robot got lost when navigating the route,", "failed"
elif status.status == graph_nav_pb2.NavigationFeedbackResponse.STATUS_STUCK:
return False, "Robot got stuck when navigating the route,", "failed"
elif status.status == graph_nav_pb2.NavigationFeedbackResponse.STATUS_ROBOT_IMPAIRED:
elif (
status.status
== graph_nav_pb2.NavigationFeedbackResponse.STATUS_ROBOT_IMPAIRED
):
return False, "Robot is impaired.", "failed"
else:
return False, "Navigation command is not complete yet.", "failed"
Expand Down

0 comments on commit 8ea1d4d

Please sign in to comment.