Skip to content

Instantly share code, notes, and snippets.

@garaemon
Created March 13, 2014 12:32
Show Gist options
  • Save garaemon/9527560 to your computer and use it in GitHub Desktop.
Save garaemon/9527560 to your computer and use it in GitHub Desktop.
rosnodejs sample

How to run

mkdir foo
cd foo
npm install git+https://github.com/baalexander/rosnodejs.git
node sample.js

verify it

$ rostopic echo publish_example
data: hello 0
---
data: hello 1
---
data: hello 2
#!/usr/bin/env node
var ros = require('rosnodejs');
var counter = 0;
function pub() {
ros.types(['std_msgs/String'], function(String) {
var publisher = new ros.topic({
node : 'talker',
topic : 'publish_example',
messageType : String
});
setTimeout(function() {
publisher.publish(new String({data: 'hello ' + counter}));
counter = counter + 1;
pub();
}, 1000);
});
}
pub();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment