GPS - Accuracy
LuckyJ
Posts: 4
Hello,
I am trying to get my BASIC stamp to compare my current position to a known point (actually a database of points). However, every time I do a calculation the stamp drops digits and my accuracy goes down. Do I need a different processor or am I doing something wrong? All I need to be able to do is compare by current position with a known position and let me know how far I am away (within about 5-10m if possible).
Thanks.
I am trying to get my BASIC stamp to compare my current position to a known point (actually a database of points). However, every time I do a calculation the stamp drops digits and my accuracy goes down. Do I need a different processor or am I doing something wrong? All I need to be able to do is compare by current position with a known position and let me know how far I am away (within about 5-10m if possible).
Thanks.
Comments
If you are losing accuracy in the calculations, it may be appropriate to scale up your numbers. Essentially, instead of doing intermediate calculations in meters, do them in centimeters or millimeters. This lets you do integer math without losing data. Then, you can scale the result to whatever units you want in the end. Of course, this may have nothing to do with your issue. Code will help to determine that.
I am trying to calculate the distance between 2 points. Say:
The simplest (and accurate enough) method is to use Pythagoras. To calculate:
Y = delta lat * mean radius of earth (delta lat is in radians, mean radius of earth is 6371000.79m)
X = delta long * mean radius of earth * cosine lat(1) (delta long is in radians, lat(1) is the latitude of point 1 in radians)
So if we run the formula:
Y = (0.912222 - 0.911844) * 6371000.79 = 2407.926
X = (-1.986433 - -1.985328) * 6371000.79 * cos(0.912222) = 4308.870
Finding the hypotenuse gives us a distance of 4936.038m. Google earth measurement gives us a value of 4944.39m. Not great, but we are looking at accuracy at smaller distances.
Say:
Y = 0.111195
X = 4.697752
So distance between is 4.696m. Google Earth tells me its 4.71m. Works for me.
If I were to do the same calculation with the restriction of each calculation cannot exceed 16 bits I get:
Y = (9118-9118)*6371 = 0
X = (19853-19853)*6371*cos(9118/10000) = 0
So the distance between when restricted to 16 bits is 0. It gives the impression like we crashed into the point, when we are actually still 5m away.
I will try and post some code when I get home but I am wondering if my problem lies with the 16 bit processor and if I need to upgrade to 32 bits.
Thanks again for the help.
One thing you can do is limit the range of your longitude and latitude values. Are you going to be operating over a limited distance?
If you are getting enough accuracy from the GPS and it's only the math that is causing the problem, try "subtracting" a constant from each latitude value (and longitude) before computing the delta.
((lat0 - constant) - (lat1 - constant)) = lat0 - lat1
The constant could be your starting latitude, for example, if you are just moving around a fixed location.
By subtracting that constant and scaling appropriately, you may be able to pick up your lost data. Note that subtracting the constant does not necessarily mean actually subtracting a value. You just want to end up with the important part of your data occupying the most bits possible. And this should be done before converting to radians.
I haven't run the math so I'm not sure what the best solution is.
If you need to do this on a global scale where you can't take advantage of this offset then you will need to implement higher precision math (I think).
I expect that there are others here who can give you a better answer and they just haven't noticed the thread yet.
there are many documentation on Web and you may find some codes also.
I recently wrote a code that computes point Scale Factor in UTM. in this code i convert (fi,Landa) from WGS84 into UTM. I upload whole code and also program into my website: gis.jigsy.com
it may be useful. If you have more questions i'll be happy to reply. please post your questions there.