【问题标题】:python ahrs complementary filter yields error for shapepython ahrs互补过滤器产生形状错误
【发布时间】:2021-10-28 02:40:40
【问题描述】:

我正在尝试使用 ahrs'Complementary filter,但无法正常工作。 数据的形状:

for ele in zip(gl, al): 
  comp.append(ahrs.filters.complementary.Complementary(ele[0],ele[1],None,200)) 

ele[0](陀螺仪数据)看起来像 [ 0.75 0.6875 -0.625 ]ele[1](加速度计数据)看起来像 [ 0.03125 -0.08935547 1.01123047]

根据 Complementary 函数的要求,两个数组的数据类型都是 <class 'numpy.ndarray'>

当前错误来自它所在的框架本身

Traceback (most recent call last):
  File "/home/luke/test_imu.py", line 111, in <module>
    comp.append(ahrs.filters.complementary.Complementary(ele[0],ele[1],None,200))
  File "/usr/lib/python3.9/site-packages/ahrs/filters/complementary.py", line 158, in __init__
    self.Q = self._compute_all()
  File "/usr/lib/python3.9/site-packages/ahrs/filters/complementary.py", line 184, in _compute_all
    Q[0] = self.am_estimation(self.acc[0], self.mag[0]) if self.q0 is None else self.q0.copy()
  File "/usr/lib/python3.9/site-packages/ahrs/filters/complementary.py", line 283, in am_estimation
    if acc.shape[-1] != 3:
IndexError: tuple index out of range

因此问题是,Q[0] = self.am_estimation(self.acc[0], self.mag[0]) if self.q0 is None else self.q0.copy() 行将第一个元素从 3 大小的 ndarray 中取出,self.acc[0]。当然值是错误的形状。

那么框架或我的数据结构中是否有错误?如何解决此错误?

【问题讨论】:

    标签: python numpy numpy-ndarray


    【解决方案1】:

    acc 和 gyr 数组是 n * 3 数组。看起来你可能只有 1x3 数组。

    【讨论】:

      猜你喜欢
      • 2018-08-27
      • 1970-01-01
      • 2019-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-17
      • 1970-01-01
      • 2011-01-11
      相关资源
      最近更新 更多