00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef LIBSWIFTNAV_AMB_KF_H
00014 #define LIBSWIFTNAV_AMB_KF_H
00015 #include "track.h"
00016 #include "almanac.h"
00017 #include "gpstime.h"
00018 #include "common.h"
00019 #include "single_diff.h"
00020 #include "constants.h"
00021
00022 #define MAX_STATE_DIM (MAX_CHANNELS - 1)
00023 #define MAX_OBS_DIM (2 * MAX_CHANNELS - 5)
00024
00025 typedef struct {
00026 u32 state_dim;
00027 u32 obs_dim;
00028 double amb_drift_var;
00029 double decor_mtx[MAX_OBS_DIM * MAX_OBS_DIM];
00030 double decor_obs_mtx[MAX_STATE_DIM * MAX_OBS_DIM];
00031 double decor_obs_cov[MAX_OBS_DIM];
00032 double null_basis_Q[(MAX_STATE_DIM - 3) * MAX_OBS_DIM];
00033 double state_mean[MAX_STATE_DIM];
00034 double state_cov_U[MAX_STATE_DIM * MAX_STATE_DIM];
00035 double state_cov_D[MAX_STATE_DIM];
00036 } nkf_t;
00037
00038
00039 void nkf_update(nkf_t *kf, double *measurements);
00040
00041 void assign_de_mtx(u8 num_sats, sdiff_t *sats_with_ref_first, double ref_ecef[3], double *DE);
00042
00043 void assign_phase_obs_null_basis(u8 num_dds, double *DE_mtx, double *q);
00044 void set_nkf(nkf_t *kf, double amb_drift_var, double phase_var, double code_var, double amb_init_var,
00045 u8 num_sdiffs, sdiff_t *sdiffs_with_ref_first, double *dd_measurements, double ref_ecef[3]);
00046 void set_nkf_matrices(nkf_t *kf, double phase_var, double code_var,
00047 u8 num_sdiffs, sdiff_t *sdiffs_with_ref_first, double ref_ecef[3]);
00048 s32 find_index_of_element_in_u8s(u32 num_elements, u8 x, u8 *list);
00049 void rebase_nkf(nkf_t *kf, u8 num_sats, u8 *old_prns, u8 *new_prns);
00050
00051 void nkf_state_projection(nkf_t *kf,
00052 u8 num_old_non_ref_sats,
00053 u8 num_new_non_ref_sats,
00054 u8 *ndx_of_new_sat_in_old);
00055 void nkf_state_inclusion(nkf_t *kf,
00056 u8 num_old_non_ref_sats,
00057 u8 num_new_non_ref_sats,
00058 u8 *ndx_of_old_sat_in_new,
00059 double int_init_var);
00060
00061 void rebase_nkf(nkf_t *kf, u8 num_sats, u8 *old_prns, u8 *new_prns);
00062 void rebase_covariance_udu(double *state_cov_U, double *state_cov_D, u8 num_sats, u8 *old_prns, u8 *new_prns);
00063 void least_squares_solve_b(nkf_t *kf, sdiff_t *sdiffs_with_ref_first, double *dd_measurements, double ref_ecef[3], double b[3]);
00064 void least_squares_solve_b_external_ambs(u8 num_dds, double *ambs, sdiff_t *sdiffs_with_ref_first, double *dd_measurements, double ref_ecef[3], double b[3]);
00065
00066 void rebase_mean_N(double *mean, u8 num_sats, u8 *old_prns, u8 *new_prns);
00067 void rebase_covariance_sigma(double *state_cov, u8 num_sats, u8 *old_prns, u8 *new_prns);
00068
00069 #endif
00070