From 303f0b1b9bcb634a4a249fbd9ddedd1d3326be64 Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Thu, 5 Sep 2024 01:32:14 -0700 Subject: [PATCH] node name print bug fix with ros2 action info. (#926) Signed-off-by: Tomoya Fujita --- ros2action/ros2action/api/__init__.py | 2 +- .../test/fixtures/fibonacci_action_server.py | 2 +- ros2action/test/test_cli.py | 30 ++++++++++--------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/ros2action/ros2action/api/__init__.py b/ros2action/ros2action/api/__init__.py index d0bf18d67..42e23171c 100644 --- a/ros2action/ros2action/api/__init__.py +++ b/ros2action/ros2action/api/__init__.py @@ -34,7 +34,7 @@ def get_action_clients_and_servers(*, node, action_name): node_names_and_ns = node.get_node_names_and_namespaces() for node_name, node_ns in node_names_and_ns: # Construct fully qualified name - node_fqn = '/'.join(node_ns) + node_name + node_fqn = '/'.join([node_ns, node_name]) # Get any action clients associated with the node client_names_and_types = node.get_action_client_names_and_types_by_node( diff --git a/ros2action/test/fixtures/fibonacci_action_server.py b/ros2action/test/fixtures/fibonacci_action_server.py index 396685d17..7c32dd87c 100644 --- a/ros2action/test/fixtures/fibonacci_action_server.py +++ b/ros2action/test/fixtures/fibonacci_action_server.py @@ -23,7 +23,7 @@ class FibonacciActionServer(Node): def __init__(self): - super().__init__('fibonacci_action_server') + super().__init__('fibonacci_action_server', namespace='/test') self._action_server = ActionServer( self, Fibonacci, diff --git a/ros2action/test/test_cli.py b/ros2action/test/test_cli.py index affda6d4d..62c2df542 100644 --- a/ros2action/test/test_cli.py +++ b/ros2action/test/test_cli.py @@ -146,15 +146,15 @@ def test_info_on_nonexistent_action(self): @launch_testing.markers.retry_on_failure(times=5, delay=1) def test_fibonacci_info(self): - with self.launch_action_command(arguments=['info', '/fibonacci']) as action_command: + with self.launch_action_command(arguments=['info', '/test/fibonacci']) as action_command: assert action_command.wait_for_shutdown(timeout=10) assert action_command.exit_code == launch_testing.asserts.EXIT_OK assert launch_testing.tools.expect_output( expected_lines=[ - 'Action: /fibonacci', + 'Action: /test/fibonacci', 'Action clients: 0', 'Action servers: 1', - ' /fibonacci_action_server' + ' /test/fibonacci_action_server' ], text=action_command.output, strict=False @@ -162,15 +162,16 @@ def test_fibonacci_info(self): @launch_testing.markers.retry_on_failure(times=5, delay=1) def test_fibonacci_info_with_types(self): - with self.launch_action_command(arguments=['info', '-t', '/fibonacci']) as action_command: + with self.launch_action_command( + arguments=['info', '-t', '/test/fibonacci']) as action_command: assert action_command.wait_for_shutdown(timeout=10) assert action_command.exit_code == launch_testing.asserts.EXIT_OK assert launch_testing.tools.expect_output( expected_lines=[ - 'Action: /fibonacci', + 'Action: /test/fibonacci', 'Action clients: 0', 'Action servers: 1', - ' /fibonacci_action_server [test_msgs/action/Fibonacci]' + ' /test/fibonacci_action_server [test_msgs/action/Fibonacci]' ], text=action_command.output, strict=False @@ -178,12 +179,13 @@ def test_fibonacci_info_with_types(self): @launch_testing.markers.retry_on_failure(times=5, delay=1) def test_fibonacci_info_count(self): - with self.launch_action_command(arguments=['info', '-c', '/fibonacci']) as action_command: + with self.launch_action_command( + arguments=['info', '-c', '/test/fibonacci']) as action_command: assert action_command.wait_for_shutdown(timeout=10) assert action_command.exit_code == launch_testing.asserts.EXIT_OK assert launch_testing.tools.expect_output( expected_lines=[ - 'Action: /fibonacci', + 'Action: /test/fibonacci', 'Action clients: 0', 'Action servers: 1', ], @@ -197,7 +199,7 @@ def test_list(self): assert action_command.wait_for_shutdown(timeout=10) assert action_command.exit_code == launch_testing.asserts.EXIT_OK assert launch_testing.tools.expect_output( - expected_lines=['/fibonacci'], + expected_lines=['/test/fibonacci'], text=action_command.output, strict=True ) @@ -208,7 +210,7 @@ def test_list_with_types(self): assert action_command.wait_for_shutdown(timeout=10) assert action_command.exit_code == launch_testing.asserts.EXIT_OK assert launch_testing.tools.expect_output( - expected_lines=['/fibonacci [test_msgs/action/Fibonacci]'], + expected_lines=['/test/fibonacci [test_msgs/action/Fibonacci]'], text=action_command.output, strict=True ) @@ -223,7 +225,7 @@ def test_list_count(self): @launch_testing.markers.retry_on_failure(times=5, delay=1) def test_type(self): - with self.launch_action_command(arguments=['type', '/fibonacci']) as action_command: + with self.launch_action_command(arguments=['type', '/test/fibonacci']) as action_command: assert action_command.wait_for_shutdown(timeout=10) assert action_command.exit_code == launch_testing.asserts.EXIT_OK assert launch_testing.tools.expect_output( @@ -238,7 +240,7 @@ def test_find(self): assert action_command.wait_for_shutdown(timeout=10) assert action_command.exit_code == launch_testing.asserts.EXIT_OK assert launch_testing.tools.expect_output( - expected_lines=['/fibonacci'], + expected_lines=['/test/fibonacci'], text=action_command.output, strict=True ) @@ -257,7 +259,7 @@ def test_send_fibonacci_goal(self): with self.launch_action_command( arguments=[ 'send_goal', - '/fibonacci', + '/test/fibonacci', 'test_msgs/action/Fibonacci', '{order: 5}' ], @@ -275,7 +277,7 @@ def test_send_fibonacci_goal_with_feedback(self): arguments=[ 'send_goal', '-f', - '/fibonacci', + '/test/fibonacci', 'test_msgs/action/Fibonacci', '{order: 5}' ],