def setWayPtCoords(self, boxCoords): #sets the waypoints of the challenge wayPtCoords = [] #order = top face, right face, bottom face, left face wayPtCoords.append(standardcalc.returnMidPoint(boxCoords[0],boxCoords[1])) wayPtCoords.append(standardcalc.returnMidPoint(boxCoords[1],boxCoords[2])) wayPtCoords.append(standardcalc.returnMidPoint(boxCoords[2],boxCoords[3])) wayPtCoords.append(standardcalc.returnMidPoint(boxCoords[3],boxCoords[0])) return wayPtCoords
def run(self, wayList): self.nav_log_timer = 0 buoyCoords = None portStartInnerPoint = None starboardStartInnerPoint = None navMidpoint = None gVars.kill_flagNav = 0 for waypoint in wayList: if (waypoint.wtype == sVars.NAV_FIRST): buoyCoords = waypoint.coordinate elif (waypoint.wtype == sVars.NAV_START_PORT): portStartInnerPoint = waypoint.coordinate elif (waypoint.wtype == sVars.NAV_START_STARBOARD): starboardStartInnerPoint = waypoint.coordinate elif (waypoint.wtype == sVars.NAV_MIDPOINT): navMidpoint = waypoint.coordinate if not (buoyCoords and portStartInnerPoint and starboardStartInnerPoint): gVars.logger.error("Arguments Incorrect!") self.interpolatedPoint = standardcalc.returnMidPoint( portStartInnerPoint, starboardStartInnerPoint) if not navMidpoint: halfwayBackPoint = datatypes.GPSCoordinate( (self.interpolatedPoint.lat + buoyCoords.lat) / 2, (self.interpolatedPoint.long + buoyCoords.long) / 2) gVars.logger.info("Using dynamically created midpoint.") else: halfwayBackPoint = navMidpoint gVars.logger.info("Using user given midpoint") gVars.logger.info("Rounding Buoy") if (gVars.kill_flagNav == 0): self.roundbuoy.run(buoyCoords) gVars.logger.info("Heading for Midpoint ") if (gVars.kill_flagNav == 0): self.pointtopoint.run(halfwayBackPoint) gVars.logger.info("Heading for Finish") if (gVars.kill_flagNav == 0): acceptDistance = 1 thread.start_new_thread(self.printNavigationLog, ()) self.pointtopoint.run(self.interpolatedPoint, acceptDistance) if gVars.kill_flagNav == 1: gVars.logger.info( "Nav Kill Flag initialized. Nav has been stopped.") else: gVars.logger.info("Navigation challenge finished")
def run(self, wayList): self.nav_log_timer=0 buoyCoords = None portStartInnerPoint = None starboardStartInnerPoint = None navMidpoint = None gVars.kill_flagNav = 0 for waypoint in wayList: if(waypoint.wtype == sVars.NAV_FIRST): buoyCoords = waypoint.coordinate elif(waypoint.wtype == sVars.NAV_START_PORT): portStartInnerPoint = waypoint.coordinate elif(waypoint.wtype == sVars.NAV_START_STARBOARD): starboardStartInnerPoint = waypoint.coordinate elif(waypoint.wtype == sVars.NAV_MIDPOINT): navMidpoint = waypoint.coordinate if not (buoyCoords and portStartInnerPoint and starboardStartInnerPoint): gVars.logger.error("Arguments Incorrect!") self.interpolatedPoint = standardcalc.returnMidPoint(portStartInnerPoint,starboardStartInnerPoint) if not navMidpoint: halfwayBackPoint = datatypes.GPSCoordinate((self.interpolatedPoint.lat+buoyCoords.lat)/2,(self.interpolatedPoint.long+buoyCoords.long)/2) gVars.logger.info("Using dynamically created midpoint.") else: halfwayBackPoint = navMidpoint gVars.logger.info("Using user given midpoint") gVars.logger.info("Rounding Buoy") if(gVars.kill_flagNav == 0): self.roundbuoy.run(buoyCoords) gVars.logger.info("Heading for Midpoint ") if(gVars.kill_flagNav == 0): self.pointtopoint.run(halfwayBackPoint) gVars.logger.info("Heading for Finish") if(gVars.kill_flagNav == 0): acceptDistance = 1 thread.start_new_thread(self.printNavigationLog, ()) self.pointtopoint.run(self.interpolatedPoint,acceptDistance) if gVars.kill_flagNav == 1: gVars.logger.info("Nav Kill Flag initialized. Nav has been stopped.") else: gVars.logger.info("Navigation challenge finished")