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

Full nodejs support #104

Merged
merged 7 commits into from
Oct 1, 2014
Merged

Full nodejs support #104

merged 7 commits into from
Oct 1, 2014

Conversation

megawac
Copy link
Contributor

@megawac megawac commented Sep 11, 2014

Requires review and if accepted will null the need of the nodejs branch. There is a ton of small build refactorings in here so this diff is going to be difficult to process -- I recommend viewing the actual branch: https://github.com/megawac/roslibjs/tree/umd-modules

I'm still in the process of running the examples and integration....

Fixes #53


Additional install steps:

$ [sudo] apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++

@megawac
Copy link
Contributor Author

megawac commented Sep 11, 2014

I'm going to break this out into multiple commits actually and squash them down later so it's easier to process

@megawac megawac force-pushed the umd-modules branch 7 times, most recently from c6c5e06 to 7fd5113 Compare September 12, 2014 14:42
@rctoris
Copy link
Contributor

rctoris commented Sep 12, 2014

Can https://github.com/megawac/roslibjs/blob/umd-modules/CONTRIBUTING.md contain at the least the original Ubuntu specific versions of the install instructions? It used to be a quick 1-2-3 copy paste for Ubuntu devs and now its just a bunch of links.

@megawac
Copy link
Contributor Author

megawac commented Sep 12, 2014

Sure thing. Should I just add points like

  • For Ubuntu
$ sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++

@rctoris
Copy link
Contributor

rctoris commented Sep 12, 2014

Yeah, there was a weird setup point for the doc building too that is nice to have. Installing Node on Ubunutu is also non-trivial to first timers so this whole guide was pretty useful:

https://github.com/RobotWebTools/roslibjs/blob/develop/utils/README.md

@megawac
Copy link
Contributor Author

megawac commented Sep 12, 2014

@megawac megawac changed the title Full nodejs support [wip] Full nodejs support Sep 12, 2014
@rctoris
Copy link
Contributor

rctoris commented Sep 12, 2014

# Install this projects Deps
sudo npm install

Non-sudo, here yes?

@megawac
Copy link
Contributor Author

megawac commented Sep 12, 2014

Building node-canvas (for image decoding) requires install to be called with sudo. I've been debating making it an optionalDependency for that reason

It also appears some older versions of node-canvas don't require it npm i canvas-superjoe

@megawac
Copy link
Contributor Author

megawac commented Sep 12, 2014

Another option is to write a Install.sh script that supports Ubuntu/OS X

On Fri, Sep 12, 2014 at 1:14 PM, Russell Toris notifications@github.com
wrote:

Install this projects Deps

sudo npm install

Non-sudo, here yes?


Reply to this email directly or view it on GitHub
#104 (comment)
.

@megawac
Copy link
Contributor Author

megawac commented Sep 12, 2014

Another cool thing we can do with this perhaps is mix a bunch of these modules into the ROSLIB.Ros prototype enabling stuff like:

var ROSLIB = require("./");
var ros = new ROSLIB.Ros({
  url : 'ws://localhost:9090'
});
var turtles = ros.Topic({
  name: '/turtle1/pose'
});

// Instead of
var ROSLIB = require("./");
var ros = new ROSLIB.Ros({
  url : 'ws://localhost:9090'
});
var turtles = new ROSLIB.Topic({
  ros: ros,
  name: '/turtle1/pose'
});

smt like

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

@rctoris
Copy link
Contributor

rctoris commented Sep 12, 2014

I think that introduces a pretty major API change though.

@rctoris
Copy link
Contributor

rctoris commented Sep 12, 2014

Side note: var ROSLIB = require("./"); isn't necessary in the browser library, correct?

@megawac
Copy link
Contributor Author

megawac commented Sep 12, 2014

Nope. ROSLIB is exposed for the browser. On top of that if the page has an AMD library, roslibjs will be exported ontop of adding the ROSLIB global

BTW - I was suggesting that for post patch - and if that is implemented it would be backwards compatible.

