コード例 #1
0
def go_inches(inches, percent_of_max_speed):
    """
    Makes the EV3 Robot move the given number of inches at the given speed.

      :type inches: float
      :type percent_of_max_speed: float  -100 to 100
    """
    left_motor = rb.LargeMotor(
        rb.Plug("B"))  # Constructs a Motor for the left wheel
    right_motor = rb.LargeMotor(rb.Plug("C"))
    left_motor.start()
    right_motor.start()
    time.sleep(2)
    left_motor.brake()
    right_motor.brake()
コード例 #2
0
def go_inches(inches, percent_of_max_speed):
    """
    Makes the EV3 Robot move the given number of inches at the given speed.

      :type inches: float
      :type percent_of_max_speed: float  -100 to 100
    """
    # DONE: 5.  Implement and test this function.

    right_motor = rb.LargeMotor(rb.Plug('B'))
    left_motor = rb.LargeMotor(rb.Plug('A'))
    right_motor.start(percent_of_max_speed)
    left_motor.start(percent_of_max_speed)
    time.sleep(inches / right_motor.speed_percent)
    left_motor.brake()
    right_motor.brake()
コード例 #3
0
def go_two_seconds():
    # --------------------------------------------------------------------------
    # DONE: 3.
    #   Make the robot move, by using this pattern:
    #      1. Turn on (start) the wheel motors.
    #      2.     time.sleep(2)  # Pause here, let other processes run for 2 seconds
    #      3. Turn off (brake or coast) the wheel motors.
    #
    # Use the DOT trick to figure out how to start, brake and coast motors.
    # --------------------------------------------------------------------------
    left_motor = rb.LargeMotor(rb.Plug("B"))
    right_motor = rb.LargeMotor(rb.Plug('A'))
    right_motor.start()  # Constructs a Motor for the left wheel
    left_motor.start()

    left_motor.brake()
    right_motor.brake()
コード例 #4
0
def go_inches(inches, percent_of_max_speed):
    """
    Makes the EV3 Robot move the given number of inches at the given speed.

      :type inches: float
      :type percent_of_max_speed: float  -100 to 100
    """
    # TODO: 5.  Implement and test this function.
    motor = rb.LargeMotor(rb.Plug("B"))
    motor.start(percent_of_max_speed)
    motor.stop(inches)
コード例 #5
0
def go_inches(inches, percent_of_max_speed):
    """
    Makes the EV3 Robot move the given number of inches at the given speed.

      :type inches: float
      :type percent_of_max_speed: float  -100 to 100
    """
    # 5: DONE  Implement and test this function.

    left_motor = rb.LargeMotor(
        rb.Plug("B"))  # Constructs a Motor for the left wheel
    left_motor.speed_percent = percent_of_max_speed
    right_motor = rb.LargeMotor(rb.Plug("A"))
    right_motor.speed_percent = percent_of_max_speed

    left_motor.start()
    right_motor.start()

    time.sleep(inches / (.01 * abs(percent_of_max_speed)))

    left_motor.stop()
    right_motor.stop()