getting the value of a filter at an arbitrary time

Posted by Andiih on Stack Overflow See other posts from Stack Overflow or by Andiih
Published on 2010-05-13T08:50:40Z Indexed on 2010/05/13 8:54 UTC
Read the original article Hit count: 203

Filed under:
|
|

Context: I'm trying to improve the values returned by the iPhone CLLocationManager, although this is a more generally applicable problem. The key is that CLLocationManger returns data on current velocity as and when it feels like it, rather than at a fixed sample rate.

I'd like to use a feedback equation to improve accuracy

v=(k*v)+(1-k)*currentVelocity

where currentVelocity is the speed returned by didUpdateToLocation:fromLocation: and v is the output velocity (and also used for the feedback element).

Because of the "as and when" nature of didUpdateToLocation:fromLocation: I could calculate the time interval since it was last called, and do something like

for (i=0;i<timeintervalsincelastcalled;i++) v=(k*v)+(1-k)*currentVelocity

which would work, but is wasteful of cycles. Especially as I probably want timeintervalsincelastcalled to be measured as 10ths of a second.

Is there a way to solve this without the loop ? i.e. rework (integrate?) the formula so I put an interval into the equation and get the same answer as I would have by iteration ?

© Stack Overflow or respective owner

Related posts about math

Related posts about iphone