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

Alternative syntax for create Topics, Services, Params, etc #110

Merged
merged 1 commit into from
Oct 1, 2014
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
10 changes: 9 additions & 1 deletion src/RosLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var ROSLIB = this.ROSLIB || {
REVISION : '0.10.0-SNAPSHOT'
};

ROSLIB.Ros = require('./core/Ros');
var Ros = ROSLIB.Ros = require('./core/Ros');
ROSLIB.Topic = require('./core/Topic');
ROSLIB.Message = require('./core/Message');
ROSLIB.Param = require('./core/Param');
Expand Down Expand Up @@ -38,4 +38,12 @@ ROSLIB.UrdfVisual = require('./urdf/UrdfVisual');
// Add URDF types
require('object-assign')(ROSLIB, require('./urdf/UrdfTypes'));

['ActionClient', 'Param', 'Service', 'SimpleActionServer', 'Topic', 'TFClient'].forEach(function(className) {
var Class = ROSLIB[className];
Ros.prototype[className] = function(options) {
options.ros = this;
return new Class(options);
};
});

module.exports = ROSLIB;
19 changes: 19 additions & 0 deletions test/examples/tf.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,23 @@ describe('TF2 Republisher Example', function() {
done();
});
});

it('tf republisher alternative syntax', function(done) {
var ros = new ROSLIB.Ros({
url: 'ws://localhost:9090'
});

var tfClient = ros.TFClient({
fixedFrame: 'world',
angularThres: 0.01,
transThres: 0.01
});

// Subscribe to a turtle.
tfClient.subscribe('turtle1', function(tf) {
expect(tf.rotation).to.be.eql(new ROSLIB.Quaternion());
expect(tf.translation).to.be.a.instanceof(ROSLIB.Vector3);
done();
});
});
});