Using Rosnode's API c++
Hi,
I work with ROS since two months and I would like to use rosnode's API.
In fact, i'm trying to create a Node that get and store the name of initiailized nodes and ping all of them.
In ordre to do that, I want to use API from rosnode as getnodenames and rosnode_ping.
So is that possible to use those API in a c++ script ? because i've tried lots of methods but none of them worked. Do I need to include a header ?
Thank you in advance for your answer
Asked by bulgrozer on 2015-05-05 08:07:21 UTC
Answers
For get_nodes_name yu can use ros::master::getNodes
. But there is no full C++ API for rosnode as it is written in python. E. g. the src of rosnode ping can be found here:
https://github.com/ros/ros_comm/blob/indigo-devel/tools/rosnode/src/rosnode/init.py#L295
But if you have to use C++ for your node it's still no problem because all rosnode methods in the end just perform plain vanilla xml_rpc calls to the Master or the node slaves. E. g. rosnode ping just performs the xml_rpc call get_pid . The ros Master and slave xml_rpc APIs are documented here:
http://wiki.ros.org/ROS/Master_Slave_APIs
http://wiki.ros.org/ROS/Master_API
http://wiki.ros.org/ROS/Slave_API
xml_rpc is available in C++, too. As an example for its usage see e. g. the the implementation of ros::master::getNodes
:
https://github.com/ros/ros_comm/blob/indigo-devel/clients/roscpp/src/libros/master.cpp#L146
Asked by Wolf on 2015-05-05 10:54:57 UTC
Comments
Sorry for answering this late and thank you a lot, I'll try to do that.
Asked by bulgrozer on 2015-05-07 04:14:30 UTC
Comments