Hi,

This a problem that seems to come up now and again on this forum, but either no-one’s posted a solution, or I’m too dumb to understand it.

Here goes....

I’m working on an autonomous vehicle project. The vehicle needs to travel a course starting from a given point, via various pre-programmed positions and then come back to the start point. It must get to within 100 meters of each of the turn points to qualify. During the course the GPS position is logged and once the vehicle has returned the logged GPS positions are used to determine if the vehicle really did manage to complete the course.

The geographical distance between two points is determined using ‘great circle’ math formula as described here.... http://www.movable-type.co.uk/scripts/latlong.html (note- all angles have to be expressed in radians, not degrees!)

It’s relatively easy to implement these formula in Arduino, the issue is that

Floats have only 6-7 decimal digits of precision

. (quoted from the reference pages). Unfortunately, this limited precision equates to several meters of inaccuracy.

The problem is that during the journey the actual latitude and longitude from the GPS module is logged verbatim to a SD card, and then converted to a number (in degrees) which is then converted to radians, and then used to work out if the vehicle reached the turnpoint. When the course has been finished, a different program (using floats with greater precision) is then used to verify the journey. So, during the journey the vehicle may think it’s got to within range of the turnpoint, but after the journey, the verifying program may decide it hasn’t!

To get greater accuracy, I’d normally just switch to a data type with greater precision, however the

double implementation is exactly the same as the float, with no gain in precision.

(quoted from the reference pages).

So what’s the solution? I think that I need to either find a data-type with greater precision, or find a set of great circle formula that work on integer values of degrees, minutes and seconds. Or do I have to move away from Arduino to a raspberry Pi instead?

Any suggestions?

thanks