-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGUI_caller.py
766 lines (603 loc) · 25.2 KB
/
GUI_caller.py
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
import ast,os,sys
import signal
from PyQt4 import QtCore, QtGui
from PyQt4.Qwt5 import Qwt
import pyqtgraph as pg
from GUI.makeGUI import Ui_RhagGUI
from PyQt4.QtCore import QTimer
from PyQt4.QtGui import QApplication, QMainWindow
from classes.rosSubscriber import RosSubscriber
from helping.importHelper import *
from pathlib import Path
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
import numpy as np
import os
import sys
from qrangeslider import QRangeSlider
pathRun=os.path.abspath(os.path.split(sys.argv[0])[0]) #path of the runfile
pathJson= pathRun + '/GUI/jsonFiles/'
pathModel = pathRun + '/models/'
jsonDefault= pathJson + 'default.json' #path of 'default.json' #default .json-file
jsonRecent= pathJson + 'recent.json'
jsonCurrent=jsonRecent#pathJson+'temp.json' #modify a temp json file
jsonVR= pathJson + 'VR.json'
traj = 0
signal.signal(signal.SIGINT, signal.SIG_DFL)
filePath=Path(sys.path[0])
def saveSettings(win, path):
'''
collects attributes of all settings-objects
puts all objects in sereval lists
iterates through lists, puts object names with attribute in dictonary 'settings'
dumps dictionary in .json-file
:param win: Current window
:param path: File Path to which parameters of object to be dumped to
:return:
'''
#todo. rebase repetitive settings
settings = {}
box = win.findChildren(QtGui.QCheckBox)
line = win.findChildren(QtGui.QLineEdit)
radio = win.findChildren(QtGui.QRadioButton)
slider = win.findChildren(QtGui.QSlider)
spinInt = win.findChildren(QtGui.QSpinBox)
date = win.findChildren(QtGui.QDateEdit)
spinFloat = win.findChildren(QtGui.QDoubleSpinBox)
combo = win.findChildren(QtGui.QComboBox)
for item in radio:
box.append(item)
for item in spinInt:
slider.append(item)
for item in spinFloat:
slider.append(item)
for item in combo:
name = item.objectName()
text = str(item.currentText())
settings[str(name)] = text
for item in box: #checkboxes
name = item.objectName()
state = item.isChecked()
settings[str(name)] = state
for item in line: #lineEdits
name = item.objectName()
if str(name) == 'qt_spinbox_lineedit': #Bugfix: dateEdit, spinBox, doubleSpinbox
continue #get found by findChildren lineEdit, skip them here
text = item.text()
text = str(text)
try:
if ('[' and ']') in text: #if lineEdit returns [] convert to list
#if there is a fraction representation, converts it to float
if '/' in text:
#first convert the string such that, the elements are shielded by ast eval as a string
# as ast eval will cough up malformed string
text=text.replace('[', "['").replace(',', "','").replace(']', "']")
#then convert the string to a list with ast eval, with the fractions treated as strings
text=ast.literal_eval(text)
#now convert the string fractions into a fraction then to a float
text=[float(fractions.Fraction(x)) for x in text]
#Yay, now we have parsed the string of list rep into an actual list
else:#if not a fraction contatining list
text = ast.literal_eval(text)
elif ('(' and ')') in text:#if lineEdit returns () convert to list
text = ast.literal_eval(text)
else :
pass#non list tuple items
# print 'what have you entered here?',text
except Exception as e:
ui.statusbar.showMessage('Error')#todo: better message
print "error is",e
showError('list gone wrong')
settings[str(name)] = text
for item in slider: #sliders
name = item.objectName()
value = item.value()
settings[str(name)] = value
for item in date: #dateEdits
name = item.objectName()
value = str(item.date().toPyDate())#necessary, dateEdit returns strange Qdatething
#value = value.replace('-', '')
settings[str(name)] = value
tupleList=[]
for key, value in settings.iteritems():
if type(value)==tuple:
tupleList.append(key)
settings['toTuplify']=tupleList
with open(path, 'w') as dictFile:#dump everything
json.dump(settings, dictFile, sort_keys=True)
# print json.dumps(settings, sort_keys=True)
ui.statusbar.showMessage('Settings successfully saved to ' + path )
def loadSettings(win,path):
# collects attributes of all settings-objects
# puts all objects in sereval lists
# iterates through lists, sets attributes of objects to stored values
#saveSettings reverse
global jsonCurrent
jsonCurrent=path
load = {}
box = win.findChildren(QtGui.QCheckBox)
line = win.findChildren(QtGui.QLineEdit)
radio = win.findChildren(QtGui.QRadioButton)
slider = win.findChildren(QtGui.QSlider)
spinInt = win.findChildren(QtGui.QSpinBox)
spinFloat = win.findChildren(QtGui.QDoubleSpinBox)
date = win.findChildren(QtGui.QDateEdit)
combo = win.findChildren(QtGui.QComboBox)
for item in radio:
box.append(item)
for item in spinInt:
slider.append(item)
for item in spinFloat:
slider.append(item)
try:
with open(path, 'r') as dictFile:
set = json.load(dictFile)
try:
for item in set['toTuplify']:
set[item]=tuple(set[item])
# print set
except KeyError:
pass
except IOError:
ui.statusbar.showMessage('.json-file not changed')
return
for item in box:
try:
name = item.objectName()
load[name] = item
temp = load[name]
temp.setChecked(set[str(name)])
except KeyError:
pass
for item in combo:
try:
name = item.objectName()
load[name] = item
temp = load[name]
index = temp.findText(set[str(name)], QtCore.Qt.MatchFixedString)
temp.setCurrentIndex(index)
except:
pass
for item in line:
try:
name = item.objectName()
if str(name) == 'qt_spinbox_lineedit':
continue
load[name] = item
temp = load[name]
temp.setText(str(set[str(name)]))
except KeyError:
pass
for item in slider:
try:
name = item.objectName()
load[name] = item
temp = load[name]
temp.setValue(set[str(name)])
except KeyError:
pass
for item in date:
try:
name = item.objectName()
load[name] = item
temp = load[name]
qtDate = QtCore.QDate.fromString(set[str(name)], 'yyyy-MM-dd')
temp.setDate(qtDate)
except KeyError:
pass
ui.statusbar.showMessage('Settings successfully loaded from ' +path)
# ui.currentLabel.setText(jsonCurrent)
def openLoad(win):
'''
helper function to open a file and load the json
opens a fileDialog
:param win: current window
:return:
'''
global jsonCurrent
path=showFileDialog(win, None, pathJson)
print "path is", path
if path == '':
ui.statusbar.showMessage('Canceled')
pass
else:
loadSettings(win, path)
jsonCurrent=path
def openSave(win):
global jsonCurrent
path = showSaveDialog(win, pathJson)
print "path is",path
if path == '':
ui.statusbar.showMessage('Canceled')
pass
else:
saveSettings(win, path)
jsonCurrent=path
def showFileDialog(win, line, pathStart,local=True):
'''
opens file dialog, returns selected file as string
if selected file is .json, changes jsonFile
prints filename in defined lineEdit
:param win: current window
:param line: the line to be used to display the path
:return: the filepath selected
'''
fname = str(QtGui.QFileDialog.getOpenFileName(win, 'Open file', pathStart))
if local:
try:
fname = Path(fname).relative_to(filePath)#local path, get path relayive to repo root directory so that bugs
except ValueError:
print "SOmething off with fnames"
# dues to different usernames are avoided.
fname = str(fname)
if line and fname != '': #set only if given a label to setText
line.setText(fname)
return fname
def showSaveDialog(win, line):
fname = str(QtGui.QFileDialog.getSaveFileName(win, "Save file as", pathJson))
try:
if line and fname != '': #set only if given a label to setText
line.setText(fname)
return fname
except AttributeError:
return fname
def caller(btn, fx, line):
btn.clicked.connect(lambda: fx(window, line, pathModel))
def callLooper(myDict):
for key, values in myDict.iteritems():
caller(values[0], values[1], values[2])
def showError(message):
error = QtGui.QMessageBox()
error.setWindowTitle('Error message')
error.setText(message)
error.exec_()
def saveClose(win):
saveSettings(win, jsonRecent)
win.close()
def startVR():
global procVR
procVR=subprocess.Popen(['python', 'main.py'])
ui.tabWidget.setCurrentIndex(5)
def startRqt():
global procRqt
procRqt=subprocess.Popen(['rqt_plot'])
#showError("VR is not available")
def stopVR():
try:
procVR.kill()
try:
# s=ValveHandler(1)
baud = 115200
v1= ValveHandler(casePort=97, baud=baud)
v2= ValveHandler(casePort=98, baud=baud)
v3= ValveHandler(casePort=99, baud=baud)
# s.move(90)
v1.move(1)
v2.move(1)
v3.move(1)
v1.move(0)
v2.move(0)
v3.move(0)
# servo.move(99, 0) # close valve to prevent odour bleeding through
# servo.move(1, 90) # close valve to prevent odour bleeding through
print "disabled valves in VR"
except (serial.serialutil.SerialException, NameError):
print "arduino faulty finally GUI"
pass # arduino disconnected or faulty, let go
except NameError:
print "VR not running"
pass
def startRoscore():
subprocess.Popen(['roscore'])
def startCameraParam():
# text expansion of bash is disabled by default for security concerns.
# Since this is not user input string, security isn't a issue in this case
# subprocess.Popen(['gedit', '~/a.txt'],shell=True)
# subprocess.Popen(['gedit', '~/src.git/Kinefly/launch/rhag/camera_1394.launch'])
subprocess.call('gedit ~/src.git/Kinefly/launch/rhag/camera_1394.launch',shell=True)
def startWbad():
subprocess.Popen(["roslaunch", "Kinefly", "main.launch"]) # start kinefly
def clbk(data):
global traj
traj = data
return traj
def resetView(cx=512,cy=512,off=20):
# off=20
s0.setRange(xRange=(cx-off,cx+off),yRange=(cy-off,cy+off))
s1.setRange(xRange=(cx-off,cx+off),yRange=(cy-off,cy+off))
s2.setRange(xRange=(cx-off,cx+off),yRange=(cy-off,cy+off))
s3.setRange(xRange=(cx-off,cx+off),yRange=(cy-off,cy+off))
r0.setRange(xRange=(cx-off,cx+off),yRange=(cy-off,cy+off))
# s0.setRange(xRange=(512-off,512+off),yRange=(512-off,512+off))
# s1.setRange(xRange=(512-off,512+off),yRange=(512-off,512+off))
# s2.setRange(xRange=(512-off,512+off),yRange=(512-off,512+off))
# s3.setRange(xRange=(512-off,512+off),yRange=(512-off,512+off))
def tick():
global vals,curve,traj0s,traj1s,traj2s,traj3s,traj0r
try:
ui.compassServo.setValue(traj.servoAngle+90)
ui.compassServo_2.setValue(traj.servoAngle+90)
ui.compassHeading.setValue(traj.pOri.x)
ui.compassSlip.setValue(traj.slip)
# ui.compassSlip.setValue((((traj.slip+180)%360)-180-90)%360)
ui.lcdServoAngle.display(traj.servoAngle)
ui.lcdHeadingAngle.display(traj.pOri.x%360)
ui.lcdSlipAngle.display((traj.slip))
ui.livePosition.setText(str(traj.pPos))
if bool(traj.valve1):
ui.odourLed.on()
ui.replayOdourLed.on()
else:
ui.odourLed.off()
ui.replayOdourLed.off()
stateText="\ntrial\t\t: "+str(traj.trial)+ \
"\nrunNum\t\t: " + str(traj.runNum) + \
"\ncase\t\t: " + str(traj.case) + \
\
"\n\nDCoffset\t: " + str(traj.DCoffset) + \
"\nisFlying\t\t: " + str(bool(traj.isFlying)) + \
"\npacketFrequency\t: " + str(traj.packetFrequency) + \
\
"\n\nvalve1\t\t: " + str(bool(traj.valve1)) + \
"\nvalve2\t\t: " + str(bool(traj.valve2)) + \
"\nvalve3\t\t: " + str(bool(traj.valve3)) + \
\
"\n\nslip\t\t: " + str((traj.slip)) + \
"\ngroundSpeed\t: " + str((np.round(traj.groundSpeed,2))) + \
\
\
"\n\n\ngain\t\t: "+str(traj.gain)+\
"\nHeading Control\t: "+str(bool(traj.headingControl))+\
"\nSpeed Control\t: "+str(bool(traj.speedControl))+\
"\nspeed\t\t: "+str(traj.speed)+ \
"\npacketDuration\t: "+str(traj.packetDuration)+ \
"\nreset\t\t: " + str(bool(traj.reset))
# "\nheadingControl\t\t: " + str(bool(traj.headingControl)) + \
# "trial\t\t: "+str(traj.trial)+\
ui.liveState.setText(stateText)
if not ui.pausePlot.isChecked():
# spots = [{'pos': np.array([traj.pPos.x, traj.pPos.y])
# , 'data': 1}]
# spots=np.array([traj.pPos.x, traj.pPos.y])
# s1.addPoints(pos=[(traj.pPos.x, traj.pPos.y)])
# my_plot.addItem(s1)
def quadPlot(trajs,s):
trajs = np.vstack((trajs,
np.array([traj.pPos.x,
traj.pPos.y,
traj.runNum,
traj.trial,
traj.runNum*traj.trial])))
s.clear()
if traj.valve2==True:
sp=(255,0,0)
else:
sp=(0,0,255)
# print sp
# print 'a',trajs[:,3]
s.plot(trajs[:, 0], trajs[:, 1], pen=None,
symbol='o', symbolPen=(255,0,0),
symbolBrush=(255,0,0),symbolSize=4)
# s.addPoints(trajs[-1, 0], trajs[-1, 1], pen=None, symbol='o', symbolPen=(255, 255, 0), symbolSize=2)
s.plot([trajs[-1, 0]], [trajs[-1, 1]], pen=(6),
symbolBrush=(0,0,255), symbolPen='w',
symbol='o', symbolSize=4)
return trajs
if traj.case ==0:
traj0s=quadPlot(traj0s,s0)
elif traj.case ==1:
traj1s=quadPlot(traj1s,s1)
traj0r=quadPlot(traj0r,r0)
elif traj.case ==2:
traj2s=quadPlot(traj2s,s2)
traj0r=quadPlot(traj0r,r0)
elif traj.case ==3:
traj3s=quadPlot(traj3s,s3)
#
# traj1s=np.vstack((traj1s,np.array([traj.pPos.x,traj.pPos.y])))
# vals=np.append(vals,traj.wbad)
# s1.clear()
# s1.plot(traj1s[:,0],traj1s[:,1], pen=None, symbol='o', symbolPen=None, symbolSize=5)
vals = np.append(vals, traj.wbad)
y, x = np.histogram(vals, bins=np.linspace(-1, 1, 60))
## notice that len(x) == len(y)+1
## We are required to use stepMode=True so that PlotCurveItem will interpret this data correctly.
curve = pg.PlotDataItem(x, y, stepMode=True, fillLevel=0, brush=(0, 0, 255, 80))
line=pg.InfiniteLine(pos=vals.mean())
my_hist.clear()
my_hist.addItem(curve)
my_hist.addItem(line)
def trackingFly(w=10):
resetView(cx=traj.pPos.x,cy= traj.pPos.y,off=w)#cx=trajs[-1, 0],cy= trajs[-1, 1]), off=w)
if ui.trackFly.isChecked():
a=2.**(0.05*(-ui.verticalSlider.value()))
# print "a",a
trackingFly(w=a)
# trackingFly(w=ui.trackWidth.value())
# ui.trackWidth.setValue(s0.get)
# # Example 1
# rs1 = QRangeSlider()
# rs1.show()
# rs1.setWindowTitle('example 1')
# rs1.setRange(15, 35)
# rs1.setBackgroundStyle('background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #222, stop:1 #333);')
# rs1.setSpanStyle('background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #282, stop:1 #393);')
#
except AttributeError:
# print "something bad,no gui update"
pass
def setHeadingLcd():
ui.lcdNumber_3.display(ui.compassHeading.value() - 90) # offset origin to E and not North
def clearPlot():
global vals,curve,traj0s,traj1s,traj2s,traj3s,traj0r
vals = np.array([])
traj0s = np.array([0,0,0,0,0])
traj1s = np.array([0,0,0,0,0])
traj2s = np.array([0,0,0,0,0])
traj3s = np.array([0,0,0,0,0])
traj0r = np.array([0,0,0,0,0])
# traj0s = np.array([0,0])
# traj1s = np.array([0,0])
# traj2s = np.array([0,0])
# traj3s = np.array([0,0])
# curve.clear()
# my_hist.clear()
# s1.points()
s1.clear()
# my_plot.clear()
# my_plot.removeItem(s1)
#todo. clear plot os not working
if __name__ == '__main__':
#necessary for getting the GUI running
try:
rostopic.get_topic_class('/rosout') # is_rosmaster_running = True
except rostopic.ROSTopicIOException as e:
roscore = subprocess.Popen('roscore') # then start roscore yourself
time.sleep(1) # wait a bit to be sure the roscore is really launched
app = QApplication(sys.argv)
window = QMainWindow()
ui = Ui_RhagGUI()
ui.setupUi(window)
# # Example 1
# rs1 = QRangeSlider()
# rs1.show()
# rs1.setWindowTitle('example 1')
# rs1.setRange(15, 35)
# rs1.setBackgroundStyle('background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #222, stop:1 #333);')
# rs1.setSpanStyle('background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #282, stop:1 #393);')
# rs1 = QRangeSlider()
ui.trajRange=QRangeSlider(ui.tab_2)
# ui.trackFly = QtGui.QCheckBox(ui.tab_2)
# ui.trajRange.setGeometry(QtCore.QRect(540, 47, 111, 22)) #functions for several buttons
ui.trajRange.show()
# rs1.setWindowTitle('example 1')
ui.trajRange.setRange(15, 35)
ui.trajRange.setBackgroundStyle('background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #222, stop:1 #333);')
ui.trajRange.setSpanStyle('background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #282, stop:1 #393);')
#applying and loading settings, closing etc.
okBtn = ui.buttonBox.button(QtGui.QDialogButtonBox.Ok)#todo: Ok needs a function
okBtn.clicked.connect(lambda : saveSettings(window, jsonVR))
#okBtn.clicked.connect(ui.statusbar.showMessage('Ok has no function yet'))
cancelBtn = ui.buttonBox.button(QtGui.QDialogButtonBox.Cancel)
cancelBtn.clicked.connect(lambda: saveClose(window))#save to recent and close
# app.aboutToQuit.connect(lambda :saveClose(window))
#todo: is closing the window smart?
#todo: is saving last known config on cancel smart?
defaultBtn = ui.buttonBox.button(QtGui.QDialogButtonBox.RestoreDefaults)
defaultBtn.clicked.connect(lambda: loadSettings(window, jsonDefault))
saveBtn = ui.buttonBox.button(QtGui.QDialogButtonBox.Save)
saveBtn.clicked.connect(lambda: saveSettings(window, jsonCurrent))
saveAsBtn = ui.buttonBox.button(QtGui.QDialogButtonBox.SaveAll)
saveAsBtn.setText("Save as")
saveAsBtn.clicked.connect(lambda: openSave(window))
loadBtn = ui.buttonBox.button(QtGui.QDialogButtonBox.Open)
loadBtn.setText("Load")#because it is actually open button
# loadBtn.clicked.connect(lambda: loadSettings(window, filePath + jsonFile))
loadBtn.clicked.connect(lambda: openLoad(window))
resetBtn=ui.buttonBox.button(QtGui.QDialogButtonBox.Reset)
resetBtn.clicked.connect(lambda: loadSettings(window, jsonCurrent))
# recordPathBtn = ui.buttonBox.button(ui.frameRecordPathBtn)
# file = str(QFileDialog.getExistingDirectory(self, "Select Directory"))
ui.frameRecordPathBtn.clicked.connect(lambda: showSaveDialog(window, ui.frameRecordPath))
# 'frameRecordPath': [ui.frameRecordPathBtn,showSaveDialog,ui.frameRecordPath],
#todo. open the last tab on close
ui.startVRBtn.clicked.connect(lambda: startVR())
ui.stopVRBtn.clicked.connect(lambda: stopVR())
ui.camParamBtn.clicked.connect(lambda: startCameraParam())
ui.wbadBtn.clicked.connect(lambda: startWbad())
ui.rqtBtn.clicked.connect(lambda: startRqt())
ui.resetView.clicked.connect(lambda :resetView())
ui.clearPlot.clicked.connect(lambda :clearPlot())
ui.clearPlot_2.clicked.connect(lambda :clearPlot())
ui.replayPathBtn.clicked.connect(lambda :showFileDialog(window, ui.replayPath, pathModel,local=False))
# ui.greenTexPathBtn, showFileDialog, ui.greenTexPath
ui.compassServo.setNeedle(Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow))
ui.compassServo.setOrigin(270)
ui.compassServo_2.setNeedle(Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow))
ui.compassServo_2.setOrigin(270)
# to set north as north
# always start rosnode inside main else imports end in loop
ui.compassHeading.setNeedle(Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow))
ui.compassHeading.setOrigin(270)# to set north as north
ui.compassSlip.setNeedle(Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow))
ui.compassSlip.setOrigin(270)# to set north as north
RosSubscriber('GUI', '/trajectory', MsgTrajectory, clbk)
'''
replay plot
'''
replay_plot= pg.GraphicsLayoutWidget()
ui.replayTrajectoryLayout.addWidget(replay_plot)
r0 = replay_plot.addPlot(title="1")
# my_plot = pg.PlotWidget()
# ui.trajectoryLayout.addWidget(my_plot)
# s1 = pg.ScatterPlotItem(size=2, pen=pg.mkPen(None), brush=pg.mkBrush(255, 255, 255, 120))
my_plot = pg.GraphicsLayoutWidget()
ui.trajectoryLayout.addWidget(my_plot)
s1 = my_plot.addPlot(title="1")
s0 = my_plot.addPlot(title="0")
my_plot.nextRow()
s2 = my_plot.addPlot(title="2")
s3 = my_plot.addPlot(title="3")
s3.setXLink(s0)
s3.setYLink(s0)
s2.setXLink(s0)
s2.setYLink(s0)
s1.setXLink(s0)
s1.setYLink(s0)
my_hist=pg.PlotWidget()
ui.histog.addWidget(my_hist)
global vals,traj0s,traj1s,traj2s,traj3s,replay
traj0s = np.array([0, 0, 0, 0, 0])
traj1s = np.array([0, 0, 0, 0, 0])
traj2s = np.array([0, 0, 0, 0, 0])
traj3s = np.array([0, 0, 0, 0, 0])
traj0r = np.array([0, 0, 0, 0, 0])
# traj0s = np.array([0,0])
# traj1s = np.array([0,0])
# traj2s = np.array([0,0])
# traj3s = np.array([0,0])
vals = np.array([0])
y, x = np.histogram(vals, bins=np.linspace(-0.5, 0.5, 80))
resetView()
## notice that len(x) == len(y)+1
## We are required to use stepMode=True so that PlotCurveItem will interpret this data correctly.
# curve = pg.PlotItem(x, y, stepMode=True, fillLevel=0, brush=(0, 0, 255, 80))
#
# my_hist.addItem(curve)
timer = QTimer()
timer.timeout.connect(tick)
timer.start(1000/60.)
myDict = {
'greenTexPath': [ui.greenTexPathBtn, showFileDialog, ui.greenTexPath],
'redTexPath': [ui.redTexPathBtn, showFileDialog, ui.redTexPath],
'object1': [ui.obj1PathBtn, showFileDialog, ui.object1],
'object2': [ui.obj2PathBtn, showFileDialog, ui.object2],
'treeTexPath': [ui.treeTexPathBtn, showFileDialog, ui.treeTexPath],
'skyMapBtn': [ui.skyMapBtn, showFileDialog, ui.skyMap],
'skyMapNullBtn': [ui.skyMapNullBtn, showFileDialog, ui.skyMapNull],
'modelHeightMap': [ui.modelHeightMapBtn, showFileDialog, ui.modelHeightMap],
'modelTextureMap': [ui.modelTextureMapBtn, showFileDialog, ui.modelTextureMap],
'modelTextureMapNull': [ui.modelTextureMapNullBtn, showFileDialog, ui.modelTextureMapNull],
'odour1': [ui.odourBtn1, showFileDialog, ui.odour1],
'odour2': [ui.odourBtn2, showFileDialog, ui.odour2],
'odour3': [ui.odourBtn3, showFileDialog, ui.odour3],
'odour4': [ui.odourBtn4, showFileDialog, ui.odour4],
'odour1Mask': [ui.odour1MaskBtn, showFileDialog, ui.odour1Mask],
'odour2Mask': [ui.odour2MaskBtn, showFileDialog, ui.odour2Mask],
'odour3Mask': [ui.odour3MaskBtn, showFileDialog, ui.odour3Mask],
'odour4Mask': [ui.odour4MaskBtn, showFileDialog, ui.odour4Mask],
'beepPath': [ui.beepPathBtn,showFileDialog,ui.beepPath],
}
callLooper(myDict)
try:
loadSettings(window, jsonCurrent)#load the last run config
except ValueError:
pass
window.show()
try:
(app.exec_())
except KeyboardInterrupt:
sys.exit()
#nothing shall be behind this line!
#don"t even dare writing somethin here!
__Version__ = '3.2'