Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ros2 service info command #703

Closed
wants to merge 1 commit into from

Conversation

schornakj
Copy link

Adds a new info verb to ros2 service, which lists the nodes that advertise clients and servers for a given service. I found that I needed a tool like this to help introspect big collections of ROS nodes, especially since some problems are really difficult to diagnose without it (for example, two nodes having service servers with the same type and topic name).

The pattern of implementation is similar to ros2 action info, and it produces similar output:

$ ros2 service info /my_service
Service:  /my_service
Service clients: 1
    /some_client_node
Service servers: 1
    /some_server_node

I modified the tests for ros2service to include a service client node in addition to the existing service server node. This required some changes to tests for other CLI tools since they have built-in assumptions about the number of nodes being run.

Signed-off-by: Joe Schornak [email protected]

@fujitatomoya
Copy link
Collaborator

@schornakj 👍 IMO, this option is worth to keep. i will have a look.

@schornakj
Copy link
Author

I'm seeing failures in the new unit tests when I run them locally that I think are caused by the output text getting mangled when it's parsed. Not sure how to resolve that right now, since these tests follow the same pattern as the other ones that deal with printed output.

FAIL: test_cli.TestROS2ServiceCLI.test_info[rmw_cyclonedds_cpp]
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/ros/rolling/lib/python3.8/site-packages/launch_testing/markers.py", line 57, in _wrapper
    return func(self, *args, **kwargs)
  File "/home/jschornak/workspaces/ros2_cli_ws/src/ros2cli/ros2service/test/test_cli.py", line 230, in test_info
    assert launch_testing.tools.expect_output(
AssertionError: assert False
 +  where False = <function expect_output at 0x7f506d5c7a60>(expected_lines=['Service: /my_ns/echo', 'Service clients: 1', '    /my_ns/echo_client', 'Service servers: 1', '    /my_ns/echo_server'], text='Service: /my_ns/echo\nService clients: 1\n    //m/y/_/n/secho_client\nService servers: 1\n    //m/y/_/n/secho_server\n', strict=True)
 +    where <function expect_output at 0x7f506d5c7a60> = <module 'launch_testing.tools' from '/opt/ros/rolling/lib/python3.8/site-packages/launch_testing/tools/__init__.py'>.expect_output
 +      where <module 'launch_testing.tools' from '/opt/ros/rolling/lib/python3.8/site-packages/launch_testing/tools/__init__.py'> = launch_testing.tools
 +    and   'Service: /my_ns/echo\nService clients: 1\n    //m/y/_/n/secho_client\nService servers: 1\n    //m/y/_/n/secho_server\n' = <launch_testing.tools.process.ProcessProxy object at 0x7f50689ec100>.output

@schornakj
Copy link
Author

@fujitatomoya Do you think it's possible for me to get this in before the feature freeze for Humble?

Right now, CI testing is failing for reasons that seem unrelated to the content of this PR, so I'm not sure how to approach resolving that.

@clalancette
Copy link
Contributor

clalancette commented Apr 6, 2022

@fujitatomoya Do you think it's possible for me to get this in before the feature freeze for Humble?

No, sorry. The feature freeze was already yesterday; we are now feature and API complete for Humble. That said, this is still valuable to get in (once freeze is lifted), and if it doesn't break API we can consider backporting it once Humble is released.

@clalancette clalancette self-assigned this Apr 21, 2022
@audrow audrow changed the base branch from master to rolling June 28, 2022 14:23
Copy link
Member

@gbiggs gbiggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending CI and tests passing.

@gbiggs
Copy link
Member

gbiggs commented Dec 29, 2022

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@schornakj schornakj mentioned this pull request Jan 2, 2023
Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ros2cli implementation conflicts with #771, probably we can merge them into one implementation, especially test scenario.

Comment on lines +30 to +35
parser.add_argument(
'-t', '--show-types', action='store_true',
help='Additionally show the service type')
parser.add_argument(
'-c', '--count', action='store_true',
help='Only display the number of service clients and service servers')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is info command, these should be always printed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ros2 topic info command always prints type and count, there is not even opt-out option.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

service_servers = []

expanded_name = expand_topic_name(service_name, node.get_name(), node.get_namespace())
validate_full_topic_name(expanded_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
validate_full_topic_name(expanded_name)
validate_full_topic_name(expanded_name,is_service=True)

@fujitatomoya
Copy link
Collaborator

i think we can come back to this PR after #771 is merged.

@Ryanf55
Copy link

Ryanf55 commented Jan 19, 2024

i think we can come back to this PR after #771 is merged.

Yay, 771 is merged!

This is a great feature and would be very handy when connecting non-ROS DDS systems to ROS based systems. Introspection is great, especially with a -v flag similar to ros2 topic -v that shows the QOS settings.

@fujitatomoya
Copy link
Collaborator

I think we can close this PR, mostly has been done with #771.

@schornakj what do you think? if you have the support -v option in mind, that requires rmw changes as well.

@fujitatomoya
Copy link
Collaborator

#877 created to follow up ros2 service info -v support for introspection.

@clalancette
Copy link
Contributor

Given the work that went into #771, and the follow-up in #877, I'm going to close this out. If you feel there is still value in some of the other work here, please feel free to open a new PR with those changes.

@clalancette clalancette closed this Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants