class BlackLine(Task): """run at black line""" def __init__(self): self.passed = False self.last_rotation = False # False - right, True - left self.color = Color() self.engine = Engine() def run(self): if self.color.is_path(): self.engine.step() else: self.find_path() def find_path(self): if self.last_rotation: self.engine.step_left() # rewrite it after line-detectors adding if not self.color.is_path(): self.engine.step_right() self.last_rotation = False else: self.engine.step_right() # rewrite it after line-detectors adding if not self.color.is_path(): self.engine.step_left() self.last_rotation = True
from lib.engine import Engine import pyb pyb.delay(3000) engine = Engine() count = 24 for i in range(0, count): engine.step() for i in range(0, count): engine.step_back() for i in range(0, count): engine.step_right() for i in range(0, count): engine.step_left()