コード例 #1
0
    def adjust_hog(self):
        # Update HOG from rudder change
        hogChange = (self.boatData.sow *
                     math.sin(self.boatData.rudder * math.pi / 180.0) *
                     self.CLOCK_INTERVAL) * self.HOG_CHANGE_FACTOR

        self.boatData.hog += hogChange
        self.boatData.hog = standardcalc.bound_to_180(self.boatData.hog)
コード例 #2
0
    def adjust_current(self):
        # self.currentFlowAngle += standardcalc.generate_bell_curve(self.CURRENT_ANGLE_FLUCTUATIONS * self.CLOCK_INTERVAL)
        # self.currentFlowSpeed += standardcalc.generate_bell_curve(self.CURRENT_SPEED_FLUCTUATIONS * self.CLOCK_INTERVAL)
        self.currentFlowAngle += random.gauss(0,1) * self.CLOCK_INTERVAL
        self.currentFlowSpeed += random.gauss(0,1) * self.CLOCK_INTERVAL
        self.currentFlowAngle = standardcalc.bound_to_180(self.currentFlowAngle)
        self.currentFlowSpeed = abs(self.currentFlowSpeed)

        self.currentFlowVector = standardcalc.Vector2D.create_from_angle(self.currentFlowAngle, self.currentFlowSpeed)
コード例 #3
0
    def adjust_current(self):
        self.currentFlowAngle += random.gauss(0, 1) * self.CLOCK_INTERVAL
        self.currentFlowSpeed += random.gauss(0, 0.3) * self.CLOCK_INTERVAL
        self.currentFlowAngle = standardcalc.bound_to_180(
            self.currentFlowAngle)
        if self.currentFlowSpeed > self.MAX_CURRENT_SPEED:
            self.currentFlowSpeed = self.MAX_CURRENT_SPEED

        self.currentFlowSpeed = abs(self.currentFlowSpeed)
        self.currentFlowVector = standardcalc.Vector2D.create_from_angle(
            self.currentFlowAngle, self.currentFlowSpeed)
コード例 #4
0
    def adjust_true_wind(self):
        # True wind angle is allowed to fluctuate
        # self.trueWindAngle += standardcalc.generate_bell_curve(self.WIND_ANGLE_FLUCTUATIONS * self.CLOCK_INTERVAL)
        # self.trueWindSpeed += standardcalc.generate_bell_curve(self.WIND_SPEED_FLUCTUATIONS * self.CLOCK_INTERVAL)

        self.trueWindAngle += random.gauss(0,1) * self.CLOCK_INTERVAL
        self.trueWindSpeed += random.gauss(0,1) * self.CLOCK_INTERVAL
        self.trueWindAngle = standardcalc.bound_to_180(self.trueWindAngle)
        self.trueWindSpeed = abs(self.trueWindSpeed)

        self.windVector = -standardcalc.Vector2D.create_from_angle(self.trueWindAngle, self.trueWindSpeed)
コード例 #5
0
 def adjust_true_wind(self):
     # True wind angle is allowed to fluctuate
     self.trueWindAngle += random.gauss(0, 1) * self.CLOCK_INTERVAL
     self.trueWindSpeed += random.gauss(0, 0.3) * self.CLOCK_INTERVAL
     if self.trueWindSpeed > self.MAX_WIND_SPEED:
         self.trueWindSpeed = self.MAX_WIND_SPEED
     if self.trueWindSpeed < self.MIN_WIND_SPEED:
         self.trueWindSpeed = self.MIN_WIND_SPEED
     self.trueWindAngle = standardcalc.bound_to_180(self.trueWindAngle)
     self.trueWindSpeed = abs(self.trueWindSpeed)
     self.windVector = -standardcalc.Vector2D.create_from_angle(
         self.trueWindAngle, self.trueWindSpeed)
コード例 #6
0
    def update_vectors(self):
        self.boatVector = standardcalc.Vector2D.create_from_angle(self.boatData.hog, self.boatData.sow) \
                          + self.currentFlowVector
        # Update COG and SOG
        self.boatData.cog = self.boatVector.angle()
        self.boatData.sog = self.boatVector.length()

        self.apparentWindVector = self.windVector - self.boatVector

        # 4 Feb 2016
        self.boatData.awa = standardcalc.bound_to_180(
            standardcalc.Vector2D.angle_between(self.boatVector, -self.apparentWindVector))
        self.boatData.windspeed = self.apparentWindVector.length()
コード例 #7
0
    def adjust_hog(self):
        # Make functional, i.e. go to desired rudder angle immediately
        # hogChange = self.currentData['sog'] * math.sin(self.currentData['rudderAngle']* math.pi / 180.0) \
        #             / self.L_CENTERBOARD_TO_RUDDER * self.TIME_SCALE
        # self.currentData['hog'] += hogChange
        # self.currentData['hog'] = standardcalc.bound_to_180(self.currentData['hog'])

        #Update HOG from rudder change
        hogChange = self.boatData.sow * math.sin(self.boatData.rudder * math.pi / 180.0) \
                    / self.L_CENTERBOARD_TO_RUDDER * self.TIME_SCALE

        self.boatData.hog += hogChange
        self.boatData.hog = standardcalc.bound_to_180(self.boatData.hog)
