Skip to content

Commit

Permalink
Rename functions
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
  • Loading branch information
aaronchongth committed Nov 15, 2024
1 parent 8140474 commit ab6f946
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions free_fleet_adapter/free_fleet_adapter/fleet_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ def run_in_parallel(*args, **kwargs):

@parallel
def update_robot(robot: Nav2RobotAdapter):
robot_pose = robot.pose()
robot_pose = robot.get_pose()
if robot_pose is None:
robot.node.get_logger().info(f'Failed to pose of robot [{robot.name}]')
return None

state = rmf_easy.RobotState(
robot.map,
robot_pose,
robot.battery_soc
robot.get_battery_soc()
)

if robot.update_handle is None:
Expand Down
6 changes: 4 additions & 2 deletions free_fleet_adapter/free_fleet_adapter/nav2_robot_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ def _battery_state_callback(sample: zenoh.Sample):
_battery_state_callback
)

def battery_soc(self) -> float:
def get_battery_soc(self) -> float:
return self.battery_soc

def pose(self) -> Annotated[list[float], 3] | None:
def get_pose(self) -> Annotated[list[float], 3] | None:
transform = self.tf_handler.get_transform()
if transform is None:
error_message = \
Expand Down Expand Up @@ -305,6 +305,8 @@ def _handle_navigate_to_pose(
self.update_handle.more().replan()
self.nav_goal_id = None
return
except RuntimeError as e:
raise e
except Exception as e:
payload = reply.err.payload.to_string()
self.node.get_logger().error(
Expand Down
4 changes: 2 additions & 2 deletions free_fleet_adapter/free_fleet_adapter/robot_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RobotAdapter(ABC):
between 0 and 1.0.
"""
@abstractmethod
def battery_soc(self) -> float:
def get_battery_soc(self) -> float:
...

"""
Expand All @@ -39,7 +39,7 @@ def battery_soc(self) -> float:
returns None.
"""
@abstractmethod
def pose(self) -> Annotated[list[float], 3] | None:
def get_pose(self) -> Annotated[list[float], 3] | None:
...

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_non_existent_robot_pose(self):

robot_exists = False
for i in range(10):
transform = robot_adapter.pose()
transform = robot_adapter.get_pose()
if transform is not None:
robot_exists = True
break
Expand All @@ -82,7 +82,7 @@ def test_robot_pose(self):

robot_exists = False
for i in range(10):
transform = robot_adapter.pose()
transform = robot_adapter.get_pose()
if transform is not None:
robot_exists = True
break
Expand All @@ -105,7 +105,7 @@ def test_robot_battery_soc(self):
tf_buffer=tf_buffer
)

battery_soc = robot_adapter.battery_soc()
battery_soc = robot_adapter.get_battery_soc()
assert math.isclose(battery_soc, 1.0)

def test_robot_unable_to_update(self):
Expand Down Expand Up @@ -168,7 +168,7 @@ def test_robot_stop_without_command(self):
tf_buffer=tf_buffer
)
assert robot_adapter.execution is None
robot_adapter.stop()
robot_adapter.stop(None)
assert robot_adapter.execution is None
assert robot_adapter._is_navigation_done()

Expand Down

0 comments on commit ab6f946

Please sign in to comment.