.. _lib_qc:

Quality Control
###############

Infrared Test
-------------------------

.. code-block:: python

    from compLib.IRSensor import IRSensor
    import time

    IRSensor.set(1, True)
    IRSensor.set(2, True)
    IRSensor.set(3, True)
    IRSensor.set(4, True)
    IRSensor.set(5, True)

    while True:
        t = time.time()
        for i in range(1, 6):
            print(f"{i}: {IRSensor.read(i)}")
        print("")
        time.sleep(0.2)

Motor Test
-------------------------

.. code-block:: python

    from compLib.Motor import Motor
    from compLib.Encoder import Encoder
    import time

    Motor.power(1, -50)
    Motor.power(4, 50)

    while True:
        print(f"L:{Encoder.read(4)} R:{Encoder.read(1)}")
        time.sleep(0.1)

Servo Test
-------------------------

.. code-block:: python

    from compLib.Servo import Servo
    import time

    for i in range(1, 8 + 1):
        Servo.set_position(i, 45)
        print(f"{i}")
        time.sleep(1)

    Servo.setup_position()
    time.sleep(10)

Vision Test
-------------------------

.. code-block:: python

    import cv2
    from compLib import Vision
    from compLib.Servo import Servo

    while True:
        frame = Vision.Streaming.get_frame()
        Vision.Streaming.publish_frame(frame)
        Servo.set_position(3, -45)
