Skip to content

Commit 133ff37

Browse files
committed
Fix flaky tests (#641)
* Move robot startup into test's setUp function * Robustify robot startup (cherry picked from commit 9088cde)
1 parent ab4e974 commit 133ff37

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

ur_robot_driver/test/robot_driver.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint
5555
from ur_msgs.msg import IOStates
5656
from ur_msgs.srv import SetIO
57+
from ur_dashboard_msgs.msg import RobotMode
58+
from ur_dashboard_msgs.srv import GetRobotMode
5759

5860
TIMEOUT_WAIT_SERVICE = 10
5961
TIMEOUT_WAIT_SERVICE_INITIAL = 60
@@ -164,6 +166,8 @@ def init_robot(self):
164166
# Connect to the rest of the required interfaces
165167
service_interfaces = {
166168
"/dashboard_client/brake_release": Trigger,
169+
"/dashboard_client/stop": Trigger,
170+
"/dashboard_client/get_robot_mode": GetRobotMode,
167171
"/controller_manager/switch_controller": SwitchController,
168172
"/io_and_status_controller/set_io": SetIO,
169173
"/io_and_status_controller/resend_robot_program": Trigger,
@@ -183,13 +187,19 @@ def init_robot(self):
183187
for (action_name, action_type) in action_interfaces.items()
184188
}
185189

190+
def setUp(self):
186191
# Start robot
187192
empty_req = Trigger.Request()
188-
self.call_service(self, "/dashboard_client/power_on", empty_req)
189-
self.call_service(self, "/dashboard_client/brake_release", empty_req)
190-
self.call_service(self, "/io_and_status_controller/resend_robot_program", empty_req)
193+
self.call_service("/dashboard_client/power_on", empty_req)
194+
self.call_service("/dashboard_client/brake_release", empty_req)
191195
time.sleep(1)
192-
self.call_service(self, "/io_and_status_controller/resend_robot_program", empty_req)
196+
robot_mode_resp = self.call_service(
197+
"/dashboard_client/get_robot_mode", GetRobotMode.Request()
198+
)
199+
self.assertEqual(robot_mode_resp.robot_mode.mode, RobotMode.RUNNING)
200+
self.call_service("/dashboard_client/stop", empty_req)
201+
time.sleep(1)
202+
self.call_service("/io_and_status_controller/resend_robot_program", empty_req)
193203

194204
#
195205
# Test functions

0 commit comments

Comments
 (0)