简体   繁体   English

来自X,Y位置流C ++的加速度和速度

[英]Acceleration and Velocity from X,Y Position Stream C++

I have a stream of (x,y) data that I want to determine velocity and acceleration from. 我有一个(x,y)数据流,我想从中确定速度和加速度。 The data is pretty typical and can be thought to represent say a car driving around. 这些数据非常典型,可以说是代表一辆汽车行驶。

A new data point comes every 2ms and I would prefer to not accumulate/store unnecessary values so I thought to use a boost::accumulator . 一个新的数据点每2ms出现一次,我宁愿不积累/存储不必要的值,所以我想使用boost::accumulator

Is there a simpler way to handle this type of task? 有没有更简单的方法来处理这种类型的任务? or perhaps other libraries that already exist which already does this? 或者其他已经存在已经存在的库? or am I on the right track with my thinking. 或者我的想法是正确的。 Not yet sure what tags I'm going to use but I like the idea that the container keeps an updated value for a given property and doesn't store the old positional data. 还不确定我将使用哪些标签,但我喜欢容器为给定属性保留更新值并且不存储旧位置数据的想法。

Another idea is to use a circular buffer (eg size 200) and calculate the acceleration based off the last 50 values and velocity based off all the values in the buffer. 另一个想法是使用循环缓冲器(例如,尺寸200)并基于最后50个值和速度基于缓冲器中的所有值计算加速度。 However if the buffer stores raw positional data this would require looping over all elements every time to calculate the acceleration and velocity. 但是,如果缓冲区存储原始位置数据,则每次需要循环遍历所有元素以计算加速度和速度。 This could be improved by instead keeping some sort of rolling acceleration and velocity value which recalculates by removing the value from the end element and adding the value from the new element to insert (with weight 1/elements in buffer). 这可以通过改为保持某种滚动加速度和速度值来改进,该值通过从结束元素中移除值并将新元素的值添加到插入(重量为1 /缓冲区中的元素)来重新计算。 However this to me seems like some sort of boost rolling weighted accumulator. 然而,这对我来说似乎是某种提升滚动加权累加器。

You probably want to apply some sort of a Kalman filter to the data. 您可能希望对数据应用某种卡尔曼滤波器。 Old data needs to be there to help reduce the impact of noise, new data needs to be there, and weighted higher so that the answer is sensitive to the latest information. 旧数据需要存在以帮助减少噪声的影响,新数据需要存在,并且加权更高,以便答案对最新信息敏感。

A fairly simple approach for position, lets call it X , where each new sample is x is: 一个相当简单的位置方法,让我们称之为X ,其中每个新样本是x

X = (1-w) * X + w * x

as each new value comes in. Where the weight w adjusts how sensitive you are to new information vs old information. 当每个新值出现时。权重w调整您对新信息与旧信息的敏感程度。 w = 1 means you don't care about history, w = 0 means you don't care at all about new information (and obviously means that you'll never store anything). w = 1意味着你不关心历史, w = 0意味着你根本不关心新信息(显然意味着你永远不会存储任何东西)。

The instantaneous velocity can be calculated by computing the difference between successive points and dividing this difference by the time interval. 可以通过计算连续点之间的差异并将该差值除以时间间隔来计算瞬时速度。 This can in turn be filtered with a Kalman filter. 这可以依次用卡尔曼滤波器进行滤波。

Acceleration is the difference in sequential velocities, again divided by the time interval. 加速度是顺序速度的差异,再次除以时间间隔。 You can filter these as well. 您也可以过滤这些内容。

The divided differences will be more sensitive to noise than the position. 划分的差异对噪声比对位置更敏感。 For example, if object whose position you're monitoring stops, you will continue to get position measurements. 例如,如果您正在监视其位置的对象停止,您将继续获得位置测量。 The velocity vectors for successive measurements will point in random directions. 连续测量的速度矢量将指向随机方向。

Boost accumulator doesn't appear to do what you want. Boost累加器似乎没有你想要的。

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

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