Skip to content
This repository was archived by the owner on Apr 13, 2021. It is now read-only.

Commit 3faffde

Browse files
committed
Merge pull request #219 from swift-nav/refactor
baseline_ set intersection
2 parents 986620a + 349fd5f commit 3faffde

19 files changed

+329
-168
lines changed

checks/run-coverage.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# requires gcovr and diff-cover
22
# pip install gcovr diff-cover
33
set -e
4+
unset GIT_DIR
45
base="$(git rev-parse --show-toplevel)"
56
echo "running coverage check from ${base}"
67
gcovr -r "${base}" --object-directory . --xml -o "${base}/.coverage.xml"

checks/setup-hooks.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ hooks="$(git rev-parse --git-dir)/hooks"
88
echo "Installing hook at: ${hooks}"
99
# insert value of builddir as first line of pre-commit
1010
echo "subdir=$builddir" | cat - checks/pre-commit > "$hooks/pre-commit"
11+
chmod +x "$hooks/pre-commit"

include/libswiftnav/ambiguity_test.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,8 @@ void assign_r_vec(residual_mtxs_t *res_mtxs, u8 num_dds, double *dd_measurements
129129
void assign_r_mean(residual_mtxs_t *res_mtxs, u8 num_dds, double *hypothesis, double *r_mean);
130130
double get_quadratic_term(residual_mtxs_t *res_mtxs, u8 num_dds, double *hypothesis, double *r_vec);
131131

132+
void print_hyp(void *arg, element_t *elem);
133+
void print_intersection_state(intersection_count_t *x);
134+
135+
132136
#endif /* LIBSWIFTNAV_AMBIGUITY_TEST_H */

include/libswiftnav/baseline.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
/** \addtogroup baseline
2121
* \{ */
2222

23+
typedef struct {
24+
double amb;
25+
u8 prn;
26+
} ambiguity_t;
27+
2328
typedef struct {
2429
double ambs[MAX_CHANNELS-1];
2530
u8 prns[MAX_CHANNELS];
@@ -46,12 +51,15 @@ s8 least_squares_solve_b_external_ambs(u8 num_dds, const double *ambs,
4651
const double ref_ecef[3], double b[3],
4752
bool disable_raim, double raim_threshold);
4853

54+
void diff_ambs(u8 ref_prn, u8 num_ambs, const ambiguity_t *amb_set,
55+
double *dd_ambs);
56+
s8 baseline_(u8 num_sdiffs, const sdiff_t *sdiffs, const double ref_ecef[3],
57+
u8 num_ambs, const ambiguity_t *single_ambs,
58+
u8 *num_used, double b[3],
59+
bool disable_raim, double raim_threshold);
4960
s8 baseline(u8 num_sdiffs, const sdiff_t *sdiffs, const double ref_ecef[3],
5061
const ambiguities_t *ambs, u8 *num_used, double b[3],
5162
bool disable_raim, double raim_threshold);
52-
s8 baseline_(u8 num_sdiffs, const sdiff_t *sdiffs, const double ref_ecef[3],
53-
u8 num_ambs, const u8 *amb_prns, const double *ambs,
54-
u8 *num_used, double b[3], bool disable_raim, double raim_threshold);
5563

5664
void ambiguities_init(ambiguities_t *ambs);
5765
s8 lesq_solve_raim(u8 num_dds_u8, const double *dd_obs,

include/libswiftnav/memory_pool.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,5 @@ s32 memory_pool_product_generator(memory_pool_t *pool, void *x0, u32 n_xs, size_
8484
s8 (*init)(void *x, element_t *elem),
8585
s8 (*next)(void *x, u32 n),
8686
void (*prod)(element_t *new, void *x, u32 n, element_t *elem));
87-
8887
#endif /* LIBSWIFTNAV_MEMORY_POOL_H */
8988

include/libswiftnav/observation.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ typedef struct {
3030
u8 prn;
3131
} sdiff_t;
3232

33+
int cmp_sdiff(const void *a_, const void *b_);
34+
int cmp_amb(const void *a_, const void *b_);
35+
int cmp_amb_sdiff(const void *a_, const void *b_);
3336
int cmp_sdiff_prn(const void *a_, const void *b_);
37+
int cmp_amb_prn(const void *a_, const void *b_);
3438

3539
u8 single_diff(u8 n_a, navigation_measurement_t *m_a,
3640
u8 n_b, navigation_measurement_t *m_b,

include/libswiftnav/printing_utils.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414
#define LIBSWIFTNAV_PRINTING_UTILS_H
1515

1616
void print_s32_mtx_diff(u32 m, u32 n, s32 *mat1, s32 *mat2);
17-
void print_hyp(void *arg, element_t *elem);
1817
void print_double_mtx(double *m, u32 _r, u32 _c);
1918
void print_pearson_mtx(double *m, u32 dim);
2019
void print_s32_mtx_diff(u32 m, u32 n, s32 *mat1, s32 *mat2);
2120
void print_s32_mtx(s32 *mat, u32 m, u32 n);
2221
void print_s32_gemv(u32 m, u32 n, s32 *M, s32 *v);
23-
void print_intersection_state(intersection_count_t *x);
24-
2522

2623
#endif /* LIBSWIFTNAV_PRINTING_UTILS_H */

include/libswiftnav/sats_management.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ typedef struct {
3030
u8 prns[MAX_CHANNELS];
3131
} sats_management_t;
3232

33+
u8 choose_reference_sat(const u8 num_sats, const sdiff_t *sats);
34+
3335
void init_sats_management(sats_management_t *sats_management,
3436
const u8 num_sats, const sdiff_t *sdiffs, sdiff_t *sdiffs_with_ref_first);
3537
void print_sats_management(sats_management_t *sats_management);

include/libswiftnav/set.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,10 @@ s32 intersection(u32 na, size_t sa, const void *as, void *a_out,
4848
u32 nb, size_t sb, const void *bs, void *b_out,
4949
cmp_fn cmp);
5050

51+
u32 insertion_index(u32 na, size_t sa, const void *as, void *b, cmp_fn cmp);
52+
u32 remove_element(u32 na, size_t sa, const void *as, void *a_out,
53+
void *b, cmp_fn cmp);
54+
u32 insert_element(u32 na, size_t sa, const void *as, void *a_out,
55+
void *b, cmp_fn cmp);
5156
#endif /* LIBSWIFTNAV_SET_H */
5257

src/ambiguity_test.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,4 +1831,68 @@ double get_quadratic_term(residual_mtxs_t *res_mtxs, u8 num_dds, double *hypothe
18311831
return quad_term;
18321832
}
18331833

1834+
void print_hyp(void *arg, element_t *elem)
1835+
{
1836+
u8 num_dds = *( (u8 *) arg );
1837+
1838+
hypothesis_t *hyp = (hypothesis_t *)elem;
1839+
printf("[");
1840+
for (u8 i=0; i< num_dds; i++) {
1841+
printf("%"PRId32", ", hyp->N[i]);
1842+
}
1843+
printf("]: %f\n", hyp->ll);
1844+
}
1845+
1846+
/** Prints a s64 valued matrix.
1847+
*
1848+
* \param m The number of rows to be printed in the matrices.
1849+
* \param n The number of columns in the matrix.
1850+
* \param mat1 The matrix to be printed.
1851+
*/
1852+
static void print_s64_mtx(s64 *mat, u32 m, u32 n)
1853+
{
1854+
for (u32 i=0; i < m; i++) {
1855+
for (u32 j=0; j < n; j++) {
1856+
printf("%"PRId64", ", mat[i*n + j]);
1857+
}
1858+
printf("\n");
1859+
}
1860+
printf("\n");
1861+
}
1862+
1863+
/* Utilities for debugging inclusion algorithm in ambiguity_test.c */
1864+
static void print_Z(s8 label, u8 full_dim, u8 new_dim, z_t * Z)
1865+
{
1866+
printf("Z %i:\n", label);
1867+
print_s64_mtx(Z, full_dim, new_dim);
1868+
}
1869+
1870+
void print_intersection_state(intersection_count_t *x)
1871+
{
1872+
u8 full_dim = x->old_dim + x->new_dim;
1873+
1874+
printf("itr lower bounds:\n");
1875+
for (u8 i = 0; i < x->new_dim; i++) {
1876+
printf("%"PRIi64"\n", x->itr_lower_bounds[i]);
1877+
}
1878+
printf("itr upper bounds:\n");
1879+
for (u8 i = 0; i < x->new_dim; i++) {
1880+
printf("%"PRIi64"\n", x->itr_upper_bounds[i]);
1881+
}
1882+
printf("box lower bounds:\n");
1883+
for (u8 i = 0; i < full_dim; i++) {
1884+
printf("%"PRIi64"\n", x->box_lower_bounds[i]);
1885+
}
1886+
printf("box upper bounds:\n");
1887+
for (u8 i = 0; i < full_dim; i++) {
1888+
printf("%"PRIi64"\n", x->box_upper_bounds[i]);
1889+
}
1890+
printf("transformation matrix:\n");
1891+
print_Z(68, full_dim, x->new_dim, x->Z);
1892+
printf("z1:\n");
1893+
print_Z(0, full_dim, full_dim, x->Z1);
1894+
printf("z2_inv:\n");
1895+
print_Z(0, x->new_dim, x->new_dim, x->Z2_inv);
1896+
}
1897+
18341898
/** \} */

0 commit comments

Comments
 (0)