Esempio n. 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()
def main():
    board = rb.RoseBotConnection(ip_address="r05.wlan.rose-hulman.edu")
    pixy = rb.RoseBotPixy(board)

    while True:
        print(pixy.object_found(MIN_SIZE_PIXELS))  # detecting an object of a minimum size in pixels^2
#         print(pixy.object_found(min_object_width=MIN_WIDTH_PIXELS)  #  Only searching for an object 20 pixels wide
#         print(pixy.object_found(min_object_length=MIN_HEIGHT_PIXELS)  #  Only searching for an object 20 pixels wide
#         pixy.print_blocks()  # prints out all detected objects

        board.sleep(0.1)
Esempio n. 4
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)  # change the 'rXX' value
    #board = rb.RoseBotConnection(use_log_file=False)  # change the 'rXX' value
    led = rb.RoseBotDigitalOutput(board, rb.RoseBotPhysicalConstants.PIN_LED)
    while True:
        print("Blink sequence"
              )  # The total delay period is 1000 ms, or 1 second.
        led.digital_write(rb.RoseBotConstants.HIGH
                          )  # Turns LED ON -- HIGH puts 5V on pin 13.
        board.sleep(0.5)  # "pauses" the program for 500 milliseconds
        led.digital_write(
            rb.RoseBotConstants.LOW)  # Turns LED ON -- HIGH puts 5V on pin 13.
        board.sleep(0.5)  # "pauses" the program for 500 milliseconds
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()
Esempio n. 8
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)
Esempio n. 10
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()
def main():
    board = rb.RoseBotConnection(ip_address="r01.wlan.rose-hulman.edu")
    pixy = rb.RoseBotPixy(board)
    while True:
        board.sleep(0.5)  # Faster is OK too but unnecessary
        pixy.print_blocks()
"""
  Exp8_1_AccelerometerRead -- RedBot Experiment 8.1

  Measuring speed, velocity, and acceleration are all key
  components to robotics. This first experiment will introduce
  you to using the Accelerometer sensor on the RedBot.

 """

import rosebot.rosebot as rb

board = rb.RoseBotConnection(ip_address='10.0.1.19', use_log_file=False)
accelerometer = rb.RoseBotAccelerometer(board)


def main():
    """Display out the X, Y, and Z - axis "acceleration" measurements and also
            the relative angle between the X-Z, Y-Z, and X-Y vectors. (These give us
            the orientation of the RedBot in 3D space."""
    while True:
        if accelerometer.available():
            values = accelerometer.read()
            #print("values = " + str(values))
            x = values[rb.RoseBotAccelerometer.VAL_X]
            y = values[rb.RoseBotAccelerometer.VAL_Y]
            z = values[rb.RoseBotAccelerometer.VAL_Z]
            angle_xz = values[rb.RoseBotAccelerometer.VAL_ANGLE_XZ]
            angle_yz = values[rb.RoseBotAccelerometer.VAL_ANGLE_YZ]
            angle_xy = values[rb.RoseBotAccelerometer.VAL_ANGLE_XY]

            tap = accelerometer.read_tap()
Esempio n. 13
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()
Esempio n. 14
0
GRIPPER_ARM_DOWN = 70
GRIPPER_ARM_MID = 120
GRIPPER_ARM_UP = 180

straight_speed = 150
turning_speed = 100
last_button = None
TURN_AMOUNT = 30
ENCODER_PIN_LEFT = 16
ENCODER_PIN_RIGHT = 10
gripper_open = False
arm_up = False

pos = GRIPPER_ARM_MID

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)  # if using a wired connection

board.keep_alive(0)  # Testing the removal of the keep alive mechanism
# Before this was added it would shut down early seems to work if added

motors = rb.RoseBotMotors(board)


def main():
    global speedo_display_straight, speedo_display_turn
    print("tkinter GUI drive")
    board.servo_config(SERVO_GRIPPER_PIN)
    board.servo_config(SERVO_GRIPPER_ARM_PIN)

    root = tkinter.Tk()