-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
76 lines (66 loc) · 2.25 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
71
72
73
74
75
<!DOCTYPE html>
<html lang="en">
<head>
<title> Turtlebot Viz</title>
<script src="include/lib/require.js" data-main="include/main"></script>
<script>
var ros;
var viewer;
var tfclient;
require(['lib/domReady','robotwebtools/ros','robotwebtools/tfclient','visualization_three/viewer3d','visualization_three/meshloader','visualization_three/urdfloader'],
function(domReady,ROS,TfClient,Viewer3D,MeshLoader,UrdfLoader) {
domReady(function(){
console.log("On load");
initViewer();
initROS();
// addMesh('package://pr2_description/meshes/base_v0/base.dae');
addUrdf('turtlebot_description/turtlebot.urdf');
// addUrdf('rail_youbot_description/youbot.urdf');
// addUrdf('pr2_description/pr2.urdf');
// addUrdf('kobuki_description/kobuki.urdf');
});
function initViewer() {
var container = document.getElementById("container");
viewer = new Viewer3D(container);
viewer.init();
viewer.resize(1024,648);
viewer.animate();
}
function initROS() {
ros = new ROS();
ros.connect('ws://localhost:9090');
tfclient = new TfClient({
ros: ros,
fixedFrame: 'odom',
angularThres: 0.01,
transThres: 0.01,
rate: 10.0,
});
}
function addMesh(meshurl) {
// var objRoot = new THREE.Object3D();
var meshLoader = new MeshLoader('./resources/');
var obj = meshLoader.load(meshurl);
viewer.addObject(obj);
}
function addUrdf(urdf_src) {
var objRoot = new THREE.Object3D();
var meshLoader = new MeshLoader('./resources/');
var url = './resources/' +urdf_src;
console.log('Robot url = ' + url);
UrdfLoader.load(objRoot,meshLoader,tfclient,url);
viewer.addObject(objRoot);
}
});
</script>
</head>
<body >
<div id="header" style="height:50px">
<h1> Hello World</h1>
</div>
<center>
<div id="container">
</div>
</center>
</body>
</html>