Call getPid to obtain node pid via XMLRPC in C++
I am trying to get the process IDs for all ROS nodes via the getPid
ROS Slave API. I have been able to run the following:
XmlRpc::XmlRpcValue args, result, payload;
args[0] = "name of some node";
ros::master::execute("getPid", args, result, payload, true);
Unfortunately, this snippet appears to return the pid of rosmaster, and is independent of the args value I pass in.
I tried creating my own XmlRpc::XmlRpcClient
instance with master host and port but different URIs. I cannot figure out how to get access to node URIs. If I do get them, I am not convinced that my approach works
std::string method = "getPid";
XmlRpc::XmlRpcClient* c = ros::XMLRPCManager::instance()->getXMLRPCClient(master_host, master_port, uri);
c->execute(method.c_str(), request, response);
Has anyone been successful here in the past? I found the following Python approach, but would very much like to do it in C++. I am using kinetic.
Thanks