ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Unfortunately, I haven't found an easy way to do this through the C++ or Python API, but I've done it by scraping the output of rostopic list <topic> --verbose
.
That will show something like:
Published topics:
* <topic> [std_msgs/String] 1 publisher
Subscribed topics:
* <topic> [std_msgs/String] 1 subscriber
The number before publisher/subscriber is the number of nodes publishing to or subscribing to that topic respectively.
2 | No.2 Revision |
I'm not sure why you're implying you can't use rostopic list
from your node. Nodes can call command line tools. Unfortunately, I haven't found there doesn't seem to be a an easy easier way to do find this info through the C++ or Python API, but I've done it by scraping API. I just scrape the output of rostopic list <topic> --verbose
. in my custom nodes.
That It will show output something like:
Published topics:
* <topic> [std_msgs/String] 1 publisher
Subscribed topics:
* <topic> [std_msgs/String] 1 subscriber
The number before publisher/subscriber is the number of nodes publishing to or subscribing to that topic respectively.respectively. You can easily use regexp or simple string parsing to extract that number.