src/main.llsp3 aktualisiert
parent
460b50a3b1
commit
ef4db27b62
|
|
@ -74,7 +74,6 @@ async def move_on_color():
|
||||||
WHITE = 10
|
WHITE = 10
|
||||||
RED = 9
|
RED = 9
|
||||||
straight = False
|
straight = False
|
||||||
turn_way_if_lost_right = True
|
|
||||||
|
|
||||||
# Distanzsensor
|
# Distanzsensor
|
||||||
ds_front = ds.distance(port.D)
|
ds_front = ds.distance(port.D)
|
||||||
|
|
@ -129,13 +128,31 @@ async def move_on_color():
|
||||||
mp.move_tank(mp.PAIR_1, speed, speed)
|
mp.move_tank(mp.PAIR_1, speed, speed)
|
||||||
time.sleep_ms(300)
|
time.sleep_ms(300)
|
||||||
|
|
||||||
|
# Schwar-Logik
|
||||||
elif front_sens > 25 and last_seen_black == "left":
|
elif front_sens > 25 and last_seen_black == "left":
|
||||||
while cs.reflection(port.C) > 25:
|
#time.sleep_ms(100)
|
||||||
mp.move_tank(mp.PAIR_1, -100, 50)
|
while cs.reflection(port.C) > 25:
|
||||||
|
if cs.color(port.B) == BLACK and cs.color(port.F) == WHITE:
|
||||||
|
last_seen_black = "left"
|
||||||
|
if cs.color(port.F) == BLACK and cs.color(port.B) == WHITE:
|
||||||
|
last_seen_black = "right"
|
||||||
|
#mp.move_tank(mp.PAIR_1, speed, speed)
|
||||||
|
#time.sleep_ms(1000)
|
||||||
|
break
|
||||||
|
mp.move_tank(mp.PAIR_1, -75, 50)
|
||||||
|
|
||||||
|
|
||||||
elif front_sens > 25 and last_seen_black == "right":
|
elif front_sens > 25 and last_seen_black == "right":
|
||||||
|
#time.sleep_ms(100)
|
||||||
while cs.reflection(port.C) > 25:
|
while cs.reflection(port.C) > 25:
|
||||||
mp.move_tank(mp.PAIR_1, 50, -100)
|
if cs.color(port.F) == BLACK and cs.color(port.B) == WHITE:
|
||||||
|
last_seen_black = "right"
|
||||||
|
if cs.color(port.B) == BLACK and cs.color(port.F) == WHITE:
|
||||||
|
last_seen_black = "left"
|
||||||
|
#mp.move_tank(mp.PAIR_1, speed, speed)
|
||||||
|
#time.sleep_ms(1000)
|
||||||
|
break
|
||||||
|
mp.move_tank(mp.PAIR_1, 50, -75)
|
||||||
|
|
||||||
elif right_color == BLACK or left_color == BLACK:
|
elif right_color == BLACK or left_color == BLACK:
|
||||||
if right_color == BLACK and left_color == BLACK:
|
if right_color == BLACK and left_color == BLACK:
|
||||||
|
|
@ -159,17 +176,18 @@ async def move_on_color():
|
||||||
runloop.sleep_ms(50)
|
runloop.sleep_ms(50)
|
||||||
|
|
||||||
if straight:
|
if straight:
|
||||||
if time.ticks_diff(time.ticks_ms(), old) > 2750:
|
if time.ticks_diff(time.ticks_ms(), old) > 200:
|
||||||
old = time.ticks_ms()
|
old = time.ticks_ms()
|
||||||
if turn_way_if_lost_right:
|
# if turn_way_if_lost_right:
|
||||||
mp.move_tank(mp.PAIR_1, speed, 0)
|
# mp.move_tank(mp.PAIR_1, speed, 0)
|
||||||
await runloop.sleep_ms(200)
|
# await runloop.sleep_ms(200)
|
||||||
turn_way_if_lost_right = not turn_way_if_lost_right
|
# turn_way_if_lost_right = not turn_way_if_lost_right
|
||||||
else:
|
# else:
|
||||||
mp.move_tank(mp.PAIR_1, 0, speed)
|
# mp.move_tank(mp.PAIR_1, 0, speed)
|
||||||
await runloop.sleep_ms(200)
|
# await runloop.sleep_ms(200)
|
||||||
turn_way_if_lost_right = not turn_way_if_lost_right
|
# turn_way_if_lost_right = not turn_way_if_lost_right
|
||||||
|
if front_sens > 25:
|
||||||
|
last_seen_black = ""
|
||||||
else:
|
else:
|
||||||
old = time.ticks_ms()
|
old = time.ticks_ms()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue