Пример #1
0
def get_frisbee():
    print "Starting get_frisbee()"
    m.arm_slow(c.ARM_UP_POS, 2, 1)
    m.backwards(900)
    m.arm_slow(c.ARM_FRISBEE_GRAB_POS, 2, 1)
    m.forwards(2000)
    m.arm_slow(c.ARM_FRISBEE_DROP_POS, 4, 1)
    m.turn_left(
        int(c.LEFT_TURN_TIME /
            5))  # An 18 degree wiggle back and forth to shake frisbee loose
    m.turn_right(int(c.RIGHT_TURN_TIME / 5))
    m.backwards(1000)
    m.lift_arm(c.ARM_FRISBEE_FARTHER_DROP_POS)
Пример #2
0
def test_servos(exit=True):
    # Used to see if basic servo commands and constants function as intended.
    print "Testing servos\n"
    m.close_claw()
    m.wait()  # Using wait() instead of msleep() to make sure wheels are off.
    m.open_claw()
    m.wait()
    m.lift_arm()
    m.wait()
    m.lower_arm()
    m.wait()
    print "Testing complete."
    if exit == True:
        print "Exiting...\n"
        exit(86)
Пример #3
0
def get_gas_valve():
    s.wfollow_right_until_black_left_front()
    s.wfollow_right_until_white_left_front()
    s.wfollow_right_until_black_left_front()
    s.wfollow_right_until_black_right()
    s.wfollow_right_until_white_right()
    s.turn_left_until_rfcliff_senses_white()
    s.turn_left_until_rfcliff_senses_black()
    m.turn_left(c.LEFT_TURN_TIME / 4.8)
    # This turns the robot closer to 90 degrees
    s.forwards_until_white_lfcliff()
    s.forwards_through_line_lfcliff()
    s.align_far_fcliffs()
    s.align_far_fcliffs()
    s.forwards_until_bump()
    m.backwards(1000)
    #g.turn_left_gyro(180)
    m.turn_left()
    m.turn_left()
    s.forwards_until_black_lfcliff()
    s.align_close_fcliffs()
    s.align_close_fcliffs()
    #m.turn_left(250)
    m.lower_arm()
    msleep(500)
    m.backwards(900)
    m.lift_arm(3, 1, c.ARM_HALF_UP_POS)
    m.backwards(300)
    m.lift_arm()
    s.forwards_until_black_lfcliff()
    s.align_close_fcliffs()
    s.forwards_until_bump()
    m.backwards(100)
    #g.turn_right_gyro()
    m.turn_right(c.RIGHT_TURN_TIME / 1.2)
    s.wfollow_left_until_white_right_front(9999)
    s.wfollow_left_until_black_right_front(9999)
    s.wfollow_left_until_white_right_front(9999)
    s.align_far_fcliffs()
    s.align_far_fcliffs()
    m.backwards(500)
    #g.turn_right_gyro(30)
    m.turn_right(c.RIGHT_TURN_TIME / 3.5)
    m.backwards(400)
    m.lower_arm(1, 1, c.ARM_DELIVERY_POS)
    shut_down_in(118)
Пример #4
0
def get_blocks():
    g.backwards_gyro_until_black_left()
    s.align_far()
    g.backwards_gyro_through_line_left(0)
    g.backwards_gyro_until_black_left()
    s.align_far()
    g.backwards_gyro_through_line_left(0)
    g.backwards_gyro(300)
    g.turn_right_gyro(90)
    g.drive_gyro(2000, should_stop=False)
    g.drive_gyro_until_white_left(0)
    g.drive_gyro_until_black_left(0)
    g.drive_gyro(500, should_stop=False)
    g.drive_gyro_until_white_left(0)
    g.drive_gyro(950)
    s.turn_left_until_black()
    m.open_claw()
    m.lower_arm()
    #s.lfollow_left_pid(13000, bias=15, should_stop=False)
    s.lfollow_left_pid_until_black_third(time=21000, bias=10)
    m.close_claw()
    g.backwards_gyro(800)
    m.lift_arm(1, 1)
    s.lfollow_left_pid_until_black_right(bias=10)
def hold_cube_and_deliver_ambulance():
    print "Starting deliver_ambulance()"
    s.backwards_until_black_left()
    m.lift_arm()
    s.drive_until_black_third()
    s.turn_right_until_black()
    s.backwards_through_line_third(0)
    s.backwards_until_black_right()
    m.lower_cube_arm()
    s.drive_through_line_third(0)
    s.drive_until_black_left()
    m.close_claw()
    m.move_cube_arm(c.CUBE_ARM_HOLDING_POS)
    m.move_claw(c.CLAW_LESS_OPEN_POS)
    m.move_cube_arm(c.CUBE_ARM_UP_POS)
    m.turn_left(int(c.RIGHT_TURN_TIME / 1.5))
    s.backwards_through_line_left(0)
    s.backwards_through_line_third()
    s.turn_right_until_left_senses_black(0)
    s.turn_right_until_left_senses_white()
    s.lfollow_left_until_right_senses_black_pid_safe_no_stop(500)

    s.lfollow_left_until_right_senses_black_pid()
    #s.lfollow_left_until_right_senses_black(1000)
    #s.lfollow_left_until_right_senses_black_smooth()
    s.turn_right_until_white(0)
    s.turn_right_until_black()
    m.lower_arm()
    w.check_zones_hospital()
    m.lift_arm()
    if c.SAFE_HOSPITAL == c.NEAR_ZONE:
        s.backwards_through_line_third()
        m.lower_arm()
        m.backwards(500)
        s.drive_until_black_third()
        m.lift_arm()

    else:  # Safe hospital is far zone
        s.backwards_through_line_third()
        s.turn_right_until_white(0)
        s.turn_right_until_black()
        s.backwards_until_white_right(0)
        m.backwards(500)
        m.lower_arm()
        # Ambulance delivered
        s.drive_through_line_third()
        s.turn_right_until_left_senses_black(0)
        s.turn_right_until_left_senses_white(0)
    print "Finished delivering ambulance and yellow cube"
