Beispiel #1
0
def main():
    board = rb.RoseBotConnection(
        ip_address="r01.wlan.rose-hulman.edu")  # change the 'rXX' value
    motors = rb.RoseBotMotors(board)

    print("Driving forward")
    motors.drive_pwm(150, 150)
    board.sleep(1.0)
    motors.brake()

    print("Pivot-- turn to right")
    motors.drive_pwm(
        100, -100
    )  # Turn on left motor counter clockwise medium power (motorPower = 150)
    board.sleep(0.5)
    motors.brake()

    print("Driving reverse")
    motors.drive_pwm(-150, -150)
    board.sleep(1.0)
    motors.brake()

    while True:
        # Figure 8 pattern -- Turn Right, Turn Left, Repeat
        print("Veering Right")
        motors.drive_pwm(150, 80)
        board.sleep(2.0)
        print("Veering Left")
        motors.drive_pwm(80, 150)
        board.sleep(2.0)
def main():
    board = rb.RoseBotConnection(ip_address="r03.wlan.rose-hulman.edu")  # change the 'rXX' value
    motors = rb.RoseBotMotors(board)
    print("Left and right motors at full speed forward")
    motors.drive_pwm(255)  # Turn on Left and right motors at full speed forward.
    board.sleep(2.0)  # Waits for 2 seconds
    print("Stop both motors")
    motors.brake()  # Stops both motors
    board.shutdown()
Beispiel #3
0
def main():
    board = rb.RoseBotConnection(
        ip_address='r01.wlan.rose-hulman.edu')  # change the 'rXX' value
    # The heartbeat keep_alive() message does not work with the input() function,
    # so disable keep_alive by setting the parameter to 0.
    board.keep_alive(0)
    motors = rb.RoseBotMotors(board)
    while True:
        speed = int(
            input()
        )  # input any integer from -255 (reverse full speed) to 255 (full speed forward)
        motors.drive_pwm(speed)
def main():
    board = rb.RoseBotConnection(
        ip_address='r03.wlan.rose-hulman.edu')  # change the 'rXX' value
    motors = rb.RoseBotMotors(board)
    encoders = rb.RoseBotEncoder(board)
    button = rb.RoseBotDigitalInput(board,
                                    rb.RoseBotPhysicalConstants.PIN_BUTTON)
    while True:
        # wait for a button press to start driving.
        if button.read() == 0:
            motors.drive_distance(12,
                                  150)  # drive 12 inches at motor_power = 150
def main():
    board = rb.RoseBotConnection(ip_address="r01.wlan.rose-hulman.edu", use_log_file=False)
    motors = rb.RoseBotMotors(board)

    print("Here is the RoseBot driving Normally (no control inbuilt) ")
    motors.drive_at_speed(30, 30, True)
    board.sleep(15)
    motors.brake()
    board.sleep(2)


    print("Here is an example of PID control to drive the RoseBot straight")
    motors.drive_at_speed(30, 30, True)
    board.sleep(8)
    motors.brake()
    board.sleep(2)
    board.shutdown()
Beispiel #6
0
def main():
    board = rb.RoseBotConnection(
        ip_address='r03.wlan.rose-hulman.edu')  # change the 'rXX' value
    motors = rb.RoseBotMotors(board)
    IR_sensor_1 = rb.RoseBotAnalogInput(board,
                                        rb.RoseBotPhysicalConstants.PIN_A3)
    IR_sensor_2 = rb.RoseBotAnalogInput(board,
                                        rb.RoseBotPhysicalConstants.PIN_A6)
    IR_sensor_3 = rb.RoseBotAnalogInput(board,
                                        rb.RoseBotPhysicalConstants.PIN_A7)
    print("Welcome to Experiment 6!")
    print("------------------------")

    while True:
        board.sleep(0.1)
        print("IR Sensor Readings: {},   {},    {}".format(
            IR_sensor_1.read(), IR_sensor_2.read(), IR_sensor_3.read()))
def main():
    board = rb.RoseBotConnection(
        ip_address="r01.wlan.rose-hulman.edu")  # change the 'rXX' value
    motors = rb.RoseBotMotors(board)
    button = rb.RoseBotDigitalInput(board,
                                    rb.RoseBotPhysicalConstants.PIN_BUTTON)
    buzzer = rb.RoseBotBuzzer(board, rb.RoseBotPhysicalConstants.PIN_9)
    while True:
        if button.read() == rb.RoseBotConstants.LOW:
            buzzer.play_tone(400, 0.5)
            board.sleep(0.75)
            buzzer.play_tone(400, 0.5)
            board.sleep(0.75)
            buzzer.play_tone(2000, None)
            board.sleep(0.75)
            buzzer.stop()

            motors.drive_pwm(255)  # Drive forward for a while
            board.sleep(1.0)
            motors.brake()
        else:
            board.sleep(rb.RoseBotConstants.SAMPLING_INTERVAL_S)
Beispiel #8
0
def main():
    board = rb.RoseBotConnection(ip_address='r01.wlan.rose-hulman.edu', use_log_file=False)  # change the 'rXX' value
    #board = rb.RoseBotConnection(use_log_file=False)  # change the 'rXX' value
    motors = rb.RoseBotMotors(board)
    encoders = rb.RoseBotEncoder(board)
    button = rb.RoseBotDigitalInput(board, rb.RoseBotPhysicalConstants.PIN_BUTTON)

    print("Left     Right")
    print("==============")
    while True:
        # wait for a button press to start driving (note make sure Pixy is NOT connected so you can use the button).
        if button.read() == 0:
            print("Detected a button press")
            encoders.reset_encoder_counts()  # Reset the counters
            motors.drive_pwm(150)  # Start driving forward
        count_left = encoders.count_left
        count_right = encoders.count_right

        print("{}       {}".format(count_left, count_right))  # stores the encoder count to a variable
        board.sleep(rb.RoseBotConstants.SAMPLING_INTERVAL_S)

        #  if either left or right motor are more than 5 revolutions, stop
        if count_left >= 5 * rb.RoseBotPhysicalConstants.COUNTS_PER_REV or count_right >= 5 * rb.RoseBotPhysicalConstants.COUNTS_PER_REV:
            motors.brake()
Beispiel #9
0
"""
  Exp5_Bumpers -- RoseBot Experiment 5

  Now let's experiment with the whisker bumpers. These super-simple switches
  let you detect a collision before it really happens- the whisker will
  bump something before your robot crashes into it.
"""
import rosebot.rosebot as rb

board = rb.RoseBotConnection(ip_address="r01.wlan.rose-hulman.edu")
# Instantiate the motor control object. This only needs to be done once.
motors = rb.RoseBotMotors(board)
left_bumper = rb.RoseBotDigitalInput(
    board,
    rb.RoseBotPhysicalConstants.PIN_3)  # initializes bumper object on pin 3
right_bumper = rb.RoseBotDigitalInput(
    board,
    rb.RoseBotPhysicalConstants.PIN_11)  # initializes bumper object on pin 11


def main():
    while True:
        motors.drive_pwm(255)
        left_bumper_state = left_bumper.read()
        right_bumper_state = right_bumper.read()
        if left_bumper_state == 0:  # left bumper is bumped
            reverse()
            turn_right()
        if right_bumper_state == 0:  # Right bumper is bumped
            reverse()
            turn_left()