Closed fmeulen closed 2 years ago
The problem here is that the measurement can be represented by a scalar. KalmanFilters.jl can not handle scalars in all cases yet. So a workaround is to represent the scalar observation in a vector with a single entry:
δ = 0.01
# Process model
F(s) = [s[1] + δ*s[2], s[2] - 9.8*sin(s[1]) * δ]
# Process noise covariance
Q = [δ^3/3 δ^2/2; δ^2/2 δ]
# Measurement model
H(s) = [sin(s[1])]
# Measurement noise covariance
R = Matrix([0.02]')
# Initial state and covariances
s_init = [0.0, 0.0]
P_init = [5.0 0.0 ; 0.0 5.0]
# Take first measurement
obs = [0.5]
mu = measurement_update(s_init, P_init, obs, H, R)
Does that work for you?
Yes, that solves it. Thanks.
Perhaps it is worthwhile to point this out in the example, as the scalar syntax seems to work for the "ordinary" kalman filter.
I am trying to use the UKF for filtering a swinging pendulum model.
I get the error
Unsure whether this is a bug, or input parameters are not provided in the right format. I could not find many examples or documentation.