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()
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()
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)