Skip to content

Commit

Permalink
Remove update handle check, and just check individually
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
  • Loading branch information
aaronchongth committed Jan 7, 2025
1 parent ecd6521 commit 57b40e5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
21 changes: 14 additions & 7 deletions free_fleet_adapter/free_fleet_adapter/nav1_robot_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,16 +430,13 @@ def _is_navigation_done(self) -> bool:
self.update_handle.more().replan()
return False

def _check_update_handle_initialization(self):
def update(self, state: rmf_easy.RobotState):
if self.update_handle is None:
error_message = \
f'Failed to update robot {self.name}, robot adapter has ' \
'not yet been initialized with a fleet update handle.'
self.node.get_logger().error(error_message)
raise RuntimeError(error_message)

def update(self, state: rmf_easy.RobotState):
self._check_update_handle_initialization()
return

activity_identifier = None
if self.execution:
Expand Down Expand Up @@ -472,7 +469,12 @@ def _handle_navigate_to_pose(
f'[{self.replan_counts}]'
)

self._check_update_handle_initialization()
if self.update_handle is None:
error_message = \
f'Failed to replan for robot {self.name}, robot adapter ' \
'has not yet been initialized with a fleet update handle.'
self.node.get_logger().error(error_message)
return
self.update_handle.more().replan()
return

Expand All @@ -496,7 +498,12 @@ def _handle_navigate_to_pose(
f'Navigation goal {nav_goal_id} was rejected, replan '
f'count [{self.replan_counts}]'
)
self._check_update_handle_initialization()
if self.update_handle is None:
error_message = \
f'Failed to replan for robot {self.name}, robot adapter has ' \
'not yet been initialized with a fleet update handle.'
self.node.get_logger().error(error_message)
return
self.update_handle.more().replan()
self.nav_goal_id = None

Expand Down
22 changes: 15 additions & 7 deletions free_fleet_adapter/free_fleet_adapter/nav2_robot_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,13 @@ def _is_navigation_done(self) -> bool:
f'{type(e)}: {e}')
continue

def _check_update_handle_initialization(self):
def update(self, state: rmf_easy.RobotState):
if self.update_handle is None:
error_message = \
f'Failed to update robot {self.name}, robot adapter has not ' \
'yet been initialized with a fleet update handle.'
self.node.get_logger().error(error_message)
raise RuntimeError(error_message)

def update(self, state: rmf_easy.RobotState):
self._check_update_handle_initialization()
return

activity_identifier = None
if self.execution:
Expand Down Expand Up @@ -266,7 +263,12 @@ def _handle_navigate_to_pose(
f'[{self.replan_counts}]'
)

self._check_update_handle_initialization()
if self.update_handle is None:
error_message = \
f'Failed to replan for robot {self.name}, robot adapter ' \
'has not yet been initialized with a fleet update handle.'
self.node.get_logger().error(error_message)
return
self.update_handle.more().replan()
return

Expand Down Expand Up @@ -314,7 +316,13 @@ def _handle_navigate_to_pose(
f'Navigation goal {nav_goal_id} was rejected, replan '
f'count [{self.replan_counts}]'
)
self._check_update_handle_initialization()
if self.update_handle is None:
error_message = \
f'Failed to replan for robot {self.name}, robot ' \
'adapter has not yet been initialized with a fleet ' \
'update handle.'
self.node.get_logger().error(error_message)
return
self.update_handle.more().replan()
self.nav_goal_id = None
return
Expand Down

0 comments on commit 57b40e5

Please sign in to comment.