-
Notifications
You must be signed in to change notification settings - Fork 3
/
desviar_obs.py
43 lines (41 loc) · 1.48 KB
/
desviar_obs.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
from displays import desviarObsDisplay
from spike_pybricks_motorpair import MotorPair
from pybricks.parameters import Port
from pybricks.tools import wait
from pybricks.pupdevices import ColorSensor, UltrasonicSensor
motors = MotorPair(Port.A,Port.B)
u2 = UltrasonicSensor(Port.E)
sc = ColorSensor(Port.D)
sd = ColorSensor(Port.C)
se = ColorSensor(Port.F)
def desviarObs(lado = 'right'):
name = ''
desviarObsDisplay()
if lado == 'right':
if name == 'axis correction **Corner**':
motors.move_tank(800, -400, 400)
motors.stop_tank()
motors.move_tank(1400, 500, 200)
motors.move_tank(700, 200, 200)
motors.move_tank(1400, 500, 130)
motors.move_tank(300, 100, 100)
elif name == 'proportional align':
motors.move_tank(800, -400, 400)
motors.stop_tank()
motors.move_tank(1850, 500, 200)
motors.move_tank(700, 200, 200)
motors.move_tank(1850, 500, 180)
while se.reflection() > 80 and sd.reflection() > 80 :
motors.start_tank(350, 150)
motors.stop_tank()
wait(1000)
return [name, lado, 'succeded']
elif lado == 'left':
motors.move_tank(1300, 400, -400)
motors.stop_tank()
while se.reflection() > 80 or sd.reflection() > 80 :
motors.start_tank(150, 350)
motors.stop_tank()
wait(1000)
return [name, lado, 'succeded']
return [name, lado, 'failed']