-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathPedsimAgentEditor.py
684 lines (629 loc) · 35.4 KB
/
PedsimAgentEditor.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
from PyQt5 import QtGui, QtCore, QtWidgets
import os
import copy
from FlatlandBodyEditor import *
from ArenaScenario import *
from QtExtensions import *
from HelperFunctions import *
class PedsimAgentEditor(QtWidgets.QWidget):
editorSaved = QtCore.pyqtSignal()
def __init__(self, pedsimAgentWidget = None, **kwargs):
super().__init__(**kwargs)
self.pedsimAgentWidget = pedsimAgentWidget
if pedsimAgentWidget == None:
self.pedsimAgent = PedsimAgent()
if get_ros_package_path("simulator_setup") != "":
path = os.path.join(get_ros_package_path("simulator_setup"), "dynamic_obstacles", "person_two_legged.model.yaml")
self.pedsimAgent.loadFlatlandModel(path)
else:
self.pedsimAgent = pedsimAgentWidget.pedsimAgent
self.tempFlatlandModel = FlatlandModel()
self.setup_ui()
self.updateValuesFromPedsimAgent()
self.updateWidgetsFromSelectedType()
self.updateWidgetsFromSelectedStartupMode()
def setup_ui(self):
self.setWindowTitle("Pedsim Agent Editor")
self.setLayout(QtWidgets.QGridLayout())
self.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
self.resize(600, 600)
self.move(220, 150)
# scrollarea
self.scrollArea = QtWidgets.QScrollArea(self)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setMinimumWidth(400)
self.layout().addWidget(self.scrollArea, 0, 0, 1, -1)
# frame
self.scrollAreaFrame = QtWidgets.QFrame()
self.scrollAreaFrame.setLayout(QtWidgets.QGridLayout())
self.scrollAreaFrame.setSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Maximum)
self.scrollAreaFrame.setMinimumWidth(400)
self.scrollArea.setWidget(self.scrollAreaFrame)
vertical_idx = 0
# heading "general"
general_label = QtWidgets.QLabel("#### General")
general_label.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(general_label, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
line = Line()
self.scrollAreaFrame.layout().addWidget(line, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# name
## label
self.nameLabel = QtWidgets.QLabel("Name")
self.nameLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.nameLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
## editbox
name = self.pedsimAgentWidget.name_label.text() if self.pedsimAgentWidget != None else "global agent"
self.name_edit = QtWidgets.QLineEdit(name)
self.name_edit.setFixedSize(200, 30)
self.scrollAreaFrame.layout().addWidget(self.name_edit, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# model file
## label
self.flatlandModelLabel = QtWidgets.QLabel("Flatland Model")
self.flatlandModelLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.flatlandModelLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
## choose button
self.modelButton = QtWidgets.QPushButton("Choose...")
self.modelButton.setFixedSize(200, 30)
self.modelButton.clicked.connect(self.onModelButtonClicked)
self.scrollAreaFrame.layout().addWidget(self.modelButton, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# type
## label
type_label = QtWidgets.QLabel("Type")
type_label.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(type_label, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
## dropdown
self.typeComboBox = QtWidgets.QComboBox()
for agent_type in PedsimAgentType:
self.typeComboBox.insertItem(agent_type.value, agent_type.name.lower())
self.typeComboBox.setFixedSize(200, 30)
self.typeComboBox.currentIndexChanged.connect(self.updateWidgetsFromSelectedType)
self.scrollAreaFrame.layout().addWidget(self.typeComboBox, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# amount
## label
amount_label = QtWidgets.QLabel("Amount")
amount_label.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(amount_label, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
## spin box
self.amountSpinBox = QtWidgets.QSpinBox()
self.amountSpinBox.setValue(1)
self.amountSpinBox.setMinimum(1)
self.amountSpinBox.setFixedSize(200, 30)
self.scrollAreaFrame.layout().addWidget(self.amountSpinBox, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# waypoint mode
## label
label = QtWidgets.QLabel("Waypoint Mode")
label.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(label, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
## dropdown
self.waypointModeComboBox = QtWidgets.QComboBox()
for mode in PedsimWaypointMode:
self.waypointModeComboBox.insertItem(mode.value, mode.name.lower())
self.waypointModeComboBox.setFixedSize(200, 30)
self.scrollAreaFrame.layout().addWidget(self.waypointModeComboBox, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# startup mode
## label
label = QtWidgets.QLabel("Startup Mode")
label.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(label, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
## dropdown
self.startupModeComboBox = QtWidgets.QComboBox()
for mode in PedsimStartupMode:
self.startupModeComboBox.insertItem(mode.value, mode.name.lower())
self.startupModeComboBox.setFixedSize(200, 30)
self.startupModeComboBox.currentIndexChanged.connect(self.updateWidgetsFromSelectedStartupMode)
self.scrollAreaFrame.layout().addWidget(self.startupModeComboBox, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# wait time
## label
self.waitTimeLabel = QtWidgets.QLabel("Wait Time (seconds)")
self.waitTimeLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.waitTimeLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
## spin box
self.waitTimeSpinBox = ArenaQDoubleSpinBox()
self.waitTimeSpinBox.setFixedSize(200, 30)
self.scrollAreaFrame.layout().addWidget(self.waitTimeSpinBox, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# trigger zone radius
## label
self.triggerZoneLabel = QtWidgets.QLabel("Trigger Zone Radius")
self.triggerZoneLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.triggerZoneLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
## spin box
self.triggerZoneSpinBox = ArenaQDoubleSpinBox()
self.triggerZoneSpinBox.setFixedSize(200, 30)
self.scrollAreaFrame.layout().addWidget(self.triggerZoneSpinBox, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# vmax
## label
self.vmax_label = QtWidgets.QLabel("Velocity<sub>max</sub>")
self.vmax_label.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.vmax_label, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
## slider
self.vmax_slider = ArenaSliderWidget(0, 20, 0.1, "m/s")
self.scrollAreaFrame.layout().addWidget(self.vmax_slider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# max talking distance
### label
self.maxTalkingDistanceLabel = QtWidgets.QLabel("Max Talking Distance")
self.maxTalkingDistanceLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.maxTalkingDistanceLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.maxTalkingDistanceSlider = ArenaSliderWidget(0, 10, 1, "m")
self.scrollAreaFrame.layout().addWidget(self.maxTalkingDistanceSlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# forces
## heading
label = QtWidgets.QLabel("#### Force Factors")
label.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(label, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
line = Line()
self.scrollAreaFrame.layout().addWidget(line, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## Desired
### label
label = QtWidgets.QLabel("Desired")
label.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(label, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.desiredForceSlider = ArenaSliderWidget(0, 20, 1, "")
self.desiredForceSlider.slider.setValue(1)
self.scrollAreaFrame.layout().addWidget(self.desiredForceSlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## Obstacle
### label
label = QtWidgets.QLabel("Obstacle")
label.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(label, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.obstacleForceSlider = ArenaSliderWidget(0, 20, 1, "")
self.obstacleForceSlider.slider.setValue(1)
self.scrollAreaFrame.layout().addWidget(self.obstacleForceSlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## Social
### label
label = QtWidgets.QLabel("Social")
label.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(label, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.socialForceSlider = ArenaSliderWidget(0, 20, 1, "")
self.socialForceSlider.slider.setValue(1)
self.scrollAreaFrame.layout().addWidget(self.socialForceSlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## Robot
### label
label = QtWidgets.QLabel("Robot")
label.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(label, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.robotForceSlider = ArenaSliderWidget(0, 20, 1, "")
self.robotForceSlider.slider.setValue(1)
self.scrollAreaFrame.layout().addWidget(self.robotForceSlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# individual talking
## heading
self.individualTalkingLabel = QtWidgets.QLabel("#### Individual Talking")
self.individualTalkingLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.individualTalkingLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
self.individualTalkingLine = Line()
self.scrollAreaFrame.layout().addWidget(self.individualTalkingLine, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## probability
### label
self.individualTalkingProbabilityLabel = QtWidgets.QLabel("Probability")
self.individualTalkingProbabilityLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.individualTalkingProbabilityLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.individualTalkingProbabilitySlider = ArenaProbabilitySliderWidget()
self.scrollAreaFrame.layout().addWidget(self.individualTalkingProbabilitySlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## base time
### label
self.individualTalkingBaseTimeLabel = QtWidgets.QLabel("Base Time")
self.individualTalkingBaseTimeLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.individualTalkingBaseTimeLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.individualTalkingBaseTimeSlider = ArenaSliderWidget(0, 100, 1, "s")
self.scrollAreaFrame.layout().addWidget(self.individualTalkingBaseTimeSlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# group talk
## heading
self.groupTalkLabel = QtWidgets.QLabel("#### Group Talk")
self.groupTalkLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.groupTalkLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
self.groupTalkLine = Line()
self.scrollAreaFrame.layout().addWidget(self.groupTalkLine, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## probability
### label
self.groupTalkProbabilityLabel = QtWidgets.QLabel("Probability")
self.groupTalkProbabilityLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.groupTalkProbabilityLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.groupTalkProbabilitySlider = ArenaProbabilitySliderWidget()
self.scrollAreaFrame.layout().addWidget(self.groupTalkProbabilitySlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## base time
### label
self.groupTalkBaseTimeLabel = QtWidgets.QLabel("Base Time")
self.groupTalkBaseTimeLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.groupTalkBaseTimeLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.groupTalkBaseTimeSlider = ArenaSliderWidget(0, 100, 1, "s")
self.scrollAreaFrame.layout().addWidget(self.groupTalkBaseTimeSlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# talk and walk
## heading
self.talkWalkLabel = QtWidgets.QLabel("#### Talk & Walk")
self.talkWalkLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.talkWalkLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
self.talkWalkLine = Line()
self.scrollAreaFrame.layout().addWidget(self.talkWalkLine, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## probability
### label
self.talkWalkProbabilityLabel = QtWidgets.QLabel("Probability")
self.talkWalkProbabilityLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.talkWalkProbabilityLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.talkWalkProbabilitySlider = ArenaProbabilitySliderWidget()
self.scrollAreaFrame.layout().addWidget(self.talkWalkProbabilitySlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## base time
### label
self.talkWalkBaseTimeLabel = QtWidgets.QLabel("Base Time")
self.talkWalkBaseTimeLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.talkWalkBaseTimeLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.talkWalkBaseTimeSlider = ArenaSliderWidget(0, 100, 1, "s")
self.scrollAreaFrame.layout().addWidget(self.talkWalkBaseTimeSlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# requesting service
## heading
self.requestingServiceLabel = QtWidgets.QLabel("#### Requesting Service")
self.requestingServiceLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.requestingServiceLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
self.requestingServiceLine = Line()
self.scrollAreaFrame.layout().addWidget(self.requestingServiceLine, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## probability
### label
self.requestingServiceProbabilityLabel = QtWidgets.QLabel("Probability")
self.requestingServiceProbabilityLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.requestingServiceProbabilityLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.requestingServiceProbabilitySlider = ArenaProbabilitySliderWidget()
self.scrollAreaFrame.layout().addWidget(self.requestingServiceProbabilitySlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## max service distance
### label
self.maxServiceDistanceLabel = QtWidgets.QLabel("Max Service Distance")
self.maxServiceDistanceLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.maxServiceDistanceLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.maxServiceDistanceSlider = ArenaSliderWidget(0, 10, 1, "m")
self.scrollAreaFrame.layout().addWidget(self.maxServiceDistanceSlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## base time requesting
### label
self.requestingServiceRequestingBaseTimeLabel = QtWidgets.QLabel("Base Time (req.)")
self.requestingServiceRequestingBaseTimeLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.requestingServiceRequestingBaseTimeLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.requestingServiceRequestingBaseTimeSlider = ArenaSliderWidget(0, 100, 1, "s")
self.scrollAreaFrame.layout().addWidget(self.requestingServiceRequestingBaseTimeSlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## base time receiving
### label
self.requestingServiceReceivingBaseTimeLabel = QtWidgets.QLabel("Base Time (recv.)")
self.requestingServiceReceivingBaseTimeLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.requestingServiceReceivingBaseTimeLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.requestingServiceReceivingBaseTimeSlider = ArenaSliderWidget(0, 100, 1, "s")
self.scrollAreaFrame.layout().addWidget(self.requestingServiceReceivingBaseTimeSlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# requesting guide
## heading
self.requestingGuideLabel = QtWidgets.QLabel("#### Requesting Guide")
self.requestingGuideLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.requestingGuideLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
self.requestingGuideLine = Line()
self.scrollAreaFrame.layout().addWidget(self.requestingGuideLine, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## probability
### label
self.requestingGuideProbabilityLabel = QtWidgets.QLabel("Probability")
self.requestingGuideProbabilityLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.requestingGuideProbabilityLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.requestingGuideProbabilitySlider = ArenaProbabilitySliderWidget()
self.scrollAreaFrame.layout().addWidget(self.requestingGuideProbabilitySlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# requesting follower
## heading
self.requestingFollowerLabel = QtWidgets.QLabel("#### Requesting Follower")
self.requestingFollowerLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.requestingFollowerLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
self.requestingFollowerLine = Line()
self.scrollAreaFrame.layout().addWidget(self.requestingFollowerLine, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
## probability
### label
self.requestingFollowerProbabilityLabel = QtWidgets.QLabel("Probability")
self.requestingFollowerProbabilityLabel.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
self.scrollAreaFrame.layout().addWidget(self.requestingFollowerProbabilityLabel, vertical_idx, 0, QtCore.Qt.AlignmentFlag.AlignLeft)
### slider
self.requestingFollowerProbabilitySlider = ArenaProbabilitySliderWidget()
self.scrollAreaFrame.layout().addWidget(self.requestingFollowerProbabilitySlider, vertical_idx, 1, QtCore.Qt.AlignmentFlag.AlignRight)
vertical_idx += 1
# save button
self.save_button = QtWidgets.QPushButton("Save and Close")
self.save_button.clicked.connect(self.onSaveClicked)
self.layout().addWidget(self.save_button, 1, 0, -1, -1)
def updateWidgetsFromSelectedStartupMode(self):
mode = PedsimStartupMode(self.startupModeComboBox.currentIndex())
if mode == PedsimStartupMode.DEFAULT:
self.waitTimeLabel.hide()
self.waitTimeSpinBox.hide()
self.triggerZoneLabel.hide()
self.triggerZoneSpinBox.hide()
elif mode == PedsimStartupMode.WAIT_TIMER:
self.waitTimeLabel.show()
self.waitTimeSpinBox.show()
self.triggerZoneLabel.hide()
self.triggerZoneSpinBox.hide()
elif mode == PedsimStartupMode.TRIGGER_ZONE:
self.waitTimeLabel.hide()
self.waitTimeSpinBox.hide()
self.triggerZoneLabel.show()
self.triggerZoneSpinBox.show()
def updateWidgetsFromSelectedType(self):
agent_type = PedsimAgentType(self.typeComboBox.currentIndex())
if agent_type in [PedsimAgentType.ADULT, PedsimAgentType.CHILD, PedsimAgentType.ELDER]:
# max talking distance
self.maxTalkingDistanceLabel.show()
self.maxTalkingDistanceSlider.show()
# individual talking
self.individualTalkingLabel.show()
self.individualTalkingLine.show()
self.individualTalkingProbabilityLabel.show()
self.individualTalkingProbabilitySlider.show()
self.individualTalkingBaseTimeLabel.show()
self.individualTalkingBaseTimeSlider.show()
# group talk
self.groupTalkLabel.show()
self.groupTalkLine.show()
self.groupTalkProbabilityLabel.show()
self.groupTalkProbabilitySlider.show()
self.groupTalkBaseTimeLabel.show()
self.groupTalkBaseTimeSlider.show()
# talk and walk
self.talkWalkLabel.show()
self.talkWalkLine.show()
self.talkWalkProbabilityLabel.show()
self.talkWalkProbabilitySlider.show()
self.talkWalkBaseTimeLabel.show()
self.talkWalkBaseTimeSlider.show()
# requesting service
self.requestingServiceLabel.show()
self.requestingServiceLine.show()
self.requestingServiceProbabilityLabel.show()
self.requestingServiceProbabilitySlider.show()
self.maxServiceDistanceLabel.hide()
self.maxServiceDistanceSlider.hide()
self.requestingServiceRequestingBaseTimeLabel.show()
self.requestingServiceRequestingBaseTimeSlider.show()
self.requestingServiceReceivingBaseTimeLabel.show()
self.requestingServiceReceivingBaseTimeSlider.show()
# requesting guide
self.requestingGuideLabel.show()
self.requestingGuideLine.show()
self.requestingGuideProbabilityLabel.show()
self.requestingGuideProbabilitySlider.show()
# requesting follower
self.requestingFollowerLabel.show()
self.requestingFollowerLine.show()
self.requestingFollowerProbabilityLabel.show()
self.requestingFollowerProbabilitySlider.show()
elif agent_type == PedsimAgentType.FORKLIFT:
# max talking distance
self.maxTalkingDistanceLabel.hide()
self.maxTalkingDistanceSlider.hide()
# individual talking
self.individualTalkingLabel.hide()
self.individualTalkingLine.hide()
self.individualTalkingProbabilityLabel.hide()
self.individualTalkingProbabilitySlider.hide()
self.individualTalkingBaseTimeLabel.hide()
self.individualTalkingBaseTimeSlider.hide()
# group talk
self.groupTalkLabel.hide()
self.groupTalkLine.hide()
self.groupTalkProbabilityLabel.hide()
self.groupTalkProbabilitySlider.hide()
self.groupTalkBaseTimeLabel.hide()
self.groupTalkBaseTimeSlider.hide()
# talk and walk
self.talkWalkLabel.hide()
self.talkWalkLine.hide()
self.talkWalkProbabilityLabel.hide()
self.talkWalkProbabilitySlider.hide()
self.talkWalkBaseTimeLabel.hide()
self.talkWalkBaseTimeSlider.hide()
# requesting service
self.requestingServiceLabel.hide()
self.requestingServiceLine.hide()
self.requestingServiceProbabilityLabel.hide()
self.requestingServiceProbabilitySlider.hide()
self.maxServiceDistanceLabel.hide()
self.maxServiceDistanceSlider.hide()
self.requestingServiceRequestingBaseTimeLabel.hide()
self.requestingServiceRequestingBaseTimeSlider.hide()
self.requestingServiceReceivingBaseTimeLabel.hide()
self.requestingServiceReceivingBaseTimeSlider.hide()
# requesting guide
self.requestingGuideLabel.hide()
self.requestingGuideLine.hide()
self.requestingGuideProbabilityLabel.hide()
self.requestingGuideProbabilitySlider.hide()
# requesting follower
self.requestingFollowerLabel.hide()
self.requestingFollowerLine.hide()
self.requestingFollowerProbabilityLabel.hide()
self.requestingFollowerProbabilitySlider.hide()
elif agent_type == PedsimAgentType.SERVICEROBOT:
# max talking distance
self.maxTalkingDistanceLabel.hide()
self.maxTalkingDistanceSlider.hide()
# individual talking
self.individualTalkingLabel.hide()
self.individualTalkingLine.hide()
self.individualTalkingProbabilityLabel.hide()
self.individualTalkingProbabilitySlider.hide()
self.individualTalkingBaseTimeLabel.hide()
self.individualTalkingBaseTimeSlider.hide()
# group talk
self.groupTalkLabel.hide()
self.groupTalkLine.hide()
self.groupTalkProbabilityLabel.hide()
self.groupTalkProbabilitySlider.hide()
self.groupTalkBaseTimeLabel.hide()
self.groupTalkBaseTimeSlider.hide()
# talk and walk
self.talkWalkLabel.hide()
self.talkWalkLine.hide()
self.talkWalkProbabilityLabel.hide()
self.talkWalkProbabilitySlider.hide()
self.talkWalkBaseTimeLabel.hide()
self.talkWalkBaseTimeSlider.hide()
# requesting service
self.requestingServiceLabel.show()
self.requestingServiceLine.show()
self.requestingServiceProbabilityLabel.hide()
self.requestingServiceProbabilitySlider.hide()
self.maxServiceDistanceLabel.show()
self.maxServiceDistanceSlider.show()
self.requestingServiceRequestingBaseTimeLabel.hide()
self.requestingServiceRequestingBaseTimeSlider.hide()
self.requestingServiceReceivingBaseTimeLabel.hide()
self.requestingServiceReceivingBaseTimeSlider.hide()
# requesting guide
self.requestingGuideLabel.hide()
self.requestingGuideLine.hide()
self.requestingGuideProbabilityLabel.hide()
self.requestingGuideProbabilitySlider.hide()
# requesting follower
self.requestingFollowerLabel.hide()
self.requestingFollowerLine.hide()
self.requestingFollowerProbabilityLabel.hide()
self.requestingFollowerProbabilitySlider.hide()
def updateValuesFromPedsimAgent(self):
self.setModelPath(self.pedsimAgent.yaml_file)
self.typeComboBox.setCurrentIndex(PedsimAgentType[self.pedsimAgent.type.upper()].value)
self.amountSpinBox.setValue(self.pedsimAgent.number_of_peds)
self.vmax_slider.setValue(self.pedsimAgent.vmax)
self.startupModeComboBox.setCurrentIndex(PedsimStartupMode[self.pedsimAgent.start_up_mode.upper()].value)
self.waitTimeSpinBox.setValue(self.pedsimAgent.wait_time)
self.triggerZoneSpinBox.setValue(self.pedsimAgent.trigger_zone_radius)
self.individualTalkingProbabilitySlider.setValue(self.pedsimAgent.chatting_probability)
self.groupTalkProbabilitySlider.setValue(self.pedsimAgent.group_talking_probability)
self.talkWalkProbabilitySlider.setValue(self.pedsimAgent.talking_and_walking_probability)
self.requestingServiceProbabilitySlider.setValue(self.pedsimAgent.requesting_service_probability)
self.requestingGuideProbabilitySlider.setValue(self.pedsimAgent.requesting_guide_probability)
self.requestingFollowerProbabilitySlider.setValue(self.pedsimAgent.requesting_follower_probability)
self.maxTalkingDistanceSlider.setValue(self.pedsimAgent.max_talking_distance)
self.maxServiceDistanceSlider.setValue(self.pedsimAgent.max_servicing_radius)
self.individualTalkingBaseTimeSlider.setValue(self.pedsimAgent.talking_base_time)
self.groupTalkBaseTimeSlider.setValue(self.pedsimAgent.group_talking_base_time)
self.talkWalkBaseTimeSlider.setValue(self.pedsimAgent.talking_and_walking_base_time)
self.requestingServiceReceivingBaseTimeSlider.setValue(self.pedsimAgent.receiving_service_base_time)
self.requestingServiceRequestingBaseTimeSlider.setValue(self.pedsimAgent.requesting_service_base_time)
# forces
self.desiredForceSlider.setValue(self.pedsimAgent.force_factor_desired)
self.obstacleForceSlider.setValue(self.pedsimAgent.force_factor_obstacle)
self.socialForceSlider.setValue(self.pedsimAgent.force_factor_social)
self.robotForceSlider.setValue(self.pedsimAgent.force_factor_robot)
self.waypointModeComboBox.setCurrentIndex(PedsimWaypointMode(self.pedsimAgent.waypoint_mode).value)
self.name_edit.setText(self.pedsimAgent.name)
def show(self):
self.updateValuesFromPedsimAgent()
return super().show()
def onModelButtonClicked(self):
initial_folder = os.path.join(get_ros_package_path("simulator_setup"), "dynamic_obstacles")
res = QtWidgets.QFileDialog.getOpenFileName(parent=self, directory=initial_folder)
path = res[0]
if path != "":
self.setModelPath(path)
def setModelPath(self, path: str):
if os.path.exists(path):
self.tempFlatlandModel.load(path)
self.modelButton.setText(path.split("/")[-1])
def updatePedsimAgentFromWidgets(self, agent: PedsimAgent):
agent.type = PedsimAgentType(self.typeComboBox.currentIndex()).name.lower()
agent.number_of_peds = self.amountSpinBox.value()
agent.vmax = self.vmax_slider.getValue()
agent.start_up_mode = PedsimStartupMode(self.startupModeComboBox.currentIndex()).name.lower()
agent.wait_time = self.waitTimeSpinBox.value()
agent.trigger_zone_radius = self.triggerZoneSpinBox.value()
agent.chatting_probability = self.individualTalkingProbabilitySlider.getValue()
agent.group_talking_probability = self.groupTalkProbabilitySlider.getValue()
agent.talking_and_walking_probability = self.talkWalkProbabilitySlider.getValue()
agent.requesting_service_probability = self.requestingServiceProbabilitySlider.getValue()
agent.requesting_guide_probability = self.requestingGuideProbabilitySlider.getValue()
agent.requesting_follower_probability = self.requestingFollowerProbabilitySlider.getValue()
agent.max_talking_distance = self.maxTalkingDistanceSlider.getValue()
agent.max_servicing_radius = self.maxServiceDistanceSlider.getValue()
agent.talking_base_time = self.individualTalkingBaseTimeSlider.getValue()
agent.group_talking_base_time = self.groupTalkBaseTimeSlider.getValue()
agent.talking_and_walking_base_time = self.talkWalkBaseTimeSlider.getValue()
agent.receiving_service_base_time = self.requestingServiceReceivingBaseTimeSlider.getValue()
agent.requesting_service_base_time = self.requestingServiceRequestingBaseTimeSlider.getValue()
# forces
agent.force_factor_desired = self.desiredForceSlider.getValue()
agent.force_factor_obstacle = self.obstacleForceSlider.getValue()
agent.force_factor_social = self.socialForceSlider.getValue()
agent.force_factor_robot = self.robotForceSlider.getValue()
agent.waypoint_mode = PedsimWaypointMode(self.waypointModeComboBox.currentIndex()).value
agent.yaml_file = self.tempFlatlandModel.path
agent.name = self.name_edit.text()
agent.flatlandModel = self.tempFlatlandModel
def onSaveClicked(self):
self.updatePedsimAgentFromWidgets(self.pedsimAgent)
self.hide()
self.editorSaved.emit()
def closeEvent(self, event):
# check if any changes have been made
current_agent = copy.deepcopy(self.pedsimAgent)
self.updatePedsimAgentFromWidgets(current_agent)
if self.pedsimAgent != current_agent:
# ask user if changes should be saved
msg_box = QtWidgets.QMessageBox()
msg_box.setText("Do you want to save changes to this agent?")
msg_box.setStandardButtons(QtWidgets.QMessageBox.Save | QtWidgets.QMessageBox.Discard | QtWidgets.QMessageBox.Cancel)
msg_box.setDefaultButton(QtWidgets.QMessageBox.Save)
ret = msg_box.exec()
if ret == QtWidgets.QMessageBox.Save:
self.onSaveClicked()
elif ret == QtWidgets.QMessageBox.Discard:
# reset to values already saved
self.updateValuesFromPedsimAgent()
elif ret == QtWidgets.QMessageBox.Cancel:
event.ignore()
class PedsimAgentEditorGlobalConfig(PedsimAgentEditor):
"""
A Pedsim Agent Editor excluding widgets that shouldn't be globally configured
and without a parent PedsimAgentWidget.
"""
def __init__(self, **kwargs):
super().__init__(**kwargs)
def setup_ui(self):
super().setup_ui()
self.nameLabel.hide()
self.name_edit.hide()
self.flatlandModelLabel.hide()
self.modelButton.hide()