Skip to content

Commit c977ecd

Browse files
committed
add more vru tests
1 parent a9be028 commit c977ecd

2 files changed

Lines changed: 33 additions & 7 deletions

File tree

src/smsfusion/_ins/_vru.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,6 @@ class VRU:
162162
P : array_like, shape (6, 6), optional
163163
Initial (a priori) estimate of the error covariance matrix. Defaults to
164164
a small diagonal matrix (1e-6 * np.eye(9)).
165-
acc_noise_density : float, optional
166-
Accelerometer noise density (velocity random walk) in (m/s)/√Hz. Defaults to
167-
0.0007 (m/s)/√Hz (SMS Motion 2 noise level).
168165
gyro_noise_density : float, optional
169166
Gyroscope noise density (angular random walk) in (rad/s)/√Hz. Defaults to
170167
0.00005 (rad/s)/√Hz (SMS Motion 2 noise level).
@@ -186,7 +183,6 @@ def __init__(
186183
q: ArrayLike = (1.0, 0.0, 0.0, 0.0),
187184
bg: ArrayLike = (0.0, 0.0, 0.0),
188185
P: ArrayLike = P0,
189-
acc_noise_density: float = 0.0007,
190186
gyro_noise_density: float = 0.00005,
191187
gyro_bias_stability: float = 0.00005,
192188
gyro_bias_corr_time: float = 50.0,
@@ -198,7 +194,6 @@ def __init__(
198194
self._nz2vg = _nz2vg(self._nav_frame)
199195

200196
# IMU noise parameters
201-
self._vrw = acc_noise_density # velocity random walk
202197
self._arw = gyro_noise_density # angular random walk
203198
self._gbs = gyro_bias_stability # gyro bias stability
204199
self._gbc = gyro_bias_corr_time # gyro bias correlation time

tests/test_ins_/test_vru.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from scipy.signal import resample_poly
44

55
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
77
from smsfusion.benchmark import (
88
benchmark_pure_attitude_beat_202311A,
99
benchmark_pure_attitude_chirp_202311A
@@ -50,6 +50,38 @@ def test_state_transition_matrix_update():
5050
np.testing.assert_almost_equal(phi_out, phi_expected)
5151

5252

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+
5385
def test_vru_init():
5486
mekf = VRU(
5587
10.0
@@ -115,7 +147,6 @@ def test_vru_benchmark(benchmark_gen):
115147
mekf = VRU(
116148
fs_imu,
117149
q=q0,
118-
acc_noise_density=sf.constants.ERR_ACC_MOTION2["N"],
119150
gyro_noise_density=sf.constants.ERR_GYRO_MOTION2["N"],
120151
gyro_bias_stability=sf.constants.ERR_GYRO_MOTION2["B"],
121152
gyro_bias_corr_time=sf.constants.ERR_GYRO_MOTION2["tau_cb"],

0 commit comments

Comments
 (0)