-
Notifications
You must be signed in to change notification settings - Fork 47
/
ros-rviz-interactive-markers.html
94 lines (84 loc) · 2.41 KB
/
ros-rviz-interactive-markers.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="imports.html">
<dom-module id="ros-rviz-interactive-markers">
<template>
<paper-input label="Interactive marker topic" on-blur="_updateDisplay" value="{{topic}}"></paper-input>
</template>
<script>
Polymer({
is: 'ros-rviz-interactive-markers',
properties: {
globalOptions: Object,
isShown: Boolean,
name: {
type: String,
value: 'Interactive Markers',
},
ros: Object,
tfClient: Object,
topic: {
type: String,
value: '/basic_controls',
notify: true,
},
viewer: Object,
_client: {
type: Object,
value: null
},
},
observers: [
'_optionsChanged(viewer, topic, ros)',
],
destroy: function() {
// Nothing to destroy.
},
// TODO: all "destroys" should just be detaches
detached: function() {
this.hide();
},
hide: function() {
if (this._client) {
this._client.unsubscribe();
}
},
show: function() {
if (this._client && this.isShown) {
this._client.subscribe(this.topic);
}
},
_optionsChanged: function(viewer, topic, ros) {
this.hide();
this._updateDisplay();
},
_updateDisplay: function() {
if (!this.viewer || !this.topic || !this.ros) {
return;
}
var that = this;
if (this._client) {
this._client.unsubscribe();
}
var loader = ROS3D.COLLADA_LOADER_2;
if (that.globalOptions.colladaLoader === 'collada') {
loader = ROS3D.COLLADA_LOADER;
} else if (that.globalOptions.colladaLoader === 'collada2') {
loader = ROS3D.COLLADA_LOADER_2;
} else {
console.warn('Unknown Collada loader', that.globalOptions.colladaLoader);
loader = ROS3D.COLLADA_LOADER_2;
}
this._client = new ROS3D.InteractiveMarkerClient({
loader: loader,
path: this.globalOptions.colladaServer,
ros: this.ros,
tfClient: this.tfClient,
topic: this.topic,
camera: this.viewer.camera,
rootObject: this.viewer.selectableObjects,
});
},
});
</script>
</dom-module>