예제 #1
0
    def resetLocalizationFromPenalty(self):
        """
        Resets localization to both possible locations, depending on team color.
        """
        if self.my.teamColor == Constants.teamColor.TEAM_BLUE:
            self.loc.resetLocTo(Constants.LANDMARK_BLUE_GOAL_CROSS_X,
                                Constants.FIELD_WHITE_BOTTOM_SIDELINE_Y,
                                Constants.HEADING_UP,
                                Constants.LANDMARK_BLUE_GOAL_CROSS_X,
                                Constants.FIELD_WHITE_TOP_SIDELINE_Y,
                                Constants.HEADING_DOWN,
                                _localization.LocNormalParams(15.0, 15.0, 1.0),
                                _localization.LocNormalParams(15.0, 15.0, 1.0))
        else:
            self.loc.resetLocTo(Constants.LANDMARK_YELLOW_GOAL_CROSS_X,
                                Constants.FIELD_WHITE_BOTTOM_SIDELINE_Y,
                                Constants.HEADING_UP,
                                Constants.LANDMARK_YELLOW_GOAL_CROSS_X,
                                Constants.FIELD_WHITE_TOP_SIDELINE_Y,
                                Constants.HEADING_DOWN,
                                _localization.LocNormalParams(15.0, 15.0, 1.0),
                                _localization.LocNormalParams(15.0, 15.0, 1.0))

        # Loc knows the side of the field now. Reset accordingly.
        self.onOwnFieldSide = True
예제 #2
0
    def resetGoalieLocalization(self):
        """
        Resets the goalie's localization to the manual position in the goalbox.
        """
        if self.my.teamColor == Constants.teamColor.TEAM_BLUE:
            self.loc.resetLocTo(Constants.FIELD_WHITE_LEFT_SIDELINE_X,
                                Constants.MIDFIELD_Y, Constants.HEADING_RIGHT,
                                _localization.LocNormalParams(15.0, 15.0, 1.0))
        else:
            self.loc.resetLocTo(Constants.FIELD_WHITE_RIGHT_SIDELINE_X,
                                Constants.MIDFIELD_Y, Constants.HEADING_LEFT,
                                _localization.LocNormalParams(15.0, 15.0, 1.0))

        # Loc knows the side of the field now. Reset accordingly.
        self.onOwnFieldSide = True
예제 #3
0
def gameInitial(player):
    """
    Ensure we are sitting down and head is snapped forward.
    In the future, we may wish to make the head move a bit slower here
    Also, in the future, gameInitial may be responsible for turning off the gains
    """
    if player.firstFrame():
        player.inKickingState = False
        player.brain.nav.stop()
        player.gainsOn()
        player.zeroHeads()
        player.GAME_INITIAL_satDown = False
        # Reset localization to proper starting position by player number.
        # Locations are defined in the wiki.
        if player.brain.my.playerNumber == 1:
            player.brain.loc.resetLocTo(
                nogginConstants.BLUE_GOALBOX_RIGHT_X,
                nogginConstants.FIELD_WHITE_BOTTOM_SIDELINE_Y,
                nogginConstants.HEADING_UP,
                _localization.LocNormalParams(15.0, 15.0, 1.0))
        elif player.brain.my.playerNumber == 2:
            player.brain.loc.resetLocTo(
                nogginConstants.LANDMARK_BLUE_GOAL_CROSS_X,
                nogginConstants.FIELD_WHITE_BOTTOM_SIDELINE_Y,
                nogginConstants.HEADING_UP,
                _localization.LocNormalParams(15.0, 15.0, 1.0))
        elif player.brain.my.playerNumber == 3:
            player.brain.loc.resetLocTo(
                nogginConstants.LANDMARK_BLUE_GOAL_CROSS_X,
                nogginConstants.FIELD_WHITE_TOP_SIDELINE_Y,
                nogginConstants.HEADING_DOWN,
                _localization.LocNormalParams(15.0, 15.0, 1.0))
        elif player.brain.my.playerNumber == 4:
            player.brain.loc.resetLocTo(
                nogginConstants.BLUE_GOALBOX_RIGHT_X,
                nogginConstants.FIELD_WHITE_TOP_SIDELINE_Y,
                nogginConstants.HEADING_DOWN,
                _localization.LocNormalParams(15.0, 15.0, 1.0))

    elif (player.brain.nav.isStopped() and not player.GAME_INITIAL_satDown
          and not player.motion.isBodyActive()):
        player.GAME_INITIAL_satDown = True
        player.executeMove(SweetMoves.SIT_POS)

    elif (not player.motion.isBodyActive()):
        player.gainsOff()

    return player.stay()
