简体   繁体   English

双卡尔曼滤波器的状态估计

[英]state estimation by Dual Kalman Filter

I want to estimate a variable x, and the observable variable y can be obtained from sensors.我想估计一个变量x,可观察变量y可以从传感器得到。 These two variables has an approximately linear relationship,ie, y=k*x + b, but k and b are difficult to get, so I use two kalman filters, one for state (x) estimation, another for parameter (k,b) estimation, which actually combines the dual kalman filter.这两个变量具有近似线性关系,即y=k*x + b,但是k和b很难得到,所以我使用了两个卡尔曼滤波器,一个用于状态(x)估计,另一个用于参数(k,b ) 估计,实际上结合了双卡尔曼滤波器。 The general scheme and code in Python is as follows, Python中的一般方案和代码如下,

the general scheme一般方案

##Python code
#initialize state estimator
kf = KalmanFilter(dim_x=1,dim_z=1)
kf.x = numpy.array([x0])              # initial state
kf.F = numpy.array([1.])              # state transition matrix
kf.Q = 1000                           # state noise variance,
kf.R = 1                              # measurement noise variance

#initialize parameter estimator
dkf = KalmanFilter(dim_x=2,dim_z=1)
dkf.x = numpy.array([[-0.01,-0.1]]).T # initial state 
dkf.F = numpy.array([[1,0],
                    [0,1]])           # state transition matrix
dkf.Q = numpy.array([[1,0],
                    [0,1]])
dkf.R = 100                           # measurement noise variance

measurements = []
resultsDKF = []                                         #dual kalman filter state estimation result
ERRDKF = []                                               #estimation error

for i in xrange(N):   # N samples
    #### parameter estimator
    dkf.H = numpy.array([[kf.x,1]])   # measurement function
    y = Y[i]
    dkf.update(y,dkf.R,dkf.H)        
    dkf.predict()

    #### state estimator
    kf.H = numpy.array([dkf.x[0]])
    z = Y[i]-dkf.x[1] # Y[i]-b
    kf.update(z,kf.R,kf.H)    
    kf.predict()

    #### save data
    measurements.append(Y[i])
    resultsDKF.append (kf.x)
    ERRDKF.append(measurements[-1]-resultsDKF[-1])

the results are also followed:结果也如下:

setting of initial state much away from true value初始状态的设置与真实值相差甚远

It seems that the predicted state varies with the true value, but there still is a big gap between predicted and true value.看起来预测状态随真值变化,但预测值和真值还是有很大差距的。

I think the dual kalman filter doesn't really track true values of x, what's the problem?我认为双卡尔曼滤波器并没有真正跟踪 x 的真实值,有什么问题? Anybody who offers advice will be much appreciated.任何提供建议的人将不胜感激。

Part of the power of the Kalman filter is that it develops and propagates correlations between the error's in the states.卡尔曼滤波器的部分功能在于它在状态中的误差之间发展和传播相关性。 By separating the problem into two filters, you preclude either filter from figuring out that there's an error it doesn't know about, because it's not modeled.通过将问题分成两个过滤器,您可以阻止任一过滤器发现它不知道的错误,因为它没有被建模。 In the specific case you've described, where:在您描述的特定情况下,其中:

y=k*x + b

with k & b both unknown you should make x, k & b states of a single Kalman filter.由于 k 和 b 都是未知的,您应该使单个卡尔曼滤波器的 x、k 和 b 状态。 Over time with enough observations of a varying x (ie y measurements from different x values), the filter can observe k and b because of the correlation in the x, k, and b states carried in the covariance matrix.随着对变化的 x 的足够观察(即来自不同 x 值的 y 测量),滤波器可以观察 k 和 b,因为协方差矩阵中携带的 x、k 和 b 状态存在相关性。 With the 'x' filter separated from the 'k' and 'b' filter, it can remain offset forever, as in your result.将 'x' 过滤器与 'k' 和 'b' 过滤器分开后,它可以永远保持偏移,就像您的结果一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM