-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwaggle.html
434 lines (370 loc) · 15.6 KB
/
waggle.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
<!doctype html>
<html>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-111922440-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-111922440-2');
</script>
<title>Waggle 1.2</title>
<link rel="stylesheet" href="css/custom.css">
<!-- For Blockly -->
<script src="js/vendor/blockly_compressed.js"></script>
<script src="js/vendor/blocks_compressed.js"></script>
<script src="js/vendor/en.js"></script>
<script src="js/vendor/javascript_compressed.js"></script>
<!-- For JS Interpretr -->
<!-- <script src="js/vendor/acorn_interpreter.js"></script> -->
<!-- For the CodeMirror JS Editor -->
<script src="js/vendor/codemirror.js"></script>
<link rel="stylesheet" href="css/codemirror.css">
<script src="js/vendor/javascript.js"></script>
<!-- Stupidly just pasting this in, because inputting from an XML file
seems to be surprisingly complex. -->
<!-- <embed src="blockly_xml/toolbox.xml" type="xml"> -->
<!-- <script src="blockly_xml/toolbox.xml" type="text/xml"></script> -->
<xml xmlns="http://www.w3.org/1999/xhtml" id="toolbox" style="display: none;">
<category name="Sensors" colour="#a55b5b">
<block type="robot_left_obstacle"></block>
<block type="robot_right_obstacle"></block>
<block type="robot_within_goal_zone"></block>
<block type="robot_inner_puck_count">
<field name="puckColour">red</field>
</block>
<block type="robot_puck_held">
<field name="puckColour">red</field>
</block>
<!--
<block type="robot_left_puck_count">
<field name="puckColour">red</field>
</block>
<block type="robot_right_puck_count">
<field name="puckColour">red</field>
</block>
-->
<block type="robot_flash_count"></block>
<block type="robot_left_nest_value"></block>
<block type="robot_centre_nest_value"></block>
<block type="robot_right_nest_value"></block>
<block type="robot_left_pheromone_value"></block>
<block type="robot_centre_pheromone_value"></block>
<block type="robot_right_pheromone_value"></block>
</category>
<category name="Actions" colour="#5ba55b">
<block type="robot_set_speed">
<field name="linearSpeed">0</field>
<field name="angularSpeed">0</field>
</block>
<block type="robot_hold_speed">
<field name="holdTime">0</field>
</block>
<!--
<block type="robot_hold_speed_slot"></block>
-->
<block type="robot_activate_gripper"></block>
<block type="robot_deactivate_gripper"></block>
<!--
<block type="robot_set_speed_slots"></block>
-->
<block type="robot_activate_flash"></block>
<block type="robot_deactivate_flash"></block>
<block type="robot_emit_pheromone">
<field name="quantity">10</field>
</block>
<!--
<block type="robot_emit_pheromone_slot"></block>
-->
<block type="robot_set_text">
<field name="text">Hi!</field>
</block>
<block type="robot_set_text_variable">
<field name="variableName">variableA</field>
</block>
<block type="robot_execute"></block>
</category>
<category name="Memory" colour="#a55ba5">
<block type="robot_set_variable">
<field name="variableName">variableA</field>
<field name="newValue">0</field>
</block>
<!--
<block type="robot_set_variable_slot">
<field name="variableName">variableA</field>
</block>
-->
<block type="robot_change_variable">
<field name="variableName">variableA</field>
<field name="deltaValue">0</field>
</block>
<!--
<block type="robot_change_variable_slot">
<field name="variableName">variableA</field>
</block>
-->
<block type="robot_get_variable">
<field name="variableName">variableA</field>
</block>
<block type="robot_set_text_variable">
<field name="variableName">variableA</field>
</block>
</category>
<sep></sep>
<category name="Logic" colour="#5C81A6">
<block type="controls_if"></block>
<block type="logic_compare">
<field name="OP">EQ</field>
</block>
<block type="logic_operation">
<field name="OP">AND</field>
</block>
<block type="logic_negate"></block>
<block type="logic_boolean">
<field name="BOOL">TRUE</field>
</block>
<block type="logic_ternary"></block>
</category>
<category name="Math" colour="#5C68A6">
<block type="math_number">
<field name="NUM">0</field>
</block>
<block type="math_single">
<field name="OP">ROOT</field>
<value name="NUM">
<shadow type="math_number">
<field name="NUM">9</field>
</shadow>
</value>
</block>
<block type="math_trig">
<field name="OP">SIN</field>
<value name="NUM">
<shadow type="math_number">
<field name="NUM">45</field>
</shadow>
</value>
</block>
<block type="math_constant">
<field name="CONSTANT">PI</field>
</block>
<block type="math_number_property">
<mutation divisor_input="false"></mutation>
<field name="PROPERTY">EVEN</field>
<value name="NUMBER_TO_CHECK">
<shadow type="math_number">
<field name="NUM">0</field>
</shadow>
</value>
</block>
<block type="math_arithmetic">
<field name="OP">ADD</field>
<value name="A">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
</value>
<value name="B">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
</value>
</block>
<block type="math_modulo">
<value name="DIVIDEND">
<shadow type="math_number">
<field name="NUM">64</field>
</shadow>
</value>
<value name="DIVISOR">
<shadow type="math_number">
<field name="NUM">10</field>
</shadow>
</value>
</block>
<block type="math_constrain">
<value name="VALUE">
<shadow type="math_number">
<field name="NUM">50</field>
</shadow>
</value>
<value name="LOW">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
</value>
<value name="HIGH">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
<block type="math_random_int">
<value name="FROM">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
</value>
<value name="TO">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
<block type="math_random_float"></block>
</category>
</xml>
<!-- For matter -->
<!--<script src="js/vendor/matter_0.14.2.js"></script>-->
<script src="js/vendor/matter_0.14.2_optimized.js"></script>
<script src="js/vendor/decomp.js"></script>
<!-- For the ability to seed the pseudo-random number generator for
Math.random() -->
<script src="js/vendor/seedrandom.min.js"></script>
<!-- For plotting. -->
<script src="js/vendor/highcharts.js"></script>
<!--<script src="https://code.highcharts.com/modules/exporting.js"></script>-->
<script src="js/vendor/exporting.js"></script>
<!-- For saving the blocks to a local file. -->
<script src="js/vendor/FileSaver.min.js"></script>
<!-- For graph data structure and algorithms. -->
<script src="js/vendor/jsgraphs.min.js"></script>
</head>
<body>
<h2>Waggle 1.2: The Online Swarm Robotics Lab</h2>
<div class="grid">
<div class="row">
<div class="gap-col"></div>
<div class="matter-col">
<div id="matterDiv"></div>
<div id="controlsDiv">
<table cellpadding="2" style="width: 100%">
<tr>
<td><button type="button" id="resetButton">Reset</button></td>
<td><button type="button" id="reseedAndResetButton">Reseed and Reset</button></td>
<td><input type="checkbox" id="allowMovementCheckbox">Movement?</input></td>
<td><input type="checkbox" id="allowRotationCheckbox">Rotation?</input></td>
<td><input type="checkbox" id="showSensorsCheckbox">Show Sensors?</input></td>
<td><input type="checkbox" id="greenToBlueCheckbox">Change Colours?</input></td>
</tr>
<tr><td>Render Skip </td>
<td><input id='renderSkipSlider' type='range' min='1' value='1' max='100' step='1'/></td>
<td id='renderSkipText'>1</td></tr>
<tr><td>Timescale </td>
<td><input id='timeScaleSlider' type='range' min='0.1' value='1.0' max='1.0' step='0.1'/></td>
<td id='timeScaleText'>1</td></tr>
<tr><td>Desired Population </td>
<td><input id='nRobotsSlider' type='range' min='0' value='1' max='100' step='1'/></td>
<td id='nRobotsText'></td>
<td >Actual Population</td>
<td id='actualPopulationText'></td></tr>
<tr>
<td id='nRedPucksLabel'>Red Pucks</td>
<td><input id='nRedPucksSlider' type='range' min='0' value='1' max='250' step='1'/></td>
<td id='nRedPucksText'></td></tr>
<tr>
<td id='nGreenPucksLabel'>Green Pucks</td>
<td><input id='nGreenPucksSlider' type='range' min='0' value='1' max='150' step='1'/></td>
<td id='nGreenPucksText'></td></tr>
<tr>
<td id='maxStepLabel'>Max. Step</td>
<td><input id='maxStepSlider' type='range' min='0' value='0' max='100000' step='1000'/></td>
<td id='maxStepText'></td></tr>
<tr>
<div id="gridDiv">
Select grid visibility:
<select id="gridSelect">
<option value="none">No grid</option>
<option value="pheromone">Show Pheromone Grid</option>
<option value="nest">Show Nest Grid</option>
</select>
</div>
</tr>
</table>
</div>
<div id="analysisControlsDiv">
<table cellpadding="2" style="width: 100%">
<tr>
<td><button type="button" id="clearPlotsAndResetButton">Clear Plots and Reset</button></td>
<td><input type="checkbox" id="doAnalysisCheckbox"></input></td>
<td id='doAnalysisText'>Plot?</td>
<td><input type="checkbox" id="resetAfterMaxStepCheckbox">Reset After Max. Step?</input></td>
</tr>
</table>
</div>
<div id='analysisMessage'></div>
<div id="chartDiv" style="width: 500px; height: 500px"></div>
</div>
<div class="gap-col"></div>
<div class="blockly-col">
<div id='statusMessage'></div>
<div class="tab">
<button class="tablinks" id="blocklyTabButton" onclick="openTab(event, 'blocklyTab')">Blockly</button>
<button class="tablinks" id="javascriptTabButton" onclick="openTab(event, 'javascriptTab')">Javascript</button>
<!-- <button class="tablinks" id="hardcodedTabButton" onclick="openTab(event, 'hardcodedTab')">Hard-Coded</button> -->
</div>
<div class="tabcontent" id="blocklyTab">
<div id="blocklyControlsDiv">
<table cellpadding="2">
<tr>
<td><button type="button" id="blocklyClearButton">Clear</button></td>
<td><div class="file-box">
<label id="loadLabel">Load</label>
<input type="file" id="blocklyFileLoader" value="pheromone_test.xml"></input></div></td>
<td><div class="file-box">
<button type="button" id="blocklySaveButton">Save As</button>
<input type="text" id="blocklySaveFileName" value="blocks.xml"></input></div></td>
<td><button type="button" id="blocklyTransferButton">Transfer to Javascript (Clears Old Content)</button></td>
<!--
<td><button type="button" id="blocklyShowXMLButton">Show XML</button></td>
-->
</tr>
<tr id="blocklyArea">
<div id="blocklyDiv" style="position: absolute"></div>
</tr>
</table>
</div>
</div>
<div class="tabcontent" id="javascriptTab" style="width: 800px; height: 800px">
<div id="jsControlsDiv">
<table cellpadding="2">
<tr>
<td><button type="button" id="jsClearButton">Clear</button></td>
<td><div class="file-box">
<label id="loadLabel">Load</label>
<input type="file" id="jsFileLoader" value="controller.js"></input></div></td>
<td><div class="file-box">
<button type="button" id="jsSaveButton">Save As</button>
<input type="text" id="jsSaveFileName" value="controller.js"></input></div></td>
</tr>
</table>
</div>
<div class="javascriptDiv" id="javascriptDiv">
</div>
</div>
<!--
<div class="tabcontent" id="hardcodedTab">
</div>
-->
</div>
</div>
<!-- My scripts -->
<script src="js/jsEditor.js"></script>
<script src="js/populate.js"></script>
<script src="js/sensors.js"></script>
<script src="js/robot.js"></script>
<script src="js/jsControllers.js"></script>
<script src="js/Controller.js"></script>
<script src="js/analysis.js"></script>
<script src="js/CustomRender.js"></script>
<script src="js/valueGrids.js"></script>
<script src="js/distToSegment.js"></script>
<script src="js/nest.js"></script>
<script src="js/blocklyConfig.js"></script>
<script src="js/my_globals.js"></script>
<!-- For my hacky tabbing between Blockly and Javascript -->
<script src="js/tabbing.js"></script>
<script src="js/main.js"></script>
</body>
</html>