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

Commit d5d6b49

Browse files
Merge pull request #10 from swift-nav/pr-699-copy
Change solution to count satellites, not tracking channels. Verified on VV-1606301020.
2 parents 3330da6 + d2c2c65 commit d5d6b49

File tree

4 files changed

+105
-2
lines changed

4 files changed

+105
-2
lines changed

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ CSRC := $(STARTUPSRC) \
123123
$(SWIFTNAV_ROOT)/src/decode.o \
124124
$(SWIFTNAV_ROOT)/src/signal.o \
125125
$(SWIFTNAV_ROOT)/src/l2c_capb.o \
126+
$(SWIFTNAV_ROOT)/src/sid_set.o \
126127
main.c
127128

128129
# C++ sources that can be compiled in ARM or THUMB mode depending on the global

src/sid_set.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (C) 2016 Swift Navigation Inc.
3+
* Contact: Roman Gezikov <rgezikov@exafore.com>
4+
*
5+
* This source is subject to the license found in the file 'LICENSE' which must
6+
* be be distributed together with this source. All other rights reserved.
7+
*
8+
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
9+
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
10+
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
11+
*/
12+
13+
#include <assert.h>
14+
#include <string.h>
15+
#include <libswiftnav/bits.h>
16+
#include "sid_set.h"
17+
18+
/** Initialize new sid set
19+
*
20+
* \param sid_list gnss_sid_set_t to be initialized
21+
*
22+
*/
23+
void sid_set_init(gnss_sid_set_t *sid_set)
24+
{
25+
memset(sid_set->sats, 0, sizeof(sid_set->sats));
26+
}
27+
28+
/** Add new element to the set
29+
*
30+
* \param sid_set gnss_sid_set_t to add new element to
31+
* \param sid element to be added
32+
*
33+
*/
34+
void sid_set_add(gnss_sid_set_t *sid_set, gnss_signal_t sid)
35+
{
36+
u16 s = sid_to_code_index(sid);
37+
assert(s < 64);
38+
sid_set->sats[sid.code] |= ((u64)0x01 << s);
39+
}
40+
41+
/** Get number of satellites in sid set
42+
*
43+
* \param sid_set gnss_sid_set_t to count number of satellites in
44+
*
45+
* \returns Number of unique satellites present in the set.
46+
*
47+
*/
48+
u32 sid_set_get_sat_count(const gnss_sid_set_t *sid_set)
49+
{
50+
u64 sats[CONSTELLATION_COUNT];
51+
memset(sats, 0, sizeof(sats));
52+
for (enum code code = 0; code < CODE_COUNT; code++) {
53+
sats[code_to_constellation(code)] |= sid_set->sats[code];
54+
}
55+
56+
u32 cnt = 0;
57+
for (enum constellation constellation = 0;
58+
constellation < CONSTELLATION_COUNT; constellation++) {
59+
cnt += count_bits_u64(sats[constellation], 1);
60+
}
61+
62+
return cnt;
63+
}

src/sid_set.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (C) 2016 Swift Navigation Inc.
3+
* Contact: Roman Gezikov <rgezikov@exafore.com>
4+
*
5+
* This source is subject to the license found in the file 'LICENSE' which must
6+
* be be distributed together with this source. All other rights reserved.
7+
*
8+
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
9+
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
10+
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
11+
*/
12+
13+
#ifndef SWIFTNAV_SID_SET_H
14+
#define SWIFTNAV_SID_SET_H
15+
16+
#include <libswiftnav/common.h>
17+
#include <libswiftnav/signal.h>
18+
19+
typedef struct {
20+
u64 sats[CODE_COUNT];
21+
} gnss_sid_set_t;
22+
23+
void sid_set_init(gnss_sid_set_t *sid_set);
24+
void sid_set_add(gnss_sid_set_t *sid_set, gnss_signal_t sid);
25+
u32 sid_set_get_sat_count(const gnss_sid_set_t *sid_set);
26+
27+
#endif /* SWIFTNAV_SID_SET_H */

src/solution.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "signal.h"
4444
#include "system_monitor.h"
4545
#include "main.h"
46+
#include "sid_set.h"
4647

4748
/* Maximum CPU time the solution thread is allowed to use. */
4849
#define SOLN_THD_CPU_MAX (0.60f)
@@ -462,7 +463,12 @@ static void solution_thread(void *arg)
462463
tracking_channel_unlock(i);
463464
}
464465

465-
if (n_ready < 4) {
466+
gnss_sid_set_t codes_in_track;
467+
sid_set_init(&codes_in_track);
468+
for (u8 i=0; i<n_ready; i++)
469+
sid_set_add(&codes_in_track, meas[i].sid);
470+
471+
if (sid_set_get_sat_count(&codes_in_track) < 4) {
466472
/* Not enough sats, keep on looping. */
467473
continue;
468474
}
@@ -517,7 +523,13 @@ static void solution_thread(void *arg)
517523
n_ready_old = n_ready;
518524
rec_tc_old = rec_tc;
519525

520-
if (n_ready_tdcp < 4) {
526+
gnss_sid_set_t codes_tdcp;
527+
sid_set_init(&codes_tdcp);
528+
for (u8 i=0; i<n_ready_tdcp; i++) {
529+
sid_set_add(&codes_tdcp, nav_meas_tdcp[i].sid);
530+
}
531+
532+
if (sid_set_get_sat_count(&codes_tdcp) < 4) {
521533
/* Not enough sats to compute PVT */
522534
continue;
523535
}

0 commit comments

Comments
 (0)