【问题标题】:Use pykalman to predict further steps on dynamic objects使用 pykalman 预测动态对象的进一步步骤
【发布时间】:2021-04-02 13:27:10
【问题描述】:

我正在尝试使用卡尔曼滤波器来预测下一个对象位置。我的数据是由纬度和经度每个1s组成的,所以我也可以得到速度。

下面的代码显示了一个 pykalman 包的尝试来预测进一步的位置。我只是通过添加前三个纬度/经度值来修改测量值。 transition_matrices 和observation_matrices 对吗?我不知道我应该如何设置它们。

#!pip install pykalman
from pykalman import KalmanFilter
import numpy as np
kf = KalmanFilter(transition_matrices = [[1, 1], [0, 1]], observation_matrices = [[0.1, 0.5], [-0.3, 0.0]])
measurements = np.asarray([[41.4043467,  2.1765616], [41.4043839,  2.1766097], [41.4044208,  2.1766576]])  # 3 observations
kf = kf.em(measurements, n_iter=5)
(filtered_state_means, filtered_state_covariances) = kf.filter(measurements)
(smoothed_state_means, smoothed_state_covariances) = kf.smooth(measurements)

结果如下,离正确的输出很远。

smoothed_state_means
array([[-1.65091776, 23.94730577],
       [23.15197525, 21.2257123 ],
       [43.96359962, 21.9785667 ]])

我该如何解决这个问题?我错过了什么?

使用纬度/经度时路径具有这种形状

更新

我试过这些转换方式:

1.

R = 6378388.0 # m
rlat1_225 = math.radians(lat_225['message_basicContainer_reference_position_latitude'].values[i-1]/10000000)
rlon1_225 = math.radians(lon_225['message_basicContainer_reference_position_longitude'].values[i-1]/10000000)
       
dx = R * math.cos(rlat1_225) * math.cos(rlon1_225)
dy = R * math.cos(rlat1_225) * math.sin(rlon1_225)
pos_x = abs(dx*1000)
pos_y= abs(dy*1000)

2.

altitude=0
arc= 2.0*np.pi*(R+altitude)/360.0 #
latitude=lat_225['message_basicContainer_reference_position_latitude']/10000000
longitude=lon_225['message_basicContainer_reference_position_longitude']/10000000
dx = arc * np.cos(latitude*np.pi/180.0) * np.hstack((0.0, np.diff(longitude))) # in m
dy = arc * np.hstack((0.0, np.diff(latitude))) # in m

第一种方法似乎是正确的形状,但是,在应用 EKF 之后(我遵循了 Michel Van Biezen 的解释,我可以在 python 中使用跟踪平面)。

所以,我按照使用 EKF 的第一种方式进行预测:

但是,当我将预测路径和原始路径重叠时,我得到了这个图

然后,使用第二种方法进行预测,结果是

似乎第一种方法是正确的,还是有其他方法?

【问题讨论】:

    标签: python latitude-longitude prediction kalman-filter pykalman


    【解决方案1】:

    您需要在本地笛卡尔坐标系统中转换纬度/经度位置。您可以在第一个收到的位置内设置原点。关于这个系统,您可以估计相对位置和速度。

    转换矩阵取决于您选择的状态,例如2 个状态,x-position 和 v-velocity 在该轴上,您将拥有:x_k+1 = x_k + v_k * dT 和 v_k+1 = v_k。即:

    transition_matrices = [[1, dT], [0, 1]]
    

    【讨论】:

    • 首先确保您的输入正确。具有 1e8 顺序的值看起来不正确
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-01
    • 1970-01-01
    • 2019-08-07
    • 1970-01-01
    • 2015-05-06
    • 1970-01-01
    • 2021-03-18
    相关资源
    最近更新 更多