コード例 #1
0
def get_low_poms():  # First pom set
    print "Starting get_low_poms()"
    m.arm_slow(c.ARM_UP_POS, 3, 1)
    f.backwards_through_line_lfcliff()
    f.backwards_through_line_lfcliff()
    f.align_close_fcliffs()
    collect_poms()
コード例 #2
0
def get_crates():
    print "Starting get_crates()"
    print "Bot in starting box\n"
    f.drive_through_two_lines_third()
    f.right_point_turn_until_black()
    f.lfollow_right_until_left_senses_black_smooth_amount(
        .5, 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_right_until_left_senses_black_smooth_amount(
        .5, c.BASE_LM_POWER, c.BASE_RM_POWER, int(.7 * c.BASE_LM_POWER),
        int(.7 * c.BASE_RM_POWER), c.BASE_LM_POWER, c.BASE_RM_POWER, False)
    f.lfollow_right_until_left_senses_black_smooth_amount(
        10, c.BASE_LM_POWER, c.BASE_RM_POWER, int(.9 * c.BASE_LM_POWER),
        int(.9 * c.BASE_RM_POWER), c.BASE_LM_POWER, c.BASE_RM_POWER, False)
    print "Bot on center tee\n"
    if c.IS_MAIN_BOT:
        m.drive_tics(1007, c.BASE_LM_POWER, c.BASE_RM_POWER)
    else:  # Clone bot
        m.drive_tics(1120, c.BASE_LM_POWER, c.BASE_RM_POWER)
    f.right_point_turn_until_third_senses_white(10, 0, 0, False)
    f.right_point_turn_until_third_senses_black(10, c.BASE_LM_POWER,
                                                -1 * c.BASE_RM_POWER)
    f.left_backwards_until_black()
    f.right_backwards_until_black()
    m.open_claw()
    m.arm_slow(c.ARM_DOWN_POS)
    m.claw_slow(c.CLAW_LESS_OPEN_POS)
    m.backwards(1400)
    print "Bot driving backwards to get crates\n"
    m.close_claw()
    print "\n\nFinished getting crates\n\n"
コード例 #3
0
def collect_poms(msleep_time=50,
                 forwards_amount=1000,
                 amount=1250):  # Actual act of collecting poms once aligned
    m.backwards(amount)
    m.arm_slow(c.ARM_COLLECTION_POS)
    msleep(msleep_time)
    m.forwards(forwards_amount)
コード例 #4
0
def get_low_poms_cheeky():  # First pom set
    print "Starting get_low_poms()"
    m.arm_slow(c.ARM_UP_POS, 3, 1)
    f.backwards_through_line_lfcliff()
    f.backwards_through_line_lfcliff()
    f.align_close_fcliffs()
    collect_poms(50, 0)
    f.forwards_until_black_lfcliff()
    m.backwards(150)
コード例 #5
0
def get_mid_poms():  # Second pom set
    print "Starting get_mid_poms()"
    f.forwards_until_black_lfcliff()
    f.align_close_fcliffs()
    m.arm_slow(c.ARM_UP_POS, 2, 1)
    m.turn_left()
    m.backwards(2680)
    m.turn_right()
    f.forwards_until_black_lfcliff()
    f.align_close_fcliffs()
    collect_poms()
コード例 #6
0
def get_farther_low_poms():
    f.forwards_until_line_fcliffs()
    f.align_close_cliffs()
    m.arm_slow(c.ARM_UP_POS, 2, 1)
    m.turn_right(int(c.RIGHT_TURN_TIME * 1.01))
    f.forwards_until_bump()
    m.backwards(200)
    m.turn_left()
    f.backwards_through_line_lfcliff()
    f.align_close_cliffs()
    collect_poms(50, 1000, 2100)
コード例 #7
0
def get_farther_mid_poms():
    f.forwards_until_line_fcliffs()
    f.align_close_cliffs()
    m.arm_slow(c.ARM_UP_POS, 2, 1)
    f.right_point_turn_until_lfcliff_senses_black()
    f.right_point_turn_until_lfcliff_senses_white()
    f.lfollow_lfcliff_smooth(2)
    f.lfollow_lfcliff_smooth_until_right_depth_senses_object()
    m.forwards(1000)
    m.turn_left()
    f.backwards_through_line_lfcliff()
    f.align_close_fcliffs()
    collect_poms()
コード例 #8
0
def get_high_poms_cheeky():
    print "Starting get_high_poms_cheeky()"
    f.forwards_until_black_lfcliff()
    f.align_close_fcliffs()
    m.arm_slow(c.ARM_UP_POS, 2, 1)
    m.turn_right()
    m.forwards(2680)
    m.turn_left()
    f.forwards_until_black_lfcliff()
    f.align_close_fcliffs()
    collect_poms(10000)
    f.backwards_until_white_lfcliff()
    m.arm_slow(c.ARM_UP_POS, 2, 1)
コード例 #9
0
def test_servos(exit = True):
# Used to see if basic servo commands and constants function as intended.
    print "Testing servos\n"
    m.claw_slow(c.CLAW_CLOSE_POS)
    m.wait()  # Using wait() instead of msleep() to make sure wheels are off.
    m.claw_slow(c.CLAW_OPEN_POS)
    m.wait()
    m.arm_slow(c.ARM_DOWN_POS)
    m.wait()
    m.arm_slow(c.ARM_HIGH_POS)
    m.wait()
    print "Testing complete."
    if exit == True:
        print "Exiting...\n"
        exit(86)
コード例 #10
0
def get_botguy():
    print "Starting get_botguy()"
    if crate_zone == c.LEFT:
        print "I'm in the left zone and going to botguy"
        f.drive_through_line_left()  # Bot on middle line
        f.snap_to_line_left()
        f.lfollow_left_until_right_senses_black_smooth(20, 0, 0, False)
        f.drive_until_white(5, c.BASE_LM_POWER, c.BASE_RM_POWER, False)
        f.lfollow_left_until_third_senses_black_smooth(5, c.BASE_LM_POWER,
                                                       c.BASE_RM_POWER, False)
        m.drive_tics(300, c.BASE_LM_POWER, c.BASE_RM_POWER)
        f.left_point_turn_until_third_senses_white(5 * c.LEFT_TURN_TIME, 0, 0)
    elif crate_zone == c.MIDDLE:
        print "I'm in the middle zone and going to botguy"
        m.turn_right()
        m.drive(1500)
        m.turn_left()
        f.drive_through_line_left()  # Bot on middle line
        f.align_far()
        f.snap_to_line_left()
        f.lfollow_left_until_right_senses_black_smooth(20, 0, 0, False)
        f.drive_until_white(5, c.BASE_LM_POWER, c.BASE_RM_POWER, False)
        f.lfollow_left_until_third_senses_black_smooth(5, c.BASE_LM_POWER,
                                                       c.BASE_RM_POWER, False)
        m.drive_tics(300, c.BASE_LM_POWER, c.BASE_RM_POWER)
        f.left_point_turn_until_third_senses_white(5 * c.LEFT_TURN_TIME, 0, 0)
    elif crate_zone == c.RIGHT:
        print "I'm in the right zone and going to botguy"
        f.drive_through_line_left()  # Bot on middle line
        f.align_far()
        f.snap_to_line_right()
        f.lfollow_right_until_left_senses_black_smooth(20, 0, 0, False)
        if c.IS_MAIN_BOT:
            m.drive_tics(1007, c.BASE_LM_POWER, c.BASE_RM_POWER)
        else:  # Clone bot
            m.drive_tics(1120, c.BASE_LM_POWER, c.BASE_RM_POWER)
        f.right_point_turn_until_third_senses_white(
            5 * c.RIGHT_TURN_TIME / 1000, 0, 0, False)
        f.right_point_turn_until_third_senses_black(10, c.BASE_LM_POWER,
                                                    -1 * c.BASE_RM_POWER)
    else:
        print "What zone am I in again? I have no idea. This is an error message"
        print "You already know I'm guessing it's in that right zone tho\n"
        exit(86)
    f.left_backwards_until_black()
    f.right_backwards_until_black()
    m.open_claw(c.CLAW_BOTGUY_OPEN_POS)
    m.arm_slow(c.ARM_DOWN_POS)
    #f.right_point_turn_until_third_senses_black()  # To do: Run more tests on this command
    f.lfollow_backwards_smooth(4.5)
    m.arm_slow(c.ARM_UP_POS)
    m.backwards(490)
    m.arm_slow(c.ARM_PUSH_CRATE_POS, 2, 1)
    m.close_claw(c.CLAW_CLOSE_POS)
    m.arm_slow(c.ARM_DOWN_POS)
    m.backwards(100)
    m.close_claw(c.BOTGUY_CLAW_CLOSE_POS)
    print "Finished getting botguy\n\n"
コード例 #11
0
def get_farther_high_poms():
    print "Starting get_farther_high_poms()"
    f.forwards_until_line_fcliffs()
    f.align_close_cliffs()
    m.arm_slow(c.ARM_UP_POS, 2, 1)
    f.right_point_turn_until_lfcliff_senses_black()
    f.right_point_turn_until_lfcliff_senses_white()
    f.lfollow_lfcliff_smooth_until_rfcliff_senses_black()
    f.forwards_until_white_rfcliff()
    f.right_point_turn_until_rfcliff_senses_black(2)
    f.right_point_turn_until_lfcliff_senses_black(2)
    f.right_point_turn_until_rfcliff_senses_white(2)
    f.right_point_turn_until_rfcliff_senses_black(2)
    f.backwards_until_black_lfcliff()
    # m.turn_right(int(0.5 * c.RIGHT_TURN_TIME), 2 * c.BASE_LM_POWER, -2 * c.BASE_RM_POWER)
    # m.turn_right(int(0.5 * c.RIGHT_TURN_TIME), 2 * c.BASE_LM_POWER, -2 * c.BASE_RM_POWER)
    m.backwards(1650)
    m.turn_right()
    f.forwards_until_line_fcliffs()
    f.align_close_fcliffs()
    collect_poms()
コード例 #12
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)
コード例 #13
0
def deliver_first_crate():
    print "Starting first_crate_delivery()"
    m.drive(500)
    if crate_zone == c.LEFT:
        print "Starting deliver_left()"
        f.snap_to_line_left()
        f.lfollow_left_until_right_senses_black_smooth(13, c.BASE_LM_POWER,
                                                       c.BASE_RM_POWER, False)
        f.lfollow_left_smooth(1, c.BASE_LM_POWER, c.BASE_RM_POWER)
        f.right_point_turn_until_left_senses_white(10, 0, 0, False)
        f.right_point_turn_until_left_senses_black(10, c.BASE_LM_POWER,
                                                   -1 * c.BASE_RM_POWER, False)
        f.right_point_turn_until_left_senses_white(10, c.BASE_LM_POWER,
                                                   -1 * c.BASE_RM_POWER, False)
        f.right_point_turn_until_left_senses_black(10, c.BASE_LM_POWER,
                                                   -1 * c.BASE_RM_POWER, False)
        f.right_point_turn_until_left_senses_white(10, c.BASE_LM_POWER,
                                                   -1 * c.BASE_RM_POWER)
        f.lfollow_left_until_right_senses_black_smooth(7)
        if c.IS_MAIN_BOT:
            f.right_point_turn_until_black_after(c.RIGHT_TURN_TIME, 0, 0,
                                                 False)
            f.right_point_turn_until_white(1, c.BASE_LM_POWER,
                                           -1 * c.BASE_RM_POWER)
        else:  # Clone bot
            f.right_point_turn_until_black_after(c.RIGHT_TURN_TIME)
    elif crate_zone == c.MIDDLE:
        print "Starting deliver_middle()"
        f.snap_to_line_right()
        f.lfollow_right_until_left_senses_black_smooth(13, c.BASE_LM_POWER,
                                                       c.BASE_RM_POWER, False)
        f.lfollow_right_smooth(1, c.BASE_LM_POWER, c.BASE_RM_POWER)
        f.left_point_turn_until_right_senses_white(10, 0, 0, False)
        f.left_point_turn_until_right_senses_black(10, -1 * c.BASE_LM_POWER,
                                                   c.BASE_RM_POWER, False)
        f.left_point_turn_until_right_senses_white(10, -1 * c.BASE_LM_POWER,
                                                   c.BASE_RM_POWER, False)
        f.left_point_turn_until_right_senses_black(10, -1 * c.BASE_LM_POWER,
                                                   c.BASE_RM_POWER, False)
        f.left_point_turn_until_right_senses_white(10, -1 * c.BASE_LM_POWER,
                                                   c.BASE_RM_POWER)
        f.lfollow_right_until_left_senses_black_smooth(7)
        f.drive_until_white_left()
        f.right_forwards_until_left_senses_black(10, 0, False)
        f.right_forwards_until_left_senses_white(10, c.BASE_RM_POWER)
        f.lfollow_left_inside_line_until_right_senses_black_smooth(
            10, 0, 0, False)
        #f.left_forwards_until_black()
        f.drive_until_white_right(2, c.BASE_LM_POWER, c.BASE_RM_POWER, False)
        if c.IS_MAIN_BOT:
            f.lfollow_left_inside_line_smooth(2.5, c.BASE_LM_POWER,
                                              c.BASE_RM_POWER)
        else:  # Clone bot
            f.lfollow_left_inside_line_smooth(2.7, 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(700, c.BASE_LM_POWER, c.BASE_RM_POWER, c.BASE_LM_POWER,
                c.BASE_RM_POWER)
    elif crate_zone == c.RIGHT:
        print "Starting deliver_right()"
        f.snap_to_line_right()
        f.lfollow_right_until_left_senses_black_smooth(13, c.BASE_LM_POWER,
                                                       c.BASE_RM_POWER, False)
        f.lfollow_right_smooth(1, c.BASE_LM_POWER, c.BASE_RM_POWER)
        f.left_point_turn_until_right_senses_white(10, 0, 0, False)
        f.left_point_turn_until_right_senses_black(10, -1 * c.BASE_LM_POWER,
                                                   c.BASE_RM_POWER, False)
        f.left_point_turn_until_right_senses_white(10, -1 * c.BASE_LM_POWER,
                                                   c.BASE_RM_POWER, False)
        f.left_point_turn_until_right_senses_black(10, -1 * c.BASE_LM_POWER,
                                                   c.BASE_RM_POWER, False)
        f.left_point_turn_until_right_senses_white(10, -1 * c.BASE_LM_POWER,
                                                   c.BASE_RM_POWER)
        f.lfollow_right_until_left_senses_black_smooth(7)
        f.left_point_turn_until_black_after(c.LEFT_TURN_TIME, 0, 0, False)
        f.left_point_turn_until_white(1, -1 * c.BASE_LM_POWER, c.BASE_RM_POWER)
        m.backwards(200)
    m.arm_slow(c.ARM_DOWN_POS)
    msleep(300)  # This pause helps keep the second crate from tipping over
    m.claw_slow(c.CLAW_LARGE_OPEN_POS)
    m.arm_slow(c.ARM_PUSH_CRATE_POS, 2, 1)
    m.backwards(500)
    print "First crate delivered\n\n"
コード例 #14
0
def put_botguy_in_correct_zone():
    approach_t()
    f.right_point_turn_until_third_senses_black(.2)
    print "Starting deliver_botguy()"
    if botguy_zone == c.LEFT:
        print "Starting deliver_left()"
        f.snap_to_line_left()
        f.lfollow_left_until_right_senses_black_smooth(13, c.BASE_LM_POWER,
                                                       c.BASE_RM_POWER, False)
        f.lfollow_left_smooth(1, c.BASE_LM_POWER, c.BASE_RM_POWER)
        f.right_point_turn_until_left_senses_white(10, 0, 0, False)
        f.right_point_turn_until_left_senses_black(10, c.BASE_LM_POWER,
                                                   -1 * c.BASE_RM_POWER, False)
        f.right_point_turn_until_left_senses_white(10, c.BASE_LM_POWER,
                                                   -1 * c.BASE_RM_POWER, False)
        f.right_point_turn_until_left_senses_black(10, c.BASE_LM_POWER,
                                                   -1 * c.BASE_RM_POWER, False)
        f.right_point_turn_until_left_senses_white(10, c.BASE_LM_POWER,
                                                   -1 * c.BASE_RM_POWER)
        f.lfollow_left_until_right_senses_black_smooth(7)
        f.right_point_turn_until_black_after(c.RIGHT_TURN_TIME, 0, 0, False)
        m.turn_right(int(c.RIGHT_TURN_TIME / 2), c.BASE_LM_POWER,
                     -1 * c.BASE_RM_POWER, c.BASE_LM_POWER,
                     -1 * c.BASE_RM_POWER)
        m.claw_slow(c.CLAW_LARGE_OPEN_POS, 3, 1)
    elif botguy_zone == c.MIDDLE:
        print "Starting deliver_middle()"
        f.drive_until_white_third(5, 0, 0, False)
        m.drive(300, c.BASE_LM_POWER, c.BASE_RM_POWER, c.BASE_LM_POWER,
                c.BASE_RM_POWER)
        f.left_point_turn_until_right_senses_black(10, 0, 0, False)
        f.left_point_turn_until_right_senses_white(10, -1 * c.BASE_LM_POWER,
                                                   c.BASE_RM_POWER, False)
        f.left_point_turn_until_right_senses_black(10, -1 * c.BASE_LM_POWER,
                                                   c.BASE_RM_POWER)
        f.backwards_through_line_left()
        f.align_close()
        if False:  # crate_zone == c.LEFT:
            m.turn_right(int(c.RIGHT_TURN_TIME / 8))
            m.backwards(900)
            m.turn_right(int(c.RIGHT_TURN_TIME / 10))
        elif False:  # crate_zone == c.RIGHT:
            m.turn_left(int(c.LEFT_TURN_TIME / 8))
            m.backwards(900)
            m.turn_left(int(c.LEFT_TURN_TIME / 20))
        m.claw_slow(c.CLAW_LARGE_OPEN_POS, 3, 1)
        m.backwards(1000)
    elif botguy_zone == c.RIGHT:
        print "Starting deliver_right()"
        f.snap_to_line_right()
        f.lfollow_right_until_left_senses_black_smooth(13, c.BASE_LM_POWER,
                                                       c.BASE_RM_POWER, False)
        f.lfollow_right_smooth(1, c.BASE_LM_POWER, c.BASE_RM_POWER)
        f.left_point_turn_until_right_senses_white(10, 0, 0, False)
        f.left_point_turn_until_right_senses_black(10, -1 * c.BASE_LM_POWER,
                                                   c.BASE_RM_POWER, False)
        f.left_point_turn_until_right_senses_white(10, -1 * c.BASE_LM_POWER,
                                                   c.BASE_RM_POWER, False)
        f.left_point_turn_until_right_senses_black(10, -1 * c.BASE_LM_POWER,
                                                   c.BASE_RM_POWER, False)
        f.left_point_turn_until_right_senses_white(10, -1 * c.BASE_LM_POWER,
                                                   c.BASE_RM_POWER)
        f.lfollow_right_until_left_senses_black_smooth(7)
        m.turn_left(c.LEFT_TURN_TIME, -1 * c.BASE_LM_POWER, c.BASE_RM_POWER,
                    -1 * c.BASE_LM_POWER, c.BASE_RM_POWER, False)
        m.turn_left(c.LEFT_TURN_TIME, -1 * c.BASE_LM_POWER, c.BASE_RM_POWER,
                    -1 * c.BASE_LM_POWER, c.BASE_RM_POWER, False)
        m.turn_left(int(c.LEFT_TURN_TIME / 2), -1 * c.BASE_LM_POWER,
                    c.BASE_RM_POWER, -1 * c.BASE_LM_POWER, c.BASE_RM_POWER)
        m.claw_slow(c.CLAW_LARGE_OPEN_POS, 3, 1)
    m.arm_slow(c.ARM_PUSH_CRATE_POS, 3, 1)
    m.backwards(300)
    print "Botguy delivered\n\n"
コード例 #15
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"
コード例 #16
0
def test_servos_extensive(exit = True):  # Runs all constant servo positions for arm and claw. Not updated.
    print "Testing servos extensively\n"
    m.claw_slow(c.STARTING_CLAW_POS)
    m.arm_slow(c.STARTING_ARM_POS)
    m.wait()
    m.claw_slow(c.CLAW_OPEN_POS)
    m.wait()
    m.claw_slow(c.CLAW_CLOSE_POS)
    m.wait()
    m.claw_slow(c.CLAW_SECOND_CRATE_GRAB_POS)
    m.wait()
    m.claw_slow(c.BOTGUY_CLAW_CLOSE_POS)
    m.wait()
    m.arm_slow(c.ARM_UP_POS)
    m.wait()
    m.arm_slow(c.ARM_DOWN_POS)
    m.wait()
    m.arm_slow(c.ARM_SECOND_CRATE_UP_POS)
    m.wait()
    m.arm_slow(c.ARM_SECOND_CRATE_GRAB_POS)
    m.wait()
    m.arm_slow(c.ARM_DOWN_POS)
    m.wait()
    print "Testing complete."
    if exit == True:
        print "Exiting...\n"
        exit(86)
コード例 #17
0
def check_zones_full():
    print "Checking zones"
    msleep(25)
    ao()
    m.arm_slow(c.ARM_HIGH_POS, 2, 1)
    camera_open()
    initialize_camera()
    console_clear()
    graphics_open(480, 260)
    graphics_fill(255, 255, 255)
    graphics_update()
    a.crate_zone = 30
    a.botguy_zone = 30
    if get_object_area(c.YELLOW,
                       0) > 50:  # Testing to see if middle zone is yellow
        print "The middle zone is yellow.\n"
        a.crate_zone = c.MIDDLE
        graphics_rectangle_fill(160, 0, 320, 260, 255, 255, 0)  # Yellow
        graphics_update()
    elif get_object_area(c.RED, 0) > 50:
        a.botguy_zone = c.MIDDLE
        graphics_rectangle_fill(160, 0, 320, 260, 255, 0, 0)  # Red
        graphics_update()
        print "The middle zone is red.\n"
    else:
        print "The middle is not red nor yellow.\n"
        graphics_rectangle_fill(160, 0, 320, 260, 0, 255, 0)  # Green
        graphics_update()
    m.turn_left(400)  # Checking the left zone
    msleep(25)
    ao()
    initialize_camera()
    if get_object_area(c.YELLOW,
                       0) > 100:  # Testing to see if left zone is yellow
        print "The left zone is yellow.\n"
        graphics_rectangle_fill(0, 0, 160, 260, 255, 255, 0)  # Yellow
        graphics_update()
        if a.crate_zone == 30:
            a.crate_zone = c.LEFT
        else:
            print "ERROR. The wallaby sensed yellow for the left zone and the middle zone.\n"
    elif get_object_area(c.RED, 0) > 100:
        print "The left zone is red\n"
        graphics_rectangle_fill(0, 0, 160, 260, 255, 0, 0)  # Red
        graphics_update()
        if a.botguy_zone == 30:
            a.botguy_zone = c.LEFT
        else:
            print "ERROR. The wallaby sensed red for the left zone and the middle zone.\n"
    else:
        print "The left zone is neither red nor yellow.\n"
        graphics_rectangle_fill(0, 0, 160, 260, 0, 255, 0)  # Green
        graphics_update()
    if a.crate_zone == 30:  # If the crate zone has not been set yet.
        a.crate_zone = c.RIGHT
        graphics_rectangle_fill(320, 0, 480, 260, 255, 255, 0)  # Yellow
        graphics_update()
        print "The right zone is yellow.\n"
    elif a.botguy_zone == 30:
        if a.crate_zone == c.RIGHT:
            print "Code failure"
        else:
            a.botguy_zone = c.RIGHT
            graphics_rectangle_fill(320, 0, 480, 260, 255, 0, 0)  # Red
            graphics_update()
        print "The right zone is red. \n"
    else:
        print "The right zone is neither red nor yellow."
        graphics_rectangle_fill(320, 0, 480, 260, 0, 255, 0)  # Green
        graphics_update()
    if a.botguy_zone == 30:
        if a.crate_zone == c.RIGHT:
            a.botguy_zone = c.LEFT
            graphics_rectangle_fill(0, 0, 160, 260, 255, 0, 0)  # Red
            graphics_update()
            print "We are guessing that the left zone is red. \n"
        else:
            a.botguy_zone = c.RIGHT
            graphics_rectangle_fill(320, 0, 480, 260, 255, 0, 0)
            graphics_update()
            print "We are guessing that the right zone is red. \n"
    f.left_forwards_until_black(
    )  # The left tophat can end up on white - Jet 6-27-18
    f.align_far()
    camera_close()
    graphics_close()
    print "Crate zone: " + str(a.crate_zone)
    print "Botguy zone: " + str(a.botguy_zone)
    print "~fin~\n\n\n"