Android 如何/我应该实施卡尔曼滤波器来获得准确的加速度计数据?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22598585/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:13:24  来源:igfitidea点击:

How to/Should I implement a Kalman filter to get accurate Accelerometer data?

androidaccelerometersensorandroid-sensorskalman-filter

提问by Kersch

I want to get as accurate data from the built in accelerometer in an Android phone as possible. I want to track two dimensional movement in x and y axis and even the small movements must be registered.

我想从 Android 手机的内置加速度计中获得尽可能准确的数据。我想跟踪 x 和 y 轴上的二维运动,甚至必须记录小运动。

When I look at the data from the accelerometer / linear acceleration when the phone is flat on a table it changes a lot when i should be zero.

当手机平放在桌子上时,当我查看来自加速度计/线性加速度的数据时,当我应该为零时,它会发生很大变化。

I have looked at Kalman filters, it seems like a good approach but I am having problems setting up a model.

我看过卡尔曼滤波器,这似乎是一个很好的方法,但我在设置模型时遇到了问题。

1. Is a Kalman filter the way to go to get as accurate data as possible from an accelerometer?

1. 卡尔曼滤波器是从加速度计获得尽可能准确数据的方法吗?

2. Will a Kalman filter work? Maybe i have misunderstood but it seems like the acceleration or the velocity must be constant?

2. 卡尔曼滤波器会起作用吗?也许我误解了,但似乎加速度或速度必须是恒定的?

3. How do I set up the model for using Kalman filter? I'm having trouble understanding (among other things) what the process noise is?

3. 如何设置使用卡尔曼滤波器的模型?我无法理解(除其他外)过程噪声是什么?

采纳答案by Stochastically

A Kalman filter applies when all measurements (of acceleration in this case) are equal to the true value plus a measurement error. The measurement error is the process noise. For for the original Kalman filter to apply the noise must be normally distributed, i.e. sometimes the error will be positive, sometimes negative, and on average zero.

当所有测量值(在这种情况下为加速度)等于真实值加上测量误差时,应用卡尔曼滤波器。测量误差是过程噪声。对于要应用的原始卡尔曼滤波器,噪声必须是正态分布的,即有时误差为正,有时为负,平均为零。

If you jerk your android phone quickly back and forth, there'll be large accelerations. I'd suggest recording the accelerometer readings in that kind of action, and reviewing by eye to see whether it looks like there's the readings are indeed subject to some kind of normally distributed process noise. My guess is that the answer will be "No", i.e. I expect they readings when plotted on a graph will be smooth-ish. But if they're not smooth, a Kalman filter could be useful.

如果你快速地来回晃动你的安卓手机,会有很大的加速度。我建议在那种动作中记录加速度计读数,并用眼睛检查,看看读数是否确实受到某种正态分布过程噪声的影响。我的猜测是答案将是“否”,即我希望他们在图表上绘制时的读数将是平滑的。但如果它们不平滑,卡尔曼滤波器可能会有用。

If you're trying to use accelerometer readings to work out location, I think your project is doomed to failure. Acceleration is the 2nd derivative of position with respect to time, and I've never heard of anyone being able to integrate the readings with sufficient accuracy to be at all useful.

如果您尝试使用加速度计读数来计算位置,我认为您的项目注定要失败。加速度是位置相对于时间的二阶导数,我从未听说过有人能够以足够准确的方式整合读数以供使用。

I have applied a Kalman filter successfully to GPS readings on an Android phone to improve the location estimate. See Smooth GPS datafor code that implements a Kalman filter for that. I subsequently wondered whether velocity and perhaps acceleration data could be used to improve the location estimate. Although I never followed up on that idea, see https://dsp.stackexchange.com/questions/8860/more-on-kalman-filter-for-position-and-velocityfor the maths that I was considering using.

我已成功将卡尔曼滤波器应用于 Android 手机上的 GPS 读数,以改进位置估计。有关为此实现卡尔曼滤波器的代码,请参阅平滑 GPS 数据。我随后想知道是否可以使用速度和加速度数据来改进位置估计。虽然我从未跟进过这个想法,但请参阅https://dsp.stackexchange.com/questions/8860/more-on-kalman-filter-for-position-and-velocity了解我正在考虑使用的数学。

The optimal way of using all the sensor inputs (GPS, accelerometer, gyroscope, etc) to get a good estimate of location is a very hard (and interesting) problem. To find out more, the key phrase to search for is "Sensor fusion". On this subject, there's an old youtube video at http://www.youtube.com/watch?v=C7JQ7Rpwn2k.

使用所有传感器输入(GPS、加速度计、陀螺仪等)来获得良好位置估计的最佳方法是一个非常困难(且有趣)的问题。要了解更多信息,要搜索的关键词是“传感器融合”。关于这个主题,http://www.youtube.com/watch?v=C7JQ7Rpwn2k 上有一个旧的 youtube 视频。

回答by tiny_m

You might find this thread useful. I came across the same issues

您可能会发现此线程很有用。我遇到了同样的问题

We think the variance when lying flat might be an issue with Gimbal lock confusing the calculations but thats just a theory right now. We've also noticed the covariance in each axis alters depending on the orientation of the device, which might be gimbal lock interference too, but again just a theory

我们认为平躺时的差异可能是万向节锁定混淆计算的一个问题,但这现在只是一个理论。我们还注意到每个轴的协方差会根据设备的方向而改变,这也可能是万向节锁定干扰,但这只是一个理论

Implement a Kalman filter to smooth data from deviceOrientation API

实现卡尔曼滤波器以平滑来自 deviceOrientation API 的数据