ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

[ROS2] How to know which topics are related to a node without running it?

asked 2022-11-29 13:31:34 -0500

Lucivius gravatar image

Hey,

I'm just starting to learn ROS2 and I'm wondering whether it is possible to know the default topics of a node (or should I say an executable?) before you run it. Something like `ros2 node info turtlesim_node' but not having to start it first? Is there a command line tool for it?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2022-12-07 09:33:59 -0500

aarsh_t gravatar image

For ROS 2, below command should print out the lines that contains the create_publisher inside the code to the terminal and you can extract the info such as topic name topic type etc from there. this should work with python and cpp

cat <path_to_source_file> | grep "create_publisher"

For ROS1, use

cat <path_to_source_file> | grep "advertise" for cpp and cat <path_to_source_file> | grep "Publisher" for python.

edit flag offensive delete link more
0

answered 2022-12-07 08:15:26 -0500

rodrigo55 gravatar image

Hi,

You can just go into the node file and look for publishers or subscribers. It would be located somewhere like this:

~/ros2_ws/src/package/package/src/file.cpp (it can also be a Python file)

For step by step instructions, check out this video: https://youtu.be/Ny7AL2XlXmY

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-11-29 13:31:34 -0500

Seen: 492 times

Last updated: Dec 07 '22