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

Add cbor-raw compression #351

Merged
merged 2 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
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
50 changes: 44 additions & 6 deletions build/roslib.js
Original file line number Diff line number Diff line change
Expand Up @@ -2425,6 +2425,7 @@ Ros.prototype.getActionServers = function(callback, failedCallback) {
*
* @param callback function with params:
* * topics - Array of topic names
* * types - Array of message type names
*/
Ros.prototype.getTopics = function(callback, failedCallback) {
var topicsClient = new Service({
Expand Down Expand Up @@ -2856,6 +2857,38 @@ Ros.prototype.decodeTypeDefs = function(defs) {
return decodeTypeDefsRec(defs[0], defs);
};

/**
* Retrieves list of topics and their associated type definitions.
*
* @param callback function with params:
* * topics - Array of topic names
* * types - Array of message type names
* * typedefs_full_text - Array of full definitions of message types, similar to `gendeps --cat`
*/
Ros.prototype.getTopicsAndRawTypes = function(callback, failedCallback) {
var topicsAndRawTypesClient = new Service({
ros : this,
name : '/rosapi/topics_and_raw_types',
serviceType : 'rosapi/TopicsAndRawTypes'
});

var request = new ServiceRequest();
if (typeof failedCallback === 'function'){
topicsAndRawTypesClient.callService(request,
function(result) {
callback(result);
},
function(message){
failedCallback(message);
}
);
}else{
topicsAndRawTypesClient.callService(request, function(result) {
callback(result);
});
}
};


module.exports = Ros;

Expand Down Expand Up @@ -3166,7 +3199,7 @@ var Message = require('./Message');
* * ros - the ROSLIB.Ros connection handle
* * name - the topic name, like /cmd_vel
* * messageType - the message type, like 'std_msgs/String'
* * compression - the type of compression to use, like 'png' or 'cbor'
* * compression - the type of compression to use, like 'png', 'cbor', or 'cbor-raw'
* * throttle_rate - the rate (in ms in between messages) at which to throttle the topics
* * queue_size - the queue created at bridge side for re-publishing webtopics (defaults to 100)
* * latch - latch the topic when publishing
Expand All @@ -3188,7 +3221,8 @@ function Topic(options) {

// Check for valid compression types
if (this.compression && this.compression !== 'png' &&
this.compression !== 'cbor' && this.compression !== 'none') {
this.compression !== 'cbor' && this.compression !== 'cbor-raw' &&
this.compression !== 'none') {
this.emit('warning', this.compression +
' compression is not supported. No compression will be used.');
this.compression = 'none';
Expand Down Expand Up @@ -3677,6 +3711,7 @@ var Goal = require('../actionlib/Goal');

var Service = require('../core/Service.js');
var ServiceRequest = require('../core/ServiceRequest.js');
var Topic = require('../core/Topic.js');

var Transform = require('../math/Transform');

Expand Down Expand Up @@ -3721,15 +3756,17 @@ function TFClient(options) {
this.republisherUpdateRequested = false;

// Create an Action client
this.actionClient = this.ros.ActionClient({
this.actionClient = new ActionClient({
ros : options.ros,
serverName : this.serverName,
actionName : 'tf2_web_republisher/TFSubscriptionAction',
omitStatus : true,
omitResult : true
});

// Create a Service client
this.serviceClient = this.ros.Service({
this.serviceClient = new Service({
ros: options.ros,
name: this.repubServiceName,
serviceType: 'tf2_web_republisher/RepublishTFs'
});
Expand Down Expand Up @@ -3815,7 +3852,8 @@ TFClient.prototype.processResponse = function(response) {
this.currentTopic.unsubscribe();
}

this.currentTopic = this.ros.Topic({
this.currentTopic = new Topic({
ros: this.ros,
name: response.topic_name,
messageType: 'tf2_web_republisher/TFArray'
});
Expand Down Expand Up @@ -3887,7 +3925,7 @@ TFClient.prototype.dispose = function() {

module.exports = TFClient;

},{"../actionlib/ActionClient":8,"../actionlib/Goal":10,"../core/Service.js":16,"../core/ServiceRequest.js":17,"../math/Transform":24}],29:[function(require,module,exports){
},{"../actionlib/ActionClient":8,"../actionlib/Goal":10,"../core/Service.js":16,"../core/ServiceRequest.js":17,"../core/Topic.js":20,"../math/Transform":24}],29:[function(require,module,exports){
var Ros = require('../core/Ros');
var mixin = require('../mixin');

Expand Down
4 changes: 2 additions & 2 deletions build/roslib.min.js

Large diffs are not rendered by default.

71 changes: 67 additions & 4 deletions src/core/Ros.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ Ros.prototype.setStatusLevel = function(level, id){
/**
* Retrieves Action Servers in ROS as an array of string
*
* @param callback function with params:
* * actionservers - Array of action server names
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
Ros.prototype.getActionServers = function(callback, failedCallback) {
var getActionServers = new Service({
Expand Down Expand Up @@ -193,6 +196,9 @@ Ros.prototype.getActionServers = function(callback, failedCallback) {
*
* @param callback function with params:
* * topics - Array of topic names
* * types - Array of message type names
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
Ros.prototype.getTopics = function(callback, failedCallback) {
var topicsClient = new Service({
Expand Down Expand Up @@ -221,9 +227,11 @@ Ros.prototype.getTopics = function(callback, failedCallback) {
/**
* Retrieves Topics in ROS as an array as specific type
*
* @param topicType topic type to find:
* @param topicType topic type to find
* @param callback function with params:
* * topics - Array of topic names
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
Ros.prototype.getTopicsForType = function(topicType, callback, failedCallback) {
var topicsForTypeClient = new Service({
Expand Down Expand Up @@ -256,6 +264,8 @@ Ros.prototype.getTopicsForType = function(topicType, callback, failedCallback) {
*
* @param callback - function with the following params:
* * services - array of service names
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
Ros.prototype.getServices = function(callback, failedCallback) {
var servicesClient = new Service({
Expand Down Expand Up @@ -284,9 +294,11 @@ Ros.prototype.getServices = function(callback, failedCallback) {
/**
* Retrieves list of services in ROS as an array as specific type
*
* @param serviceType service type to find:
* @param serviceType service type to find
* @param callback function with params:
* * topics - Array of service names
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
Ros.prototype.getServicesForType = function(serviceType, callback, failedCallback) {
var servicesForTypeClient = new Service({
Expand Down Expand Up @@ -320,6 +332,8 @@ Ros.prototype.getServicesForType = function(serviceType, callback, failedCallbac
* @param service name of service:
* @param callback - function with params:
* * type - String of the service type
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
Ros.prototype.getServiceRequestDetails = function(type, callback, failedCallback) {
var serviceTypeClient = new Service({
Expand Down Expand Up @@ -350,9 +364,11 @@ Ros.prototype.getServiceRequestDetails = function(type, callback, failedCallback
/**
* Retrieves a detail of ROS service request.
*
* @param service name of service:
* @param service name of service
* @param callback - function with params:
* * type - String of the service type
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
Ros.prototype.getServiceResponseDetails = function(type, callback, failedCallback) {
var serviceTypeClient = new Service({
Expand Down Expand Up @@ -385,6 +401,8 @@ Ros.prototype.getServiceResponseDetails = function(type, callback, failedCallbac
*
* @param callback - function with the following params:
* * nodes - array of node names
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
Ros.prototype.getNodes = function(callback, failedCallback) {
var nodesClient = new Service({
Expand Down Expand Up @@ -418,6 +436,8 @@ Ros.prototype.getNodes = function(callback, failedCallback) {
* * publications - array of published topic names
* * subscriptions - array of subscribed topic names
* * services - array of service names hosted
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
Ros.prototype.getNodeDetails = function(node, callback, failedCallback) {
var nodesClient = new Service({
Expand Down Expand Up @@ -450,6 +470,8 @@ Ros.prototype.getNodeDetails = function(node, callback, failedCallback) {
*
* @param callback function with params:
* * params - array of param names.
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
Ros.prototype.getParams = function(callback, failedCallback) {
var paramsClient = new Service({
Expand Down Expand Up @@ -480,6 +502,8 @@ Ros.prototype.getParams = function(callback, failedCallback) {
* @param topic name of the topic:
* @param callback - function with params:
* * type - String of the topic type
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
Ros.prototype.getTopicType = function(topic, callback, failedCallback) {
var topicTypeClient = new Service({
Expand Down Expand Up @@ -513,6 +537,8 @@ Ros.prototype.getTopicType = function(topic, callback, failedCallback) {
* @param service name of service:
* @param callback - function with params:
* * type - String of the service type
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
Ros.prototype.getServiceType = function(service, callback, failedCallback) {
var serviceTypeClient = new Service({
Expand Down Expand Up @@ -543,9 +569,11 @@ Ros.prototype.getServiceType = function(service, callback, failedCallback) {
/**
* Retrieves a detail of ROS message.
*
* @param message - String of a topic type
* @param callback - function with params:
* * details - Array of the message detail
* @param message - String of a topic type
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
Ros.prototype.getMessageDetails = function(message, callback, failedCallback) {
var messageDetailClient = new Service({
Expand Down Expand Up @@ -624,5 +652,40 @@ Ros.prototype.decodeTypeDefs = function(defs) {
return decodeTypeDefsRec(defs[0], defs);
};

/**
* Retrieves list of topics and their associated type definitions.
*
* @param callback function with params:
* * topics - Array of topic names
* * types - Array of message type names
* * typedefs_full_text - Array of full definitions of message types, similar to `gendeps --cat`
mvollrath marked this conversation as resolved.
Show resolved Hide resolved
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*
*/
Ros.prototype.getTopicsAndRawTypes = function(callback, failedCallback) {
var topicsAndRawTypesClient = new Service({
ros : this,
name : '/rosapi/topics_and_raw_types',
serviceType : 'rosapi/TopicsAndRawTypes'
});

var request = new ServiceRequest();
if (typeof failedCallback === 'function'){
topicsAndRawTypesClient.callService(request,
function(result) {
callback(result);
},
function(message){
failedCallback(message);
}
);
}else{
topicsAndRawTypesClient.callService(request, function(result) {
callback(result);
});
}
};


module.exports = Ros;
5 changes: 3 additions & 2 deletions src/core/Topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var Message = require('./Message');
* * ros - the ROSLIB.Ros connection handle
* * name - the topic name, like /cmd_vel
* * messageType - the message type, like 'std_msgs/String'
* * compression - the type of compression to use, like 'png' or 'cbor'
* * compression - the type of compression to use, like 'png', 'cbor', or 'cbor-raw'
* * throttle_rate - the rate (in ms in between messages) at which to throttle the topics
* * queue_size - the queue created at bridge side for re-publishing webtopics (defaults to 100)
* * latch - latch the topic when publishing
Expand All @@ -40,7 +40,8 @@ function Topic(options) {

// Check for valid compression types
if (this.compression && this.compression !== 'png' &&
this.compression !== 'cbor' && this.compression !== 'none') {
this.compression !== 'cbor' && this.compression !== 'cbor-raw' &&
this.compression !== 'none') {
this.emit('warning', this.compression +
' compression is not supported. No compression will be used.');
this.compression = 'none';
Expand Down