"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
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;
}
}
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2014-04-10 04:42:34 -0500
Seen: 659 times
Last updated: Apr 13 '14
Using rosservice across multiple machines [closed]
Setting camera image publisher for 100 Mbit/s transfer
programmatically load yaml parameters in C
C++ How to set a callback to point to a non-static member function of an object instance?
How to convert Float 64 to Double?
How to publish two different messages at a time.