Exemplo n.º 1
0
 def handle_menu_select_item(self, item):
     if item is None:
         return
     if isinstance(item, type) and issubclass(item, mode.Mode):
         start_task(self.enter_mode(item))
     else:
         item()
Exemplo n.º 2
0
 def handle_event(self, event):
     if super().handle_event(event):
         return True
     if isinstance(event, messages.ControllerButtonMessage):
         if event.button == "l2":
             start_task(self.turn(-90))
             return True
         elif event.button == "r2":
             start_task(self.turn(90))
             return True
     return False
Exemplo n.º 3
0
 async def fire(self):
     self.angle = self.shooter.barrel.get_angle()
     self.aimable = False
     self.shooter.pump.on()
     self.shooter.pointer.off()
     # FIXME create firing solution here and implement it
     while True:
         await asyncio.sleep(0.1)
         if self.shooter.pressure.get_pressure() > 108000:
             start_task(self.load())
             break
Exemplo n.º 4
0
 async def run(self):
     start_task(super().run())
     self.set_state(self.off)
     while True:
         if self.joystick and self.joystick.connected:
             if self.aimable:
                 y = self.joystick['ry']
                 if y != 0.0:
                     self.angle += y * 20.0
                     print("Angle = ", self.angle)
                     self.shooter.barrel.set_pos(self.angle)
         await asyncio.sleep(0.1)
Exemplo n.º 5
0
 def set_state(self, state):
     name = state.__name__.capitalize()
     print("Setting state to ", name)
     self.display.draw_text(name)
     if self.state_task is not None:
         self.state_task.cancel()
     self.state = state
     self.state_task = start_task(state())
Exemplo n.º 6
0
 def on_start(self):
     super().on_start()
     self.colour = Colours()
     self.current_col = [-10, 80, 30], [10, 255, 255]
     self.limits = {
         MIN_HUE: (-40, 180),
         MAX_HUE: (-40, 180),
         MIN_SAT: (0, 255),
         MIN_VAL: (0, 255)
     }
     self.mode = MIN_HUE
     self.image_shower = util.start_task(self.show_image())
Exemplo n.º 7
0
    def __init__(self, joystick, hardware):
        self.joystick = joystick
        self.drive = None
        self.display = None
        self.camera = None
        self.pixels = None
        self.grabber = None
        self.shooter = None
        self.stabber = None
        self.laser = None
        for item in self.HARDWARE:
            if getattr(hardware, item) is None:
                raise HardwareNotFoundError(item)
            setattr(self, item, getattr(hardware, item))

        self.on_start()
        self.task = start_task(self.run())
Exemplo n.º 8
0
 async def aim(self):
     angle_task = start_task(
         asyncio.wait_for(
             self.shooter.barrel.set_angle(self.angle), 2.0))
     while True:
         await asyncio.sleep(0.1)
         if self.shooter.pressure.get_pressure() > 105000:
             self.shooter.pump.on()
         else:
             self.shooter.pump.off()
         if angle_task and angle_task.done():
             try:
                 angle_task.result()
             except asyncio.TimeoutError:
                 pass
             self.shooter.pointer.on()
             self.aimable = True
             self.angle = self.shooter.barrel.get_pos()
             angle_task = None
Exemplo n.º 9
0
 def __init__(self, event_queue):
     self.event_queue = event_queue
     start_task(self.monitor())