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

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.

thanks

edit retag flag offensive close merge delete

Comments

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
6

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

Comments

1

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
3

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

Comments

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

Question Tools

1 follower

Stats

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

Seen: 6,614 times

Last updated: Jan 16 '13