diff --git a/example_1/package.xml b/example_1/package.xml index 35257c505..9776a32cf 100644 --- a/example_1/package.xml +++ b/example_1/package.xml @@ -35,9 +35,9 @@ xacro ament_cmake_pytest + controller_manager launch_testing_ros liburdfdom-tools - ros2_control_demo_testing xacro diff --git a/example_1/test/test_rrbot_launch.py b/example_1/test/test_rrbot_launch.py index 30fa7467e..aaeb91785 100644 --- a/example_1/test/test_rrbot_launch.py +++ b/example_1/test/test_rrbot_launch.py @@ -41,7 +41,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_1/test/test_rrbot_launch_cli_direct.py b/example_1/test/test_rrbot_launch_cli_direct.py index 0aa14fabb..5e8b5441d 100644 --- a/example_1/test/test_rrbot_launch_cli_direct.py +++ b/example_1/test/test_rrbot_launch_cli_direct.py @@ -41,7 +41,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import check_controllers_running +from controller_manager.test_utils import check_controllers_running # Executes the given launch file and checks if all nodes can be started diff --git a/example_10/package.xml b/example_10/package.xml index 8943501fe..8d25965ba 100644 --- a/example_10/package.xml +++ b/example_10/package.xml @@ -34,9 +34,9 @@ xacro ament_cmake_pytest + controller_manager launch_testing_ros liburdfdom-tools - ros2_control_demo_testing xacro diff --git a/example_10/test/test_rrbot_launch.py b/example_10/test/test_rrbot_launch.py index e9df25da7..d5b140bb6 100644 --- a/example_10/test/test_rrbot_launch.py +++ b/example_10/test/test_rrbot_launch.py @@ -39,7 +39,7 @@ from launch_testing.actions import ReadyToTest import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_11/package.xml b/example_11/package.xml index 27e00444d..352744a04 100644 --- a/example_11/package.xml +++ b/example_11/package.xml @@ -33,9 +33,9 @@ xacro ament_cmake_pytest + controller_manager launch_testing_ros liburdfdom-tools - ros2_control_demo_testing xacro diff --git a/example_11/test/test_carlikebot_launch.py b/example_11/test/test_carlikebot_launch.py index 1afb4ff33..f7e4472e0 100644 --- a/example_11/test/test_carlikebot_launch.py +++ b/example_11/test/test_carlikebot_launch.py @@ -40,7 +40,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_12/package.xml b/example_12/package.xml index 1982b1591..1a7021578 100644 --- a/example_12/package.xml +++ b/example_12/package.xml @@ -35,9 +35,9 @@ xacro ament_cmake_pytest + controller_manager launch_testing_ros liburdfdom-tools - ros2_control_demo_testing xacro diff --git a/example_12/test/test_rrbot_launch.py b/example_12/test/test_rrbot_launch.py index 5abbec91a..91f7c853a 100644 --- a/example_12/test/test_rrbot_launch.py +++ b/example_12/test/test_rrbot_launch.py @@ -41,7 +41,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_13/package.xml b/example_13/package.xml index 9e0af6f60..843a77ed4 100644 --- a/example_13/package.xml +++ b/example_13/package.xml @@ -32,13 +32,13 @@ ament_cmake_pytest ament_cmake_ros + controller_manager launch_ros launch_testing_ament_cmake launch_testing launch liburdfdom-tools rclpy - ros2_control_demo_testing xacro diff --git a/example_13/test/test_three_robots_launch.py b/example_13/test/test_three_robots_launch.py index eaaa12ac1..f4cb45f8a 100644 --- a/example_13/test/test_three_robots_launch.py +++ b/example_13/test/test_three_robots_launch.py @@ -40,7 +40,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_14/package.xml b/example_14/package.xml index 6c9672bb0..69d4b9f33 100644 --- a/example_14/package.xml +++ b/example_14/package.xml @@ -32,9 +32,9 @@ xacro ament_cmake_pytest + controller_manager launch_testing_ros liburdfdom-tools - ros2_control_demo_testing xacro diff --git a/example_14/test/test_rrbot_modular_actuators_without_feedback_sensors_for_position_feedback_launch.py b/example_14/test/test_rrbot_modular_actuators_without_feedback_sensors_for_position_feedback_launch.py index b26ee3a40..3f296d4b9 100644 --- a/example_14/test/test_rrbot_modular_actuators_without_feedback_sensors_for_position_feedback_launch.py +++ b/example_14/test/test_rrbot_modular_actuators_without_feedback_sensors_for_position_feedback_launch.py @@ -40,7 +40,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_15/package.xml b/example_15/package.xml index b4594cb17..45bcd917f 100644 --- a/example_15/package.xml +++ b/example_15/package.xml @@ -30,9 +30,9 @@ xacro ament_cmake_pytest + controller_manager launch_testing_ros liburdfdom-tools - ros2_control_demo_testing xacro diff --git a/example_15/test/test_multi_controller_manager_launch.py b/example_15/test/test_multi_controller_manager_launch.py index a78cfdc78..77919c9fb 100644 --- a/example_15/test/test_multi_controller_manager_launch.py +++ b/example_15/test/test_multi_controller_manager_launch.py @@ -40,7 +40,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_15/test/test_rrbot_namespace_launch.py b/example_15/test/test_rrbot_namespace_launch.py index 702be9d52..ce6e32181 100644 --- a/example_15/test/test_rrbot_namespace_launch.py +++ b/example_15/test/test_rrbot_namespace_launch.py @@ -40,7 +40,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_2/package.xml b/example_2/package.xml index 54c8f0876..eb2ffc33a 100644 --- a/example_2/package.xml +++ b/example_2/package.xml @@ -34,9 +34,9 @@ xacro ament_cmake_pytest + controller_manager launch_testing_ros liburdfdom-tools - ros2_control_demo_testing xacro diff --git a/example_2/test/test_diffbot_launch.py b/example_2/test/test_diffbot_launch.py index d84de296a..b76acf3de 100644 --- a/example_2/test/test_diffbot_launch.py +++ b/example_2/test/test_diffbot_launch.py @@ -40,7 +40,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_3/package.xml b/example_3/package.xml index 289e9979b..7a9d140d0 100644 --- a/example_3/package.xml +++ b/example_3/package.xml @@ -34,9 +34,9 @@ xacro ament_cmake_pytest + controller_manager launch_testing_ros liburdfdom-tools - ros2_control_demo_testing xacro diff --git a/example_3/test/test_rrbot_system_multi_interface_launch.py b/example_3/test/test_rrbot_system_multi_interface_launch.py index 9b5529654..9d9670d30 100644 --- a/example_3/test/test_rrbot_system_multi_interface_launch.py +++ b/example_3/test/test_rrbot_system_multi_interface_launch.py @@ -40,7 +40,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_4/package.xml b/example_4/package.xml index 0f5ed8a8f..3e3c6faa3 100644 --- a/example_4/package.xml +++ b/example_4/package.xml @@ -33,9 +33,9 @@ xacro ament_cmake_pytest + controller_manager launch_testing_ros liburdfdom-tools - ros2_control_demo_testing xacro diff --git a/example_4/test/test_rrbot_system_with_sensor_launch.py b/example_4/test/test_rrbot_system_with_sensor_launch.py index 9e5001654..600538df5 100644 --- a/example_4/test/test_rrbot_system_with_sensor_launch.py +++ b/example_4/test/test_rrbot_system_with_sensor_launch.py @@ -40,7 +40,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_5/package.xml b/example_5/package.xml index 4e20d02be..fe272299b 100644 --- a/example_5/package.xml +++ b/example_5/package.xml @@ -33,9 +33,9 @@ xacro ament_cmake_pytest + controller_manager launch_testing_ros liburdfdom-tools - ros2_control_demo_testing xacro diff --git a/example_5/test/test_rrbot_system_with_external_sensor_launch.py b/example_5/test/test_rrbot_system_with_external_sensor_launch.py index e965d5ace..057b98876 100644 --- a/example_5/test/test_rrbot_system_with_external_sensor_launch.py +++ b/example_5/test/test_rrbot_system_with_external_sensor_launch.py @@ -40,7 +40,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_6/package.xml b/example_6/package.xml index 0e08490fe..fb0ac64a7 100644 --- a/example_6/package.xml +++ b/example_6/package.xml @@ -32,9 +32,9 @@ xacro ament_cmake_pytest + controller_manager launch_testing_ros liburdfdom-tools - ros2_control_demo_testing xacro diff --git a/example_6/test/test_rrbot_modular_actuators_launch.py b/example_6/test/test_rrbot_modular_actuators_launch.py index 3e8a5e9d4..20cc42c33 100644 --- a/example_6/test/test_rrbot_modular_actuators_launch.py +++ b/example_6/test/test_rrbot_modular_actuators_launch.py @@ -40,7 +40,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_7/package.xml b/example_7/package.xml index ef7fb3b2c..6f19fa150 100644 --- a/example_7/package.xml +++ b/example_7/package.xml @@ -41,9 +41,9 @@ xacro ament_cmake_pytest + controller_manager launch_testing_ros liburdfdom-tools - ros2_control_demo_testing xacro diff --git a/example_7/test/test_r6bot_controller_launch.py b/example_7/test/test_r6bot_controller_launch.py index 968f789f1..ca131d4bc 100644 --- a/example_7/test/test_r6bot_controller_launch.py +++ b/example_7/test/test_r6bot_controller_launch.py @@ -40,7 +40,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_8/package.xml b/example_8/package.xml index 1e6c6ac06..8fae190dd 100644 --- a/example_8/package.xml +++ b/example_8/package.xml @@ -35,9 +35,9 @@ xacro ament_cmake_pytest + controller_manager launch_testing_ros liburdfdom-tools - ros2_control_demo_testing xacro diff --git a/example_8/test/test_rrbot_transmissions_system_position_only_launch.py b/example_8/test/test_rrbot_transmissions_system_position_only_launch.py index a16f4d7a7..18791d97a 100644 --- a/example_8/test/test_rrbot_transmissions_system_position_only_launch.py +++ b/example_8/test/test_rrbot_transmissions_system_position_only_launch.py @@ -40,7 +40,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/example_9/package.xml b/example_9/package.xml index 2e401b563..2190ea67f 100644 --- a/example_9/package.xml +++ b/example_9/package.xml @@ -37,9 +37,9 @@ xacro ament_cmake_pytest + controller_manager launch_testing_ros liburdfdom-tools - ros2_control_demo_testing xacro diff --git a/example_9/test/test_rrbot_launch.py b/example_9/test/test_rrbot_launch.py index 6817f0e03..20283a590 100644 --- a/example_9/test/test_rrbot_launch.py +++ b/example_9/test/test_rrbot_launch.py @@ -40,7 +40,7 @@ # import launch_testing.markers import rclpy -from ros2_control_demo_testing.test_utils import ( +from controller_manager.test_utils import ( check_controllers_running, check_if_js_published, check_node_running, diff --git a/ros2_control_demo_testing/package.xml b/ros2_control_demo_testing/package.xml deleted file mode 100644 index bc16dcf4a..000000000 --- a/ros2_control_demo_testing/package.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - ros2_control_demo_testing - 0.0.0 - Utilities for launch testing - Christoph Froehlich - Apache-2.0 - - sensor_msgs - launch_testing_ros - controller_manager - - - ament_python - - diff --git a/ros2_control_demo_testing/resource/ros2_control_demo_testing b/ros2_control_demo_testing/resource/ros2_control_demo_testing deleted file mode 100644 index e69de29bb..000000000 diff --git a/ros2_control_demo_testing/ros2_control_demo_testing/__init__.py b/ros2_control_demo_testing/ros2_control_demo_testing/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/ros2_control_demo_testing/ros2_control_demo_testing/test_utils.py b/ros2_control_demo_testing/ros2_control_demo_testing/test_utils.py deleted file mode 100644 index e23ca7bc8..000000000 --- a/ros2_control_demo_testing/ros2_control_demo_testing/test_utils.py +++ /dev/null @@ -1,106 +0,0 @@ -# Copyright (c) 2024 AIT - Austrian Institute of Technology GmbH -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of the {copyright_holder} nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# Author: Christoph Froehlich - -import time - -from launch_testing_ros import WaitForTopics -from sensor_msgs.msg import JointState -from controller_manager.controller_manager_services import list_controllers - - -def check_node_running(node, node_name, timeout=5.0): - - start = time.time() - found = False - while time.time() - start < timeout and not found: - found = node_name in node.get_node_names() - time.sleep(0.1) - assert found, f"{node_name} not found!" - - -def check_controllers_running(node, cnames, namespace="", state="active"): - - # wait for controller to be loaded before we call the CM services - found = {cname: False for cname in cnames} # Define 'found' as a dictionary - start = time.time() - # namespace is either "/" (empty) or "/ns" if set - if namespace: - namespace_api = namespace - if not namespace_api.startswith("/"): - namespace_api = "/" + namespace_api - if namespace.endswith("/"): - namespace_api = namespace_api[:-1] - else: - namespace_api = "/" - - while time.time() - start < 10.0 and not all(found.values()): - node_names_namespaces = node.get_node_names_and_namespaces() - for cname in cnames: - if any(name == cname and ns == namespace_api for name, ns in node_names_namespaces): - found[cname] = True - time.sleep(0.1) - assert all( - found.values() - ), f"Controller node(s) not found: {', '.join(['ns: ' + namespace_api + ', ctrl:' + cname for cname, is_found in found.items() if not is_found])}, but seeing {node.get_node_names_and_namespaces()}" - - found = {cname: False for cname in cnames} # Define 'found' as a dictionary - start = time.time() - # namespace is either "/" (empty) or "/ns" if set - if not namespace: - cm = "controller_manager" - else: - if namespace.endswith("/"): - cm = namespace + "controller_manager" - else: - cm = namespace + "/controller_manager" - while time.time() - start < 10.0 and not all(found.values()): - controllers = list_controllers(node, cm, 5.0).controller - assert controllers, "No controllers found!" - for c in controllers: - for cname in cnames: - if c.name == cname and c.state == state: - found[cname] = True - break - time.sleep(0.1) - - assert all( - found.values() - ), f"Controller(s) not found or not {state}: {', '.join([cname for cname, is_found in found.items() if not is_found])}" - - -def check_if_js_published(topic, joint_names): - wait_for_topics = WaitForTopics([(topic, JointState)], timeout=20.0) - assert wait_for_topics.wait(), f"Topic '{topic}' not found!" - msgs = wait_for_topics.received_messages(topic) - msg = msgs[0] - assert len(msg.name) == len(joint_names), "Wrong number of joints in message" - # use a set to compare the joint names, as the order might be different - assert set(msg.name) == set(joint_names), "Wrong joint names" - wait_for_topics.shutdown() diff --git a/ros2_control_demo_testing/setup.cfg b/ros2_control_demo_testing/setup.cfg deleted file mode 100644 index 5d0f85421..000000000 --- a/ros2_control_demo_testing/setup.cfg +++ /dev/null @@ -1,4 +0,0 @@ -[develop] -script_dir=$base/lib/ros2_control_demo_testing -[install] -install_scripts=$base/lib/ros2_control_demo_testing diff --git a/ros2_control_demo_testing/setup.py b/ros2_control_demo_testing/setup.py deleted file mode 100644 index 62f25ff4e..000000000 --- a/ros2_control_demo_testing/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright (c) 2024 AIT - Austrian Institute of Technology GmbH -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of the {copyright_holder} nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# Author: Christoph Froehlich - -from setuptools import find_packages, setup - -package_name = "ros2_control_demo_testing" - -setup( - name=package_name, - version="0.0.0", - packages=find_packages(exclude=["test"]), - data_files=[ - ("share/ament_index/resource_index/packages", ["resource/" + package_name]), - ("share/" + package_name, ["package.xml"]), - ], - install_requires=["setuptools"], - zip_safe=True, - maintainer="Christoph Froehlich", - maintainer_email="christoph.froehlich@ait.ac.at", - description="Utilities for launch testing", - license="Apache-2.0", - tests_require=["pytest"], - entry_points={ - "console_scripts": [], - }, -) diff --git a/ros2_control_demos.jazzy.repos b/ros2_control_demos.jazzy.repos index 8ba0dc2c1..4185c8b75 100644 --- a/ros2_control_demos.jazzy.repos +++ b/ros2_control_demos.jazzy.repos @@ -10,7 +10,7 @@ repositories: ros2_control: type: git url: https://github.com/ros-controls/ros2_control.git - version: master + version: add/test_utils ros2_controllers: type: git url: https://github.com/ros-controls/ros2_controllers.git diff --git a/ros2_control_demos.rolling.repos b/ros2_control_demos.rolling.repos index 7eba4e042..cc68c01e1 100644 --- a/ros2_control_demos.rolling.repos +++ b/ros2_control_demos.rolling.repos @@ -10,7 +10,7 @@ repositories: ros2_control: type: git url: https://github.com/ros-controls/ros2_control.git - version: master + version: add/test_utils ros2_controllers: type: git url: https://github.com/ros-controls/ros2_controllers.git