Skip to content

Commit 81b7b9c

Browse files
authored
tool_contact_test: Check result status directly (backport of #1345) (#1353)
Re-using the goal handle seems to be flaky.
1 parent fe78fb4 commit 81b7b9c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

ur_robot_driver/test/integration_test_tool_contact.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import sys
3232
import time
3333
import unittest
34+
import logging
3435

3536
import pytest
3637

@@ -131,10 +132,20 @@ def test_deactivate_controller_aborts_action(self):
131132
deactivate_controllers=["tool_contact_controller"],
132133
).ok
133134
)
134-
# Wait for action to finish
135-
self._tool_contact_interface.get_result(goal_handle, 5)
136-
# Check status of goal handle, as result does not contain information about the status of the action. Only the empty result definition.
137-
self.assertEqual(goal_handle._status, GoalStatus.STATUS_ABORTED)
135+
future_res = goal_handle.get_result_async()
136+
137+
timeout = 5.0
138+
logging.info("Waiting for action result from controller with timeout %fs", timeout)
139+
rclpy.spin_until_future_complete(self.node, future_res, timeout_sec=timeout)
140+
141+
if future_res.result() is not None:
142+
logging.info(" Received result: %s", future_res.result().result)
143+
# Check status of goal handle, as result does not contain information about the status of the action. Only the empty result definition.
144+
self.assertEqual(future_res.result().status, GoalStatus.STATUS_ABORTED)
145+
else:
146+
raise Exception(
147+
f"Exception while calling action '{self.__action_name}': {future_res.exception()}"
148+
)
138149

139150
def test_inactive_controller_rejects_actions(self):
140151
self.assertTrue(

0 commit comments

Comments
 (0)