def test_go_straight_for_inches_using_encoder():
    robot = rosebot.RoseBot()
    robot.drive_system.go_straight_for_inches_using_encoder(10, 100)
    robot.drive_system.go_straight_for_inches_using_encoder(10, -100)
    robot.drive_system.go_straight_for_inches_using_encoder(20, 100)
    robot.drive_system.go_straight_for_inches_using_encoder(20, -100)

    #def test_go(speed1, speed2):
    #   robot = rosebot.RoseBot()
    #   robot.drive_system.go(speed1,speed2)

    #def test_stop():

    robot = rosebot.RoseBot()
    robot.drive_system.stop()
def main():
    """
    This code, which must run on the ROBOT:
      1. Constructs a robot, an mqtt_sender, and a delegate to respond
         to messages from the LAPTOP sent via MQTT.
      2. Stays in an infinite loop while a listener (for MQTT messages)
         runs in the background.
    """
    robot = rosebot.RoseBot()

    delegate = DelegateForRobotCode(robot)
    mqtt_sender = mqtt.MqttClient(delegate)
    delegate.set_mqtt_sender(mqtt_sender)

    mqtt_sender.connect_to_pc(lego_robot_number=1)
    # DONE 3: Replace 99 in the above by YOUR team's robot number.

    time.sleep(1)  # To let the connection process complete
    print()
    print("Starting to listen for messages. The delegate responds to them.")
    print()

    # Stay in an infinite loop while the listener (for MQTT messages)
    # runs in the background:
    while True:
        time.sleep(0.01)
        if delegate.is_time_to_quit:
            break
Exemple #3
0
def enter_pyramid(speed):
    robot = rosebot.RoseBot()
    robot.sound_system.speech_maker.speak(
        "Ok, I gonna go into the dangerous pyramid!")
    robot.drive_system.go(speed, speed)
    while True:
        if robot.sensor_system.color_sensor.get_color() == "black":
            robot.drive_system.left(speed, speed)
            time.sleep(0.01)
            robot.drive_system.go(speed, speed)
        else:
            robot.drive_system.right(speed, speed)
            time.sleep(0.01)
            robot.drive_system.go(speed, speed)
        # if robot.sensor_system.color_sensor.get_color() == "black":
        #     robot.drive_system.left(speed,speed)
        #     time.sleep(0.1)
        #     robot.drive_system.go(speed,speed)
        if robot.sensor_system.ir_proximity_sensor.get_distance_in_inches(
        ) < 2:
            break
    robot.drive_system.stop()


# def detect_danger():
def run_test_drive_system():
    """ Test a robot's DRIVE SYSTEM. """
    print()
    print('--------------------------------------------------')
    print('Testing the  DRIVE SYSTEM  of a robot')
    print('--------------------------------------------------')

    # -------------------------------------------------------------------------
    # TODO: 2. Construct a robot, that is, a rosebot.RoseBot() object.
    # -------------------------------------------------------------------------
    robot = rosebot.RoseBot()

    # -------------------------------------------------------------------------
    # STUDENTS: Do the work in this module as follows.
    #   Otherwise, you will be overwhelmed by the number of tests happening.
    #
    #   For each function that you implement:
    #     1. Locate the statements just below this comment that call TEST functions.
    #     2. UN-comment only one test at a time.
    #     3. Implement that function per its _TODO_.
    #     4. Implement as needed the appropriate class methods
    #     5. When satisfied with your work, move onto the next test,
    #        RE-commenting out the previous test to reduce the testing.
    # -------------------------------------------------------------------------

    # run_test_go_stop(robot)
    # run_test_go_straight_for_seconds(robot)
    # run_test_go_straight_for_inches(robot)
    run_test_spin_in_place_for_seconds(robot)
