-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·70 lines (64 loc) · 2.3 KB
/
index.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css"
href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<script src="http://cdn.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="http://cdn.robotwebtools.org/roslibjs/current/roslib.js"></script>
<script src="keyboardteleop.js"></script>
<script>
/**
* Setup all GUI elements when the page is loaded.
*/
function init() {
// Connecting to ROS.
var ros = new ROSLIB.Ros({
url : 'ws://angmar.engr.oregonstate.edu:9090'
});
ros.on('connection', function() {
console.log('Connected to websocket server.'); });
ros.on('error', function(error) {
document.write('Error connecting to websocket server: ', error); });
ros.on('close', function() {
console.log('Connection to websocket server closed.'); });
// Initialize the teleop.
var teleop = new KEYBOARDTELEOP.Teleop({
ros : ros,
topic : 'cmd_vel_mux/input/teleop'
});
// Create a UI slider using JQuery UI.
$('#speed-slider').slider({
range : 'min',
min : 0,
max : 100,
value : 90,
slide : function(event, ui) {
// Change the speed label.
$('#speed-label').html('Speed: ' + ui.value + '%');
// Scale the speed.
teleop.scale = (ui.value / 100.0);
}
});
// Set the initial speed .
$('#speed-label').html('Speed: ' + ($('#speed-slider').slider('value')) + '%');
teleop.scale = ($('#speed-slider').slider('value') / 100.0);
}
</script>
</head>
<body onload="init()">
<h1>Simple Keyboard Teleop Example</h1>
<p>Run the following commands in the terminal then refresh this page. Check the JavaScript
console for the output.</p>
<ol>
<li><tt>roslaunch pr2_gazebo pr2_empty_world.launch</tt></li>
<li><tt>roslaunch rosbridge_server rosbridge_websocket.launch</tt></li>
<li>Use your arrow keys on your keyboard to move the robot (must have this browser window
focused).</li>
</ol>
<div id="speed-label"></div>
<div id="speed-slider"></div>
</body>
</html>