-
Notifications
You must be signed in to change notification settings - Fork 0
/
ros_bridge_test_publisher.html
55 lines (42 loc) · 1.35 KB
/
ros_bridge_test_publisher.html
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript"
src="http://static.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script type="text/javascript" src="http://static.robotwebtools.org/roslibjs/current/roslib.min.js"></script>
<script type="text/javascript" type="text/javascript">
// Connecting to ROS
// -----------------
var ros = new ROSLIB.Ros({
url: 'ws://localhost:9090'
});
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.');
});
// Publishing a Topic
// ------------------
var publisher = new ROSLIB.Topic({
ros: ros,
name: '/testing',
messageType: 'std_msgs/String'
});
var str = new ROSLIB.Message({
data: "Hello ros!"
});
for (let i = 0; i < 10; i++) {
publisher.publish(str);
}
</script>
</head>
<body>
<h1>Simple roslib Example</h1>
<p>Check your Web Console for output.</p>
</body>
</html>