@megawac megawac force-pushed the umd-modules branch 2 times, most recently from 0c1d82f to f6ca4e2 Compare September 14, 2014 02:48
@megawac
Copy link
Contributor Author

megawac commented Sep 24, 2014

Rebased --- Have been running the examples/integration_tests I've tested so far without issue. Is there anything

I've been playing around a bit further and have been using this like below:

var Ros = require("roslibjs/src/core/Ros");
var ros = new Ros(/*connect to rosbridge*/);

var navsat = ros.Topic({
  name: '/navsat/fix',
  messageType: 'sensor_msgs/NavSatFix'
});

Areas for further exploration include connecting to bridge via a TCP socket instead of a websocket (w/o impacting the clientside code), topic -> stream, some refactoring

@megawac
Copy link
Contributor Author

megawac commented Sep 24, 2014

Roslib TF example

tf

Node version -- nearly identical...

var Ros = require('../src/core/Ros');
var TFClient = require('../src/tf/TFClient');
var ros = new Ros();
ros.on('error', function(error) {
    console.log(error);
});
ros.on('connection', function() {
    console.log('Connection made!');
});
ros.on('close', function() {
    console.log('Connection closed.');
});
ros.connect('ws://localhost:9090');
var tfClient = new TFClient({
    ros : ros,
    fixedFrame : 'world',
    angularThres : 0.01,
    transThres : 0.01
});
tfClient.subscribe('turtle1', function(tf) {
    console.log(tf);
});

@megawac megawac force-pushed the umd-modules branch 7 times, most recently from e49d840 to b589698 Compare September 29, 2014 17:38
@megawac megawac changed the title [wip] Full nodejs support Full nodejs support Sep 29, 2014
@megawac
Copy link
Contributor Author

megawac commented Sep 29, 2014

Alright at this point, I'm happy with the state of things -- few others points I feel out of scope for this pr (e.g. supporting TCP connections). @rctoris any other comments?

@rctoris
Copy link
Contributor

rctoris commented Sep 29, 2014

Sorry for the delay in response! Have been on the road the past few days with limited internet access along the way. Will get back to this and the other open requests within the next day or so!!

@rctoris
Copy link
Contributor

rctoris commented Oct 1, 2014

Looks great to me! Awesome work here!!! I hated having the separate branches this is perfect.

rctoris added a commit that referenced this pull request Oct 1, 2014
@rctoris rctoris merged commit 4894b08 into RobotWebTools:develop Oct 1, 2014
@jihoonl
Copy link
Member

jihoonl commented Oct 1, 2014

👍

@jihoonl
Copy link
Member

jihoonl commented Oct 1, 2014

Looks sweet! I would like to re-release the new version in npm too. Is there any suggested way?

@jihoonl
Copy link
Member

jihoonl commented Oct 1, 2014

Once I release, I will remove nodejs branch.

@megawac
Copy link
Contributor Author

megawac commented Oct 1, 2014

Are you planning to change the package name from roslib to roslibjs?
Otherwise it should be straightforward

https://www.npmjs.org/package/roslib

@megawac megawac deleted the umd-modules branch October 1, 2014 23:31
@megawac
Copy link
Contributor Author

megawac commented Oct 27, 2014

Turns out you don't need to sudo npm install if you own your ~/.npm folder as long as you have cario and other deps installed.

chfritz added a commit to chfritz/turtles_draw that referenced this pull request Feb 7, 2016
- this is necessary to make sure all native dependencies (such as
  cairo) can be installed locally. As a meteor package on atmosphere
  we would have to publish binary builts which I don't yet know how to
  do given those third-party dependencies. The way it is now you just
  need to make sure all those dependencies are already installed on
  your machine (RobotWebTools/roslibjs#104):

  On Ubuntu:

  $ sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++

  on osx this might work (assuming you have xcode with command line tools installed):

  brew install cairo libjpeg libgif
@mklntf mklntf mentioned this pull request Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port roslibjs to work in Node.js
4 participants