Skip to content

Commit 7a4e67f

Browse files
committed
adding prototype getNodes to ROSLIB.Ros allowing to get list of available nodes
1 parent 934a595 commit 7a4e67f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/core/Ros.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,26 @@ ROSLIB.Ros.prototype.getServices = function(callback) {
232232
});
233233
};
234234

235+
/**
236+
* Retrieves list of active node names in ROS.
237+
*
238+
* @param callback - function with the following params:
239+
* * nodes - array of node names
240+
*/
241+
ROSLIB.Ros.prototype.getNodes = function(callback) {
242+
var nodesClient = new ROSLIB.Service({
243+
ros : this,
244+
name : '/rosapi/nodes',
245+
serviceType : 'rosapi/Nodes'
246+
});
247+
248+
var request = new ROSLIB.ServiceRequest();
249+
250+
nodesClient.callService(request, function(result) {
251+
callback(result.nodes);
252+
});
253+
};
254+
235255
/**
236256
* Retrieves list of param names from the ROS Parameter Server.
237257
*

0 commit comments

Comments
 (0)