ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

API to know if a node is alive?

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

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 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

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

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 -0500 )edit

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

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

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

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 -0500 )edit

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


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

Seen: 5,974 times

Last updated: Jan 16 '13