问题描述
嗨,我正在尝试运行代码来验证 RPI4 上的加速计传感器。似乎我的库没有采样率选项,“fs”,因为我不断收到错误;
TypeError: butter() 得到了一个意外的关键字参数 'fs'
有什么想法可以解决这个问题吗?
def imu_integrator():
#############################
# Main Loop to Integrate IMU
#############################
#
data_indx = 1 # index of variable to integrate
dt_stop = 5 # seconds to record and integrate
plt.style.use('ggplot')
plt.ion()
fig,axs = plt.subplots(3,1,figsize=(12,9))
break_bool = False
while True:
#
##################################
# Reading and Printing IMU values
##################################
#
accel_array,t_array = [],[]
print("Starting Data Acquisition")
[axs[ii].clear() for ii in range(0,3)]
t0 = time.time()
loop_bool = False
while True:
try:
ax,ay,az,wx,wy,wz = mpu6050_conv() # read and convert mpu6050 data
mx,my,mz = AK8963_conv() # read and convert AK8963 magnetometer data
t_array.append(time.time()-t0)
data_array = [ax,wz,mx,mz]
accel_array.append(accel_fit(data_array[data_indx],*accel_coeffs[data_indx]))
if not loop_bool:
loop_bool = True
print("Start Moving IMU...")
except:
continue
if time.time()-t0>dt_stop:
print("Data Acquisition Stopped")
break
if break_bool:
break
#
##################################
# Signal Filtering
##################################
#
Fs_approx = len(accel_array)/dt_stop
b_filt,a_filt = signal.butter(4,5,'low',fs=Fs_approx)
accel_array = signal.filtfilt(b_filt,a_filt,accel_array)
accel_array = np.multiply(accel_array,9.80665)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)