Skip to content

Commit

Permalink
Simplify estimation of many samples.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayitzin committed Feb 12, 2022
1 parent 8e29107 commit f4b9049
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ahrs/filters/famc.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@
import numpy as np

class FAMC:
"""Fast Accelerometer-Magnetometer Combination
"""
Fast Accelerometer-Magnetometer Combination
Parameters
----------
Expand Down Expand Up @@ -212,7 +213,8 @@ def __init__(self, acc: np.ndarray = None, mag: np.ndarray = None):
self.Q = self._compute_all()

def _compute_all(self) -> np.ndarray:
"""Estimate the quaternions given all data.
"""
Estimate the quaternions given all data.
Attributes ``acc`` and ``mag`` must contain data.
Expand All @@ -228,13 +230,11 @@ def _compute_all(self) -> np.ndarray:
if self.acc.ndim < 2:
return self.estimate(self.acc, self.mag)
num_samples = len(self.acc)
Q = np.zeros((num_samples, 4))
for t in range(num_samples):
Q[t] = self.estimate(self.acc[t], self.mag[t])
return Q
return np.array([self.estimate(self.acc[t], self.mag[t]) for t in range(num_samples)])

def estimate(self, acc: np.ndarray, mag: np.ndarray) -> np.ndarray:
"""Attitude Estimation
"""
Attitude Estimation
Parameters
----------
Expand Down

0 comments on commit f4b9049

Please sign in to comment.