Exemple #5
0
def main():
    """ Test a robot's Remote Control, Brick Buttons, and LEDs. """
    print()
    print('--------------------------------------------------')
    print(' Testing Remote Control, Brick Buttons, and LEDs')
    print('--------------------------------------------------')

    # -------------------------------------------------------------------------
    # TODO: 2. Construct a robot, that is, a rosebot.RoseBot() object.
    # -------------------------------------------------------------------------
    robot = rosebot.RoseBot()

    # -------------------------------------------------------------------------
    # STUDENTS: Do the work in this module as follows.
    #   Otherwise, you will be overwhelmed by the number of tests happening.
    #
    #   For each function that you implement:
    #     1. Locate the statements just below this comment that call TEST functions.
    #     2. UN-comment only one test at a time.
    #     3. Implement that function per its _TODO_.
    #     4. Implement as needed the appropriate class methods
    #     5. When satisfied with your work, move onto the next test,
    #        RE-commenting out the previous test to reduce the testing.
    # -------------------------------------------------------------------------

    # run_test_leds_on_off(robot)
    # run_test_leds_colors(robot)
    # run_test_brick_buttons(robot)
    run_test_remote_control(robot)
def drive_camera_tests():
    robot = rosebot.RoseBot()
    robot.drive_system.spin_clockwise_until_sees_object(50, 40)
    robot.drive_system.display_camera_data()
    time.sleep(3)
    robot.drive_system.spin_counterclockwise_until_sees_object(50, 40)
    robot.drive_system.display_camera_data()
Exemple #7
0
def color_sensor_play_note(time_to_stop):
    robot = rosebot.RoseBot()
    print("Hello")
    print("Play Note Based on Color")
    initial_time = time.time()
    robot.drive_system.go(50, 50)
    while True:
        if robot.sensor_system.color_sensor.get_color_as_name() == 'Red':
            print("Red")
            robot.drive_system.stop()
            A4_note()
            break
        if robot.sensor_system.color_sensor.get_color_as_name() == 'Green':
            print("Green")
            robot.drive_system.stop()
            B4_note()
            break
        if robot.sensor_system.color_sensor.get_color_as_name() == 'Yellow':
            print("Yellow")
            robot.drive_system.stop()
            C5_note()
            break
        if robot.sensor_system.color_sensor.get_color_as_name() == 'Black':
            print("Black")
            robot.drive_system.stop()
            C5_sharp_note()
            break
        if time.time() - initial_time >= time_to_stop:
            print("I did not find any color")
            robot.drive_system.stop()
            robot.sound_system.speech_maker.speak("I did not find any color")
            break
def m3_led_proximity_sensor(initial, rate_of_increase):
    robot = rosebot.RoseBot()
    secs = float(initial)
    threshold = 20
    robot.led_system.left_led.turn_off()
    robot.led_system.right_led.turn_off()
    robot.arm_and_claw.calibrate_arm()
    robot.drive_system.go(50, 50)
    while True:
        distance = robot.sensor_system.ir_proximity_sensor.get_distance()
        print(distance)
        # Led Cycle
        robot.led_system.left_led.turn_on()
        time.sleep(secs / 4)
        robot.led_system.left_led.turn_off()
        robot.led_system.right_led.turn_on()
        time.sleep(secs / 4)
        robot.led_system.right_led.turn_off()
        robot.led_system.left_led.turn_on()
        robot.led_system.right_led.turn_on()
        time.sleep(secs / 4)
        robot.led_system.left_led.turn_off()
        robot.led_system.right_led.turn_off()
        time.sleep(secs / 4)
        if distance < threshold:
            robot.drive_system.stop()
            robot.arm_and_claw.raise_arm()
            break
        increment = float(initial) / float(rate_of_increase)
        sub = 100 / increment
        pos = 100 - distance
        x = pos / sub
        secs = initial - (float(rate_of_increase) * x)
        if secs < 0:
            secs = 0
