# Simple implementation of GPS position filtering ( cheap pseudo Kalman )

As told by Menion, Locus does not currently use filtration of GPS position. Such filtering ( ala GPS averaging ) could be useful for geocaching or terrain surveying for OSM mapping.

I got idea of optional use of such filtering, eventually triggered by speed limit, similarly as magnetic compass is.

I suggest very simple filtering, using weighted average of the measured position and the position predicted from previous 2 filtered positions - a kind of a cheap pseudo Kalman filter. Prediction supposes you are moving without acceleration, with initial position, direction and speed given by last 2 filtered positions.

N is an index of position timeline

X is weighting factor, the higher means stronger filtration. 0 means zero filtration, >>1 means very strong filtration

Note that such filtering will apply to altitude as well, as part of 3D position.

As first 2 filtered positions would be trivially taken 2 subsequent measured positions.

Edit: As a waist shoot, values X=1-4 could be a good trial values.

- FilteredPosition(n+1)=(MeasuredPosition(n+1,GPS) + X * PredictedPosition(n+1))/(X+1)
- PredictedPosition(n+1)= 2 * FilteredPosition(n) - FilteredPosition(n-1)

Hm, perhaps a static initial state FilteredPosition(2)=FilteredPosition(1) would be better, as otherwise initial state could be too "jumpy".

For low enough speed would be probably better ..

PredictedPosition(n+1)= FilteredPosition(n)

And generally the true Kalman filter.

I would need this filter to "smoothen" the speed value.

I suppose so as well. a good solution would be double exponential smoothing,

ALFA and BETA are smoothing time constants for both position and velocity, respectively.

Both have value from 0 - total filtering - unusable till 1 - zero filtering.

Generally , the lower the ratio of speed/GPS error is, the stronger the filtering should be.

Seems like ALFA is good 0.2-0.6, BETA 0.05-0.2

NewEstimatedVelocity = BETA * ( NewEstimatedPosition - PreviousEstimatedPosition ) + ( 1-BETA)*PreviousEstimatedVelocity

Loading...Comments have been locked on this page!