|
3 | 3 | from scipy.signal import resample_poly |
4 | 4 |
|
5 | 5 | import smsfusion as sf |
6 | | -from smsfusion._ins._vru import VRU, _state_transition_matrix_init, _state_transition_matrix_update |
| 6 | +from smsfusion._ins._vru import VRU, _state_transition_matrix_init, _state_transition_matrix_update, _measurement_matrix_init, _reset, _process_noise_covariance_matrix |
7 | 7 | from smsfusion.benchmark import ( |
8 | 8 | benchmark_pure_attitude_beat_202311A, |
9 | 9 | benchmark_pure_attitude_chirp_202311A |
@@ -50,6 +50,38 @@ def test_state_transition_matrix_update(): |
50 | 50 | np.testing.assert_almost_equal(phi_out, phi_expected) |
51 | 51 |
|
52 | 52 |
|
| 53 | +def test_measurement_matrix_init(): |
| 54 | + np.testing.assert_array_equal(_measurement_matrix_init(), np.zeros((3, 6))) |
| 55 | + |
| 56 | + |
| 57 | +def test_process_noise_covariance_matrix(): |
| 58 | + dt = 0.1 |
| 59 | + arw = 0.00005 |
| 60 | + gbs = 0.00005 |
| 61 | + gbc = 50.0 |
| 62 | + Q_out = _process_noise_covariance_matrix(dt, arw, gbs, gbc) |
| 63 | + Q_expect = np.array([ |
| 64 | + [dt * arw**2, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 65 | + [0.0, dt * arw**2, 0.0, 0.0, 0.0, 0.0], |
| 66 | + [0.0, 0.0, dt * arw**2, 0.0, 0.0, 0.0], |
| 67 | + [0.0, 0.0, 0.0, dt * (2.0 * gbs**2 / gbc), 0.0, 0.0], |
| 68 | + [0.0, 0.0, 0.0, 0.0, dt * (2.0 * gbs**2 / gbc), 0.0], |
| 69 | + [0.0, 0.0, 0.0, 0.0, 0.0, dt * (2.0 * gbs**2 / gbc)], |
| 70 | + ]) |
| 71 | + |
| 72 | + |
| 73 | +def test_reset(): |
| 74 | + q_nb = np.array([1.0, 0.0, 0.0, 0.0]) |
| 75 | + bg_b = np.zeros(3) |
| 76 | + dx = np.array([0.01, 0.0, 0.0, 0.1, -0.1, 0.2]) |
| 77 | + |
| 78 | + dx, q_nb, bg_b = _reset(dx, q_nb, bg_b) |
| 79 | + |
| 80 | + np.testing.assert_allclose(dx, np.zeros_like(dx)) |
| 81 | + np.testing.assert_allclose(bg_b, np.array([0.1, -0.1, 0.2])) |
| 82 | + np.testing.assert_allclose(q_nb, np.array([np.cos(0.01/2), np.sin(0.01/2), 0.0, 0.0]), atol=1e-6) |
| 83 | + |
| 84 | + |
53 | 85 | def test_vru_init(): |
54 | 86 | mekf = VRU( |
55 | 87 | 10.0 |
@@ -115,7 +147,6 @@ def test_vru_benchmark(benchmark_gen): |
115 | 147 | mekf = VRU( |
116 | 148 | fs_imu, |
117 | 149 | q=q0, |
118 | | - acc_noise_density=sf.constants.ERR_ACC_MOTION2["N"], |
119 | 150 | gyro_noise_density=sf.constants.ERR_GYRO_MOTION2["N"], |
120 | 151 | gyro_bias_stability=sf.constants.ERR_GYRO_MOTION2["B"], |
121 | 152 | gyro_bias_corr_time=sf.constants.ERR_GYRO_MOTION2["tau_cb"], |
|
0 commit comments