balzer82 / Kalman

Some Python Implementations of the Kalman Filter
1.04k stars 366 forks source link

Got error in kalman gain calculation #21

Open royaalto opened 2 years ago

royaalto commented 2 years ago

different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. arr = N.array(data, dtype=dtype, copy=copy)

UFuncTypeError Traceback (most recent call last) /home/roy/softwares/Kalman/Extended-Kalman-Filter-CHCV.ipynb Cell 39' in <cell line: 1>() 47 S = JH @ P @ JH.T + R 48 S.astype('float64') ---> 49 K = (P @ JH.T) @ np.linalg.inv(S) 50 # K=(PJH.T)inv(JHPJH.T + R)#Kalman Gain 51 # Update the estimate via 52 Z = measurements[:,filterstep].reshape(JH.shape[0],1)

File <__array_function__ internals>:180, in inv(*args, **kwargs)

File ~/.local/lib/python3.10/site-packages/numpy/linalg/linalg.py:545, in inv(a) 543 signature = 'D->D' if isComplexType(t) else 'd->d' 544 extobj = get_linalg_error_extobj(_raise_linalgerror_singular) --> 545 ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj) 546 return wrap(ainv.astype(result_t, copy=False))

UFuncTypeError: Cannot cast ufunc 'inv' input from dtype('O') to dtype('float64') with casting rule 'same_kind'