Simple implementation of GPS position filtering ( cheap pseudo Kalman )

Libor Poutnik Striz shared this idea 1 year ago
Collecting votes

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.

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

Comments (6)

photo
1

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

photo
1

For low enough speed would be probably better ..

PredictedPosition(n+1)= FilteredPosition(n)

And generally the true Kalman filter.

photo
1

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

photo
1

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

  1. NewEstimatedPosition = ALFA * NewMeasuredPosition + ( 1-ALFA)*( PreviousEstimatedPosition + PreviousEstimatedVelocity )
  2. NewEstimatedVelocity = BETA * ( NewEstimatedPosition - PreviousEstimatedPosition ) + ( 1-BETA)*PreviousEstimatedSpeed

photo
1

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

photo
1

  1. ALFA = 0.2 + 0.4 * PreviousEstimatedSpeed(m/s) / (10+PreviousEstimatedSpeed(m/s) )
  2. BETA = 0.05 + 0.35 * PreviousEstimatedSpeed(m/s) / (10+PreviousEstimatedSpeed(m/s) )
  3. NewEstimatedPosition = ALFA * NewMeasuredPosition + ( 1-ALFA)*( PreviousEstimatedPosition + PreviousEstimatedVelocity )
  4. NewEstimatedVelocity = BETA * ( NewEstimatedPosition - PreviousEstimatedPosition ) + ( 1-BETA)*PreviousEstimatedVelocity