Ask Your Question

checking another node from node with rosnode package

asked 2020-08-29 01:19:35 -0500

Ray_Shim gravatar image

updated 2020-08-29 01:25:43 -0500

Hi guys.

I want to check whether another node exist or not. I really want to use 'rosnode_ping(). (that is in rosnode package). But it doesn't work. Terminal said there is no rosnode_ping.

I think i should add some header or modify cmake file. If there is anyone who is useing rosnode package. Could i get some advice?

or if there is another way to check node, it will be great, too.

rosnode api and package link :

Thanks for your interest, Ray.

/home/raptor/nav_ws/src/patrol_and_tracking/src/manager.cpp:19:34: error: ‘rosnode_ping’ was not declared in this scope
patrol_and_tracking/CMakeFiles/manager.dir/build.make:62: recipe for target 'patrol_and_tracking/CMakeFiles/manager.dir/src/manager.cpp.o' failed
make[2]: *** [patrol_and_tracking/CMakeFiles/manager.dir/src/manager.cpp.o] Error 1
CMakeFiles/Makefile2:28967: recipe for target 'patrol_and_tracking/CMakeFiles/manager.dir/all' failed
make[1]: *** [patrol_and_tracking/CMakeFiles/manager.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-08-29 11:08:52 -0500

dtyugin gravatar image

updated 2020-08-29 11:10:24 -0500

As far as I know there is no such API for c++. rosnode package just a python script. You can try to implement c++ version of what python code in rosnode package is doing. Probably there is more elegant solution which I don't know.

  1. Get node URI.
  2. Establish TCP connection with this URI using tcp socket. If connection was established in some time (100 ms for local execution, more time if you are using remote access) then node is ok. Otherwise it is fail.

You can get node uri using XML RPC call. You should provide node name which you want to ping.

XmlRpc::XmlRpcValue args, result, payload;
args[0] =  ros::this_node::getName();
args[1] =  std::string(nodename.toStdString());
if(ros::ok() && ros::master::check())
    if (!ros::master::execute("lookupNode", args, result, payload, true))
             //parse payload here, it's a string containing host and port and some other stuff
edit flag offensive delete link more

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: 2020-08-29 01:19:35 -0500

Seen: 145 times

Last updated: Aug 29 '20