"rosservice list" and "info" from c++
How can I access to the functions of "rosservice" from a c++? I need to know the existing services and information about each service. Thanks
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
How can I access to the functions of "rosservice" from a c++? I need to know the existing services and information about each service. Thanks
A simple way might be to call rosservice.
Alternatively you can use the ROS Master API. In this case getSystemState.
Probably in roscpp? This might help: http://docs.ros.org/hydro/api/roscpp/html/namespaceros_1_1master.html
With this code, you can get the name of all the running services and copy them to an array.
ros::init(argc, argv, "node");
ros::NodeHandle n;
XmlRpc::XmlRpcValue req = "/node";
XmlRpc::XmlRpcValue res;
XmlRpc::XmlRpcValue pay;
if (ros::ok() == true)
{
ros::master::execute("getSystemState",req ,res ,pay ,true);
std::string state[res.size()];
for(int x=0 ; x<res[2][2].size() ; x++)
{
std::string gh = res[2][2][x][0].toXml().c_str();
gh.erase(gh.begin(), gh.begin()+7);
gh.erase(gh.end()-8, gh.end());
state[x] = gh;
}
}
Asked: 2014-04-10 04:42:34 -0600
Seen: 1,208 times
Last updated: Apr 13 '14