Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit de8edc3

Browse files
Merge pull request #15 from swift-nav/pr-721-copy
Fix CN0 filter for L2CM. Verified on VV-1606301020.
2 parents c539bae + 08d0bee commit de8edc3

File tree

3 files changed

+58
-5
lines changed

3 files changed

+58
-5
lines changed

libswiftnav

Submodule libswiftnav updated from b0d4425 to 8bba136

src/track/track_gps_l1ca.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ static void tracker_gps_l1ca_update(const tracker_channel_info_t *channel_info,
290290

291291
common_data->cn0 = cn0_est(&data->cn0_est,
292292
pparams,
293-
cs[1].I/data->int_ms, cs[1].Q/data->int_ms);
293+
(float) cs[1].I/data->int_ms,
294+
(float) cs[1].Q/data->int_ms);
294295
}
295296

296297
if (common_data->cn0 > track_cn0_drop_thres)

src/track/track_gps_l2cm.c

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@
6464

6565
#define CN0_EST_LPF_CUTOFF 5
6666

67+
#define INTEG_PERIOD_20_MS 20
68+
69+
static const u8 integration_periods[] = {
70+
INTEG_PERIOD_20_MS
71+
};
72+
73+
#define INTEG_PERIODS_NUM (sizeof(integration_periods) / \
74+
sizeof(integration_periods[0]))
75+
76+
static cn0_est_params_t cn0_est_pre_computed[INTEG_PERIODS_NUM];
77+
6778
static struct loop_params {
6879
float code_bw, code_zeta, code_k, carr_to_code;
6980
float carr_bw, carr_zeta, carr_k, carr_fll_aid_gain;
@@ -112,6 +123,7 @@ static void tracker_gps_l2cm_update(const tracker_channel_info_t *channel_info,
112123

113124
static bool parse_loop_params(struct setting *s, const char *val);
114125
static bool parse_lock_detect_params(struct setting *s, const char *val);
126+
static void precompute_cn0_est_params(void);
115127

116128
static const tracker_interface_t tracker_interface_gps_l2cm = {
117129
.code = CODE_GPS_L2CM,
@@ -155,6 +167,8 @@ void track_gps_l2cm_register(void)
155167
gps_l2cm_trackers[i].data = &gps_l2cm_tracker_data[i];
156168
}
157169

170+
precompute_cn0_est_params();
171+
158172
tracker_interface_register(&tracker_interface_list_element_gps_l2cm);
159173
}
160174

@@ -425,9 +439,33 @@ static void tracker_gps_l2cm_update(const tracker_channel_info_t *channel_info,
425439
corr_t* cs = data->cs;
426440

427441
/* Update C/N0 estimate */
428-
common_data->cn0 = cn0_est(&data->cn0_est,
429-
cs[1].I / data->int_ms,
430-
cs[1].Q / data->int_ms);
442+
{
443+
cn0_est_params_t params;
444+
const cn0_est_params_t *pparams = NULL;
445+
446+
/* TODO
447+
* Store a pointer to the cn0_est_params_t in the gps_l1ca_tracker_data_t
448+
* structure so we don't have to scan through the whole array each time
449+
*/
450+
for(u32 i = 0; i < INTEG_PERIODS_NUM; i++) {
451+
if(data->int_ms == integration_periods[i]) {
452+
pparams = &cn0_est_pre_computed[i];
453+
break;
454+
}
455+
}
456+
457+
if(NULL == pparams) {
458+
cn0_est_compute_params(&params, 1e3f / data->int_ms, CN0_EST_LPF_CUTOFF,
459+
1e3f / data->int_ms);
460+
pparams = &params;
461+
}
462+
463+
common_data->cn0 = cn0_est(&data->cn0_est,
464+
pparams,
465+
(float) cs[1].I/data->int_ms,
466+
(float) cs[1].Q/data->int_ms);
467+
}
468+
431469
if (common_data->cn0 > track_cn0_drop_thres) {
432470
common_data->cn0_above_drop_thres_count = common_data->update_count;
433471
}
@@ -570,3 +608,17 @@ static bool parse_lock_detect_params(struct setting *s, const char *val)
570608

571609
return true;
572610
}
611+
612+
/* Pre-compute C/N0 estimator and filter parameters. The parameters are
613+
* computed using equivalent of cn0_est_compute_params() function for
614+
* integration periods and cut-off frequency defined in this file.
615+
*/
616+
static void precompute_cn0_est_params(void)
617+
{
618+
for(u32 i = 0; i < INTEG_PERIODS_NUM; i++) {
619+
cn0_est_compute_params(&cn0_est_pre_computed[i],
620+
1e3f / integration_periods[i],
621+
CN0_EST_LPF_CUTOFF,
622+
1e3f / integration_periods[i]);
623+
}
624+
}

0 commit comments

Comments
 (0)