Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ CSRC := $(STARTUPSRC) \
$(SWIFTNAV_ROOT)/src/decode.o \
$(SWIFTNAV_ROOT)/src/signal.o \
$(SWIFTNAV_ROOT)/src/l2c_capb.o \
$(SWIFTNAV_ROOT)/src/iono.o \
$(SWIFTNAV_ROOT)/src/sid_set.o \
main.c

Expand Down
16 changes: 16 additions & 0 deletions src/base_obs.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "base_obs.h"
#include "ephemeris.h"
#include "signal.h"
#include "iono.h"

extern bool disable_raim;

Expand Down Expand Up @@ -146,6 +147,21 @@ static void update_obss(obss_t *new_obss)
gnss_solution soln;
dops_t dops;

/* check if we have fix, if yes, calculate iono and tropo correction */
if(base_obss.has_pos) {
double llh[3];
wgsecef2llh(base_obss.pos_ecef, llh);
log_debug("Base: IONO/TROPO correction");
ionosphere_t i_params;
ionosphere_t *p_i_params = &i_params;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just use &i_params directly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p_i_params is used as a flag and can be set to NULL.

/* get iono parameters if available */
if(!gps_iono_params_read(p_i_params)) {
p_i_params = NULL;
}
calc_iono_tropo(base_obss.n, base_obss.nm, base_obss.pos_ecef, llh,
p_i_params);
}

/* Calculate a position solution. */
/* disable_raim controlled by external setting (see solution.c). */
s32 ret = calc_PVT(base_obss.n, base_obss.nm, disable_raim, &soln, &dops);
Expand Down
7 changes: 7 additions & 0 deletions src/decode/decode_gps_l1ca.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "sbp_utils.h"
#include "signal.h"
#include "l2c_capb.h"
#include "iono.h"

typedef struct {
nav_msg_t nav_msg;
Expand Down Expand Up @@ -115,6 +116,12 @@ static void decoder_gps_l1ca_process(const decoder_channel_info_t *channel_info,
gps_l2cm_l2c_cap_store(dd.gps_l2c_sv_capability);
}

if (dd.iono_corr_upd_flag) {
/* store new iono parameters */
log_debug("Iono parameters received");
gps_iono_params_store(&dd.iono);
}

if(dd.ephemeris_upd_flag) {
/* Decoded a new ephemeris. */
ephemeris_new(&dd.ephemeris);
Expand Down
52 changes: 52 additions & 0 deletions src/iono.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2016 Swift Navigation Inc.
* Contact: Dmitry Tatarinov <[email protected]>
*
* This source is subject to the license found in the file 'LICENSE' which must
* be be distributed together with this source. All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/

#include <assert.h>
#include <string.h>
#include <ch.h>

#include "iono.h"
#include "signal.h"

static MUTEX_DECL(iono_mutex);

static ionosphere_t iono_params;
static bool iono_params_decoded_flag = false;

/** Stores ionospheric parameters
* \param params pointer to ionospheric parameters to be stored
*/
void gps_iono_params_store(const ionosphere_t *params)
{
assert(params != NULL);
chMtxLock(&iono_mutex);
memcpy(&iono_params, params, sizeof(ionosphere_t));
iono_params_decoded_flag = true;
chMtxUnlock(&iono_mutex);
}

/** Reads ionospheric parameters
* \param params pointer to ionospheric
* \return 1 if iono parameters available otherwise 0
*/
u8 gps_iono_params_read(ionosphere_t *params)
{
u8 result = 0;
assert(params != NULL);
chMtxLock(&iono_mutex);
if (iono_params_decoded_flag) {
memcpy(params, &iono_params, sizeof(ionosphere_t));
result = 1;
}
chMtxUnlock(&iono_mutex);
return result;
}
22 changes: 22 additions & 0 deletions src/iono.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (C) 2016 Swift Navigation Inc.
* Contact: Dmitry Tatarinov <[email protected]>
*
* This source is subject to the license found in the file 'LICENSE' which must
* be be distributed together with this source. All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/

#ifndef SRC_IONO_H_
#define SRC_IONO_H_

#include <libswiftnav/common.h>
#include <libswiftnav/ionosphere.h>

void gps_iono_params_store(const ionosphere_t *params);
u8 gps_iono_params_read(ionosphere_t *params);

#endif /* SRC_IONO_H_ */
24 changes: 23 additions & 1 deletion src/solution.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/

#include <stdio.h>
#include <string.h>

Expand All @@ -23,6 +22,7 @@
#include <libswiftnav/dgnss_management.h>
#include <libswiftnav/baseline.h>
#include <libswiftnav/linear_algebra.h>
#include <libswiftnav/troposphere.h>

#define memory_pool_t MemoryPool
#include <ch.h>
Expand All @@ -43,6 +43,7 @@
#include "signal.h"
#include "system_monitor.h"
#include "main.h"
#include "iono.h"
#include "sid_set.h"

/* Maximum CPU time the solution thread is allowed to use. */
Expand Down Expand Up @@ -433,6 +434,9 @@ static void sol_thd_sleep(systime_t *deadline, systime_t interval)
static THD_WORKING_AREA(wa_solution_thread, 8000);
static void solution_thread(void *arg)
{
/* The flag is true when we have a fix */
bool soln_flag = false;

(void)arg;
chRegSetThreadName("solution");

Expand Down Expand Up @@ -534,6 +538,20 @@ static void solution_thread(void *arg)
continue;
}

/* check if we have a solution, if yes calc iono and tropo correction */
if (soln_flag) {
ionosphere_t i_params;
ionosphere_t *p_i_params = &i_params;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just use &i_params directly.

Copy link
Author

@rge-exafore rge-exafore Jun 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p_i_params is used as a flag and can be set to NULL.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok.

/* get iono parameters if available */
if(!gps_iono_params_read(p_i_params)) {
p_i_params = NULL;
}
calc_iono_tropo(n_ready_tdcp, nav_meas_tdcp,
position_solution.pos_ecef,
position_solution.pos_llh,
p_i_params);
}

dops_t dops;
/* Calculate the SPP position
* disable_raim controlled by external setting. Defaults to false. */
Expand All @@ -548,11 +566,15 @@ static void solution_thread(void *arg)
log_warn("PVT solver: %s (code %d)", pvt_err_msg[-pvt_ret-1], pvt_ret);
);

soln_flag = false;

/* Send just the DOPs and exit the loop */
solution_send_sbp(0, &dops, clock_jump);
continue;
}