def m3_rps(chosen_play):
    print('Running rps')
    robot = rosebot.RoseBot()
    x = random.randrange(1, 4)
    print(x)
    if x == 1:  # Rock
        robot.arm_and_claw.raise_arm()
        robot.sound_system.speech_maker.speak('I chose Rock')
        if chosen_play is 'Paper':
            robot.sound_system.speech_maker.speak('You win')
        else:
            robot.sound_system.speech_maker.speak('You lose')
    elif x == 2:  # Paper
        robot.arm_and_claw.move_arm_to_position(0)
        robot.sound_system.speech_maker.speak('I chose Paper')
        if chosen_play is 'Scissors':
            robot.sound_system.speech_maker.speak('You win')
        else:
            robot.sound_system.speech_maker.speak('You lose')
    elif x == 3:  # Scissors
        robot.arm_and_claw.move_arm_to_position(2500)
        robot.sound_system.speech_maker.speak('I chose Scissors')
        if chosen_play is 'Rock':
            robot.sound_system.speech_maker.speak('You win')
        else:
            robot.sound_system.speech_maker.speak('You lose')
    robot.arm_and_claw.move_arm_to_position(0)
def test_arm_and_claw():
    """ Test a robot's ARM AND CLAW. """
    print()
    print('--------------------------------------------------')
    print('Testing the  ARM AND CLAW  of a robot')
    print('--------------------------------------------------')

    # -------------------------------------------------------------------------
    # TODO: 2. Construct a robot, that is, a rosebot.RoseBot() object.
    # -------------------------------------------------------------------------
    robot = rosebot.RoseBot()

    # -------------------------------------------------------------------------
    # STUDENTS: Do the work in this module as follows.
    #   Otherwise, you will be overwhelmed by the number of tests happening.
    #
    #   For each function that you implement:
    #     1. Locate the statements just below this comment that call TEST functions.
    #     2. UN-comment only one test at a time.
    #     3. Implement that function per its _TODO_.
    #     4. Implement as needed the appropriate class methods
    #     5. When satisfied with your work, move onto the next test,
    #        RE-commenting out the previous test to reduce the testing.
    # -------------------------------------------------------------------------

    # run_test_touch_sensor(robot)
    # run_test_calibrate(robot)
    # run_test_raise_and_lower(robot)
    run_test_move_arm_to_position(robot)
Exemple #11
0
def run_test_arm():
    robot = rosebot.RoseBot()
    robot.arm_and_claw.raise_arm()
    robot.arm_and_claw.lower_arm()
    robot.arm_and_claw.move_arm_to_position(10 * 360)
    robot.arm_and_claw.lower_arm()
    robot.arm_and_claw.calibrate_arm()
def celebration():
    robot = rosebot.RoseBot()
    robot.arm_and_claw.calibrate_arm()
    robot.sound_system.speech_maker.speak('Cleaned Up for Macy')
    robot.arm_and_claw.move_arm_to_position(2000)
    robot.led_system.left_led.turn_on()
    robot.led_system.right_led.turn_on()
    time.sleep(.1)
    robot.arm_and_claw.move_arm_to_position(1000)
    robot.led_system.left_led.turn_off()
    robot.led_system.right_led.turn_off()
    time.sleep(.1)
    robot.arm_and_claw.move_arm_to_position(2000)
    robot.led_system.left_led.turn_on()
    robot.led_system.right_led.turn_on()
    time.sleep(.1)
    robot.arm_and_claw.move_arm_to_position(1000)
    robot.led_system.left_led.turn_off()
    robot.led_system.right_led.turn_off()
    time.sleep(.1)
    robot.arm_and_claw.move_arm_to_position(2000)
    robot.led_system.left_led.turn_on()
    robot.led_system.right_led.turn_on()
    time.sleep(.1)
    robot.arm_and_claw.move_arm_to_position(0)
    robot.led_system.left_led.turn_off()
    robot.led_system.right_led.turn_off()
