Beispiel #1
0
 def build_maps(self):
     self.instructions = {
         'fwd': lambda t: myro.forward(self.speed),
         'bwd': lambda t: myro.backward(self.speed),
         'ccw': lambda t: myro.rotate(self.speed),
         'cw': lambda t: myro.rotate(-self.speed)
     }
     self.conditions = {
         'ir>': lambda v: average(myro.getObstacle()) > v,
         'time': lambda t: self.time > t,
         'dist': lambda d: self.time > dist_to_time(d, self.speed),
         'angle': lambda a: self.time > angle_to_time(a, self.speed),
         'forever': lambda _: False,
     }
Beispiel #2
0
def obstacle_average():
    """Returns the average of the three obstacle sensor readings."""
    return average(myro.getObstacle())
Beispiel #3
0
def obstacle_average():
    """Returns the average of the three obstacle sensor readings."""
    return average(myro.getObstacle())