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 imagemaero ( 2014-09-30 11:31:27 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
5

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

tbh 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 imageMac ( 2013-01-16 05:50:49 -0500 )edit

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

lucasw gravatar imagelucasw ( 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 imagethinwybk ( 2018-05-29 10:59:53 -0500 )edit

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

thinwybk gravatar imagethinwybk ( 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

Stats

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

Seen: 3,448 times

Last updated: Jan 16 '13