-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.py
251 lines (199 loc) · 11.4 KB
/
gui.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
import tkinter as tk
from datetime import datetime, timedelta
from db import DB
from ros import Ros
class GUI:
def __init__(self):
self.db = DB()
self.last_timestamp = self.db.get_last_timestamp()[0] or 0.0
self.current_timestamp = self.last_timestamp
for entry in self.db.get_entries():
print(entry)
self.root = tk.Tk()
button = tk.Button(self.root, text='add Timestamp', width=25, command=self.timestamp_callback)
button.grid(column=1, row=1)
button = tk.Button(self.root, text='update Timestamp', width=25, command=self.timestamp_update_callback)
button.grid(column=1, row=2)
text = tk.Text(self.root, height=1, width=40)
text.insert(tk.END, "Last Timestamp: " + str(self.last_timestamp))
text.grid(column=1, row=3)
button = tk.Button(self.root, text='distance: 5', width=25, command=self.distance5_callback)
button.grid(column=1, row=4)
button = tk.Button(self.root, text='distance: 10', width=25, command=self.distance10_callback)
button.grid(column=1, row=5)
button = tk.Button(self.root, text='distance: 15', width=25, command=self.distance15_callback)
button.grid(column=1, row=6)
button = tk.Button(self.root, text='distance: 20', width=25, command=self.distance20_callback)
button.grid(column=1, row=7)
button = tk.Button(self.root, text='distance: 25', width=25, command=self.distance25_callback)
button.grid(column=1, row=8)
button = tk.Button(self.root, text='distance: 30', width=25, command=self.distance30_callback)
button.grid(column=1, row=9)
button = tk.Button(self.root, text='distance: 35', width=25, command=self.distance35_callback)
button.grid(column=1, row=10)
button = tk.Button(self.root, text='distance: 40', width=25, command=self.distance40_callback)
button.grid(column=1, row=11)
button = tk.Button(self.root, text='distance: 45', width=25, command=self.distance45_callback)
button.grid(column=1, row=12)
button = tk.Button(self.root, text='distance: 50', width=25, command=self.distance50_callback)
button.grid(column=1, row=13)
button = tk.Button(self.root, text='walking away', width=25, command=self.walk_away_callback)
button.grid(column=2, row=1)
button = tk.Button(self.root, text='walking towards', width=25, command=self.walk_towards_callback)
button.grid(column=2, row=2)
button = tk.Button(self.root, text='walking right', width=25, command=self.walk_right_callback)
button.grid(column=2, row=3)
button = tk.Button(self.root, text='walking left', width=25, command=self.walk_left_callback)
button.grid(column=2, row=4)
button = tk.Button(self.root, text='walking away (crate)', width=25, command=self.walk_away_crate_callback)
button.grid(column=3, row=1)
button = tk.Button(self.root, text='walking towards (crate)', width=25, command=self.walk_towards_crate_callback)
button.grid(column=3, row=2)
button = tk.Button(self.root, text='walking right (crate)', width=25, command=self.walk_right_crate_callback)
button.grid(column=3, row=3)
button = tk.Button(self.root, text='walking left (crate)', width=25, command=self.walk_left_crate_callback)
button.grid(column=3, row=4)
button = tk.Button(self.root, text='crate down away', width=25, command=self.crate_down_away_callback)
button.grid(column=4, row=1)
button = tk.Button(self.root, text='crate down side', width=25, command=self.crate_down_side_callback)
button.grid(column=4, row=2)
button = tk.Button(self.root, text='crate down side (unhealthy)', width=25, command=self.crate_down_side_unhealthy_callback)
button.grid(column=4, row=3)
button = tk.Button(self.root, text='crate down towards', width=25, command=self.crate_down_towards_callback)
button.grid(column=4, row=4)
button = tk.Button(self.root, text='crate up away', width=25, command=self.crate_up_away_callback)
button.grid(column=5, row=1)
button = tk.Button(self.root, text='crate up side', width=25, command=self.crate_up_side_callback)
button.grid(column=5, row=2)
button = tk.Button(self.root, text='crate up side (unhealthy)', width=25, command=self.crate_up_side_unhealthy_callback)
button.grid(column=5, row=3)
button = tk.Button(self.root, text='crate up towards', width=25, command=self.crate_up_towards_callback)
button.grid(column=5, row=4)
button = tk.Button(self.root, text='gesture: wave', width=25, command=self.gesture_wave_callback)
button.grid(column=6, row=1)
button = tk.Button(self.root, text='gesture: come', width=25, command=self.gesture_come_callback)
button.grid(column=6, row=2)
button = tk.Button(self.root, text='gesture: shush', width=25, command=self.gesture_shush_callback)
button.grid(column=6, row=3)
button = tk.Button(self.root, text='gesture: stop', width=25, command=self.gesture_stop_callback)
button.grid(column=6, row=4)
button = tk.Button(self.root, text='gesture: thumbs up', width=25, command=self.gesture_thumbs_up_callback)
button.grid(column=6, row=5)
button = tk.Button(self.root, text='gesture: thumbs down', width=25, command=self.gesture_thumbs_down_callback)
button.grid(column=6, row=6)
button = tk.Button(self.root, text='gesture: arm up', width=25, command=self.gesture_arm_up_callback)
button.grid(column=6, row=7)
button = tk.Button(self.root, text='gesture: arm down', width=25, command=self.gesture_arm_down_callback)
button.grid(column=6, row=8)
button = tk.Button(self.root, text='pointing: 0', width=25, command=self.point0_callback)
button.grid(column=7, row=1)
button = tk.Button(self.root, text='pointing: 45', width=25, command=self.point45_callback)
button.grid(column=7, row=2)
button = tk.Button(self.root, text='pointing: 90', width=25, command=self.point90_callback)
button.grid(column=7, row=3)
button = tk.Button(self.root, text='pointing: 135', width=25, command=self.point135_callback)
button.grid(column=7, row=4)
button = tk.Button(self.root, text='pointing: 180', width=25, command=self.point180_callback)
button.grid(column=7, row=5)
button = tk.Button(self.root, text='pointing: 225', width=25, command=self.point225_callback)
button.grid(column=7, row=6)
button = tk.Button(self.root, text='pointing: 270', width=25, command=self.point270_callback)
button.grid(column=7, row=7)
button = tk.Button(self.root, text='pointing: 315', width=25, command=self.point315_callback)
button.grid(column=7, row=8)
def time_callback(self, msg):
self.current_timestamp = msg.clock.secs + msg.clock.nsecs * 1e-9
def timestamp_callback(self):
self.last_timestamp = self.current_timestamp
self.db.add_timestamp(self.last_timestamp)
def timestamp_update_callback(self):
self.db.update_timestamp(self.last_timestamp, self.current_timestamp)
self.last_timestamp = self.current_timestamp
def walk_away_callback(self):
self.db.add_type(self.last_timestamp, "walk_away")
def walk_towards_callback(self):
self.db.add_type(self.last_timestamp, "walk_towards")
def walk_right_callback(self):
self.db.add_type(self.last_timestamp, "walk_right")
def walk_left_callback(self):
self.db.add_type(self.last_timestamp, "walk_left")
def walk_away_crate_callback(self):
self.db.add_type(self.last_timestamp, "walk_away_crate")
def walk_towards_crate_callback(self):
self.db.add_type(self.last_timestamp, "walk_towards_crate")
def walk_right_crate_callback(self):
self.db.add_type(self.last_timestamp, "walk_right_crate")
def walk_left_crate_callback(self):
self.db.add_type(self.last_timestamp, "walk_left_crate")
def crate_down_away_callback(self):
self.db.add_type(self.last_timestamp, "crate_down_away")
def crate_down_side_callback(self):
self.db.add_type(self.last_timestamp, "crate_down_side")
def crate_down_side_unhealthy_callback(self):
self.db.add_type(self.last_timestamp, "crate_down_side_unhealthy")
def crate_down_towards_callback(self):
self.db.add_type(self.last_timestamp, "crate_down_towards")
def crate_up_away_callback(self):
self.db.add_type(self.last_timestamp, "crate_up_away")
def crate_up_side_callback(self):
self.db.add_type(self.last_timestamp, "crate_up_side")
def crate_up_side_unhealthy_callback(self):
self.db.add_type(self.last_timestamp, "crate_up_side_unhealthy")
def crate_up_towards_callback(self):
self.db.add_type(self.last_timestamp, "crate_up_towards")
def gesture_wave_callback(self):
self.db.add_type(self.last_timestamp, "gesture_wave")
def gesture_come_callback(self):
self.db.add_type(self.last_timestamp, "gesture_come")
def gesture_shush_callback(self):
self.db.add_type(self.last_timestamp, "gesture_shush")
def gesture_stop_callback(self):
self.db.add_type(self.last_timestamp, "gesture_stop")
def gesture_thumbs_up_callback(self):
self.db.add_type(self.last_timestamp, "gesture_thumbs_up")
def gesture_thumbs_down_callback(self):
self.db.add_type(self.last_timestamp, "gesture_thumbs_down")
def gesture_arm_up_callback(self):
self.db.add_type(self.last_timestamp, "gesture_arm_up")
def gesture_arm_down_callback(self):
self.db.add_type(self.last_timestamp, "gesture_arm_down")
def point0_callback(self):
self.db.add_type(self.last_timestamp, "point_0")
def point45_callback(self):
self.db.add_type(self.last_timestamp, "point_45")
def point90_callback(self):
self.db.add_type(self.last_timestamp, "point_90")
def point135_callback(self):
self.db.add_type(self.last_timestamp, "point_135")
def point180_callback(self):
self.db.add_type(self.last_timestamp, "point_180")
def point225_callback(self):
self.db.add_type(self.last_timestamp, "point_225")
def point270_callback(self):
self.db.add_type(self.last_timestamp, "point_270")
def point315_callback(self):
self.db.add_type(self.last_timestamp, "point_315")
def distance5_callback(self):
self.db.add_distance(self.last_timestamp, 5)
def distance10_callback(self):
self.db.add_distance(self.last_timestamp, 10)
def distance15_callback(self):
self.db.add_distance(self.last_timestamp, 15)
def distance20_callback(self):
self.db.add_distance(self.last_timestamp, 20)
def distance25_callback(self):
self.db.add_distance(self.last_timestamp, 25)
def distance30_callback(self):
self.db.add_distance(self.last_timestamp, 30)
def distance35_callback(self):
self.db.add_distance(self.last_timestamp, 35)
def distance40_callback(self):
self.db.add_distance(self.last_timestamp, 40)
def distance45_callback(self):
self.db.add_distance(self.last_timestamp, 45)
def distance50_callback(self):
self.db.add_distance(self.last_timestamp, 50)
def start(self):
Ros(self.time_callback)
self.root.mainloop()
self.db.close_db()