def main():
    """ Test a robot's color sensor and line following. """
    print()
    print('--------------------------------------------------')
    print('Testing the Color sensor (in two modes) of a robot')
    print('--------------------------------------------------')

    # -------------------------------------------------------------------------
    # TODO: 2. Construct a robot, that is, a rosebot.RoseBot() object.
    # -------------------------------------------------------------------------
    robot = rosebot.RoseBot()

    # -------------------------------------------------------------------------
    # STUDENTS: Do the work in this module as follows.
    #   Otherwise, you will be overwhelmed by the number of tests happening.
    #
    #   For each function that you implement:
    #     1. Locate the statements just below this comment that call TEST functions.
    #     2. UN-comment only one test at a time.
    #     3. Implement that function per its _TODO_.
    #     4. Implement as needed the appropriate class methods
    #     5. When satisfied with your work, move onto the next test,
    #        RE-commenting out the previous test to reduce the testing.
    # -------------------------------------------------------------------------

    # Color Sensor tests
    # run_test_display_color_names(robot)
    # run_test_drive_until_color(robot)
    # run_test_display_reflected_light_readings(robot)
    # run_test_calibrate_line_follower(robot)
    run_test_line_follower(robot)
def test_go_straight_for_inches_using_time():
    robot = rosebot.RoseBot()
    robot.drive_system.go_straight_for_inches_using_time(10, 100)
    robot.drive_system.go_straight_for_inches_using_time(10, -100)
    robot.drive_system.go_straight_for_inches_using_time(5, 25)
    robot.drive_system.go_straight_for_inches_using_time(0, 75)
    robot.drive_system.go_straight_for_inches_using_time(3, 60)
Exemple #15
0
def fight(robot):
    robot = rosebot.RoseBot()
    button = robot.sensor_system.touch_sensor
    speech = robot.sound_system.speech_maker
    counter = 0
    counter_1 = 0
    counter_2 = 0
    counter_3 = 0
    while True:
        if button.is_pressed() == True:
            counter = counter + 1
        if counter == 1:
            counter_1 = counter_1 + 1
            if counter_1 == 1:
                speech.speak("Hey! Watch what you're doing, twerp!")
        if counter == 2:
            counter_2 = counter_2 + 1
            if counter_2 == 1:
                speech.speak("You'll be gettin a knuckle sandwich, punk!")
        if counter == 3:
            counter_3 = counter_3 + 1
            if counter_3 == 1:
                speech.speak("Alright bub, you asked for it!")
                break
    robot.drive_system.go(50, -50)
    time.sleep(2.8)
    robot.drive_system.go_forward_until_distance_is_less_than(2, 50)
    speech.speak("Take this, you cur!")
    robot.arm_and_claw.raise_arm()
    time.sleep(1)
    speech.speak("Get ready for the Grand Hand Slam!")
    time.sleep(3)
    robot.arm_and_claw.lower_arm()
    speech.speak("Serves you right, you jerk!")
    def song(self):
        robot = rosebot.RoseBot()
        NOTE_A4 = 440
        NOTE_B4 = 494
        NOTE_CS5 = 554
        NOTE_E5 = 659
        NOTE_FS5 = 740
        NOTE_GS5 = 831

        quarter_note = 500
        eighth_note = 250

        notes = [
            NOTE_A4, NOTE_B4, NOTE_CS5, NOTE_E5, NOTE_FS5, NOTE_GS5, NOTE_FS5,
            NOTE_E5, NOTE_CS5, NOTE_B4
        ]

        robot.sound_system.tone_maker.play_tone(notes[0], quarter_note).wait()
        robot.sound_system.tone_maker.play_tone(notes[1], quarter_note).wait()
        robot.sound_system.tone_maker.play_tone(notes[2], quarter_note).wait()
        robot.sound_system.tone_maker.play_tone(notes[3], quarter_note).wait()
        robot.sound_system.tone_maker.play_tone(notes[4], quarter_note).wait()
        robot.sound_system.tone_maker.play_tone(notes[5], eighth_note).wait()
        robot.sound_system.tone_maker.play_tone(notes[6], quarter_note).wait()
        robot.sound_system.tone_maker.play_tone(notes[7], quarter_note).wait()
        robot.sound_system.tone_maker.play_tone(notes[8], 1500).wait()
        robot.sound_system.tone_maker.play_tone(notes[9], 1500).wait()
