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

API to know if a node is alive?

asked 2013-01-16 01:44:28 -0600

Daniel Pinyol gravatar image

I could run a system("rosnode ping -c1 /nodeName"), but this always return return code 0. I could grep the standard output of rosnode, but it sounds quite dirty.


edit retag flag offensive close merge delete


did you manage to find out a way to do that?

maero gravatar image maero  ( 2014-09-30 11:31:27 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-01-16 04:07:11 -0600

thebyohazard gravatar image

I don't know why you're checking for existence, but if your node provides an action, you can wait for the server to start with waitForServer. You can also wait for a transform to become available with waitForTransform.

If you have other reasons, there's apparently a package, interface tester, that was designed to do this, but I can only find the tutorial, not the source. Maybe you'll have better luck finding it.

You could also use the rosnode api. It's in python, and there might be zombie nodes, but it should give you what you need.

edit flag offensive delete link more



If your node provides an action _or a service_. Or you could even have it publish on /i_am_alive...

Mac gravatar image Mac  ( 2013-01-16 05:50:49 -0600 )edit

The answer in #q164601 shows use of the rosnode api.

lucasw gravatar image lucasw  ( 2019-08-13 20:36:17 -0600 )edit

answered 2013-01-16 05:25:30 -0600

To extend on what @tbh said, if you're not using python, the internals of rosnode.rosnode_ping() shows you how pinging a node works. It's basically just doing a xmlrpc call asking for the node's PID and seeing if that succeeds.

edit flag offensive delete link more


To extend what others said: rosnode _sub_rosnode_listnodes() shows that rosnode list gets nodes ...

thinwybk gravatar image thinwybk  ( 2018-05-29 10:59:53 -0600 )edit

... via rosnode get_node_names() from the rosgraph.

thinwybk gravatar image thinwybk  ( 2018-05-29 11:00:56 -0600 )edit

Question Tools

1 follower


Asked: 2013-01-16 01:44:28 -0600

Seen: 6,585 times

Last updated: Jan 16 '13