예제 #4
0
    def resetInitialLocalization(self):
        """
        Reset loc according to team number and team color.
        Note: Loc uses truly global coordinates.
        """
        if self.my.teamColor == Constants.teamColor.TEAM_BLUE:
            if self.my.playerNumber == 1:
                self.loc.resetLocTo(
                    Constants.BLUE_GOALBOX_RIGHT_X,
                    Constants.FIELD_WHITE_BOTTOM_SIDELINE_Y,
                    Constants.HEADING_UP,
                    _localization.LocNormalParams(15.0, 15.0, 1.0))
            elif self.my.playerNumber == 2:
                self.loc.resetLocTo(
                    Constants.BLUE_GOALBOX_RIGHT_X,
                    Constants.FIELD_WHITE_TOP_SIDELINE_Y,
                    Constants.HEADING_DOWN,
                    _localization.LocNormalParams(15.0, 15.0, 1.0))
            elif self.my.playerNumber == 3:
                self.loc.resetLocTo(
                    Constants.LANDMARK_BLUE_GOAL_CROSS_X,
                    Constants.FIELD_WHITE_TOP_SIDELINE_Y,
                    Constants.HEADING_DOWN,
                    _localization.LocNormalParams(15.0, 15.0, 1.0))
            elif self.my.playerNumber == 4:
                self.loc.resetLocTo(
                    Constants.LANDMARK_BLUE_GOAL_CROSS_X,
                    Constants.FIELD_WHITE_BOTTOM_SIDELINE_Y,
                    Constants.HEADING_UP,
                    _localization.LocNormalParams(15.0, 15.0, 1.0))
        else:
            if self.my.playerNumber == 1:
                self.loc.resetLocTo(
                    Constants.YELLOW_GOALBOX_LEFT_X,
                    Constants.FIELD_WHITE_TOP_SIDELINE_Y,
                    Constants.HEADING_DOWN,
                    _localization.LocNormalParams(15.0, 15.0, 1.0))
            elif self.my.playerNumber == 2:
                self.loc.resetLocTo(
                    Constants.YELLOW_GOALBOX_LEFT_X,
                    Constants.FIELD_WHITE_BOTTOM_SIDELINE_Y,
                    Constants.HEADING_UP,
                    _localization.LocNormalParams(15.0, 15.0, 1.0))
            elif self.my.playerNumber == 3:
                self.loc.resetLocTo(
                    Constants.LANDMARK_YELLOW_GOAL_CROSS_X,
                    Constants.FIELD_WHITE_BOTTOM_SIDELINE_Y,
                    Constants.HEADING_UP,
                    _localization.LocNormalParams(15.0, 15.0, 1.0))
            elif self.my.playerNumber == 4:
                self.loc.resetLocTo(
                    Constants.LANDMARK_YELLOW_GOAL_CROSS_X,
                    Constants.FIELD_WHITE_TOP_SIDELINE_Y,
                    Constants.HEADING_DOWN,
                    _localization.LocNormalParams(15.0, 15.0, 1.0))

        # Loc knows the side of the field now. Reset accordingly.
        self.onOwnFieldSide = True
예제 #5
0
    def resetSetLocalization(self):

        gameSetResetUncertainties = _localization.LocNormalParams(50, 200, 1.0)

        if self.my.teamColor == Constants.teamColor.TEAM_BLUE:
            # #            if self.my.playerNumber == 1:
            # #                self.loc.resetLocTo(Constants.BLUE_GOALBOX_RIGHT_X,
            # #                                    Constants.FIELD_WHITE_BOTTOM_SIDELINE_Y,
            # #                                    Constants.HEADING_UP)
            #             if self.gameController.ownKickOff:
            #                 self.loc.resetLocTo(Constants.LANDMARK_BLUE_GOAL_CROSS_X,
            #                                     Constants.CENTER_FIELD_Y,
            #                                     0,
            #                                     gameSetResetUncertainties)
            #             else:
            #                 self.loc.resetLocTo(Constants.BLUE_GOALBOX_RIGHT_X,
            #                                     Constants.CENTER_FIELD_Y,
            #                                     0,
            #                                     gameSetResetUncertainties)
            self.loc.resetLocToSide(True)
        else:
            # if self.gameController.ownKickOff:
            #     self.loc.resetLocTo(Constants.LANDMARK_YELLOW_GOAL_CROSS_X,
            #                         Constants.CENTER_FIELD_Y,
            #                         180,
            #                         gameSetResetUncertainties)
            # else:
            #     self.loc.resetLocTo(Constants.YELLOW_GOALBOX_LEFT_X,
            #                         Constants.CENTER_FIELD_Y,
            #                         180,
            #                         gameSetResetUncertainties)
            self.loc.resetLocToSide(False)
예제 #6
0
def gameSet(player):
    """
    Fixate on the ball, or scan to look for it
    """
    if player.firstFrame():
        player.brain.logger.startLogging()
        player.inKickingState = False
        player.brain.nav.stand()
        player.gainsOn()
        player.brain.loc.resetBall()
        player.brain.tracker.trackBallFixedPitch()

        if (player.brain.my.playerNumber == 4
                and player.brain.gameController.ownKickOff):
            print "Setting Kickoff to True"
            player.shouldKickOff = True
        else:
            player.shouldKickOff = False

        if player.lastDiffState == 'gamePenalized':
            player.brain.resetSetLocalization()

    # For the goalie, reset loc every frame.
    # This way, garaunteed to have correctly set loc and be standing in that
    #  location for a frame before gamePlaying begins.
    if player.brain.play.isRole(GOALIE):
        player.brain.loc.resetLocTo(
            nogginConstants.FIELD_WHITE_LEFT_SIDELINE_X,
            nogginConstants.MIDFIELD_Y, nogginConstants.HEADING_RIGHT,
            _localization.LocNormalParams(15.0, 15.0, 1.0))

    # Wait until the sensors are calibrated before moving.
    while (not player.brain.motion.calibrated()):
        return player.stay()

    return player.stay()