"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 | Q&A answers.ros.org |
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 -0600
Seen: 946 times
Last updated: Apr 13 '14
Migrating from ros indigo to ros kinetic, CMake can't finish the run.
Is the Tag in Package.xml redundant?
Where should I put generated Python srv
how to publish current scene in c++
How to read and writing ROS message efficient into files c++
Publishing my sensor values in binary from decimal
ROS2 how can I call a service and wait for the response from within a subscriber callback?