-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
28 lines (21 loc) · 778 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var ros = new ROSLIB.Ros();
ros.on('connection', function () {
console.log('Connected to websocket server.');
});
ros.on('error', function (error) {
console.log('Error connecting to websocket server: ', error);
});
ros.on('close', function () {
console.log('Connection to websocket server closed.');
});
ros.connect('ws://talker-over-rosbridge-ws:9090');
// First, we create a Topic object with details of the topic's name and message type.
var chatter = new ROSLIB.Topic({
ros: ros,
name: '/chatter',
messageType: 'std_msgs/String'
});
// Then we add a callback to be called every time a message is published on this topic.
chatter.subscribe(function (message) {
console.log('Received message on ' + chatter.name + ': ' + message.data);
});