def findByForce(): global gForceType global gForceFired global gForceCounter global gForceSpinDir # If we need to force anything, then force it. gForceFired = True if gForceCounter > 0: if gForceType == FORCE_SPIN: findBySpin(gForceSpinDir) elif gForceType == FORCE_FOLLOW: if gForceCounter < 20: findByGps() else: hTrack.scan() if not gHeadOnly: Action.walk(Action.MAX_FORWARD,0,0) elif gForceType == FORCE_LAST_VISUAL: hTrack.scan() if not gHeadOnly: walkToBall(Global.fstVisBallDist, Global.fstVisBallHead, getBehind = gGetBehind) Global.lostBall = 0 gForceCounter -= 1
def findByDropInSignal(): hTrack.scan() if not gHeadOnly: # Make sure we use gps's information, not wireless # FIXME: if we are going to dodgy dog then don't get behind walkToBall(Global.gpsLocalBall.getDistance(), Global.gpsLocalBall.getHeading(), getBehind = gGetBehind)
def findByBackingOff(): hTrack.scan() Action.walk(-Action.MAX_FORWARD,0,0,minorWalkType=Action.SkeFastForwardMWT) # After you backed off for a while, then use cccluded ball strategy if we need it. if Global.lostBall >= Constant.LOST_BALL_GPS + 20: ballX, ballY = Global.gpsGlobalBall.getPos() import sDodgyDog if sDodgyDog.shouldIBeDodgy(ballX,ballY): sDodgyDog.dodgyDogTo(ballX,ballY)
def findByWireless(): hTrack.scan(highSpeed=10,minPan=-60,maxPan=60) if not gHeadOnly: selfX, selfY = Global.selfLoc.getPos() # Make sure we get a ball distance from wireless info. if Global.ballD < WIRELESS_BALL_CLOSE_DIST: findBySpin() else: Action.walk(0,0,Global.ballH,minorWalkType=Action.SkeFastForwardMWT)
def findBallDefender(): time = Global.lostBall % TIMER_3 if time < TIMER_1: turnccw = hMath.CLIP(Global.ballH,80) Action.walk(0,0,turnccw, minorWalkType = Action.SkeFastForwardMWT) hTrack.scan() elif time < TIMER_2: hFWHead.compulsoryAction = hFWHead.doNothing sFindBall.findBySpin() else: targetH = Global.selfLoc.getHeading() + Global.ballH hTrack.saGoToTargetFacingHeading(Global.selfLoc.getX(), \ Constant.FIELD_LENGTH * 0.25, targetH)
def findBallStriker(): time = Global.lostBall % TIMER_3 if time < TIMER_1: turnccw = hMath.CLIP(Global.ballH, 80) Action.walk(0, 0, turnccw, minorWalkType=Action.SkeFastForwardMWT) hTrack.scan() elif time < TIMER_2: hFWHead.compulsoryAction = hFWHead.doNothing sFindBall.findBySpin() else: targetH = Global.selfLoc.getHeading() + Global.ballH targetX, targetY, _rangeX = hWhere.getStrikerPos(True) hTrack.saGoToTargetFacingHeading(targetX, targetY, targetH)
def findByWireless(): hTrack.scan(highSpeed=10, minPan=-60, maxPan=60) if not gHeadOnly: selfX, selfY = Global.selfLoc.getPos() # Make sure we get a ball distance from wireless info. ballDSquared = hMath.getDistSquaredBetween(selfX, selfY, Global.sharedBallX, Global.sharedBallY) if ballDSquared < hMath.SQUARE(WIRELESS_BALL_CLOSE_DIST): findBySpin() else: Action.walk(0, 0, Global.ballH, minorWalkType=Action.SkeFastForwardMWT)
def findBall(tx, ty): global gSpinCounter global gTargetPointReqAccuracy selfX, selfY = Global.selfLoc.getPos() distSquared = hMath.getDistSquaredBetween(selfX, selfY, tx, ty) if gSpinCounter > 0: sFindBall.findBySpin() gSpinCounter -= 1 elif distSquared <= hMath.SQUARE(gTargetPointReqAccuracy): gTargetPointReqAccuracy = TARGET_PT_ACC_LARGE_CIRCLE sFindBall.findBySpin() gSpinCounter = 100 else: gTargetPointReqAccuracy = TARGET_PT_ACC_SMALL_CIRCLE hTrack.scan() hTrack.saGoToTarget(tx, ty)
def findByScan(): # Nobu: I've put in the hHeadOnly test since the bird was stopping when # it lost the ball. if gHeadOnly: hTrack.scan() else: # If the last seen ball is far away, then continue walking for a while. # Use obstacle occluded as well? if Global.weightedVisBallDist > 150: hTrack.scan(lowCrane=0, highCrane=0, minPan=-60, maxPan=60, lookDown=False) Action.walk(Action.MAX_FORWARD, 0, 0, minorWalkType=Action.SkeFastForwardMWT) else: hTrack.scan() Action.walk(0, 0, 0, minorWalkType=Action.SkeFastForwardMWT)
def findByScan(): if gHeadOnly: hTrack.scan() else: # If the last seen ball is far away, then continue walking for a while. # Use obstacle occluded as well? if Global.gpsLocalBall.getDistance() > 150: hTrack.scan() #hTrack.scan(minPan=-60,maxPan=60,lookDown=False) Action.walk(Action.MAX_FORWARD,0,0,minorWalkType=Action.SkeFastForwardMWT) else: hTrack.scan() Action.walk(0,0,0,minorWalkType=Action.SkeFastForwardMWT)