Пример #6
0
def pick_up_coupler():
    m.base_backwards(0.1)
    m.lift_arm(4,1)
    m.deactivate_motors()
Пример #7
0
def deliver_second_crate():
    print "Starting second_crate_delivery()"
    m.drive(250)
    m.arm_slow(c.ARM_SECOND_CRATE_GRAB_POS, 2, 1)
    m.backwards(100)
    m.claw_slow(c.CLAW_SECOND_CRATE_GRAB_POS, 3, 1)
    m.lift_arm(c.ARM_SECOND_CRATE_UP_POS)
    m.wait(100)
    if crate_zone == c.LEFT:
        f.left_point_turn_until_black()
        if c.IS_MAIN_BOT:
            f.lfollow_left_smooth_amount(.7, c.BASE_LM_POWER, c.BASE_RM_POWER,
                                         int(.5 * c.BASE_LM_POWER),
                                         int(.5 * c.BASE_RM_POWER), 0, 0,
                                         False)
            f.lfollow_left_smooth(.8, c.BASE_LM_POWER, c.BASE_RM_POWER)
        else:  # Clone bot
            f.lfollow_left_smooth(1.5)
        f.left_point_turn_until_right_senses_black()
        f.lfollow_right_inside_line_until_left_senses_black_smooth_amount(
            1, c.BASE_LM_POWER, c.BASE_RM_POWER, int(.4 * c.BASE_LM_POWER),
            int(.4 * c.BASE_RM_POWER), 0, 0, False)
        f.lfollow_right_inside_line_until_left_senses_black_smooth(
            10, 0, 0, False)
        m.drive(150, c.BASE_LM_POWER, c.BASE_RM_POWER, c.BASE_LM_POWER,
                c.BASE_RM_POWER)
        m.turn_right()
        f.align_in_zone_safely()
    elif crate_zone == c.MIDDLE:
        f.right_point_turn_until_black()
        f.lfollow_right_smooth(1.5)
        f.right_point_turn_until_left_senses_black()
        f.lfollow_left_inside_line_until_right_senses_black_smooth_amount(
            1, c.BASE_LM_POWER, c.BASE_RM_POWER, int(.4 * c.BASE_LM_POWER),
            int(.4 * c.BASE_RM_POWER), 0, 0, False)
        f.lfollow_left_inside_line_until_right_senses_black_smooth(
            10, 0, 0, False)
        m.drive(180, c.BASE_LM_POWER, c.BASE_RM_POWER, c.BASE_LM_POWER,
                c.BASE_RM_POWER)
        f.right_point_turn_until_black(5, 0, 0, False)
        f.right_point_turn_until_white(5, c.BASE_LM_POWER,
                                       -1 * c.BASE_RM_POWER, False)
        f.right_point_turn_until_black(5, c.BASE_LM_POWER,
                                       -1 * c.BASE_RM_POWER, False)
        f.right_point_turn_until_left_senses_black(5, c.BASE_LM_POWER,
                                                   -1 * c.BASE_RM_POWER, False)
        m.turn_right(c.RIGHT_TURN_TIME, c.BASE_LM_POWER, -1 * c.BASE_RM_POWER,
                     c.BASE_LM_POWER, -1 * c.BASE_RM_POWER)
        f.align_in_zone_safely()
    elif crate_zone == c.RIGHT:
        f.drive_until_white_third(10, 0, 0, False)
        m.drive(300, c.BASE_LM_POWER, c.BASE_RM_POWER, c.BASE_LM_POWER,
                c.BASE_RM_POWER)
        f.right_point_turn_until_black()
        f.lfollow_right(3)
        f.right_point_turn_until_left_senses_black()
        f.lfollow_left_inside_line_until_right_senses_black_smooth_amount(
            2, c.BASE_LM_POWER, c.BASE_RM_POWER, int(.4 * c.BASE_LM_POWER),
            int(.4 * c.BASE_RM_POWER), 0, 0, False)
        f.lfollow_left_inside_line_until_right_senses_black_smooth(
            10, c.BASE_LM_POWER, c.BASE_RM_POWER, False)
        m.drive(200, c.BASE_LM_POWER, c.BASE_RM_POWER, c.BASE_LM_POWER,
                c.BASE_RM_POWER)
        m.turn_left()
        f.align_in_zone_safely()
    f.drive_through_line_third(10, 0, 0, False)
    m.drive(800, c.BASE_LM_POWER, c.BASE_RM_POWER, c.BASE_LM_POWER,
            c.BASE_RM_POWER)
    m.arm_slow(c.ARM_SECOND_CRATE_DEPOSIT_POS, 2, 1)
    m.claw_slow(c.CLAW_LARGE_OPEN_POS, 3, 1)
    m.arm_slow(c.ARM_PUSH_CRATE_POS, 2, 1)
    m.backwards(600)
    msleep(10)
    m.drive(200)
    m.arm_slow(c.ARM_HIGH_POS, 2, 1)
    print "Second crate delivered\n\n"