def run_test_arm():
    robot = rosebot.RoseBot()
    robot.arm_and_claw.raise_arm()
    print("Raise arm successful!")
    time.sleep(2)
    robot.arm_and_claw.lower_arm()
    print("Lower arm successful!")
def main():
    """ Test a robot's IR sensor (proximity and beacon seeking). """
    print()
    print('--------------------------------------------------')
    print('Testing the Infrared sensor (in two modes) of a robot')
    print('--------------------------------------------------')

    # -------------------------------------------------------------------------
    # TODO: 2. Construct a robot, that is, a rosebot.RoseBot() object.
    # -------------------------------------------------------------------------
    robot = rosebot.RoseBot()

    # -------------------------------------------------------------------------
    # STUDENTS: Do the work in this module as follows.
    #   Otherwise, you will be overwhelmed by the number of tests happening.
    #
    #   For each function that you implement:
    #     1. Locate the statements just below this comment that call TEST functions.
    #     2. UN-comment only one test at a time.
    #     3. Implement that function per its _TODO_.
    #     4. Implement as needed the appropriate class methods
    #     5. When satisfied with your work, move onto the next test,
    #        RE-commenting out the previous test to reduce the testing.
    # -------------------------------------------------------------------------

    # run_test_sounds(robot)
    # run_test_proximity_readings(robot)
    # run_test_drive_until_distance(robot)

    # run_test_beacon_sensor(robot)
    # run_test_spin_until_beacon_seen(robot)
    # run_test_spin_to_track_beacon(robot)
    run_test_drive_towards_beacon(robot)
Exemple #19
0
def led_blinker(initial, rate):
    robot = rosebot.RoseBot()
    robot.arm_and_claw.calibrate_arm()
    robot.drive_system.go(25, 25)
    while True:
        robot.led_system.left_led.turn_on()
        time.sleep(get_sleep(initial, rate))

        robot.led_system.left_led.turn_off()
        robot.led_system.right_led.turn_on()
        time.sleep(get_sleep(initial, rate))

        robot.led_system.left_led.turn_on()
        time.sleep(get_sleep(initial, rate))

        robot.led_system.left_led.turn_off()
        robot.led_system.right_led.turn_off()
        time.sleep(get_sleep(initial, rate))

        d = robot.sensor_system.ir_proximity_sensor.get_distance_in_inches()
        if d <= 3:
            robot.drive_system.stop()
            robot.arm_and_claw.raise_arm()
            robot.led_system.right_led.turn_off()
            robot.led_system.left_led.turn_off()
            break
def main():
    """
    This code, which must run on the ROBOT:
      1. Constructs a robot, an MQTT SENDER, and a DELEGATE to respond
           to messages FROM the LAPTOP sent TO the ROBOT via MQTT.
      2. Stays in an infinite loop while a listener (for MQTT messages)
           runs in the background, "delegating" work to the "delegate".
    """
    robot = rosebot.RoseBot()

    delegate = DelegateForRobotCode(robot)
    mqtt_sender = mqtt.MqttClient(delegate)
    delegate.set_mqtt_sender(mqtt_sender)

    number = m0_set_robot_number.get_robot_number()
    if number is not None:
        mqtt_sender.connect_to_mqtt_to_talk_to_laptop(lego_robot_number=number)

    time.sleep(1)  # To let the connection process complete
    print()
    print("Starting to listen for messages. The delegate responds to them.")
    print()

    # Stay in an infinite loop while the listener (for MQTT messages)
    # runs in the background:
    while True:
        time.sleep(0.01)
        if delegate.is_time_to_quit:
            break
