test_filters module
Tests for a general KF
- class test_filters.MSD_UKF(init_dict, params_dict)[source]
Bases:
BaseUnscentedKalmanFilter
Mass spring damper system for testing EKF implementation
- k
Spring constant of system
- Type:
float
- m
Mass of system
- Type:
float
- b
Damping coefficient of system
- Type:
float
- _abc_impl = <_abc_data object>
- dyn_model(x, u, predict_dict=None)[source]
Full dynamics model
- Parameters:
x (UKF belief state under unscented transformation) –
u (Input vector) –
predict_dict (Dict) – Additional update parameters, not used in current implementation
- Returns:
x_new – predicted state, dimension 2 x 1
- Return type:
np.ndarray
- class test_filters.MsdEkf(init_dict, params_dict)[source]
Bases:
BaseKalmanFilter
Mass spring damper system for testing EKF implementation
- k
Spring constant of system
- Type:
float
- m
Mass of system
- Type:
float
- b
Damping coeeficient of system
- Type:
float
- _abc_impl = <_abc_data object>
- get_B(predict_dict=None)[source]
Map from control space to state space . No control signals in this example
- Parameters:
predict_dict (Dict) – Additional predict parameters, not used in current implementation
- Returns:
B – 2 x 1 array of all zero elements
- Return type:
np.ndarray
- test_filters.msd_ekf_params()[source]
Return dictionary of initial parameters for MSD KF implementation
- Returns:
ekf_init_dict – Dictionary with KF state dimension, initial state and covariance
- Return type:
Dict
- test_filters.msd_exact_sol(times)[source]
Compute exact solution for mass-spring-damper position evolution
- Parameters:
times (np.ndarray) – Vector of linearly spaced time values for MSD
- Returns:
exact_sol – Vector of exact position solutions for MSD system
- Return type:
np.ndarray
- test_filters.msd_filter_sol(times, x_exact, init_dict, params_dict, q, r, filter_type)[source]
Run filter for all time steps
- Parameters:
times (np.ndarray) – Vector containing time instances for exact state evolution
x_exact (np.ndarray) – Vector containing exact state positions
init_dict (Dict) – Dictionary of filter initialization parameters
params_dict (Dict) – Dictionary of MSD parameters
q (float) – Process noise covariance values on diagonal term
r (float) – NavData noise covariance values on diagonal term
filter_type (string) – Type of filter to test, currently ekf
- Returns:
x_filter (np.ndarray) – Position estimated by filter, dimension T x 1
P_pre (np.ndarray) – State covariance after prediction step, dimension T x 2 x 2
P_post (np.ndarray) – State covariance after update step, dimension T x 2 x 2
- test_filters.msd_params()[source]
Return dictionary of additional parameters for MSD KF implementation
- Returns:
params – Dictionary with MSD mass, spring constant and damping coefficient
- Return type:
Dict
- test_filters.msd_times()[source]
Return time vector for MSD system evolution
- Returns:
msd_times – Vector of linearly spaced time values from 0 to 20 seconds
- Return type:
np.ndarray
- test_filters.msd_ukf_params()[source]
Return dictionary of initial parameters for MSD UKF implementation
- Returns:
ekf_init_dict – Dictionary with UKF state dimension, initial state and covariance
- Return type:
Dict
- test_filters.test_exact_sol(times, x_exact, init_dict, params_dict, filter_type)[source]
Compare solution from KF to exact solution of the system
- Parameters:
times (np.ndarray) – Vector containing time instances for exact state evolution
x_exact (np.ndarray) – Vector containing exact state positions
init_dict (Dict) – Dictionary of filter initialization parameters
params_dict (Dict) – Dictionary of MSD parameters
filter_type (string) – Type of filter to test, currently ekf
- test_filters.test_filter_cov_tests(times, x_exact, init_dict, params_dict, q, r, filter_type)[source]
Test that covariance is PSD, decreases after update and increases after prediction step
- Parameters:
times (np.ndarray) – Vector containing time instances for exact state evolution
x_exact (np.ndarray) – Vector containing exact state positions
init_dict (Dict) – Dictionary of EKF initialization parameters
params_dict (Dict) – Dictionary of MSD parameters
q (float) – Process noise covariance values on diagonal term
r (float) – Measurement noise covariance values on diagonal term
filter_type (string) – Type of filter to test, currently ekf