Exemplo n.º 1
0
def setup(yaw_motor, pitch_motor, freq=100):
    """Attempt to setup the Raspberry Pi and PWM outputs.
    Returns a state object to be used throughout the program.
    """
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(yaw_motor, GPIO.OUT)
    GPIO.setup(pitch_motor, GPIO.OUT)
    yaw_pwm = GPIO.PWM(yaw_motor, 100)
    pitch_pwm = GPIO.PWM(pitch_motor, 100)
    state = ProgramState(yaw_pwm, pitch_pwm)
    state.yaw_motor.start(angle_to_dutycycle(state.yaw))
    state.pitch_motor.start(angle_to_dutycycle(state.pitch))
    return state
Exemplo n.º 2
0
def test_angle_to_dutycycle_range(angle):
    """Test that angle_to_dutycycle returns results in the proper range"""
    assert(0 <= motor.angle_to_dutycycle(angle) <= 100)
Exemplo n.º 3
0
def test_angle_dutycycle_inverse(angle):
    """Test the results of angle_to_dutycycle against its inverse, dutycycle_to_angle,
    angle = ((dutycycle / 5) - 1) * 180. Passing of this test implies that
    dutycycle_to_angle gives the proper results given angle_to_dutycycle.
    """
    assert(math.isclose(motor.dutycycle_to_angle(motor.angle_to_dutycycle(angle)), angle))