-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualizeModel.js
More file actions
58 lines (54 loc) · 1.73 KB
/
Copy pathvisualizeModel.js
File metadata and controls
58 lines (54 loc) · 1.73 KB
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
// visualizeModel.js
export default {
props: ['ros', 'connected'],
data() {
return {
viewer: null,
tfClient: null,
urdfClient: null,
};
},
methods: {
setup3DViewer() {
this.viewer = new ROS3D.Viewer({
background: '#cccccc',
divID: 'div3DViewer',
width: 300,
height: 300,
antialias: true,
fixedFrame: 'odom'
})
// Zoom in
this.viewer.camera.fov *= 0.15;
this.viewer.camera.updateProjectionMatrix();
// Add a grid.
this.viewer.addObject(new ROS3D.Grid({
color: '#0181c4',
cellSize: 0.5,
num_cells: 20
}))
// Setup a client to listen to TFs.
this.tfClient = new ROSLIB.TFClient({
ros: this.ros,
angularThres: 0.01,
transThres: 0.01,
rate: 10.0
})
// Setup the URDF client.
this.urdfClient = new ROS3D.UrdfClient({
ros: this.ros,
param: 'robot_description',
tfClient: this.tfClient,
// We use "path: location.origin + location.pathname"
// instead of "path: window.location.href" to remove query params,
// otherwise the assets fail to load
path: location.origin + location.pathname,
rootObject: this.viewer.scene,
loader: ROS3D.COLLADA_LOADER_2
})
},
unset3DViewer() {
document.getElementById('div3DViewer').innerHTML = ''
},
},
};