Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New services clients #234

Merged
merged 8 commits into from
Sep 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 102 additions & 1 deletion src/core/Ros.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Ros.prototype.getTopics = function(callback, failedCallback) {
if (typeof failedCallback === 'function'){
topicsClient.callService(request,
function(result) {
callback(result.topics);
callback(result);
},
function(message){
failedCallback(message);
Expand Down Expand Up @@ -260,6 +260,72 @@ Ros.prototype.getServicesForType = function(serviceType, callback, failedCallbac
}
};

/**
* Retrieves a detail of ROS service request.
*
* @param service name of service:
* @param callback - function with params:
* * type - String of the service type
*/
Ros.prototype.getServiceRequestDetails = function(type, callback, failedCallback) {
var serviceTypeClient = new Service({
ros : this,
name : '/rosapi/service_request_details',
serviceType : 'rosapi/ServiceRequestDetails'
});
var request = new ServiceRequest({
type: type
});

if (typeof failedCallback === 'function'){
serviceTypeClient.callService(request,
function(result) {
callback(result);
},
function(message){
failedCallback(message);
}
);
}else{
serviceTypeClient.callService(request, function(result) {
callback(result);
});
}
};

/**
* Retrieves a detail of ROS service request.
*
* @param service name of service:
* @param callback - function with params:
* * type - String of the service type
*/
Ros.prototype.getServiceResponseDetails = function(type, callback, failedCallback) {
var serviceTypeClient = new Service({
ros : this,
name : '/rosapi/service_response_details',
serviceType : 'rosapi/ServiceResponseDetails'
});
var request = new ServiceRequest({
type: type
});

if (typeof failedCallback === 'function'){
serviceTypeClient.callService(request,
function(result) {
callback(result);
},
function(message){
failedCallback(message);
}
);
}else{
serviceTypeClient.callService(request, function(result) {
callback(result);
});
}
};

/**
* Retrieves list of active node names in ROS.
*
Expand Down Expand Up @@ -290,6 +356,41 @@ Ros.prototype.getNodes = function(callback, failedCallback) {
}
};

/**
* Retrieves list subscribed topics, publishing topics and services of a specific node
*
* @param node name of the node:
* @param callback - function with params:
* * publications - array of published topic names
* * subscriptions - array of subscribed topic names
* * services - array of service names hosted
*/
Ros.prototype.getNodeDetails = function(node, callback, failedCallback) {
var nodesClient = new Service({
ros : this,
name : '/rosapi/node_details',
serviceType : 'rosapi/NodeDetails'
});

var request = new ServiceRequest({
node: node
});
if (typeof failedCallback === 'function'){
nodesClient.callService(request,
function(result) {
callback(result.subscribing, result.publishing, result.services);
},
function(message) {
failedCallback(message);
}
);
} else {
nodesClient.callService(request, function(result) {
callback(result);
});
}
};

/**
* Retrieves list of param names from the ROS Parameter Server.
*
Expand Down