soln_flag = true;

if (pvt_ret == 1)
log_warn("calc_PVT: RAIM repair");

Expand Down
4 changes: 2 additions & 2 deletions src/track/track_gps_l1ca.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#define LD_PARAMS_EXTRAOPT "0.02, 0.8, 150, 50"
#define LD_PARAMS_DISABLE "0.02, 1e-6, 1, 1"

#define CN0_EST_LPF_CUTOFF 5
#define CN0_EST_LPF_CUTOFF 0.1

#define INTEG_PERIOD_1_MS 1
#define INTEG_PERIOD_2_MS 2
Expand Down Expand Up @@ -86,7 +86,7 @@ static struct lock_detect_params {
u16 lp, lo;
} lock_detect_params;

static float track_cn0_use_thres = 31.0; /* dBHz */
static float track_cn0_use_thres = 37.0; /* dBHz */
static float track_cn0_drop_thres = 31.0;

static char loop_params_string[120] = LOOP_PARAMS_MED;
Expand Down
4 changes: 2 additions & 2 deletions src/track/track_gps_l2cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define LD_PARAMS "0.0247, 1.5, 50, 240"
#define LD_PARAMS_DISABLE "0.02, 1e-6, 1, 1"

#define CN0_EST_LPF_CUTOFF 5
#define CN0_EST_LPF_CUTOFF 0.1f

#define INTEG_PERIOD_20_MS 20

Expand All @@ -86,7 +86,7 @@ static struct lock_detect_params {
u16 lp, lo;
} lock_detect_params;

static float track_cn0_use_thres = 31.0; /* dBHz */
static float track_cn0_use_thres = 37.0; /* dBHz */
static float track_cn0_drop_thres = 31.0; /* dBHz */

static char loop_params_string[120] = LOOP_PARAMS_MED;
Expand Down