0

Hi I am trying to run a code to validate my acceleromter sensor on RPI4. Seems my libray does not have a sample rate optio, 'fs' as I keep getting the error;

TypeError: butter() got an unexpected keyword argument 'fs'

Any ideas how i could fix this?

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,ay,az,wx,wy,wz,mx,my,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)
Mac
  • 1
  • 1
  • You should provide at least a minimum level of (not) working code so people can look at it trying to figure out what's wrong in it... – nico9T Apr 13 '21 at 20:57
  • Okay, I've just edited the question with the code. The thing is it seems that the 'fs' function (sampling frequency digital system) requires a higher scipy version than the one i have in my pi. I am currently using version 1.1.0. (https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.butter.html) any ideas how to upgrade the version? – Mac Apr 17 '21 at 13:14
  • https://stackoverflow.com/questions/5183672/how-do-i-update-a-python-package – nico9T Apr 17 '21 at 13:48

0 Answers0