-
-
Save mookerji/23adac81bf24a642370a to your computer and use it in GitHub Desktop.
single diff measurement question (intersection of two structs via prns)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compiles with gcc -O0 single_diff_libswiftnav.c | |
#include <stdint.h> | |
#include <stdbool.h> | |
#include <string.h> | |
#include <stdio.h> | |
#include <inttypes.h> | |
typedef uint8_t u8; | |
typedef uint16_t u16; | |
/** Structure representing a GPS time. */ | |
typedef struct __attribute__((packed)) { | |
double tow; /**< Seconds since the GPS start of week. */ | |
u16 wn; /**< GPS week number. */ | |
} gps_time_t; | |
typedef struct { | |
double pseudorange; | |
double carrier_phase; | |
double doppler; | |
double sat_pos[3]; | |
double snr; | |
double lock_time; | |
gps_time_t tot; | |
u8 prn; | |
} navigation_measurement_t; | |
// Calculate single difference observations | |
typedef struct { | |
double pseudorange; | |
double carrier_phase; | |
double doppler; | |
double sat_pos[3]; | |
double snr; | |
u8 prn; | |
} sdiff_t; | |
/** Given given two lists of undifferenced input observations | |
* (navigation_measurement_t), nav_meas_1 and nav_meas_2, ordered | |
* ascendingly by PRN, constructs the pseudorange, carrier_phase, and | |
* doppler sdiffs (single difference observations) using the | |
* intersection of their PRNs. | |
* | |
* Also: | |
* 0. SNR in the output is the min of the SNRs of inputs 1 and 2. | |
* 1. `sat_pos` and `sat_vel` are taken from input 1. | |
* | |
* Returns the number of sdiffs in the intersection. | |
* | |
* \param nav_meas1_len Number of measurements in `nav_meas1` | |
* \oaram nav_meas1 Array of undifferenced observations, sorted by PRN | |
* \param nav_meas2_len Number of measurements in `nav_meas2` | |
* \oaram nav_meas2 Array of navigation measurements, sorted by PRN | |
* \param sdiff Single difference observations | |
* | |
* \return The number of observations written to `sdiff` | |
* | |
*/ | |
u8 single_diff(u8 nav_meas1_len, | |
navigation_measurement_t *nav_meas1, | |
u8 nav_meas2_len, | |
navigation_measurement_t *nav_meas2, | |
sdiff_t *sdiff) | |
{ | |
return 0; | |
} | |
void call() { | |
// Fake measurements | |
navigation_measurement_t nm1 = {.prn = 1}; | |
navigation_measurement_t nm2 = {.prn = 2}; | |
navigation_measurement_t nm3 = {.prn = 3}; | |
navigation_measurement_t nm4 = {.prn = 4}; | |
// Array of measurements. | |
navigation_measurement_t nms_no_match1[2]; | |
navigation_measurement_t nms_no_match2[2]; | |
// Single differences | |
sdiff_t sds_out[3]; | |
memcpy(&nms_no_match1[0], &nm1, sizeof(navigation_measurement_t)); | |
memcpy(&nms_no_match1[1], &nm2, sizeof(navigation_measurement_t)); | |
memcpy(&nms_no_match2[0], &nm1, sizeof(navigation_measurement_t)); | |
memcpy(&nms_no_match2[1], &nm3, sizeof(navigation_measurement_t)); | |
u8 num_match = single_diff(2, nms_no_match1, | |
2, nms_no_match2, | |
sds_out); | |
printf("%d", num_match); | |
} | |
int main() { | |
call(); | |
printf("Test!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment