Can a ros node do the equivalent of 'rosnode ping'
Is there a way (hopefully in rospy) do something like 'rosnode ping' natively? I want to check if another node is running.
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
Is there a way (hopefully in rospy) do something like 'rosnode ping' natively? I want to check if another node is running.
Yes, but its probably a bad idea to code this sort of logic into your nodes. The intent of an anon pub/sub system is to not know what other nodes are running. That way you can freely interchange bags, alternate implementations, etc... Instead, test for the data/state you want to see, rather than the nodes you want to see.
For how to do the ping operation, simply read the source of rosnode. It requires making outbound XMLRPC calls, so it is a 'slow' operation.
Please see the API overview docs: http://ros.org/wiki/rospy/Overview/Names%20and%20Node%20Information
You can use rosnode_ping_all() or rosnode_ping()
import rosnode
alive_nodes, unpinged_nodes = rosnode.rosnode_ping_all()
rosnode.rosnode_ping(node, max_count=5)
you can find the documentation of the rosnode module here
Asked: 2012-03-06 05:30:23 -0600
Seen: 2,321 times
Last updated: Jun 03 '22