0
votes

How can I get reasonably accurate GPS positioning?

I'm trying to create a simple golf app for my "LG Leon LTE" phone that tells me how far I have hit each shot. My plan is to use the GPS only when needed - to get the position of my starting point and then get the position of my ending point, and calculate the distance between them. I don't think I need continuous updates.

I wrote a test program that uses the following to get a single position at a starting point and an ending point:

  locationManager.requestSingleUpdate(LocationManager.GPS_PROVIDER, locationListener, null);

My locationlistener includes:

longitude = loc.getLongitude(); 
latitude = loc.getLatitude();

I also include:

accuracy = loc.getAccuracy();
numberOfSatellites = loc.getExtras().getInt("satellites");

And to calculate the distance between the two points I use:

loc.distanceBetween(oldLatitude, oldLongitude, newLatitude, newLongitude, result);
distance = ((int) ((result[0] * 1.09361) + 0.5));  // meters to yards

The manifest for my app includes:

android.permission.ACCESS_FINE_LOCATION
android.hardware.location.gps

and My phone's "Location" function is on, and the "Location Mode" setting is "GPS only"

Hoping to improve the accuracy, I collect 5 data points at the starting and ending location, and I calculate the distance traveled two ways:

  1. using the "average" of the starting and ending positions, and
  2. using the "best" starting and ending positions (those with the lowest "accuracy" value).

My simple tests are conducted in front of my house in a residential area with houses on only one side of the street, and they consist of:

  1. standing in one place and displaying the distance traveled, and
  2. pacing 20 yards and displaying the distance traveled. (Note that, on the golf course I consistently pace 100 yards and am accurate within +-2 yards.

The results are very confusing.

  1. Standing still produces "distance traveled" results ranging from 0 to 20 yards, usually in the range of 7-10 yards.
  2. Pacing 20 yards produces results ranging from 1-15 yards. (I've never gotten 20 yards or more.)
  3. Neither "average" nor "best" calculations consistently show an advantage. Sometimes "average" produces a more accurate result, and sometimes "best" is best.
  4. The number of satellites is never more than 9. Sometimes it's 1, and sometimes it's 0!! (What does it mean to get a position with 0 satellites?) I downloaded the "GPS essential" app, and it shows 20 or more satellites when I stand in front of my house!

Can someone suggest ways to improve my results - more satellites, more accuracy? (Golf range finder apps for my phone seem to be more accurate; how do they do it?)

Thank you.

1

1 Answers

0
votes

You seem to think GPS has infinite accuracy. It doesn't. With the type of hardware in the average phone, its accurate to about 10-15 meters- call it 30-50 feet. You aren't going to get better than that without really accurate gps equipment- stuff that costs a couple hundred bucks just for the GPS. So seeing 20 yard swings isn't out of spec, its about what I'd expect (remember accuracy is a circle, so that 10-15m is the radius- expect 20-30m between the two extremes). You will even once in a while get some weird reading that's totally off.

As for satellites- the entire GPS system has 24 satellites. If you see 20 outside your house, either its showing both the US and EU networks, or its showing every satellite in the system. You can't reach 20 at once even if you could listen to both networks at once. 7 is sufficient to get your position. 9 is even better. You won't get more than that ever, you don't have line of sight to them.

That said, there are filtering algorithms you can use to try and filter out the noise and get a more steady position. Look up Kalman filtering.