gpt4 book ai didi

java - 如何在 Apache Commons Kalman 过滤器实现中填充矩阵

转载 作者:太空宇宙 更新时间:2023-11-04 12:49:20 26 4
gpt4 key购买 nike

背景:为了给大家一些背景知识,我正在尝试使用卡尔曼滤波器(Apache 共同实现)。我应该包含什么样的动态噪声 在我关于矩阵 P0、Q 和 R 的实现中,知道 除了位置(X 和 Y)之外,我唯一的输入是水平的 X 和 Y 分量的精度和速度。这不是一个常数 速度示例,因为速度可能会从 1 ping 变为 另一个 ping。

实现库:Apache Common
-http://commons.apache.org/proper/commons-math/userguide/filter.html

用法:我现在只考虑二维空间

我随身携带的输入: 1.纬度
2.经度
3. 水平精度或水平精度因子 (HDOP),单位为米/秒
4. 两次 ping 之间的时间 (dt) = 30 秒

我关心的输出
1.新纬度
2.新经度

计算值:Vx(X 方向的速度) Vy(Y 方向的速度) 物体将不断移动,但 改变速度,这样我就可以使用公式计算 Vx 和 Vy V * sin(theta) 和 V * Cosine(theta)

我应该如何将我的值映射到 Apache Common 实现。?

当前设置:

X = Initial State = [  

{X Y X-Vel Y-Vel}

]

// I only care about X and Y coordinates so this is a 2 * 4 matrix
H = Observation variables = [

{1, 0, 0, 0},
{0, 1, 0, 0}



]

// This is a 4 * 4 matrix
P0 = Cov(X) = [

{(horizontal accuracy from i/p), 0, 0, 0},
{0, (horizontal accuracy from i/p), 0, 0},
{0, 0, (some initial value for VY), 0},
{0, 0, 0, (some initial value for VX) }

]

// Copied this from somewhere. What values should I have in this? //
This is a 4 * 4 matrix
Q = Cov(Dynamic noise) = [

{ Math.pow(dt, 4d)/4d, 0d, Math.pow(dt, 3d)/2d, 0d },
{ 0d, Math.pow(dt, 4d)/4d, 0d, Math.pow(dt, 3d)/2d },
{ Math.pow(dt, 3d)/2d, 0d, Math.pow(dt, 2d), 0d },
{ 0d, Math.pow(dt, 3d)/2d, 0d, Math.pow(dt, 2d) }

]

// This is a 2 * 2 matrix
R = Cov(measurement noise) = [

{ Math.pow((horizontal accuracy from i/p), 2d) , 0},
{ 0, Math.pow((horizontal accuracy from i/p), 2d)}

]

// This is a 4 * 4 matrix
A = State transition matrix = [

{ 1d, 0d, dt, 0d },
{ 0d, 1d, 0d, dt },
{ 0d, 0d, 1d, 0 },
{ 0d, 0d, 0d, 1d }

]

我的矩阵对于我想要做的事情是否正确?当我运行它们时我 不断收到 MatrixDimensionMismatchException,因此我决定 问一个问题。任何帮助将不胜感激。

最佳答案

我能够通过使用最新版本的 Apache Commons Math 库解决这个问题。

事实证明,Apache Commons Math 3.2 及更早版本存在重大错误
此处报告:https://issues.apache.org/jira/browse/MATH-1033

问题是 measNoise 列维度必须始终为 1,这意味着矩阵 R 应该始终只有 1 列

// row dimension of R must be equal to row dimension of H
if (measNoise.getRowDimension() != measurementMatrix.getRowDimension() ||
measNoise.getColumnDimension() != 1) {
throw new MatrixDimensionMismatchException(measNoise.getRowDimension(), measNoise.getColumnDimension(), measurementMatrix.getRowDimension(), 1);
}

关于java - 如何在 Apache Commons Kalman 过滤器实现中填充矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35996303/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com