def m3_grab_object_LED(start_time, increase):
    robot = rosebot.RoseBot()
    robot.arm_and_claw.calibrate_arm()
    robot.drive_system.go(20, 20)
    led = 1
    wait_time = int(start_time)
    while robot.sensor_system.ir_proximity_sensor.get_distance_in_inches(
    ) > 0.25:
        if led == 1:
            robot.led_system.left_led.turn_on()
            time.sleep(wait_time)
        if led == 2:
            robot.led_system.left_led.turn_off()
            robot.led_system.right_led.turn_on()
            time.sleep(wait_time)
        if led == 3:
            robot.led_system.left_led.turn_on()
            time.sleep(wait_time)
        if led == 4:
            robot.led_system.right_led.turn_off()
            robot.led_system.left_led.turn_off()
            time.sleep(wait_time)
        if led == 4:
            led = 0
        led = led + 1
        wait_time = wait_time - (
            float(increase) /
            (robot.sensor_system.ir_proximity_sensor.get_distance_in_inches() +
             5))
        if wait_time <= 0:
            wait_time = 0
    robot.drive_system.stop()
    robot.arm_and_claw.raise_arm()
Exemple #22
0
def check(cup_2_entry):
    robot = rosebot.RoseBot()
    if cup_2_entry == 'x':
        robot.sound_system.tone_maker.play_tone(440, 2).wait()
        robot.sound_system.tone_maker.play_tone(880, 2).wait()
        robot.sound_system.beeper.beep().wait()
        print('YOU DID IT!')
Exemple #23
0
def real_thing():
    # Connects computer to ev3 via delegate
    robot = rosebot.RoseBot()
    delegate = m2_shared_gui_delegate_on_robot.Delegate(robot)
    mqtt_receiver = com.MqttClient(delegate)
    mqtt_receiver.connect_to_pc()

    # Connects ev3 to computer via delegate
    mqtt_client = mqtt_receiver

    while True:

        # If get_distance_in_inches method has been called, distance_counter = 1.
        # If distance_counter = 1, robot tells computer to execute 'handle_change_anxiety'
        # method via MQTT / delegate running on PC
        if robot.sensor_system.ir_proximity_sensor.distance_counter == 1:
            dis = robot.sensor_system.ir_proximity_sensor.get_distance_in_inches()
            mqtt_client.send_message('handle_change_anxiety', [dis])
            time.sleep(2)
            robot.sensor_system.ir_proximity_sensor.distance_counter = 0

        # If is_pressed method has been called, touch_counter = 1.
        # If touch_counter = 1, robot tells computer to execute 'handle_change_hostility'
        # method via MQTT / delegate running on PC
        if robot.sensor_system.touch_sensor.touch_counter == 1:
            mqtt_client.send_message('handle_change_hostility')
            time.sleep(2)
            robot.sensor_system.touch_sensor.touch_counter = 0

        if not delegate.enabled:
            time.sleep(0.01)
Exemple #24
0
def camera_test():
    robot = rosebot.RoseBot()
    while True:
        b = robot.sensor_system.camera.get_biggest_blob()

        print(b)
        time.sleep(5)
def anything():
    robot = rosebot.RoseBot()
    pixy = robot.sensor_system.camera
    print('1')
    blob = pixy.get_biggest_blob()
    Area = blob.width * blob.height
    print(Area)
def whale(n, k):
    robot = rosebot.RoseBot()
    sensor = robot.sensor_system.ir_proximity_sensor
    robot.drive_system.go(30, 30)
    left = robot.led_left
    right = robot.led_right
    n = float(n)
    k = float(k)
    while True:
        ir = sensor.get_distance()
        left.turn_on()
        left.turn_off()
        time.sleep(k * ir / n)

        right.turn_on()
        right.turn_off()
        time.sleep(k * ir / n)

        left.turn_on()
        right.turn_on()
        left.turn_off()
        right.turn_off()
        time.sleep(k * ir / n)

        if ir <= 3:
            left.set_color_by_name((0, 1))
            right.set_color_by_name((0, 1))
            break
    robot.drive_system.stop()
