Skip to content

Commit 5e840c8

Browse files
committed
ains
1 parent 09cec81 commit 5e840c8

4 files changed

Lines changed: 862 additions & 9 deletions

File tree

src/smsfusion/_ins/_ahrs.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class AHRS:
229229
----------
230230
fs : float
231231
Sampling rate in Hz.
232-
v : array_like, shape (3,), optional
232+
vel : array_like, shape (3,), optional
233233
Initial velocity estimate in m/s. Defaults to zero velocity (stationary).
234234
q : Attitude or array_like, shape (4,), optional
235235
Initial attitude estimate as a unit quaternion (qw, qx, qy, qz). Defaults
@@ -263,7 +263,7 @@ class AHRS:
263263
def __init__(
264264
self,
265265
fs: float,
266-
v: ArrayLike = (0.0, 0.0, 0.0),
266+
vel: ArrayLike = (0.0, 0.0, 0.0),
267267
q: ArrayLike = (1.0, 0.0, 0.0, 0.0),
268268
bg: ArrayLike = (0.0, 0.0, 0.0),
269269
P: ArrayLike = P0,
@@ -288,7 +288,7 @@ def __init__(
288288
self._gbc = gyro_bias_corr_time # gyro bias correlation time
289289

290290
# State and covariance estimates
291-
self._v_n = np.asarray_chkfinite(v).reshape(3).copy()
291+
self._v_n = np.asarray_chkfinite(vel).reshape(3).copy()
292292
self._q_nb = np.asarray_chkfinite(q).reshape(4).copy()
293293
self._bg_b = np.asarray_chkfinite(bg).reshape(3).copy()
294294
self._P = np.asarray_chkfinite(P).reshape(9, 9).copy()
@@ -307,18 +307,18 @@ def __init__(
307307
)
308308
self._H = _measurement_matrix_init(self._q_nb)
309309

310-
def quaternion(self) -> NDArray[np.float64]:
311-
"""
312-
Attitude expressed as a unit quaternion.
313-
"""
314-
return self._q_nb.copy()
315-
316310
def velocity(self) -> NDArray[np.float64]:
317311
"""
318312
Velocity expressed in the navigation frame.
319313
"""
320314
return self._v_n.copy()
321315

316+
def quaternion(self) -> NDArray[np.float64]:
317+
"""
318+
Attitude expressed as a unit quaternion.
319+
"""
320+
return self._q_nb.copy()
321+
322322
def euler(self, degrees: bool = False) -> NDArray[np.float64]:
323323
"""
324324
Attitude expressed as Euler angles (roll, pitch, yaw).

src/smsfusion/_ins/_aiding.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,33 @@
1313
)
1414

1515

16+
@njit # type: ignore[misc]
17+
def _aiding_update_pos(
18+
dx: NDArray[np.float64],
19+
P: NDArray[np.float64],
20+
H: NDArray[np.float64],
21+
pos_n: NDArray[np.float64],
22+
pos_meas: NDArray[np.float64],
23+
pos_var: NDArray[np.float64],
24+
R_nb: NDArray[np.float64],
25+
lever_arm: NDArray[np.float64],
26+
) -> tuple[NDArray[np.float64], NDArray[np.float64]]:
27+
"""
28+
Update with position aiding measurement.
29+
"""
30+
31+
if pos_var is None:
32+
raise ValueError("'pos_var' not provided.")
33+
34+
if not lever_arm.any():
35+
dz = pos_meas - (pos_n + R_nb @ lever_arm)
36+
else:
37+
dz = pos_meas - pos_n
38+
39+
dx, P = _kalman_update_sequential(dx, P, dz, pos_var, H)
40+
return dx, P
41+
42+
1643
@njit # type: ignore[misc]
1744
def _aiding_update_vel(
1845
dx: NDArray[np.float64],

0 commit comments

Comments
 (0)