コード例 #1
0
 def perform(self, comms):
     rot_angle = utils.defender_get_rotation_to_catch_point(
         Vector(self.robot.x, self.robot.y, self.robot.angle, 0),
         utils.get_defence_point(self.world), 0)[0]
     logging.info("Facing direction to move to defence area. Rotating %f degrees.", math.degrees(rot_angle))
     comms.turn(rot_angle)
     return utils.defender_turn_delay(rot_angle)
コード例 #2
0
class FaceOppositePitchSide(Action):
    preconditions = [(lambda w, r: abs(utils.dist(r.vector, utils.get_defence_point(w))) < DEFENCE_AREA_THRESHOLD, "At defence point.")]

    def perform(self, comms):
        if self.world.our_side == 'left':
            target_angle = pi / 2
        else:
            target_angle = 3 * pi / 2
        print target_angle
        rot_angle = (target_angle - self.robot.angle + pi) % (2 * pi) - pi
        logging.info("Facing opposite pitch side. Rotating %f degrees.", math.degrees(rot_angle))
        comms.turn(rot_angle)
        return utils.defender_turn_delay(rot_angle)
コード例 #3
0
 def perform(self, comms):
     dist = utils.dist(self.robot, utils.get_defence_point(self.world))
     dist *= utils.get_movement_direction_from_vector(self.robot, utils.get_defence_point(self.world))
     logging.info("Moving to defence area. Moving %f right.", dist)
     comms.move(dist)
     return utils.defender_move_delay(abs(dist))
コード例 #4
0
class MoveToDefenceArea(Action):

    preconditions = [(lambda w, r: abs(utils.defender_get_rotation_to_catch_point(Vector(r.x, r.y, r.angle, 0), utils.get_defence_point(w), 0)[0]) < ROTATION_THRESHOLD, "Aligned to move to defence point.")]

    def perform(self, comms):
        dist = utils.dist(self.robot, utils.get_defence_point(self.world))
        dist *= utils.get_movement_direction_from_vector(self.robot, utils.get_defence_point(self.world))
        logging.info("Moving to defence area. Moving %f right.", dist)
        comms.move(dist)
        return utils.defender_move_delay(abs(dist))