def main():
    """ Test a robot's using MQTT. """
    print()
    print('--------------------------------------------------')
    print(' Listening for MQTT messages from the PC')
    print('--------------------------------------------------')

    # -------------------------------------------------------------------------
    # TODO: 2. Construct a robot, that is, a rosebot.RoseBot() object.
    # -------------------------------------------------------------------------
    robot = rosebot.RoseBot()

    # -------------------------------------------------------------------------
    # TODO: 3. Construct an MQTT client passing in the robot as the argument.
    # -------------------------------------------------------------------------
    mqtt_client = com.MqttClient(robot)

    # -------------------------------------------------------------------------
    # TODO: 4. Connect to talk to the laptop
    # -------------------------------------------------------------------------
    # mqtt_client.connect_to_mqtt_to_talk_to_laptop()
    mqtt_client.connect_to_mqtt_to_talk_to_laptop("broker.hivemq.com")  # Off campus use this broker

    # -------------------------------------------------------------------------
    # TODO: 5. Create a loop which can be shutdown
    #          Add a field on the robot called should_shutdown
    #          That is set to False
    #          And add a method that can modify that field called shutdown
    # -------------------------------------------------------------------------

    while True:
        time.sleep(0.1)
        if robot.should_shutdown:
            break
Exemple #28
0
def drive_bowser():
    # calls the functions that will move the robot through the bowser track
    robot = rosebot.RoseBot()
    speed = 50
    starting_beeps(robot)
    bowser_course(robot, speed)
    robot.arm_and_claw.lower_arm()
def test_increasing_beeps_a1s_approach(initial_beep_rate,
                                       rate_of_beep_increase):
    robot = rosebot.RoseBot()
    initial_distance = robot.sensor_system.ir_proximity_sensor.get_distance_in_inches(
    )

    robot.arm_and_claw.calibrate_arm()
    robot.drive_system.go(50, 50)
    initial_beep_rate = int(initial_beep_rate)
    rate_of_beep_increase = int(rate_of_beep_increase)
    print('this edit has worked')

    while True:
        percent_distance = (robot.sensor_system.ir_proximity_sensor.
                            get_distance_in_inches()) / (initial_distance)
        pause_time = 3 * (percent_distance) / ((initial_beep_rate) +
                                               ((rate_of_beep_increase) *
                                                (1 - percent_distance)))
        robot.sound_system.beeper.beep().wait()
        # print(robot.sensor_system.ir_proximity_sensor.get_distance_in_inches())
        print(pause_time)

        time.sleep(abs(pause_time))
        if robot.sensor_system.ir_proximity_sensor.get_distance_in_inches(
        ) <= 2:
            robot.drive_system.stop()
            break

    robot.arm_and_claw.raise_arm()
    robot.arm_and_claw.calibrate_arm()  # this is to reset it for testing
def test_go_distance():
    """ Tests the   go_distance   function. """
    print()
    print('------------------------------------------------------')
    print('Testing the   go_distance   function:')
    print('  See the robot.')
    print('------------------------------------------------------')
    # ------------------------------------------------------------------
    # DONE: 4. Implement this TEST function.
    #   It TESTS the   go_distance   function defined below.
    #   Include at least 2 reasonable tests, with a "sleep" in between
    #   the tests so that you can see what happened on each test.
    # ------------------------------------------------------------------
    robot = rb.RoseBot()
    robot.connect_wifly(16)  # Use the number on YOUR robot
    connection = robot.connection

    # Put your FIRST test here:
    go_distance(robot, 1000, 150)

    connection.sleep(.5)

    # Put a SECOND test here:
    go_distance(robot, 1000, 200)

    connection.shutdown()