File tree Expand file tree Collapse file tree 3 files changed +23
-27
lines changed Expand file tree Collapse file tree 3 files changed +23
-27
lines changed Original file line number Diff line number Diff line change 4141from rclpy .node import Node
4242from sensor_msgs .msg import JointState
4343from trajectory_msgs .msg import JointTrajectory , JointTrajectoryPoint
44- from ur_dashboard_msgs .msg import RobotMode
4544from ur_msgs .msg import IOStates
4645
4746sys .path .append (os .path .dirname (__file__ ))
4847from test_common import ( # noqa: E402
49- ControllerManagerInterface ,
5048 ActionInterface ,
49+ ControllerManagerInterface ,
5150 DashboardInterface ,
5251 IoStatusInterface ,
5352 generate_driver_test_description ,
@@ -101,17 +100,7 @@ def init_robot(self):
101100 )
102101
103102 def setUp (self ):
104- # Start robot
105- self .assertTrue (self ._dashboard_interface .power_on ().success )
106- self .assertTrue (self ._dashboard_interface .brake_release ().success )
107-
108- time .sleep (1 )
109-
110- robot_mode = self ._dashboard_interface .get_robot_mode ()
111- self .assertTrue (robot_mode .success )
112- self .assertEqual (robot_mode .robot_mode .mode , RobotMode .RUNNING )
113-
114- self .assertTrue (self ._dashboard_interface .stop ().success )
103+ self ._dashboard_interface .start_robot ()
115104 time .sleep (1 )
116105 self .assertTrue (self ._io_status_controller_interface .resend_robot_program ().success )
117106
Original file line number Diff line number Diff line change 4444from launch_testing .actions import ReadyToTest
4545from rclpy .action import ActionClient
4646from std_srvs .srv import Trigger
47+ from ur_dashboard_msgs .msg import RobotMode
4748from ur_dashboard_msgs .srv import (
4849 GetLoadedProgram ,
4950 GetProgramState ,
@@ -199,7 +200,24 @@ class DashboardInterface(
199200 "stop" : Trigger ,
200201 },
201202):
202- pass
203+ def start_robot (self ):
204+ self ._check_call (self .power_on ())
205+ self ._check_call (self .brake_release ())
206+
207+ time .sleep (1 )
208+
209+ robot_mode = self .get_robot_mode ()
210+ self ._check_call (robot_mode )
211+ if robot_mode .robot_mode .mode != RobotMode .RUNNING :
212+ raise Exception (
213+ f"Incorrect robot mode: Expected { RobotMode .RUNNING } , got { robot_mode .robot_mode .mode } "
214+ )
215+
216+ self ._check_call (self .stop ())
217+
218+ def _check_call (self , result ):
219+ if not result .success :
220+ raise Exception ("Service call not successful" )
203221
204222
205223class ControllerManagerInterface (
Original file line number Diff line number Diff line change 3535import rclpy
3636import rclpy .node
3737from std_msgs .msg import String as StringMsg
38- from ur_dashboard_msgs .msg import RobotMode
3938from ur_msgs .msg import IOStates
4039
4140sys .path .append (os .path .dirname (__file__ ))
4241from test_common import ( # noqa: E402
42+ ControllerManagerInterface ,
4343 DashboardInterface ,
4444 IoStatusInterface ,
4545 generate_driver_test_description ,
46- ControllerManagerInterface ,
4746)
4847
4948ROBOT_IP = "192.168.56.101"
@@ -78,17 +77,7 @@ def init_robot(self):
7877 )
7978
8079 def setUp (self ):
81- # Start robot
82- self .assertTrue (self ._dashboard_interface .power_on ().success )
83- self .assertTrue (self ._dashboard_interface .brake_release ().success )
84-
85- time .sleep (1 )
86-
87- robot_mode = self ._dashboard_interface .get_robot_mode ()
88- self .assertTrue (robot_mode .success )
89- self .assertEqual (robot_mode .robot_mode .mode , RobotMode .RUNNING )
90-
91- self .assertTrue (self ._dashboard_interface .stop ().success )
80+ self ._dashboard_interface .start_robot ()
9281 time .sleep (1 )
9382 self .assertTrue (self ._io_status_controller_interface .resend_robot_program ().success )
9483
You can’t perform that action at this time.
0 commit comments