Ejemplo n.º 1
0
def main():
    """
    Robot will use two corners on one side of the wall in the arena.
    It will try to put all 4 tokens into slots. This gives us 9 points.
    """
    option = 2

    robot = Robot()
    reset_log(robot)
    robot.sound = Sound(robot, USING_SOUND)
    robot.sound.play('R2D2')
    robot.position = Tracker(robot.zone)
    set_pins(robot)

    slots_x = 2.91 if robot.zone in [0, 3] else 5.09
    target_theta = pi / 2 if robot.zone in [0, 3] else 1.5 * pi
    if robot.zone in [0, 1]:
        dy = 0.9
        slot_y_0 = 2.65
    else:
        dy = -0.9
        slot_y_0 = 5.65

    while 1:
        try:
            if option == 1:
                put_down(robot)
                grab(robot)

                token_to_slot(robot, robot.zone)
                for i in range(4):
                    zone = robot.zone if i < 2 else 3 - robot.zone

                    has_token = get_token_from_corner(robot, zone)

                    if has_token:
                        token_to_slot(robot, zone)
            elif option == 2:
                put_down(robot)
                grab(robot)
                for i in range(4):
                    zone = robot.zone if i < 2 else 3 - robot.zone
                    if i == 0:
                        move_to_point(robot, slots_x, slot_y_0 + 0.9,
                                      target_theta)
                        token_to_slot_2(robot)
                    elif i == 1:
                        move_to_point(robot, 2, 2)
                        get_token_from_corner(robot, zone)
                        move_to_point(robot, slots_x, slot_y_0, target_theta)
                        token_to_slot_2(robot)
                    else:
                        move_to_point(robot, 2, 2)
                        get_token_from_corner(robot, zone)
                        slot_y = slot_y_0 + dy * i
                        move_to_point(robot, slots_x, slot_y, target_theta)
                        token_to_slot_2(robot)
        except:
            print_exc()
            restart(robot)
Ejemplo n.º 2
0
def main():
    """
    Robot will use two corners on one side of the wall in the arena.
    It will try to put all 4 tokens into slots. This gives us 9 points.
    """
    option = 2

    robot = Robot()
    reset_log(robot)
    robot.sound = Sound(robot, USING_SOUND)
    robot.sound.play('R2D2')
    robot.position = Tracker(robot.zone)
    set_pins(robot)

    slots_x = 2.91 if robot.zone in [0, 3] else 5.09
    target_theta = pi/2 if robot.zone in [0, 3] else 1.5*pi
    if robot.zone in [0, 1]:
        dy = 0.9
        slot_y_0 = 2.65
    else:
        dy = -0.9
        slot_y_0 = 5.65

    while 1:
        try:
            if option == 1:
                put_down(robot)
                grab(robot)

                token_to_slot(robot, robot.zone)
                for i in range(4):
                    zone = robot.zone if i < 2 else 3-robot.zone

                    has_token = get_token_from_corner(robot, zone)

                    if has_token:
                        token_to_slot(robot, zone)
            elif option == 2:
                put_down(robot)
                grab(robot)
                for i in range(4):
                    zone = robot.zone if i < 2 else 3-robot.zone
                    if i == 0:
                        move_to_point(robot, slots_x, slot_y_0+0.9, target_theta)
                        token_to_slot_2(robot)
                    elif i == 1:
                        move_to_point(robot, 2, 2)
                        get_token_from_corner(robot, zone)
                        move_to_point(robot, slots_x, slot_y_0, target_theta)
                        token_to_slot_2(robot)
                    else:
                        move_to_point(robot, 2, 2)
                        get_token_from_corner(robot, zone)
                        slot_y = slot_y_0 + dy*i
                        move_to_point(robot, slots_x, slot_y, target_theta)
                        token_to_slot_2(robot)
        except:
            print_exc()
            restart(robot)
Ejemplo n.º 3
0
def avoidance_test(robot):
    move_to_point(robot, 1, 1, robot.position.theta, True)
Ejemplo n.º 4
0
def avoidance_test(robot):
    move_to_point(robot, 1, 1, robot.position.theta, True)