Example #1
0
 def next(self, quantum=1):
     "State after quantum."
     self.time += quantum
     avspeed = (2 * self.speed + self.h_acc * quantum) / 2
     avclimb = (2 * self.climb + self.v_acc * quantum) / 2
     self.alt += avclimb * quantum
     self.speed += self.h_acc * quantum
     self.climb += self.v_acc * quantum
     distance = avspeed * quantum
     # Formula from <http://williams.best.vwh.net/avform.htm#Rhumb>
     # Initial point cannot be a pole, but GPS doesn't work at high.
     # latitudes anyway so it would be OK to fail there.
     # Seems to assume a spherical Earth, which means it's going
     # to have a slight inaccuracy rising towards the poles.
     # The if/then avoids 0/0 indeterminacies on E-W courses.
     tc = gps.Deg2Rad(self.course)
     lat = gps.Deg2Rad(self.lat)
     lon = gps.Deg2Rad(self.lon)
     lat += distance * math.cos(tc)
     dphi = math.log(
         math.tan(lat / 2 + math.pi / 4) /
         math.tan(self.lat / 2 + math.pi / 4))
     if abs(lat - self.lat) < math.sqrt(1e-15):
         q = math.cos(self.lat)
     else:
         q = (lat - self.lat) / dphi
     dlon = -distance * math.sin(tc) / q
     self.lon = gps.Rad2Deg(
         math.mod(lon + dlon + math.pi, 2 * math.pi) - math.pi)
     self.lat = gps.Rad2Deg(lat)
Example #2
0
    def __init__(self, gpstype):
        self.ksv = ksv()

        self.ksv.lat = gps.Rad2Deg(0.592539)
        self.ksv.lon = gps.Rad2Deg(2.066470)

        self.ksv.alt = 250
        self.ksv.speed = 0.629650
        self.ksv.distance = gps.Deg2Rad(3.5 / 60.0)
        self.ksv.course = 79.3
        self.ephemeris = {}
        # This sets up satellites at random.  Not really what we want.
        for PRN in self.active_PRNs:
            for (prn, satellite) in self.ephemeris.items():
                self.skyview[prn] = (random.randint(-60, +61),
                                     random.randint(0, 359))
        self.have_ephemeris = False
        self.channels = {}
        self.output = None
        self.status = gps.STATUS_NO_FIX
        self.mode = gps.MODE_NO_FIX
        self.validity = "V"
        self.satellites_used = 0
        self.filename = None
        self.lineno = 0
        self.gpstype = gpstype
Example #3
0
    def next(self, quantum=1):

        "State after quantum."
        #self.time += quantum
        #avspeed = (2*self.speed + self.h_acc*quantum)/2
        #avclimb = (2*self.climb + self.v_acc*quantum)/2
        #self.alt += avclimb * quantum
        #self.speed += self.h_acc * quantum
        #self.climb += self.v_acc * quantum
        #distance = avspeed * quantum
        # Formula from <http://williams.best.vwh.net/avform.htm#Rhumb>
        # Initial point cannot be a pole, but GPS doesn't work at high.
        # latitudes anyway so it would be OK to fail there.
        # Seems to assume a spherical Earth, which means it's going
        # to have a slight inaccuracy rising towards the poles.
        # The if/then avoids 0/0 indeterminacies on E-W courses.
        tc = gps.Deg2Rad(self.course)
        #print "lat, lon: " + str(self.lat) + ", " + str(self.lon)

        lat1R = gps.Deg2Rad(self.lat)
        lon1R = gps.Deg2Rad(self.lon)

        #print "lat, lon: " + str(lat1R) + ", " + str(lon1R)

        distance = self.distance
        #print "dist: " + str(gps.Rad2Deg(distance))

        latR = lat1R + distance * math.cos(tc)
        #print "lat, lon: " + str(latR) + ", " + str(lon1R)

        if abs(latR) > math.pi / 2.0:
            print "error d too large. You can't go this far along this rhumb line!"
        if abs(latR - lat1R) < math.sqrt(1e-15):
            q = math.cos(lat1R)
        else:
            t1 = math.tan(latR / 2.0 + math.pi / 4.0)
            t2 = math.tan(lat1R / 2.0 + math.pi / 4.0)
            #print "t1, t2: " + str(t1) + ", " + str(t2)

            dphi = math.log(t1 / t2)
            q = (latR - lat1R) / dphi
        dlon = -distance * math.sin(tc) / q
        self.lon = gps.Rad2Deg(
            math.fmod(lon1R + dlon + math.pi, 2.0 * math.pi) - math.pi)
        self.lat = gps.Rad2Deg(latR)