-
Notifications
You must be signed in to change notification settings - Fork 14
/
robotchecks
executable file
·336 lines (282 loc) · 8.98 KB
/
robotchecks
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
#!/usr/bin/env python3
import sys
import os
import re
import time
from utils import *
import subprocess
import signal
# Retrieving ip and hostname
ip: str = "10.0.0.1" if len(sys.argv) == 1 else sys.argv[1]
hostname: str = rhio_get_value(ip, "/server/hostname")
bright(f"[STARTUP] Running a startup to {ip}, hostname is {hostname}")
def check_all(func):
for i in range(1, len(func)+1):
result = func[i]()
def check_devices():
step_title("CHECK PRESENCE OF DEVICES")
# Checking devices
while True:
bright(f"[CHECK] Checking that devices are present...")
result = rhio(ip, "rhalCheck")
if "All devices are present" not in result:
error(result)
if not yes_no("Devices are missing, try again ?", "y"):
break
else:
success("[CHECK] All devices are present")
break
def zero_leg_backslash():
step_title("ZERO AND LEGS BACKLASH")
bright("[INIT] Press ENTER to run init")
input()
print(rhio(ip, "init"))
step_msg_check("Check for misalignments and important backlashes")
press_enter()
def piano_wires():
step_title("PIANO WIRES")
step_msg_check(
"Check that piano wires are not bent, head should not hit the ground when the robot fall"
)
press_enter()
def camera_focus_horizon():
step_title("CAMERA FOCUS AND HORIZON CHECK")
step_msg_check("Check that the camera focus is not blurry")
step_msg_check(
"Check that the (blue) horizon line is properly positionned.\nYou can have a look at a goal post, the horizon line should be at the same height that the robot if it was there."
)
bright("[CAMERAHORIZONVIEW] Press enter to view Horizon Camera")
input()
print(rhio(ip, "view /Vision/TaggedImg"))
def perception_yolo():
step_title("PERCEPTION YOLO CHECK")
step_msg_check("Check that the objects are well detected.")
bright("[CAMERAYOLOVIEW] Press enter to view Yolo Camera")
input()
print(rhio(ip, "view /Vision/yolo/out"))
def ball_position():
step_title("BALL POSITION CHECK")
bright("[WALK] Press ENTER to run walk")
input()
print(rhio(ip, "walk"))
print(rhio(ip, "/moves/head/disabled=0"))
step_msg_check("Put the ball in front of the robot")
bright("Press enter when the ball is placed...")
input()
print(
rhio(ip, "localisation/ballX")
+ Style.BRIGHT
+ Fore.YELLOW
+ " should be ~0.2"
+ Style.RESET_ALL
)
print(
rhio(ip, "localisation/ballY")
+ Style.BRIGHT
+ Fore.YELLOW
+ " should be 0"
+ Style.RESET_ALL
)
while True:
if yes_no("Do you want to try again ?", "n"):
print(
rhio(ip, "localisation/ballX")
+ Style.BRIGHT
+ Fore.YELLOW
+ " should be ~0.2"
+ Style.RESET_ALL
)
print(
rhio(ip, "localisation/ballY")
+ Style.BRIGHT
+ Fore.YELLOW
+ " should be 0"
+ Style.RESET_ALL
)
else:
break
def standup():
bright("[WALK] Press ENTER to run walk")
input()
print(rhio(ip, "walk"))
step_title("STANDUP CHECK")
step_msg_check("Put the robot on the FRONT side")
bright("[STANDUP] Press enter to try standing up")
input()
print(rhio(ip, "standup"))
while rhio_get_value(ip, "/moves/standup/over") == "false":
time.sleep(0.2)
rhio(ip, "stop")
time.sleep(0.2)
rhio(ip, "walk")
while True:
if yes_no("Do you want to try again ?", "n"):
print(rhio(ip, "standup"))
while rhio_get_value(ip, "/moves/standup/over") == "false":
time.sleep(0.2)
rhio(ip, "stop")
time.sleep(0.2)
rhio(ip, "walk")
else:
break
step_msg_check("Put the robot on the BACK side")
bright("[STANDUP] Press enter to try standing up")
input()
print(rhio(ip, "standup"))
while rhio_get_value(ip, "/moves/standup/over") == "false":
time.sleep(0.2)
rhio(ip, "stop")
time.sleep(0.2)
rhio(ip, "walk")
while True:
if yes_no("Do you want to try again ?", "n"):
print(rhio(ip, "standup"))
while rhio_get_value(ip, "/moves/standup/over") == "false":
time.sleep(0.2)
rhio(ip, "stop")
time.sleep(0.2)
rhio(ip, "walk")
else:
break
def kick_ball():
step_title("KICK CHECK")
bright("[WALK] Press ENTER to run walk")
input()
print(rhio(ip, "walk"))
step_msg_check("Put a ball in front of the RIGHT kick")
rhio(ip, "/moves/kick/kickName=classic")
rhio(ip, "/moves/kick/left=false")
bright("[KICK] Press enter to try RIGHT CLASSIC kick")
input()
rhio(ip, "kick")
while True:
if yes_no("Do you want to try again ?", "n"):
rhio(ip, "kick")
else:
break
step_msg_check("Put a ball in front of the RIGHT kick")
rhio(ip, "/moves/kick/kickName=small")
bright("[KICK] Press enter to try RIGHT SMALL kick")
input()
rhio(ip, "kick")
while True:
if yes_no("Do you want to try again ?", "n"):
rhio(ip, "kick")
else:
break
if yes_no("Do you want to check LEFT foot ?", "n"):
rhio(ip, "/moves/kick/kickName=classic")
rhio(ip, "/moves/kick/left=true")
step_msg_check("Put a ball in front of the LEFT kick")
bright("[KICK] Press enter to try LEFT CLASSIC kick")
input()
rhio(ip, "kick")
while True:
if yes_no("Do you want to try again ?", "n"):
rhio(ip, "kick")
else:
break
rhio(ip, "/moves/kick/kickName=small")
bright("[KICK] Press enter to try LEFT SMALL kick")
input()
rhio(ip, "kick")
while True:
if yes_no("Do you want to try again ?", "n"):
rhio(ip, "kick")
else:
break
def imu():
step_title("IMU CHECK")
bright("[WALK] Press ENTER to run walk")
input()
print(rhio(ip, "walk"))
os.chdir("{0}/src/rhoban/sigmaban_model/".format(os.getcwd()))
print("Current working directory: {0}".format(os.getcwd()))
step_msg_check("Put the robot on the ground")
f = open(os.devnull, "w")
with subprocess.Popen(["python3", "client.py", ip], stdout=f, stderr=f) as proc:
print("PyBullet Launched")
print("Press Esc to quit Pybullet")
def foot_pressure():
step_title("FOOT PRESSURE CHECK")
bright("Putting robot in 'tare' mode")
while True:
bright("[TARE] Hold me in the air for the tare and press ENTER")
input()
bright("[TARE] Taring...")
result = rhio(ip, "tare")
if "Error" in result:
error(result)
if not yes_no("[TARE] Error while taring, try again ?", "y"):
break
else:
success("[TARE] Tare successful")
break
step_msg_check(
"Press the RIGHT foot jauges and check that each one is moving positively"
)
with subprocess.Popen(
[
"rhio",
hostname,
"plot",
"/lowlevel/right_pressure/pressure_0",
"/lowlevel/right_pressure/pressure_1",
"/lowlevel/right_pressure/pressure_2",
"/lowlevel/right_pressure/pressure_3",
]
) as proc:
print("LEFT pressure check Launched")
step_msg_check(
"Press the LEFT foot jauges and check that each one is moving positively"
)
with subprocess.Popen(
[
"rhio",
hostname,
"plot",
"/lowlevel/left_pressure/pressure_0",
"/lowlevel/left_pressure/pressure_1",
"/lowlevel/left_pressure/pressure_2",
"/lowlevel/left_pressure/pressure_3",
]
) as proc:
print("RIGHT pressure check Launched")
functions = {
1: check_devices,
2: zero_leg_backslash,
3: piano_wires,
4: camera_focus_horizon,
5: perception_yolo,
6: ball_position,
7: standup,
8: kick_ball,
9: imu,
10: foot_pressure,
}
check_devices()
bright("[INIT] Press ENTER to run init")
input()
print(rhio(ip, "init"))
while True:
print("\n")
print("-1: Finish check")
print("0: Check all")
print("1: Check presence of devices")
print("2: Check zero leg backslash")
print("3: Check piano wires")
print("4: Check camera focus and horizon")
print("5: Check perception yolo")
print("6: Check check ball position")
print("7: Check standup")
print("8: Check kick ball")
print("9: Check IMU")
print("10: Check foot pressure\n")
input_ret = input("Choose a test and press enter :")
if int(input_ret) == 0:
check_all(functions)
elif int(input_ret) == -1:
break
else:
result = functions[int(input_ret)]()
print("Check Finished")