예제 #1
0
def fixes_to_numpy(gps_filename):
    """ The main fixes generator. """
    logging.info("Retrieving fixes")
    source = gps.open_gps(gps_filename)
    return numpy.fromiter(
        (
            (msg.latitude, msg.longitude, msg.hdop)
            for msg in source.filtered_messages([gps.sirf_messages.GeodeticNavigationData])
        ),
        dtype=[('lat', numpy.float), ('lon', numpy.float), ('hdop', numpy.float)])
예제 #2
0
파일: record.py 프로젝트: bluecube/thesis
arg_parser = argparse.ArgumentParser(
    description="(Re)Records a GPS data stream to a file.")

arg_parser.add_argument('sources', nargs='+',
    help="Source GPS or one or more recordings.")
arg_parser.add_argument('--output',
    help="Target recording.")
arg_parser.add_argument('--verbose', action = 'store_true',
    help="Print status of the GPS roughly every 10 seconds.")
arguments = arg_parser.parse_args()

saver = gps.gps_saver.GpsSaver(arguments.output)

try:
    for source_file in arguments.sources:
        source = gps.open_gps(source_file)
        saver.init_source(source)
        try:
            if arguments.verbose:
                geodetic_nav_data_id = gps.sirf_messages.GeodeticNavigationData.get_message_id()
                counter = 0
                while True:
                    msg = saver.save_message();

                    if gps.sirf.bytes_to_message_id(msg) == geodetic_nav_data_id:
                        counter += 1
                        if counter == 10:
                            msg = gps.sirf.from_bytes(msg)
                            print(msg.status_line())
                            counter = 0
예제 #3
0
파일: checksum.py 프로젝트: bluecube/thesis
def setup_logging():
    logging.basicConfig(
        format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
        level = logging.INFO
    )

setup_logging()

logger = logging.getLogger('main')
logger.setLevel(logging.DEBUG)

arg_parser = argparse.ArgumentParser(
    description="Calculate crc32 checksum from recorded messages' payloads.")

arg_parser.add_argument('gps',
    help="Gps port or recording.")
arguments = arg_parser.parse_args()

x = gps.open_gps(arguments.gps)

checksum = crc32(b'')

try:
    while True:
        checksum = crc32(x._read_binary_sirf_msg(), checksum)
except StopIteration:
    pass

print("checksum: {:#08x}".format(checksum & 0xffffffff))
예제 #4
0
    def do(self, source_filename, receiver_pos, fit_window, outlier_threshold):
        """ Initialize the state, parse all samples and convert to numpy arrays """
        self._outlier_threshold = outlier_threshold
        source = gps.open_gps(source_filename)
        self.receiver_state = gps.StationState(
            pos = receiver_pos,
            velocity = numpy.matrix([[0, 0, 0]]),
            clock_offset = 0,
            clock_drift = 0)

        self.ephemeris = gps.BroadcastEphemeris()
        self.measurements = gps.MessageCollector(gps.sirf_messages.NavigationLibraryMeasurementData)

        self.clock_corrections = []

        self.times = [] # Measurement times in receiver time frame
        self.sv_ids = []
        self.measurement_errors = []
        self.clock_correction_values  = []
        self.doppler_errors = []

        self.last_avg_error = None

        self.last_derivation = None
        self.last_time = None
        self.unmodified_last_time = None
        self.week_offset = 0 # offset of the current gps week from the first recorded one

        logging.info("Reading measurements...")

        try:
            source.loop([self.ephemeris, self.measurements], self.cycle_end_callback)
        except KeyboardInterrupt:
            pass

        self.cycle_end_callback() # Last cycle doesn't end, so this wouldn't be otherwise called.

        logging.info("Processing...")

        logging.info("- Convert to arrays...")
        self.times = numpy.array(self.times, dtype=numpy.float)
        self.measurement_errors = numpy.array(self.measurement_errors, dtype=numpy.float)
        self.clock_correction_values = numpy.array(self.clock_correction_values, dtype=numpy.float)

        logging.info("- Fit clock offset...")

        clock_drifts, clock_offsets = self.fit_clock_offsets(self.times,
            self.measurement_errors + self.clock_correction_values,
            fit_window)
        clock_offsets -= self.clock_correction_values

        return numpy.fromiter(
            itertools.izip(
                self.times,
                self.sv_ids,
                self.measurement_errors,
                self.doppler_errors,
                clock_offsets,
                clock_drifts,
                self.clock_correction_values
                ),
            dtype=[
                ('times', numpy.float),
                ('sv_ids', numpy.uint8),
                ('errors', numpy.float),
                ('velocity_errors', numpy.float),
                ('clock_offsets', numpy.float),
                ('clock_drifts', numpy.float),
                ('clock_corrections', numpy.float)])
예제 #5
0
    replay.setLevel(logging.INFO)


setup_logging()

logger = logging.getLogger('main')

arg_parser = argparse.ArgumentParser(
    description="Calculate the average ECEF and WGS84 positions as reported"
    "by the receiver's software.")
arg_parser.add_argument('gps',
    help="GPS port or recording file.")

arguments = arg_parser.parse_args()

gps_dev = gps.open_gps(arguments.gps)

logger.info("Starting.")

count = 0
x = stats.Stats(1000)
y = stats.Stats(1000)
z = stats.Stats(1000)

geod_count = 0
lat = stats.Stats(1000)
lon = stats.Stats(1000)

try:
    for msg in gps_dev:
        if isinstance(msg, MeasureNavigationDataOut):