简体   繁体   English

使用卡尔曼滤波器跟踪机器人的圆周运动

[英]Tracking a robot in circular motion using Kalman Filter

What I'm trying to do: 我正在尝试做的是:

  • Localize the robot moving in a circular motion using Kalman Filter or Extended Kalman Filter 使用卡尔曼滤波器或扩展卡尔曼滤波器定位以圆周运动方式移动的机器人
  • Using trigonometry and linear algebra, I am able to predict a "circular motion," but I wanted to find out if I can use the Kalman Filter to localize the robot (without assuming it's in the circular motion) 使用三角函数和线性代数,我能够预测“圆周运动”,但是我想确定是否可以使用卡尔曼滤波器对机器人进行定位(不假设机器人处于圆周运动中)
  • The robot senses its coordinate (x, y). 机器人感应其坐标(x,y)。

What I'm having a trouble with: 我遇到的问题是:

  • The state vectors from Kalman Filter converges to the center of the circle 来自卡尔曼滤波器的状态向量收敛到圆的中心
  • The Kalman Filter fails to find the true positions 卡尔曼滤波器无法找到真实位置
  • Screenshot: Robot vs Kalman Filter 屏幕截图: 机器人与卡尔曼滤波器

My code Implementation 我的代码实现

I think there are two issues here. 我认为这里有两个问题。 One is that you are missing the process covariance matrix Q. If your state transition model is not perfect this will give the algorithm a hint of how uncertain the prediction is. 一种是您缺少过程协方差矩阵Q。如果您的状态转换模型不完美,这将为算法提供一个提示,表明预测的不确定性。 A large Q will make the algorithm rely more on the measurements. 较大的Q将使算法更多地依赖于测量。 Try initialising 尝试初始化

self.q = 0.001*self.f.dot(self.f.transpose())

and later in the predict function 然后在预测功能中

self.p = self.f.dot(self.p).dot(self.f.transpose()) + self.q

The other issue is that you are measuring a circular (polar) movement in an cartesian plane. 另一个问题是您正在测量笛卡尔平面中的圆周(极)运动。 The rotation gives an acceleration in X and Y and it is missing in the F matrix. 旋转会在X和Y方向产生加速度,而在F矩阵中会消失。 I would update the F matrix to include the complete physical model including acceleration. 我将更新F矩阵以包括完整的物理模型,包括加速度。 The time step (dT) is also missing and could be added as an argument. 时间步长(dT)也丢失了,可以作为参数添加。

class KalmanFilter(Filter):
    def __init__(self, sigma, dT):
    ...
    self.f = np.array([[1, 0, dT, 0, dT*dT/2,   0],
                       [0, 1, 0, dT,   0, dT*dT/2],
                       [0, 0, 1, 0,   dT,   0],
                       [0, 0, 0, 1,   0,   dT],
                       [0, 0, 0, 0,   1,   0],
                       [0, 0, 0, 0,   0,   1]])

and finally in your main function 最后是你的主要功能

KF = KalmanFilter(sigma=1,dT=0.1)

I also increased sigma to 1 to get a smoother prediction and decreased the P initialisation to 1 from 999 to visualize the initial overshoot. 我还将sigma增加到1以得到更平滑的预测,并将P初始化从999减小到1以可视化初始过冲。

Here is the result: 结果如下: 在此处输入图片说明

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

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