ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

"rosservice list" and "info" from c++

asked 2014-04-10 04:42:34 -0600

Bastbeat gravatar image

updated 2016-10-24 08:36:48 -0600

ngrennan gravatar image

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

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-04-10 08:55:42 -0600

dornhege gravatar image

A simple way might be to call rosservice.

Alternatively you can use the ROS Master API. In this case getSystemState.

edit flag offensive delete link more


are there some examples of that?

Bastbeat gravatar image Bastbeat  ( 2014-04-10 11:18:51 -0600 )edit
dornhege gravatar image dornhege  ( 2014-04-11 08:52:06 -0600 )edit

Thanks, I posted the solution. Your link was really usefull.

Bastbeat gravatar image Bastbeat  ( 2014-04-13 03:18:21 -0600 )edit

But, how can I get information about a service?

Bastbeat gravatar image Bastbeat  ( 2014-04-13 04:19:50 -0600 )edit

answered 2014-04-13 03:12:11 -0600

Bastbeat gravatar image

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;
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



Asked: 2014-04-10 04:42:34 -0600

Seen: 946 times

Last updated: Apr 13 '14