Exemplo n.º 1
0
def straight_line_light_black(angle, speed, color_sensor):
    drive_base.reset()
    while color_sensor.reflection() <= 10:
        fix_amount = p_controller(angle, gyro)

        drive_base.drive(speed, -fix_amount)
    drive_base.stop()
Exemplo n.º 2
0
def straight_line(angle, speed, duration):
    timer = StopWatch()
    while timer.time() <= duration:
        screen.clear()

        fix_amount = p_controller(angle, gyro)
        drive_base.drive(speed, -fix_amount)
Exemplo n.º 3
0
def follow_line_left(speed, duration):
    while timer.time() < duration:
        deviation = color_sensor.reflection() - setpoint

        turn_rate = K_P * deviation

        drive_base.drive(speed, turn_rate)

        wait(10)
Exemplo n.º 4
0
def straight_line_distance(angle, speed, distance):
    drive_base.reset()
    while abs(drive_base.distance()) <= distance:
        fix_amount = p_controller(angle, gyro)

        screen.print(gyro.angle())

        drive_base.drive(speed, -fix_amount)
    drive_base.stop()
Exemplo n.º 5
0
def follow_line_right(speed, duration):
    timer = StopWatch()
    while timer.time() <= duration:
        deviation = right_color_sensor.reflection() - setpoint
        turn_rate = K_P * deviation
        screen.print(right_color_sensor.reflection())

        drive_base.drive(speed, turn_rate)

        wait(10)
Exemplo n.º 6
0
def follow_line_distance_left(speed, distance):
    timer = StopWatch()
    drive_base.reset()
    while abs(drive_base.distance()) <= distance:
        deviation = left_color_sensor.reflection() - setpoint
        turn_rate = K_P * deviation
        screen.print(left_color_sensor.reflection())

        drive_base.drive(speed, turn_rate)

        wait(10)
Exemplo n.º 7
0
def turn_white(angle, threshold, color_sensor):
    while color_sensor.reflection() >= 60:
        fix_amount = p_controller(angle, gyro)
        drive_base.drive(0, -fix_amount)
Exemplo n.º 8
0
def turn(angle, threshold):
    while gyro.angle() <= angle - threshold or gyro.angle(
    ) >= angle + threshold:
        fix_amount = p_controller(angle, gyro)
        drive_base.drive(0, -fix_amount)