Skip to content

Commit

Permalink
Using all statuses
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <[email protected]>
  • Loading branch information
aaronchongth committed Nov 15, 2024
1 parent 60d0f5d commit fdff8bc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
42 changes: 26 additions & 16 deletions free_fleet_adapter/free_fleet_adapter/nav2_robot_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,32 @@ def _is_navigation_done(self) -> bool:
reply.ok.payload.to_bytes()
)
self.node.get_logger().debug(f'Result: {rep.status}')
if rep.status == GoalStatus.STATUS_EXECUTING.value:
return False
elif rep.status == GoalStatus.STATUS_SUCCEEDED.value:
self.node.get_logger().info(
f'Navigation goal {self.nav_goal_id} reached'
)
return True
else:
# TODO(ac): test replanning behavior if goal status is
# neither executing or succeeded
self.replan_counts += 1
self.node.get_logger().error(
f'Navigation goal {self.nav_goal_id} status '
f'{rep.status}, replan count [{self.replan_counts}]')
self.update_handle.more().replan()
return False
match rep.status:
case GoalStatus.STATUS_EXECUTING.value | \
GoalStatus.STATUS_ACCEPTED.value | \
GoalStatus.STATUS_CANCELING.value:
return False

Check warning on line 196 in free_fleet_adapter/free_fleet_adapter/nav2_robot_adapter.py

View check run for this annotation

Codecov / codecov/patch

free_fleet_adapter/free_fleet_adapter/nav2_robot_adapter.py#L196

Added line #L196 was not covered by tests
case GoalStatus.STATUS_SUCCEEDED.value:
self.node.get_logger().info(
f'Navigation goal {self.nav_goal_id} reached'
)
return True
case GoalStatus.STATUS_CANCELED.value:
self.node.get_logger().info(
f'Navigation goal {self.nav_goal_id} was cancelled'
)
return True
case _:

Check warning on line 207 in free_fleet_adapter/free_fleet_adapter/nav2_robot_adapter.py

View check run for this annotation

Codecov / codecov/patch

free_fleet_adapter/free_fleet_adapter/nav2_robot_adapter.py#L207

Added line #L207 was not covered by tests
# TODO(ac): test replanning behavior if goal status is
# neither executing or succeeded
self.replan_counts += 1
self.node.get_logger().error(

Check warning on line 211 in free_fleet_adapter/free_fleet_adapter/nav2_robot_adapter.py

View check run for this annotation

Codecov / codecov/patch

free_fleet_adapter/free_fleet_adapter/nav2_robot_adapter.py#L210-L211

Added lines #L210 - L211 were not covered by tests
f'Navigation goal {self.nav_goal_id} status '
f'{rep.status}, replan count '
f'[{self.replan_counts}]'
)
self.update_handle.more().replan()
return False

Check warning on line 217 in free_fleet_adapter/free_fleet_adapter/nav2_robot_adapter.py

View check run for this annotation

Codecov / codecov/patch

free_fleet_adapter/free_fleet_adapter/nav2_robot_adapter.py#L216-L217

Added lines #L216 - L217 were not covered by tests
except Exception as e:
self.node.get_logger().debug(
f'Received (ERROR: "{reply.err.payload.to_string()}"): '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ def test_robot_handle_navigate_to_pose(self):
except RuntimeError:
able_to_handle_navigate = False

Check warning on line 230 in free_fleet_adapter/tests/integration/test_nav2_robot_adapter.py

View check run for this annotation

Codecov / codecov/patch

free_fleet_adapter/tests/integration/test_nav2_robot_adapter.py#L229-L230

Added lines #L229 - L230 were not covered by tests
assert able_to_handle_navigate
assert not robot_adapter._is_navigation_done()
time.sleep(5)
assert robot_adapter._is_navigation_done()

Expand Down

0 comments on commit fdff8bc

Please sign in to comment.