Skip to content

Commit

Permalink
Test whether the driver advertises all ROS2 interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanscherzinger committed Jul 22, 2024
1 parent 83adb99 commit 43af5b5
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
2 changes: 1 addition & 1 deletion schunk_egu_egk_gripper_driver/launch/schunk.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def generate_launch_description():
package="schunk_egu_egk_gripper_driver",
plugin="SchunkGripperNode",
name="schunk_gripper_driver",
namespace="EGK_50_M_B",
namespace="",
parameters=[
{"IP": LaunchConfiguration("IP")},
{"port": LaunchConfiguration("port")},
Expand Down
2 changes: 1 addition & 1 deletion schunk_egu_egk_gripper_tests/test/test_http_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ def test_driver_connnects_to_gripper_dummy(launch_context, isolated, gripper_dum
timeout = 3

time.sleep(until_dummy_ready)
assert CheckTopic("/EGK_50_M_B/joint_states", JointState).event.wait(timeout)
assert CheckTopic("/joint_states", JointState).event.wait(timeout)
59 changes: 59 additions & 0 deletions schunk_egu_egk_gripper_tests/test/test_ros_interfaces.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python3
import pytest
from rclpy.node import Node
import time
from test.conftest import launch_description


def check_each_in(elements: list, node_method: str) -> None:
node = Node("test")
until_ready = 2.0 # sec
time.sleep(until_ready)
existing = getattr(node, node_method)()
advertised = [i[0] for i in existing]
for element in elements:
assert element in advertised


@pytest.mark.launch(fixture=launch_description)
def test_driver_advertices_all_relevant_topics(launch_context, isolated, gripper_dummy):
topic_list = [
"/diagnostics",
"/joint_states",
"/state",
]
check_each_in(topic_list, "get_topic_names_and_types")


@pytest.mark.launch(fixture=launch_description)
def test_driver_advertices_all_relevant_services(
launch_context, isolated, gripper_dummy
):
service_list = [
"/acknowledge",
"/brake_test",
"/fast_stop",
"/gripper_info",
"/prepare_for_shutdown",
"/reconnect",
"/release_for_manual_movement",
"/softreset",
"/stop",
]
check_each_in(service_list, "get_service_names_and_types")


@pytest.mark.launch(fixture=launch_description)
def test_driver_advertices_all_relevant_actions(
launch_context, isolated, gripper_dummy
):
action_list = [
"/grip",
"/grip_with_position",
"/gripper_control",
"/move_to_absolute_position",
"/move_to_relative_position",
"/release_workpiece",
]
action_list = [a + "/_action/status" for a in action_list]
check_each_in(action_list, "get_topic_names_and_types")

0 comments on commit 43af5b5

Please sign in to comment.