Skip to content

Commit

Permalink
Make sure AMRs are up before sending task
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <[email protected]>
  • Loading branch information
luca-della-vedova committed Dec 18, 2024
1 parent 4e83aa3 commit 4fe4811
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions nexus_integration_tests/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<depend>rclcpp_components</depend>
<depend>rclcpp_lifecycle</depend>
<depend>rclpy</depend>
<depend>rmf_fleet_msgs</depend>
<depend>std_srvs</depend>
<depend>tf2_ros</depend>
<depend>yaml-cpp</depend>
Expand Down
9 changes: 9 additions & 0 deletions nexus_integration_tests/ros_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import rclpy.node
from lifecycle_msgs.msg import State
from lifecycle_msgs.srv import GetState
from rmf_fleet_msgs.msg import RobotState

T = TypeVar("T", bound="RosTestCase")

Expand Down Expand Up @@ -102,6 +103,14 @@ def wait_for_nodes(self, *nodes: Sequence[str]):
time.sleep(0.1)
undiscovered.difference_update(self.node.get_node_names())

async def wait_for_robot_state(self):
fut = rclpy.Future()
sub = self.node.create_subscription(
RobotState, "/robot_state", fut.set_result, 10
)
result = await fut
self.assertIsNotNone(result)

async def ros_sleep(self, secs: float):
"""
async sleep using ros timers
Expand Down
2 changes: 2 additions & 0 deletions nexus_integration_tests/test_pick_and_place.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ async def asyncSetUp(self):
print("all workcells are ready")
await self.wait_for_transporters("transporter_node")
print("all transporters are ready")
await self.wait_for_robot_state()
print("AMRs are ready")

# give some time for discovery to happen
await self.ros_sleep(5)
Expand Down

0 comments on commit 4fe4811

Please sign in to comment.