-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
189 lines (156 loc) · 7.55 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<html>
<head>
<meta charset="UTF-8"/>
<title>demo-bevy_robot</title>
<link data-trunk rel="rust" data-wasm-opt=s data-integrity="none"/>
<link data-trunk rel="copy-dir" href="assets"/>
<script defer="defer" type="text/javascript">
function input_robot_joint_click(robot, joint) {
const element_id = `input_robot${robot}_joint${joint}`;
const angle = document.getElementById(element_id).value;
window.wasmBindings.set_robot_joint_pos(robot, joint, angle);
}
function input_robot_finger_click(robot, finger) {
const element_id = `input_robot${robot}_finger${finger}`;
const pos = document.getElementById(element_id).value;
window.wasmBindings.set_robot_finger_pos(robot, finger, pos);
}
window.addEventListener("joint_changed", function (event) {
const robot = event.detail["robot"];
const joint = event.detail["joint"];
const angle = event.detail["angle"];
const element_id = `input_robot${robot}_joint${joint}`;
document.getElementById(element_id).value = angle;
})
window.addEventListener("finger_changed", function (event) {
const robot = event.detail["robot"];
const finger = event.detail["finger"];
const pos = event.detail["pos"];
const element_id = `input_robot${robot}_finger${finger}`;
document.getElementById(element_id).value = pos;
})
</script>
<style>
.par_row {
display: flex;
justify-content: space-around;
margin: 10px;
}
.input_label {
width: 80px;
}
.input_box {
width: 60px;
margin-right: 20px;
}
</style>
</head>
<body>
<h1 style="text-align: center">demo-bevy_robot</h1>
<div style="width: 80%;height: 60%; margin: auto">
<canvas id="demo-bevy_robot"></canvas>
<script type="text/javascript">
document.getElementById("demo-bevy_robot").oncontextmenu = function () {
return false;
}
</script>
</div>
<div style="display: flex; justify-content: space-around">
<div id="robot0">
<label>Robot0</label>
<div class="par_row">
<label class="input_label" for="input_robot0_joint1">Joint 1:</label>
<input class="input_box" type="number" id="input_robot0_joint1" min="-720" max="720" value="0"/>
<button onclick="input_robot_joint_click(0,1)">set</button>
</div>
<div class="par_row">
<label class="input_label" for="input_robot0_joint2">Joint 2:</label>
<input class="input_box" type="number" id="input_robot0_joint2" min="-720" max="720" value="0"/>
<button onclick="input_robot_joint_click(0,2)">set</button>
</div>
<div class="par_row">
<label class="input_label" for="input_robot0_joint3">Joint 3:</label>
<input class="input_box" type="number" id="input_robot0_joint3" min="-720" max="720" value="0"/>
<button onclick="input_robot_joint_click(0,3)">set</button>
</div>
<div class="par_row">
<label class="input_label" for="input_robot0_joint4">Joint 4:</label>
<input class="input_box" type="number" id="input_robot0_joint4" min="-720" max="720" value="0"/>
<button onclick="input_robot_joint_click(0,4)">set</button>
</div>
<div class="par_row">
<label class="input_label" for="input_robot0_joint5">Joint 5:</label>
<input class="input_box" type="number" id="input_robot0_joint5" min="-720" max="720" value="0"/>
<button onclick="input_robot_joint_click(0,5)">set</button>
</div>
<div class="par_row">
<label class="input_label" for="input_robot0_joint6">Joint 6:</label>
<input class="input_box" type="number" id="input_robot0_joint6" min="-720" max="720" value="0"/>
<button onclick="input_robot_joint_click(0,6)">set</button>
</div>
<div class="par_row">
<label class="input_label" for="input_robot0_finger1">Finger 1:</label>
<input class="input_box" type="number" id="input_robot0_finger1" min="0" max="100" value="0"/>
<button onclick="input_robot_finger_click(0,1)">set</button>
</div>
<div class="par_row">
<label class="input_label" for="input_robot0_finger2">Finger 2:</label>
<input class="input_box" type="number" id="input_robot0_finger2" min="0" max="100" value="0"/>
<button onclick="input_robot_finger_click(0,2)">set</button>
</div>
</div>
<div id="robot1">
<label>Robot1</label>
<div class="par_row">
<label class="input_label" for="input_robot1_joint1">Joint 1:</label>
<input class="input_box" type="number" id="input_robot1_joint1" min="-720" max="720" value="0"/>
<button onclick="input_robot_joint_click(1,1)">set</button>
</div>
<div class="par_row">
<label class="input_label" for="input_robot1_joint2">Joint 2:</label>
<input class="input_box" type="number" id="input_robot1_joint2" min="-720" max="720" value="0"/>
<button onclick="input_robot_joint_click(1,2)">set</button>
</div>
<div class="par_row">
<label class="input_label" for="input_robot1_joint3">Joint 3:</label>
<input class="input_box" type="number" id="input_robot1_joint3" min="-720" max="720" value="0"/>
<button onclick="input_robot_joint_click(1,3)">set</button>
</div>
<div class="par_row">
<label class="input_label" for="input_robot1_joint4">Joint 4:</label>
<input class="input_box" type="number" id="input_robot1_joint4" min="-720" max="720" value="0"/>
<button onclick="input_robot_joint_click(1,4)">set</button>
</div>
<div class="par_row">
<label class="input_label" for="input_robot1_joint5">Joint 5:</label>
<input class="input_box" type="number" id="input_robot1_joint5" min="-720" max="720" value="0"/>
<button onclick="input_robot_joint_click(1,5)">set</button>
</div>
<div class="par_row">
<label class="input_label" for="input_robot1_joint6">Joint 6:</label>
<input class="input_box" type="number" id="input_robot1_joint6" min="-720" max="720" value="0"/>
<button onclick="input_robot_joint_click(1,6)">set</button>
</div>
<div class="par_row">
<label class="input_label" for="input_robot1_finger1">Finger 1:</label>
<input class="input_box" type="number" id="input_robot1_finger1" min="0" max="100" value="0"/>
<button onclick="input_robot_finger_click(1,1)">set</button>
</div>
<div class="par_row">
<label class="input_label" for="input_robot1_finger2">Finger 2:</label>
<input class="input_box" type="number" id="input_robot1_finger2" min="0" max="100" value="0"/>
<button onclick="input_robot_finger_click(1,2)">set</button>
</div>
</div>
<script>
const joints_default_pos = [90.0, -120.0, 90.0, -60.0, -90.0, 0.0];
for (let robot = 0; robot < 2; robot++) {
for (let joint = 0; joint < 6; joint++) {
const element_id = `input_robot${robot}_joint${joint + 1}`;
document.getElementById(element_id).value = joints_default_pos[joint];
}
}
</script>
</div>
</body>
</html>