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(); |