I recently was in the situation, that two nodes were publishing on the same topic, and I thought it might have been helpful if there was a command to find the IP address of each node in the system.
To reproduce you can run something like the following in two shells:
docker run --rm -it osrf/ros:humble-desktop ros2 run demo_nodes_cpp talker --ros-args --remap __node:=talker_1
docker run --rm -it osrf/ros:humble-desktop ros2 run demo_nodes_cpp talker --ros-args --remap __node:=talker_2
Then, we can see two nodes with different GID publish on the same topic:
$ ros2 topic info -v /chatter
Type: std_msgs/msg/String
Publisher count: 2
Node name: talker_2
Node namespace: /
Topic type: std_msgs/msg/String
Endpoint type: PUBLISHER
GID: 01.0f.70.b7.2d.00.a6.f6.01.00.00.00.00.00.12.03.00.00.00.00.00.00.00.00
QoS profile:
Reliability: RELIABLE
History (Depth): UNKNOWN
Durability: VOLATILE
Lifespan: Infinite
Deadline: Infinite
Liveliness: AUTOMATIC
Liveliness lease duration: Infinite
Node name: talker_1
Node namespace: /
Topic type: std_msgs/msg/String
Endpoint type: PUBLISHER
GID: 01.0f.eb.7d.2c.00.3b.5a.01.00.00.00.00.00.12.03.00.00.00.00.00.00.00.00
QoS profile:
Reliability: RELIABLE
History (Depth): UNKNOWN
Durability: VOLATILE
Lifespan: Infinite
Deadline: Infinite
Liveliness: AUTOMATIC
Liveliness lease duration: Infinite
Subscription count: 0
We can query info about the nodes, which isn’t really helpful to find the host the node runs on though (did I miss a verbose option?).
$ ros2 node info /talker_1
/talker_1
Subscribers:
/parameter_events: rcl_interfaces/msg/ParameterEvent
Publishers:
/chatter: std_msgs/msg/String
/parameter_events: rcl_interfaces/msg/ParameterEvent
/rosout: rcl_interfaces/msg/Log
Service Servers:
/talker_1/describe_parameters: rcl_interfaces/srv/DescribeParameters
/talker_1/get_parameter_types: rcl_interfaces/srv/GetParameterTypes
/talker_1/get_parameters: rcl_interfaces/srv/GetParameters
/talker_1/list_parameters: rcl_interfaces/srv/ListParameters
/talker_1/set_parameters: rcl_interfaces/srv/SetParameters
/talker_1/set_parameters_atomically: rcl_interfaces/srv/SetParametersAtomically
Service Clients:
Action Servers:
Action Clients:
We can find the IP addresses participating in the system by examining the discovery messages, which is helpful, but only tells part of the story:
$ sudo tcpdump -i any udp port 7400
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked v1), capture size 262144 bytes
09:41:55.548303 IP 172.17.0.3.47847 > 239.255.0.1.7400: UDP, length 308
09:41:55.548323 IP 172.17.0.3.47847 > 239.255.0.1.7400: UDP, length 308
09:41:55.548327 IP 172.17.0.3.47847 > 239.255.0.1.7400: UDP, length 308
09:41:57.362414 IP 172.17.0.2.35195 > 239.255.0.1.7400: UDP, length 308
09:41:57.362447 IP 172.17.0.2.35195 > 239.255.0.1.7400: UDP, length 308
09:41:57.362454 IP 172.17.0.2.35195 > 239.255.0.1.7400: UDP, length 308
09:41:58.548465 IP 172.17.0.3.47847 > 239.255.0.1.7400: UDP, length 308
09:41:58.548491 IP 172.17.0.3.47847 > 239.255.0.1.7400: UDP, length 308
09:41:58.548504 IP 172.17.0.3.47847 > 239.255.0.1.7400: UDP, length 308
09:42:00.362493 IP 172.17.0.2.35195 > 239.255.0.1.7400: UDP, length 308
09:42:00.362517 IP 172.17.0.2.35195 > 239.255.0.1.7400: UDP, length 308
09:42:00.362522 IP 172.17.0.2.35195 > 239.255.0.1.7400: UDP, length 308
^C
12 packets captured
16 packets received by filter
0 packets dropped by kernel
Is there a way to query that info already (from the DDS maybe)? If not, I’d like to feature request it for some kind of ros2 node info --verbose
output (maybe with a query by GID in case node names collide). I already skimmed through ros2cli but I didn’t find any obvious approach to add this myself.
Any suggestions, remarks or opinions regarding this feature?
For reference:
- Related question which received only little attention so far: [ROS2] How can I find out which host is running a node? - ROS Answers: Open Source Q&A Forum
- In ROS 1 there seemed to be a workaround to query IP addresses from the roscore apparantly.