コード例 #8
0
    def adjust_aw(self):
        self.boatVector = standardcalc.Vector2D.create_from_angle(self.boatData.hog, self.boatData.sow) \
                          - self.currentFlowVector
        # Update COG and SOG
        self.boatData.cog = self.boatVector.angle()
        self.boatData.sog = self.boatVector.length()

        self.apparentWindVector = self.windVector - self.boatVector

        # print str(self.apparentWindVector.angle()) + " " + str(self.apparentWindVector.length())
        self.boatData.awa = standardcalc.bound_to_180(
            standardcalc.Vector2D.angle_between(self.boatVector,
                                                -self.apparentWindVector))
        self.boatData.windspeed = self.apparentWindVector.length()
コード例 #9
0
 def gust_manager(self):
     if self.gustTimer <= 0:
         if random.randint(1, self.GUST_PROBABILITY / self.TIME_SCALE) == 2:
             self.preGustTrueWindAngle = self.trueWindAngle
             self.preGustTrueWindSpeed = self.trueWindSpeed
             self.trueWindSpeed = random.randint(20, 30)
             self.trueWindAngle += random.randint(-5, 5)
             self.gustTimer = random.randint(5, 80) / self.TIME_SCALE
     else:
         self.gustTimer -= 1
         if self.verbose:
             print "Gust is active. Timer: " + str(self.gustTimer)
         if self.gustTimer <= 0:
             self.trueWindSpeed = abs(self.preGustTrueWindSpeed + random.randint(-2, 2))
             self.trueWindAngle = standardcalc.bound_to_180(self.preGustTrueWindAngle + random.randint(-1, 1))
コード例 #10
0
 def gust_manager(self):
     if self.gustTimer <= 0:
         if random.randint(1, self.GUST_PROBABILITY /
                           self.CLOCK_INTERVAL) == 2:
             self.preGustTrueWindAngle = self.trueWindAngle
             self.preGustTrueWindSpeed = self.trueWindSpeed
             self.trueWindSpeed = random.randint(20, 30)
             self.trueWindAngle += random.randint(-5, 5)
             self.gustTimer = random.randint(5, 80) / self.CLOCK_INTERVAL
     else:
         self.gustTimer -= 1
         if self.verbose:
             print "Gust is active. Timer: " + str(self.gustTimer)
         if self.gustTimer <= 0:
             self.trueWindSpeed = abs(self.preGustTrueWindSpeed +
                                      random.randint(-2, 2))
             self.trueWindAngle = standardcalc.bound_to_180(
                 self.preGustTrueWindAngle + random.randint(-1, 1))
コード例 #11
0
def data():
    lat = boatDataStruct.gps_coord.lat
    lng = boatDataStruct.gps_coord.long
    aws = boatDataStruct.windspeed
    awa = boatDataStruct.awa
    hog = boatDataStruct.hog
    sow = boatDataStruct.sow
    tws = TWS
    twa = TWA
    awa_abs = standardcalc.bound_to_180(boatDataStruct.hog +
                                        boatDataStruct.awa)
    # Data to be sent in one array.
    coords = [
        lat, lng, awa_abs, sow, hog, dest.lat, dest.long,
        currentVector.length(),
        currentVector.angle(), awa, aws, twa, tws
    ]
    # Converts data to JSON.
    return json.dumps(coords)
コード例 #12
0
	def testNoChange(self):
		self.assertEqual(standardcalc.bound_to_180(self.num1), self.num1bounded)
コード例 #13
0
 def testNoChange(self):
     self.assertEqual(standardcalc.bound_to_180(self.num1),
                      self.num1bounded)
コード例 #14
0
 def testGreaterThan180(self):
     self.assertEqual(standardcalc.bound_to_180(self.num2),
                      self.num2bounded)
コード例 #15
0
 def testLessThan180(self):
     self.assertEqual(standardcalc.bound_to_180(self.num3),
                      self.num3bounded)
コード例 #16
0
	def testLessThan360ToPositive(self):
		self.assertEqual(standardcalc.bound_to_180(self.num7), self.num7bounded)
コード例 #17
0
	def testGreaterThan360ToNegative(self):
		self.assertEqual(standardcalc.bound_to_180(self.num5), self.num5bounded)
コード例 #18
0
	def testLessThan360ToNegative(self):
		self.assertEqual(standardcalc.bound_to_180(self.num6), self.num6bounded)
コード例 #19
0
	def testLessThan180(self):
		self.assertEqual(standardcalc.bound_to_180(self.num3), self.num3bounded)
コード例 #20
0
	def testGreaterThan360ToPositive(self):
		self.assertEqual(standardcalc.bound_to_180(self.num4), self.num4bounded)
コード例 #21
0
	def testGreaterThan180(self):
		self.assertEqual(standardcalc.bound_to_180(self.num2), self.num2bounded)
コード例 #22
0
 def testGreaterThan360ToPositive(self):
     self.assertEqual(standardcalc.bound_to_180(self.num4),
                      self.num4bounded)
コード例 #23
0
 def testLessThan360ToPositive(self):
     self.assertEqual(standardcalc.bound_to_180(self.num7),
                      self.num7bounded)
コード例 #24
0
 def testLessThan360ToNegative(self):
     self.assertEqual(standardcalc.bound_to_180(self.num6),
                      self.num6bounded)
コード例 #25
0
 def testGreaterThan360ToNegative(self):
     self.assertEqual(standardcalc.bound_to_180(self.num5),
                      self.num5bounded)