Example #1
0
def main():

    capture_layer = CaptureLayer()
    input_layer = InputLayer()
    control_layer = ControlLayer()

    main_loop = True

    capture_thread = Process(target=capture_layer.run_capture)
    serial_thread = Process(target=serial_control)

    capture_thread.start()
    serial_thread.start()
    last_busy = 1

    while main_loop:
        shape = capture_layer.marker_shape[:]

        input_layer.update(shape, motor_busy.value)

        control_layer.update(input_layer)
        control_vector[0:3] = control_layer.get_control_vector()

        if last_busy != motor_busy.value:
            last_busy = motor_busy.value
            print("BUSY" if motor_busy.value else "FREE")

        if control_vector[1] != 0:
            print("%d cm, %.1f deg" % (input_layer.distance_cm, input_layer.angle_deg)," "*8)
            print("desired %d cm = %d steps" % (control_layer.desired_cm, control_vector[1]),
                "conf: %.2f" % input_layer.distance_filter.confidence())

        sleep(0.020)