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

Can a ros node do the equivalent of 'rosnode ping'

asked 2012-03-06 05:30:23 -0600

Murph gravatar image

Is there a way (hopefully in rospy) do something like 'rosnode ping' natively? I want to check if another node is running.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2012-03-06 05:35:19 -0600

kwc gravatar image

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.

edit flag offensive delete link more

Comments

1

Thanks for the answer. Yeah, this is not a good idea generally, but it makes sense for my project.

Murph gravatar image Murph  ( 2012-03-07 08:29:12 -0600 )edit

As a follow-up, can a node figure out it's actual name? (If it was created with anonymous=True).

Murph gravatar image Murph  ( 2012-03-07 08:30:18 -0600 )edit
kwc gravatar image kwc  ( 2012-03-07 09:46:09 -0600 )edit
0

answered 2022-06-03 06:06:37 -0600

mohamed ahmed gravatar image

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

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2012-03-06 05:30:23 -0600

Seen: 2,321 times

Last updated: Jun 03 '22