Skip to content

Commit 8b46761

Browse files
committed
started writing integration tests
1 parent 947c30f commit 8b46761

File tree

6 files changed

+107
-5
lines changed

6 files changed

+107
-5
lines changed

ur_controllers/src/tool_contact_controller_parameters.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ tool_contact_controller:
44
type: string,
55
default_value: "",
66
description: "Urdf prefix of the corresponding arm"
7-
}
7+
}

ur_robot_driver/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,9 @@ if(BUILD_TESTING)
200200
TIMEOUT
201201
500
202202
)
203+
add_launch_test(test/integration_test_tool_contact.py
204+
TIMEOUT
205+
800
206+
)
203207
endif()
204208
endif()

ur_robot_driver/config/ur_controllers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ controller_manager:
3838

3939
ur_configuration_controller:
4040
type: ur_controllers/URConfigurationController
41-
41+
4242
tool_contact_controller:
4343
type: ur_controllers/ToolContactController
4444

ur_robot_driver/launch/ur_control.launch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def controller_spawner(controllers, active=True):
169169
"force_torque_sensor_broadcaster",
170170
"tcp_pose_broadcaster",
171171
"ur_configuration_controller",
172-
"tool_contact_controller"
172+
"tool_contact_controller",
173173
]
174174
controllers_inactive = [
175175
"scaled_joint_trajectory_controller",
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/env python
2+
# Copyright 2025, Universal Robots A/S
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# * Redistributions of source code must retain the above copyright
8+
# notice, this list of conditions and the following disclaimer.
9+
#
10+
# * Redistributions in binary form must reproduce the above copyright
11+
# notice, this list of conditions and the following disclaimer in the
12+
# documentation and/or other materials provided with the distribution.
13+
#
14+
# * Neither the name of the {copyright_holder} nor the names of its
15+
# contributors may be used to endorse or promote products derived from
16+
# this software without specific prior written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
# POSSIBILITY OF SUCH DAMAGE.
29+
30+
import os
31+
import sys
32+
import time
33+
import unittest
34+
35+
import pytest
36+
37+
import launch_testing
38+
import rclpy
39+
from rclpy.node import Node
40+
41+
from controller_manager_msgs.srv import SwitchController
42+
43+
from ur_msgs.action import ToolContact
44+
45+
sys.path.append(os.path.dirname(__file__))
46+
from test_common import ( # noqa: E402
47+
ControllerManagerInterface,
48+
DashboardInterface,
49+
IoStatusInterface,
50+
ActionInterface,
51+
generate_driver_test_description,
52+
)
53+
54+
TIMEOUT_EXECUTE_TRAJECTORY = 30
55+
56+
57+
@pytest.mark.launch_test
58+
@launch_testing.parametrize(
59+
"tf_prefix",
60+
[(""), ("my_ur_")],
61+
)
62+
def generate_test_description(tf_prefix):
63+
return generate_driver_test_description(tf_prefix=tf_prefix)
64+
65+
66+
class RobotDriverTest(unittest.TestCase):
67+
@classmethod
68+
def setUpClass(cls):
69+
# Initialize the ROS context
70+
rclpy.init()
71+
cls.node = Node("robot_driver_test")
72+
time.sleep(1)
73+
cls.init_robot(cls)
74+
75+
@classmethod
76+
def tearDownClass(cls):
77+
# Shutdown the ROS context
78+
cls.node.destroy_node()
79+
rclpy.shutdown()
80+
81+
def init_robot(self):
82+
self._dashboard_interface = DashboardInterface(self.node)
83+
self._controller_manager_interface = ControllerManagerInterface(self.node)
84+
self._io_status_controller_interface = IoStatusInterface(self.node)
85+
self._tool_contact_interface = ActionInterface(
86+
self.node, "/tool_contact_controller/enable_tool_contact", ToolContact
87+
)
88+
89+
def setUp(self):
90+
self._dashboard_interface.start_robot()
91+
time.sleep(1)
92+
self.assertTrue(self._io_status_controller_interface.resend_robot_program().success)
93+
94+
def test_start_tool_contact_controller(self):
95+
self.assertTrue(
96+
self._controller_manager_interface.switch_controller(
97+
strictness=SwitchController.Request.BEST_EFFORT,
98+
activate_controllers=["tool_contact_controller"],
99+
).ok
100+
)

ur_robot_driver/test/test_common.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ class IoStatusInterface(
260260
initial_services={"set_io": SetIO},
261261
services={
262262
"resend_robot_program": Trigger,
263-
"start_tool_contact": Trigger,
264-
"end_tool_contact": Trigger,
265263
},
266264
):
267265
pass

0 commit comments

Comments
 (0)