ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I don't know how about C++/roscpp, but in node.js (using rosnodejs) this is relative straightforward:
const rosnodejs = require('rosnodejs');
rosnodejs.initNode('/testing').then((rosNode) => {
rosNode._node._masterApi.getSystemState().then(state => {
const s = Object.keys(state.services).find(
serviceName => serviceName.match(/^\/rviz.*save/));
const client = rosNode.serviceClient(s, 'rviz/SendFilePath');
console.log(`calling service ${s}`);
client.call({path: { data: '/tmp/rviz.rviz' }}).then( response => {
console.log('service response:', response);
rosnodejs.shutdown();
});
});
});
Output:
> node test.js
[INFO] [1603735888.341] (ros): Connected to master at http://localhost:11311!
calling service /rviz_1603735127814459630/save_config
service response: SendFilePathResponse { success: true }
In C++ you would presumably need to follow a similar approach, i.e., make a xmlrpc call to the ROS master API to lookup all services and then match your regex against that list. But I'm not familiar with how to do that in C++.
Hope this helps.