Pages: 1 [2]   Go Down
Author Topic: How does Ardupilot do it?? GPS accuracy issues !!! Distance Calculations  (Read 5413 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
*
Karma: 3
Posts: 1001
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The only calculation I propose is the difference between two structures -- subtraction.
The difference in longitude (the distance moved in the west to east direction) depends on latitude. If we travel along the equator this can be approximated as an arithmetic difference, but for any other latitude (such as somewhere in North America) this is not so. To account for this difference we need the trigonometric functions. Precision becomes the least of your worries if you ignore this fact.
Logged

Offline Offline
Full Member
***
Karma: 11
Posts: 147
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The only calculation I propose is the difference between two structures -- subtraction.
The difference in longitude (the distance moved in the west to east direction) depends on latitude. If we travel along the equator this can be approximated as an arithmetic difference, but for any other latitude (such as somewhere in North America) this is not so. To account for this difference we need the trigonometric functions. Precision becomes the least of your worries if you ignore this fact.


Got it, a move of X degrees east and Y degrees north is not the same distance everywhere on the globe, it depends on latitude.

There are several formulas for calculating distance between two points on a sphere, but for any of them, your inputs are going to be the latitude of the first point, the latitude of the second point, the difference in latitude between them and the difference in longitudge between them.

My point is that for calculating the differences in latitude and longitude, you preserve precision by subracting first and converting to radians second rather than converting to radians and then subtracting. 

For short distances -- like hundreds of yards -- to exploit the full precision of the GPS signal the floating point library on an Arduino is inadequate, at least using great-circle calculations.  If two points are a kilometer apart the cosine of the angle between them is  0.9999999877. That's seven nines in a row, and the difference between that number and 1 compared to 1 is less than the precision of a 32-bit float.  The GPS can give you measurements that are more precise than what you can calculate using great-circle methods.

I suspect you would get more useful results pretending that your little patch of the earth is flat, calculating the length of a second of latitude and a second of longitude at your latitude, constructing a right triangle with height equal to the difference in seconds of latitude and width equal  to the difference in seconds of longitude, and then calculating the length of the hypontenuse of that triangle using the Pythagorean theorem. 

This Pythagorean method is what the haversine formula simplifies to if you assume the same latitude for the starting and ending points.  The advantage of the Pythagorean method is that you don't do any trigonometric calculations on tiny, tiny angles. You do multiplication, addition, square root and cosine on large angles (latitude), but your precision is preserved throughout.

Good discussion though. It has really helped focus my thinking for a project I'm working on.
Logged

Pages: 1 [2]   Go Up
Jump to: