5656)
5757
5858TIMEOUT_EXECUTE_TRAJECTORY = 30
59- MOCK_HARDWARE = False
60-
61- def set_mock_hardware_flag (use_mock_hardware ):
62- return use_mock_hardware == "true"
6359
6460
6561@pytest .mark .launch_test
6662@launch_testing .parametrize (
67- "tf_prefix, use_mock_hardware, mock_sensor_commands" ,
68- [("" , "false" , "false" ), ("my_ur_" , "false" , "false" ), ("" , "true" , "true" )]
63+ "tf_prefix, use_mock_hardware" , [("" , "false" ), ("my_ur_" , "false" ), ("" , "true" )]
6964)
65+ def generate_test_description (tf_prefix , use_mock_hardware ):
66+ return generate_driver_test_description (
67+ tf_prefix = tf_prefix , use_mock_hardware = use_mock_hardware
68+ )
7069
71- def generate_test_description (tf_prefix , use_mock_hardware , mock_sensor_commands ):
72- global MOCK_HARDWARE
73- MOCK_HARDWARE = set_mock_hardware_flag (use_mock_hardware )
74- return generate_driver_test_description (tf_prefix = tf_prefix , use_mock_hardware = use_mock_hardware , mock_sensor_commands = mock_sensor_commands )
7570
7671class RobotDriverTest (unittest .TestCase ):
7772 @classmethod
78- def setUpClass (cls ):
73+ def setUpClass (cls , use_mock_hardware ):
7974 # Initialize the ROS context
8075 rclpy .init ()
8176 cls .node = Node ("robot_driver_test" )
8277 time .sleep (1 )
78+ cls .mock_hardware = use_mock_hardware == "true"
8379 cls .init_robot (cls )
8480
8581 @classmethod
@@ -89,7 +85,7 @@ def tearDownClass(cls):
8985 rclpy .shutdown ()
9086
9187 def init_robot (self ):
92- if ( not MOCK_HARDWARE ) :
88+ if not self . mock_hardware :
9389 self ._dashboard_interface = DashboardInterface (self .node )
9490 else :
9591 self ._dashboard_interface = None
@@ -109,7 +105,7 @@ def init_robot(self):
109105 )
110106
111107 def setUp (self ):
112- if ( self ._dashboard_interface ) :
108+ if self ._dashboard_interface :
113109 self ._dashboard_interface .start_robot ()
114110 time .sleep (1 )
115111 self .assertTrue (self ._io_status_controller_interface .resend_robot_program ().success )
@@ -149,6 +145,8 @@ def test_start_passthrough_controller(self):
149145
150146 def test_set_io (self ):
151147 """Test to set an IO and check whether it has been set."""
148+ if self .mock_hardware :
149+ return True
152150 # Create io callback to verify result
153151 io_msg = None
154152
@@ -282,6 +280,8 @@ def test_trajectory_scaled(self, tf_prefix):
282280
283281 def test_trajectory_scaled_aborts_on_violation (self , tf_prefix ):
284282 """Test that the robot correctly aborts the trajectory when the constraints are violated."""
283+ if self .mock_hardware :
284+ return True
285285 # Construct test trajectory
286286 test_trajectory = [
287287 (Duration (sec = 6 , nanosec = 0 ), [0.0 for j in ROBOT_JOINTS ]),
@@ -361,7 +361,7 @@ def js_cb(msg):
361361 # self.node.get_logger().info("Received result GOAL_TOLERANCE_VIOLATED")
362362
363363 def test_passthrough_trajectory (self , tf_prefix ):
364- if ( MOCK_HARDWARE ) :
364+ if self . mock_hardware :
365365 return True
366366 self .assertTrue (
367367 self ._controller_manager_interface .switch_controller (
0 commit comments