From 03687750e200409c92d149df06e10c5eb11a62d1 Mon Sep 17 00:00:00 2001 From: Mayitzin Date: Wed, 13 Jul 2022 00:17:59 +0200 Subject: [PATCH] Add optional estimation without magnetometer. --- ahrs/filters/complementary.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ahrs/filters/complementary.py b/ahrs/filters/complementary.py index 0edbfb8..07de323 100644 --- a/ahrs/filters/complementary.py +++ b/ahrs/filters/complementary.py @@ -109,6 +109,7 @@ import numpy as np from ..common.orientation import ecompass +from ..common.orientation import acc2q from ..utils.core import _assert_numerical_iterable class Complementary: @@ -268,6 +269,8 @@ def am_estimation(self, acc: np.ndarray, mag: np.ndarray = None) -> np.ndarray: q_am : numpy.ndarray Estimated attitude. """ + if mag is None: + return acc2q(acc) return ecompass(acc, mag, frame='NED', representation='quaternion') def update(self, q: np.ndarray, gyr: np.ndarray, acc: np.ndarray, mag: np.ndarray = None, dt: float = None) -> np.ndarray: