예제 #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)
예제 #2
0
파일: robot.py 프로젝트: Homletmoo/SR-2014
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)
예제 #3
0
	def __init__(self):
		SingleThreadAccess.__init__(self)
		#Make sure the soton class is initiated, so we can connect to motors
		Robot.__init__(self, wait_start = False)
		atexit.register(self.stop)
		
		#Name the motors, for easy access
		self.leftMotor = self.motors[0]
		self.rightMotor = self.motors[1]

		self._leftSpeed = 0
		self._rightSpeed = 0