Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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