Go to the documentation of this file.00001
00002 #include <check.h>
00003 #include <stdio.h>
00004 #include "amb_kf.h"
00005 #include "single_diff.h"
00006 #include "check_utils.h"
00007
00008 START_TEST(test_lsq) {
00009 sdiff_t sdiffs[5];
00010 sdiffs[0].sat_pos[0] = 1;
00011 sdiffs[0].sat_pos[1] = 0;
00012 sdiffs[0].sat_pos[2] = 0;
00013
00014 sdiffs[1].sat_pos[0] = 1;
00015 sdiffs[1].sat_pos[1] = 1;
00016 sdiffs[1].sat_pos[2] = 0;
00017
00018 sdiffs[2].sat_pos[0] = 0;
00019 sdiffs[2].sat_pos[1] = 1;
00020 sdiffs[2].sat_pos[2] = 0;
00021
00022 sdiffs[3].sat_pos[0] = 0;
00023 sdiffs[3].sat_pos[1] = 0;
00024 sdiffs[3].sat_pos[2] = 1;
00025
00026 sdiffs[4].sat_pos[0] = 0;
00027 sdiffs[4].sat_pos[1] = 1;
00028 sdiffs[4].sat_pos[2] = 1;
00029
00030 nkf_t kf;
00031 kf.state_mean[0] = 0;
00032 kf.state_mean[1] = 0;
00033 kf.state_mean[2] = 0;
00034 kf.state_mean[3] = 0;
00035 kf.state_dim = 4;
00036
00037 double meas[4];
00038 meas[0] = 0;
00039 meas[1] = 0;
00040 meas[2] = 0;
00041 meas[3] = 0;
00042
00043 double b[3];
00044
00045 double ref_ecef[3];
00046 ref_ecef[0] = 0;
00047 ref_ecef[1] = 0;
00048 ref_ecef[2] = 0;
00049
00050 least_squares_solve_b(&kf, sdiffs, &meas[0], ref_ecef, b);
00051 fail_unless(within_epsilon(b[0], 0));
00052 fail_unless(within_epsilon(b[1], 0));
00053 fail_unless(within_epsilon(b[2], 0));
00054
00055 meas[1] = 1;
00056 least_squares_solve_b(&kf, sdiffs, &meas[0], ref_ecef, b);
00057 fail_unless(within_epsilon(b[0], -0.324757));
00058 fail_unless(within_epsilon(b[1], -0.134519));
00059 fail_unless(within_epsilon(b[2], -0.324757));
00060
00061 meas[1] = 2;
00062 least_squares_solve_b(&kf, sdiffs, &meas[0], ref_ecef, b);
00063 fail_unless(within_epsilon(b[0], -0.324757 * 2));
00064 fail_unless(within_epsilon(b[1], -0.134519 * 2));
00065 fail_unless(within_epsilon(b[2], -0.324757 * 2));
00066 }
00067 END_TEST
00068
00069 Suite* amb_kf_test_suite(void)
00070 {
00071 Suite *s = suite_create("Ambiguity Kalman Filter");
00072
00073 TCase *tc_core = tcase_create("Core");
00074 tcase_add_test(tc_core, test_lsq);
00075 suite_add_tcase(s, tc_core);
00076
00077 return s;
00078 }
00079