View Full Version : Motion Smoothing Algorithm

Hi

This might not be specific to opengl but I'm sure someone here has encountered this problem.

I am working a project which is basically a flight simulator. We are taking GPS position data from an aircraft and attempting to recreate it's movements in 3D. The trouble is the position data is only refreshed at 4Hz. So basically when we simulate it directly it is like we are getting 4fps.

We need an algorithm that can basically "fill in the gaps" to give the effect of smooth motion in OpenGL. I'm sure this must have been done a million times before. And for better or worse the only resources we have are time and brain-power (no money, minimal expertise).

At the moment we are using our GPS position data to move a camera in an OpenGL world. So it would need to be the camera motion that is smoothed.

If anyone can direct me to some resource, tutorial even just a concept that could help that would be cool.

CHeers

dy

What you need is called "interpolation", and there are several ways, from the easyest linear up to any higher order (quadratic, cubic, n-th order).

So here is the easy, linear interpolation.

I assume you have something like x-position and y-position (coordinates) from your gps.

You also have a (hopefully) fixed time step of 4Hz, which means 25 milliseconds between the positions.

Lets take the first position with x1 and y1, the second with x2 and y2.

Calculate

delta_x=x2-x1

delta_y=y2-y1

k_x=delta_x/0.25

k_y=delta_y/0.25

Now you can calculate the position at ANY time between the two positions.

pos_x=x1+k_x*time

pos_y=y1+k_y*time

"time" should be any value from 0 to 0.25, so you need the time between 2 frames. This is also easy when you programmed a timer or fixed frame rate, else you need some way to get the elapsed time between the frames

If you want 20fps, the time between the frames is

0.05 ms.

frame=1:time=0.0 (=pos1)

frame=2:time=0.05

frame=3:time=0.10

frame=4:time=0.15

frame=5:time=0.20

now start from beginning with the next point (pos2 and pos3).

Get a math book, when you want to go to higher order interpolation (for smoother curve movement)

or search for "quardatic interpolation", this should be sufficient for your needs.

Of course, the above mentioned way can be taken for ANY data you collect (roll,gear,height...)

Hope this helped!

Originally posted by dydx:

Hi

This might not be specific to opengl but I'm sure someone here has encountered this problem.

I am working a project which is basically a flight simulator. We are taking GPS position data from an aircraft and attempting to recreate it's movements in 3D. The trouble is the position data is only refreshed at 4Hz. So basically when we simulate it directly it is like we are getting 4fps.

We need an algorithm that can basically "fill in the gaps" to give the effect of smooth motion in OpenGL. I'm sure this must have been done a million times before. And for better or worse the only resources we have are time and brain-power (no money, minimal expertise).

At the moment we are using our GPS position data to move a camera in an OpenGL world. So it would need to be the camera motion that is smoothed.

If anyone can direct me to some resource, tutorial even just a concept that could help that would be cool.

CHeers

dy

For better linear interpolation, I would have take in account the acceleration. But I'm really not sure as I never have done it yet. It's just an idea and I don't know if it's feasible. If it could work it will certainly give a better result as you only have 4 positions per second.

David Spilling

04-19-2006, 02:54 PM

Also google for "dead reckoning algorithm", which is the vis-sim term for what you are trying to do.

earthquad

04-20-2006, 12:22 PM

i can't resist adding TCB splines to the mix. I've been playing with these lately and they're pretty darn sweet. They're basically Catmull-Rom splines, but with added control.

For interpolation of orientation, you might look at quaternions, but I don't suppose you have those data, just positions. In that case you can use the spline curve itself to derive your TNB triad from successive derivatives. Heck, you probably want the aircraft to point in the direction of flight anyways, so that really just leaves roll. Just guessing there, though...

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.