def DecideNextAction(): global lockMode Global.myRole = Constant.ATTACKER if GrabTurnKick.lockMode: GrabTurnKick.DecideNextAction() lockMode = True return lockMode = False if Global.ballY < Constant.FIELD_LENGTH/2: Forward.resetEachFrame() rAttacker.DecideNextAction() FWHead.DecideNextAction() return me_x = Global.selfLoc.getX() me_y = Global.selfLoc.getY() #ballToGoalDist = HelpMath.getDistanceBetween( \ # Global.ballX, Global.ballY, \ # Constant.TARGET_GOAL_X, Constant.TARGET_GOAL_Y) angleMeBallGoal = \ HelpMath.angleBetweenTwoPointsFromPivotPoint( \ me_x, me_y, \ Constant.TARGET_GOAL_X, Constant.TARGET_GOAL_Y, \ Global.ballX, Global.ballY ) distToGoal = HelpMath.getDistanceBetween(me_x, me_y, Constant.TARGET_GOAL_X, Constant.TARGET_GOAL_Y) MyTrack.DecideNextAction() # for head controlling if canDoKick() and distToGoal < 100: if isInRange(angleMeBallGoal, -KICK_MAX, -KICK_MIN): Kick.UPright() elif isInRange(angleMeBallGoal, KICK_MIN, KICK_MAX): Kick.UPleft() elif HelpTrack.inTargetGoalBox(Global.ballX, Global.ballY): # if ball in the goal box goalBoxKick(angleMeBallGoal) else: GrabTurnKick.DecideNextAction()
def chooseApproach_slowDown(): # Use HoverToBall for slow down approaches HoverToBall.DecideNextAction() global Grabbing_ForHK, Grabbing_ForVOAK myx, myy = Global.selfLoc.getPos() #------------------------------------------ # Should slow down for edge spin (disallow the top edge case, often flicks the ball down field) if ((not HelpTrack.isInRange(40, 320) and HelpTrack.ballOnREdge(15)) or (HelpTrack.isInRange(140, 220) and HelpTrack.ballOnLEdge(15)) or (HelpTrack.isInRange(50, 130) and (HelpTrack.ballOnTREdge(15) or HelpTrack.ballOnTLEdge(15))) ##~ (HelpTrack.isInRange(230,310) and HelpTrack.ballOnBEdge(15)) ): AttackerSlowDown(25.0, 10.0, 6.0, 2.0) return True #--------------------------------------------------------- # Grab turn kick elif (Global.ballY > Constant.FIELD_LENGTH / 2.0 and #HelpTrack.ballNotAlongEdge() and # Cant grap well on edge, should get behind #not HelpTrack.isInRange(20,160) and # going up, dont grap & upen len(HelpTeam.whichGpsOpponentWithinDistVar(50, 50)) == 0 # No opps too close by #not (myy > Constant.TOP_GOALBOX_EDGE_Y and myx < Constant.MIN_GOALBOX_EDGE_X) and #not (myy > Constant.TOP_GOALBOX_EDGE_Y and myx > Constant.MAX_GOALBOX_EDGE_X) ): GrabTurnKick.DecideNextAction() return True #--------------------------------------------------------- # getBehind and upenn rather than fast upenn elif ( #HelpTrack.ballNotAlongEdge() and # Cant grap well on edge, should get behind not (myy > Constant.TOP_GOALBOX_EDGE_Y and myx < Constant.MIN_GOALBOX_EDGE_X) and not (myy > Constant.TOP_GOALBOX_EDGE_Y and myx > Constant.MAX_GOALBOX_EDGE_X)): ballRgnBounds = InWhichBallRegion( 100.0) # input is the decision boundary if ballRgnBounds is not None: # Do getBehindBall if needed. # Once doing it will not stop unless conditions break it out in StillDoingGetBehind(). if chooseGetBehind_Upenn(ballRgnBounds): return True return False
def DecideNextAction(): global lockMode Global.myRole = Constant.ATTACKER #---------------------------------------------------------- # Grabbing ball for turn and kick lockMode = GrabTurnKick.lockMode if GrabTurnKick.lockMode: GrabTurnKick.DecideNextAction() return #---------------------------------------------------------- # stuck Detection (hysteresis) global stuckDetectTimer if stuckDetectTimer <= 30 and stuckDetectTimer != 0: StuckResolution() return #---------------------------------------------------------- # This is localise / locate ball / track ball decision if ShouldIStationaryLocalise( ): # do it when really lost (high pos / heading var), with no opp nearby return # Should I track the ball or do active localise, according to the allow and disallow timers values LocaliseOrTrackOrFindBall() if ShouldLocateBall or ShouldLocateWirelessBall: return #========================================= # Mostly VISION_BALL from HERE ONWARDS # Other balls? # -------------------------------------------------------------------------- # This is the hysteresis for different approach if StillDoingGetBehind(): return # ------------------------------------------------------------ # ------ CHOOSE APPROACH STRATEGY ----- # ------------------------------------------------------------ if Global.ballD < 30 and Global.lostBall == 0: setLocaliseTimer(0, 2) if chooseApproach_noSlowDown(): return if chooseApproach_slowDown(): return HoverToBall.DecideNextAction()
def DecideNextAction(): global lockMode Global.myRole = Constant.ATTACKER #---------------------------------------------------------- # Grabbing ball for turn and kick lockMode = GrabTurnKick.lockMode if lockMode: GrabTurnKick.DecideNextAction() return #---------------------------------------------------------- # stuck Detection (hysteresis) global stuckDetectTimer if stuckDetectTimer <= 30 and stuckDetectTimer != 0: StuckResolution() return ####################################################################### # Nobuyuki (16/02/2005) # Does the robot have to stop when it is really lost? # If it is in the middle of tracking the ball, why stop? # If it is not tracking the ball, then finding the ball is much more # important than localising. # Thus, I'll comment the lines below... # # I also implemented active localisation criteria used in 2003. ####################################################################### #if ShouldIStationaryLocalise(): # do it when really lost (high pos / heading var), with no opp nearby # return if ShouldIActivelyLocalise(): ActivelyLocalise() return ################################################################### # Nobuyuki (17/02/2005) # If the robot is not localising then let it do either tracking or # finding. ################################################################### TrackOrFindBall() if ShouldLocateBall or ShouldLocateWirelessBall: return #========================================= # Mostly VISION_BALL from HERE ONWARDS # Other balls? # -------------------------------------------------------------------------- # This is the hysteresis for different approach if StillDoingGetBehind(): return if StillEdgeSpinning(): return # ------------------------------------------------------------ # ------ CHOOSE APPROACH STRATEGY ----- # ------------------------------------------------------------ if Global.ballD < 30 and Global.lostBall == 0: setLocaliseTimer(0, 2) if chooseApproach_noSlowDown(): return if chooseApproach_slowDown(): return HoverToBall.DecideNextAction()