-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.qml
1143 lines (1082 loc) · 37.4 KB
/
main.qml
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
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import QtQuick 2.12
import QtQuick.Window 2.2
import QtGraphicalEffects 1.0
import QtQuick.Controls 2.15
import QtWebSockets 1.15
//import Ros 1.0
import ImagePainterQml 1.0
Window {
id: window
visible: true
//visibility: Window.FullScreen
width: 2736
height: 1824
property bool simu: true
property int prevWidth:800
property int prevHeight:600
property var initTime: 0
property bool autonomous: false
property bool moving: false
property var pandaPose: Qt.vector3d(.36,0,.56)
property var scaleX: 1 //map.width / map.paintedWidth
property var scaleY: 1 //map.height / map.paintedHeight
property var pixScale: map.ratio //map.width / map.paintedWidth
//property var socketIP: "ws://146.151.105.145:49152"
property var socketIP: "ws://192.168.0.157:49152"
//property var socketIP: "ws://192.168.0.158:49152"
//property var socketIP: "ws://10.134.71.33:49152"
//url: "ws://0.0.0.0:49155"
title: qsTr("Authoring GUI")
MouseArea{
id: clickRecorder
z:200
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onPressed: {
if (mouse.button == Qt.RightButton)
pubEvent("right_click")
else
pubEvent("left_click")
mouse.accepted = false
}
}
Item {
id: displayView
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
height: Math.min(width*3/4, window.height)
rotation: 0
ImagePainter{
id: map
anchors.centerIn: parent
width: parent.width
height: parent.height
/*
fillMode: Image.PreserveAspectFit
property string toLoad: realCamera
property string virtualCamera: "image://rosimage/virtual_camera/image_repub"
property string realCamera: "res/default.jpg"
property string realCamera: simu ? virtualCamera : "image://rosimage/rgb/image_raw"
property bool useRealImage: true
source: toLoad
cache: false
rotation: 0
Timer {
id: imageLoader
interval: 100
repeat: true
running: true
onTriggered: {
map.source = "";
if(map.useRealImage){
map.source = map.toLoad;
interval = 100
}
else{
toLoad: "res/default.jpg"
repeat = false
}
}
}
onSourceChanged: {
if(source == realCamera){
rotation = 0
horizontalAlignment = Image.AlignLeft
}
else{
rotation = 0
horizontalAlignment = Image.AlignLeft
}
}
*/
Item{
id: pois
visible: hidePoisButton.show
property var cmd: null
function addPoi(type,id,x,y){
var component = Qt.createComponent("POI.qml")
var color = "red"
if(type === "screw")
color = "yellow"
if(type === "box")
color = "gainsboro"
if(type === "hole"){
//return
color = "white"
}
if(type === "drawer")
color = "aliceblue"
if(type === "edge")
color = "blue"
var poi = component.createObject(pois, {type:type,index:id,color:color,x:x,y:y})
}
function clearPoi(){
for(var i =0;i<pois.children.length;i++){
try{
pois.children[i].destroy()
}
catch(err) {
;
}
}
}
onCmdChanged: {timerPoi.start()}
Timer{
id: timerPoi
interval: 500
onTriggered: {pois.updatePois()}
}
function updatePois(){
//if(map.paintedWidth < 1000)
// return
for(var i =0;i<pois.children.length;i++){
pois.children[i].enabled = false
}
for(var i=0;i<cmd.length-1;i++){
var info = cmd[i+1].split(":")
var type = info[0]
var id = parseInt(info[1])
var coord = info[2]
var x = (parseInt(coord.split(",")[0])) * pixScale
var y = (parseInt(coord.split(",")[1]) - map.offset) * pixScale
var new_poi = true
for(var j =0;j<pois.children.length;j++){
var poi = pois.children[j]
if(poi.type === type && poi.index === id){
poi.x = x
poi.y = y
new_poi = false
poi.enabled = true
break
}
}
if(new_poi)
pois.addPoi(type, id, x, y)
}
//for(var i = pois.children.length; i > 0 ; i--) {
// if (pois.children[i-1].updated === false){
// pois.children[i-1].destroy()
// }
//}
if(waitGui.waitPoi){
roi.visible = true
}
for(var i=0;i<figures.children.length;i++){
figures.children[i].poiUpdated()
}
if(roi.poi !== null){
roi.x = roi.poi.x-roi.width/2
roi.y = roi.poi.y-roi.width/2
}
}
}
Rectangle{
id: selectionArea
opacity: .2
color: "grey"
property var startPoint: null
visible: false
}
MouseArea{
enabled: globalStates.state === "command"
anchors.fill: parent
property bool active: false
onPressed: {
print(triggers.currentTrig)
if(triggerPannel.visible && triggers.currentTrig !== null){
active = false
return
}
for(var i = 0;i<figures.children.length;i++){
if(figures.children[i].name === "rect" && figures.children[i].inHull(Qt.point(mouseX,mouseY)) && figures.children[i].visible){
active = false
return
}
}
active = true
selectionArea.startPoint = Qt.point(mouseX,mouseY)
selectionArea.x = selectionArea.startPoint.x
selectionArea.y = selectionArea.startPoint.y
selectionArea.width = 0
selectionArea.height = 0
selectionArea.visible = true
}
onPositionChanged: {
if(!active)
return
selectionArea.width = Math.abs(mouseX-selectionArea.startPoint.x)
selectionArea.height = Math.abs(mouseY-selectionArea.startPoint.y)
selectionArea.visible = selectionArea.width>map.width/40 || selectionArea.height > map.height/40
console.log(selectionArea.visible)
selectionArea.x = Math.min(mouseX,selectionArea.startPoint.x)
selectionArea.y = Math.min(mouseY,selectionArea.startPoint.y)
}
onReleased: {
if(!selectionArea.visible)
return
if(selectionArea.width === 0){
console.log("is 0")
selectionArea.width = map.width/12
selectionArea.height = map.width/12
selectionArea.x -= selectionArea.width/2
selectionArea.y -= selectionArea.height/2
console.log(-selectionArea.width/2)
}
selectionArea.visible = false
if(gamePlan.visible)
figures.createRect(selectionArea.x,selectionArea.y,Math.max(100,selectionArea.width),Math.max(selectionArea.height))
else
triggers.createTrig(selectionArea.x,selectionArea.y,Math.max(100,selectionArea.width),Math.max(selectionArea.height))
}
}
}
MouseArea{
id:protectionArea
width: parent.width*2.02/3
anchors.right: parent.right
height: parent.height/6.5
anchors.bottom: parent.bottom
z:9
}
Figures {
id:figures
z:10
}
Triggers {
id: triggers
z:10
}
/*Item{
id: movedPois
visible: false
function updatePoi(type,id,x,y,objColor){
var found = false
for(var i=0;i<movedPois.children.length;i++){
var poi = movedPois.children[i]
if(poi.type === type && poi.index === id && poi.color == objColor){
poi.x = x
poi.y = y
found = true
break
}
}
if(!found){
var component = Qt.createComponent("POI.qml")
var poi = component.createObject(movedPois, {type:type,index:id,color:objColor,x:x,y:y})
}
}
function removePoi(type, index, objColor){
for(var i =0;i<movedPois.children.length;i++){
var poi = movedPois.children[i]
if (poi.type === type && poi.index === index && poi.color == objColor){
movedPois.children[i].destroy()
}
}
}
}*/
}
GamePlan{
id: gamePlan
visible: false
}
TriggerPannel{
id: triggerPannel
visible: ! gamePlan.visible
}
Item{
id:gestureGui
anchors.fill: parent
visible: false
GuiButton{
id: addGestureButton
z:10
anchors.bottom: parent.bottom
anchors.bottomMargin: height
anchors.horizontalCenter: parent.horizontalCenter
name: "add"
onClicked:{
drawingarea.addGesture = true
}
TextEdit{
id: gestureName
width: addGestureButton.width
height: addGestureButton.height
anchors.top: addGestureButton.bottom
anchors.horizontalCenter: addGestureButton.horizontalCenter
text: "gestureName"
color: "white"
}
}
GuiButton{
id: saveButton
z:10
anchors.left: addGestureButton.right
anchors.leftMargin: height
anchors.verticalCenter: addGestureButton.verticalCenter
name: "save"
onClicked:{
var string = recognizer._r.GetUserGestures()
fileio.write("/src/authoring-gui/res/gestures.json",string)
}
}
}
Item{
id:visualizationGui
width: map.width
height: map.height
anchors.left: parent.left
anchors.top: parent.top
visible: true
}
Rectangle{
id: displayArea
anchors.top: parent.top
anchors.left: parent.left
height: map.height
width: map.width
color: "transparent"
GuiButton{
id: commandButton
z:10
width: parent.width/20
anchors.right: displayArea.right
anchors.rightMargin: width/2
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenterOffset: -parent.width/4
name: "play"
onClicked:{gamePlan.sendCommand("exec");
globalStates.state = "execution"
}
visible: false//commandGui.visible
}
GuiButton{
id: simulateButton
z:10
anchors.bottom: commandButton.top
anchors.bottomMargin: height/2
anchors.horizontalCenter: commandButton.horizontalCenter
name: "sim"
color: "#ffc27a"
onClicked:{
gamePlan.sendCommand("sim");
globalStates.state = "simulation"
}
visible: false //commandGui.visible
}
GuiButton{
id: hidePoisButton
z:10
anchors.verticalCenter: deleteButton.verticalCenter
anchors.left: displayArea.left
anchors.leftMargin: width
name: show ? "hide" : "show"
property bool show: true
onClicked:{
show = ! show
}
visible: globalStates.state === "command"
}
GuiButton{
id: resetWorldButton
anchors.horizontalCenter: hidePoisButton.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: width
name: 'world'
color: "purple"
onClicked: {
pubEvent("reset_world;")
}
}
BehaviorDisplay{
id: behaviorDisplay
}
ControlPanel{
id: controlPanel
}
/*
GuiButton{
id: bookButton
anchors.verticalCenter: resetButton.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: -parent.width / 5 - width/2
z:10
property int counter: 0
color: figures.colors[counter]
name: "bookview"
onClicked:{
viewButtons.children[counter].visible = true
commandPublisher.text = "save_view;"+counter.toString()
counter = (counter+1)%2
}
visible: false// commandGui.visible
}
Item{
id:viewButtons
anchors.verticalCenter: bookButton.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: + parent.width / 5
visible: commandGui.visible
GuiButton{
property int number: 0
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: number * 3/2 * width
color: figures.colors[number]
z:10
name: "view"
onClicked:{
commandPublisher.text = "load_view;"+number.toString()
}
visible: false
}
GuiButton{
property int number: 1
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: number * 3/2 * width
color: figures.colors[number]
z:10
name: "view"
onClicked:{
commandPublisher.text = "load_view;"+number.toString()
}
visible: false
}
}
*/
// GuiButton{
// id: resetButton
// anchors.horizontalCenter: commandButton.horizontalCenter
// anchors.bottom: parent.bottom
// anchors.bottomMargin: width
// z:10
// name: "reset"
// onClicked:{
// globalStates.state = "execution"
// commandPublisher.text = "reset_position"
// }
// visible: visible
// }
GuiButton{
id: deleteButton
z:10
anchors.verticalCenter: viewButton.verticalCenter
anchors.horizontalCenter: viewButton.horizontalCenter
anchors.horizontalCenterOffset: -2*width
name: "del"
color: "red"
onClicked:{
if(figures.currentItem !== null){
try{
figures.currentItem.destroy()
}
catch(err){
console.log(err)
}
figures.currentItem = null
timerCurrentItem.start()
}
}
visible: commandGui.visible
}
Timer{
id: timerCurrentItem
interval: 200
onTriggered: {
if(figures.currentItem === null){
if(figures.children.length>0){
figures.children[figures.children.length-1].currentItem = true
}
}
}
}
GuiButton{
id: infoButton
z:10
anchors.verticalCenter: deleteButton.verticalCenter
anchors.horizontalCenter: deleteButton.horizontalCenter
anchors.horizontalCenterOffset: -2*width
name: "unknown"
color: "orange"
onClicked:{
var item = figures.currentItem
if(item !== null){
item.nextTip()
}
}
visible: commandGui.visible && figures.children.length>0
}
GuiButton{
id: viewButton
z:10
visible: false//true
anchors.horizontalCenter: commandButton.horizontalCenter
anchors.top: parent.top
anchors.topMargin: height/2
name: "switch"
color: "#ffc27a"
onClicked:{
switch(globalStates.state){
case "visualization":
globalStates.state = "command"
map.toLoad = map.realCamera
pubCommand("init_gui")
break
case "command":
globalStates.state = "visualization"
map.toLoad = map.virtualCamera
pubCommand("unlock")
break
case "simulation":
globalStates.state = "command"
pubCommand("stop_sim")
break
case "execution":
globalStates.state = "command"
break
}
}
}
GuiButton{
id: lockViewButton
visible: false
z:10
anchors.horizontalCenter: commandButton.horizontalCenter
anchors.top: viewButton.bottom
anchors.topMargin: height/2
name: "lock"
color: "FireBrick"
onClicked:{
globalStates.state = "command"
pubCommand("lock")
}
}
GuiButton{
id: goToButton
visible: false
z:10
anchors.horizontalCenter: commandButton.horizontalCenter
anchors.verticalCenter: commandButton.verticalCenter
name: "send"
onClicked:{
globalStates.state = "execution"
map.toLoad = map.realCamera
pubCommand("go")
}
}
/* GuiButton{
id: stopButton
z:10
visible: executionGui.visible
anchors.horizontalCenter: resetButton.horizontalCenter
anchors.verticalCenter: resetButton.verticalCenter
name: "stop"
color: "red"
onClicked:{
commandPublisher.text = "stop"
globalStates.state = "command"
}
}
GuiButton{
id: pauseButton
z:10
visible: false//executionGui.visible
anchors.horizontalCenter: stopButton.horizontalCenter
anchors.verticalCenter: commandButton.verticalCenter
name: "pause"
color: "orange"
onClicked:{
commandPublisher.text = name
if(name === "pause"){
name = "play"
color = "green"
}
else{
name = "pause"
color = "orange"
}
}
}
GuiButton{
id: editButton
z:10
//visible: executionGui.visible
visible: false//executionGui.visible
anchors.right: parent.right
anchors.rightMargin: width/2
anchors.top: parent.top
anchors.topMargin: height/2
name: "edit"
color: "#ffc27a"
onClicked:{
eventPublisher.text = 'start_edit'
pauseButton.name = "play"
pauseButton.color = "green"
commandPublisher.text = "pause"
globalStates.state = "edit"
}
}
GuiButton{
id: stopEditButton
z:10
visible: false
anchors.right: parent.right
anchors.rightMargin: width/2
anchors.top: parent.top
anchors.topMargin: height/2
name: "stop_edit"
color: "#ffc27a"
onClicked:{
eventPublisher.text = 'stop_edit'
globalStates.state = "execution"
}
}
GuiButton{
id: actButton
visible: roi.visible
z:20
anchors.horizontalCenter: stopButton.horizontalCenter
anchors.top: commandButton.bottom
anchors.topMargin: height/2
name: "act"
onClicked:{
waitGui.visible = false
eventPublisher.text = "act"
hideRoiTimer.start()
}
}
GuiButton{
id: nextButton
visible: roi.visible
z:30
anchors.horizontalCenter: stopButton.horizontalCenter
anchors.bottom: commandButton.top
anchors.bottomMargin: height/2
name: "skip"
onClicked:{
waitGui.visible = false
eventPublisher.text = "skip"
hideRoiTimer.start()
}
}*/
}
Item{
id:executionGui
visible: false
}
Item{
id:fdGui
visible: false
anchors.fill: parent
GuiButton{
id: controlButton
z:10
visible: true
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
width: parent.width/5
anchors.bottomMargin: height
text: "Take Back Control"
onClicked:{
pubEvent("gui_takeover")
globalStates.state = "command"
}
}
}
Item{
id:waitGui
property bool waitPoi: false
visible: false
anchors.fill: parent
Timer{
id: hideRoiTimer
interval: 100
onTriggered: roi.visible = false
}
Rectangle{
id: roi
x:0
y:0
property var poi: null
visible: false
width: 100
height: width
radius: width/2
opacity: .5
color: "transparent"
border.color: "red"
border.width: width/10
}
onVisibleChanged: {
waitPoi = true
}
}
Item{
id:commandGui
anchors.fill: parent
visible: false
}
GuiButton{
id: gestureEditButton
z:10
visible: false
anchors.left: parent.left
anchors.top: parent.top
text: "Switch Mode"
onClicked:{
if (globalStates.state === "gestureEdit")
globalStates.state = "command"
else
globalStates.state = "gestureEdit"
}
}
Rectangle{
id: backWarningDepth
anchors.verticalCenter: warningDepth.verticalCenter
anchors.horizontalCenter: warningDepth.horizontalCenter
width: 1.1 * warningDepth.width
height: 1.2 * warningDepth.height
color: "gainsboro"
radius: height/4
border.color: "steelblue"
visible: warningDepth.visible
opacity: .8
}
Label{
id: warningDepth
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: parent.height/10.
text: "Bad depth, please move one handle"
font.pixelSize: 50
color: "red"
visible: false
}
Rectangle{
id: backWarningReach
anchors.verticalCenter: warningReach.verticalCenter
anchors.horizontalCenter: warningReach.horizontalCenter
width: 1.1 * warningReach.width
height: 1.2 * warningReach.height
color: "gainsboro"
radius: height/4
border.color: "steelblue"
visible: warningReach.visible
opacity: .8
}
Label{
id: warningReach
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: parent.height/10.
text: "Position out of reach, please move one handle"
font.pixelSize: 50
color: "red"
visible: false
}
/*
RosStringPublisher{
id: commandPublisher
topic: "/gui/command"
text:""
Component.onCompleted: text="reset_position"
}
RosStringPublisher{
id: eventPublisher
topic: "/event"
text:""
}
*/
function pubCommand(msg){
socket.sendTextMessage("command:"+msg)
}
function pubEvent(msg){
socket.sendTextMessage("event:"+msg)
}
/*
RosStringSubscriber{
id: eventsSubscriber
topic: "/event"
text:""
onTextChanged:{
onEvent(text)
}
}
RosStringSubscriber{
id: infoSubscriber
topic: "/parser/gui_info"
text:""
onTextChanged:{
onParser(text)
}
}
*/
WebSocket {
id: socket
url: socketIP
onTextMessageReceived: {
if(message.startsWith("event:"))
onEvent(message.substring("event:".length))
if(message.startsWith("parser:"))
onParser(message.substring("parser:".length))
}
onBinaryMessageReceived: {
map.bArray = message
map.update()
}
onStatusChanged:{
if (socket.status == WebSocket.Error) {
console.log("Error: " + socket.errorString)
//socketChecker.restart()
} else if (socket.status == WebSocket.Open) {
} else if (socket.status == WebSocket.Closed) {
console.log("Socket closed")
}
}
active: true
}
function onParser(text){
if(text === "bad_depth"){
warningDepth.visible = true
globalStates.state = "command"
warningReach.visible = false
return
}
if(text === "out_of_reach"){
console.log("got it")
warningReach.visible = true
warningDepth.visible = false
globalStates.state = "command"
return
}
if(text === "good_move"){
warningDepth.visible = false
warningReach.visible = false
return
}
var cmd = text.split(";")
if(cmd[0] === "poi" && globalStates.state === "command"){
pois.cmd = cmd
}
if(cmd[0] === "panda_pose"){
var pose = cmd[1].split(",")
var panda_pose =[]
for(var i=0;i<pose.length;i++){
panda_pose.push(parseFloat(pose[i]))
}
controlPanel.filter_button(panda_pose)
}
}
function onEvent(text){
console.log("event")
if(text === "start_exec"){
moving = true
}
if(text === "motion_finished"){
moving = false
for(var i =0; i < figures.children.length; i++){
if(figures.children[i].testDelete()){
try{
figures.children[i].destroy()
}
catch(err){
;
}
}
}
globalStates.state = "command"
delayedTimerUpdateActions.start()
return
}
var cmd = text.split(";")
if (cmd[0] === "action_finished"){
cmd = cmd[1].split(":")
var name = cmd[0]
var target = cmd[1]
for (var i = 0; i<figures.children.length;i++){
if(figures.children[i].testDone(name, target)){
gamePlan.update()
break
}
}
}
if (cmd[0] === "wait"){
if(globalStates.state !== "command"){
waitGui.visible = true
for(var j =0;j<pois.children.length;j++){
var poi = pois.children[j]
if(poi.name === cmd[1]){
roi.poi = poi
roi.x = poi.x-roi.width/2
roi.y = poi.y-roi.width/2
}
}
}
}
if (cmd[0] === "fd_takeover"){
globalStates.state = "force_dimension"
}
if (cmd[0] === "recorded"){
behaviorDisplay.addBehavior(cmd.splice(1).join(";"))
}
/*if (cmd[0] === "z_or"){
// Use commanded theta and add absolute difference, not relative! Use orientation on click?
var theta = -parseFloat(cmd[1])
rotationSlider.theta_r = theta*180/Math.PI
theta += rotationSlider.theta_h/180.*Math.PI
dial.x=rotationSlider.width/2*(1+Math.sin(theta))-dial.width/2
dial.y=rotationSlider.height/2*(1-Math.cos(theta))-dial.height/2
displayView.rotation = theta/Math.PI*180
return
var theta=Math.atan2(dialCenter.y-rotationSlider.width/2,dialCenter.x-rotationSlider.width/2)
theta += parseFloat(cmd[1])/25.
}*/
}
Recognizer{
id: recognizer
}
Column{
id: palette
visible: false
anchors.top: parent.top
anchors.topMargin: parent.height/10
anchors.right: parent.right
anchors.rightMargin: parent.width/10
spacing: 10