Beispiel #1
0
def initialActions():
    ctr = 0
    while True:
        motor_control.addAngleInstruction(45)
        time.sleep(2)
        sensor_control.event.wait()
        markers = sensor_control.getMarkers()
        sensor_control.event.clear()
        if len(markers) > 0:
            for m in markers:
                if m.info.marker_type == MARKER_ARENA and m.dist < 2100:
                    code = m.info.code
                    strategy.homenumber = (
                        0 if 0 <= code <= 6 else 1 if 21 <= code <= 27 else 2 if 14 <= code <= 20 else 3
                    )
                    coor = m_info[code]
                    homecoor = computeAbsolutePositionByArenaMarker(m)
                    motor_control.currentAngle = homecoor[2]
                    home = (homecoor[0], homecoor[1])
                    strategy.home = home
                    motor_control.addAngleInstruction(-ctr * 30)
                    debug("Token found!")
                    break
        else:
            debug("No token found!")

        ctr += 1
Beispiel #2
0
def startEventLoop():
    debug("Starting event loop")
    global running
    running = True
    strategy = Strategy(robot)
    while running:
        sensor_control.event.wait()
        markers = sensor_control.getMarkers()
        sensor_control.event.clear()
        strategy.reach(markers)