00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef LIBSWIFTNAV_TRACK_H
00014 #define LIBSWIFTNAV_TRACK_H
00015
00016 #include "common.h"
00017 #include "ephemeris.h"
00018
00028 typedef struct {
00029 float pgain;
00030 float igain;
00031 float prev_error;
00032 float y;
00033 } simple_lf_state_t;
00034
00038 typedef struct {
00039 float code_freq;
00040 float carr_freq;
00041 simple_lf_state_t code_filt;
00042 simple_lf_state_t carr_filt;
00043 } simple_tl_state_t;
00044
00049 typedef struct {
00050 float code_freq;
00051 float carr_freq;
00052 simple_lf_state_t code_filt;
00053 simple_lf_state_t carr_filt;
00054 u32 sched;
00055 u32 n;
00056 float A;
00057 float carr_to_code;
00058 } comp_tl_state_t;
00059
00060
00064 typedef struct {
00065 float I;
00066 float Q;
00067 } correlation_t;
00068
00072 typedef struct {
00073 float log_bw;
00074 float A;
00075 float I_prev_abs;
00076 float nsr;
00077 } cn0_est_state_t;
00078
00081 typedef struct {
00082 u8 prn;
00083 double code_phase_chips;
00084 double code_phase_rate;
00085 double carrier_phase;
00086 double carrier_freq;
00087 u32 time_of_week_ms;
00088 double receiver_time;
00089 double snr;
00090 } channel_measurement_t;
00091
00092 typedef struct {
00093 u8 prn;
00094 double raw_pseudorange;
00095 double raw_pseudorange_rate;
00096 double pseudorange;
00097 double pseudorange_rate;
00098 gps_time_t tot;
00099 double sat_pos[3];
00100 double sat_vel[3];
00101 double snr;
00102 } navigation_measurement_t;
00103
00104 void calc_loop_gains(float bw, float zeta, float k, float loop_freq,
00105 float *pgain, float *igain);
00106 float costas_discriminator(float I, float Q);
00107 float dll_discriminator(correlation_t cs[3]);
00108
00109 void simple_lf_init(simple_lf_state_t *s, float y0,
00110 float pgain, float igain);
00111 float simple_lf_update(simple_lf_state_t *s, float error);
00112
00113 void simple_tl_init(simple_tl_state_t *s, float loop_freq,
00114 float code_freq, float code_bw,
00115 float code_zeta, float code_k,
00116 float carr_freq, float carr_bw,
00117 float carr_zeta, float carr_k);
00118 void simple_tl_update(simple_tl_state_t *s, correlation_t cs[3]);
00119
00120 void comp_tl_init(comp_tl_state_t *s, float loop_freq,
00121 float code_freq, float code_bw,
00122 float code_zeta, float code_k,
00123 float carr_freq, float carr_bw,
00124 float carr_zeta, float carr_k,
00125 float tau, float cpc, u32 sched);
00126 void comp_tl_update(comp_tl_state_t *s, correlation_t cs[3]);
00127
00128 void cn0_est_init(cn0_est_state_t *s, float bw, float cn0_0,
00129 float cutoff_freq, float loop_freq);
00130 float cn0_est(cn0_est_state_t *s, float I);
00131
00132 void calc_navigation_measurement(u8 n_channels, channel_measurement_t meas[],
00133 navigation_measurement_t nav_meas[],
00134 double nav_time, ephemeris_t ephemerides[]);
00135 void calc_navigation_measurement_(u8 n_channels, channel_measurement_t* meas[],
00136 navigation_measurement_t* nav_meas[],
00137 double nav_time, ephemeris_t* ephemerides[]);
00138
00139 #endif
00140