0

I'm trying to get a good position via android and GNSS. The locationManager of Android gives me in every Case only one update per second. So i decided to switch to the GoogleFusedApi and the FusedLocationProviderClient to get my current position more often.


I tried different use cases and had different results:

Going down the street:

Update between 200ms and 1000ms => Average: 450ms


Driving same route with the bike:

Update between 300ms and 1000ms BUT Average: 840ms


I don't get why i get less updates if my speed is much higher. In both cases the smartphone was in my pocket.

The important snippet of my code:

    private FusedLocationProviderClient mFusedLocationClient;
    private LocationRequest locationRequest;
    private LocationCallback locationCallback;

    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);

    locationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 0)
                .setWaitForAccurateLocation(false)
                .setMinUpdateIntervalMillis(0)
                .setMaxUpdateDelayMillis(0)
                .build();

    locationCallback = new LocationCallback() {
            @Override
            public void onLocationResult(LocationResult locationResult) {
                if (locationResult == null) {
                    return;
                }
                location = locationResult.getLastLocation();
            }
     };

    private void getLocation() {
        if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
         
        }
        mFusedLocationClient.requestLocationUpdates(locationRequest, locationCallback, null);
    }

Maybe i did something wrong with the locationRequestSetup or something else? I hope anyone could help me to get the updates on Bike as fast as while walking.. Or could explain why i get the position more often while walking..

Is there any other soloution to get the Position with an average about 500ms in Android?

THANKS FOR HELPING!

Nicooost
  • 76
  • 6
  • Why do you need updates that frequently? If you're walking at 3mph (a faster than average speed), that's 1.3 meters per second. Or .7m per update. GPS isn't that accurate, the accuracy of most phones is +/-10m. So there's no reason to want that in the first place. Even by car at 60 mph that barely breaks the inaccuracy of the sensor. – Gabe Sechan Nov 28 '22 at 18:02
  • On bike at 25 km/h you got 7 Meter per second. I need a better accuracy to predict a possible trajectory which is driven by the bike. – Nicooost Nov 28 '22 at 19:51
  • So even on a bike you're going to be moving less than the inaccuracy of the sensor in 2x the speed of updates you want. In other words, your data at that rate would be garbage. Instead, use the heading and speed of your previous point to predict if necessary. If you actually need more accuracy than that (and you really, really don't), you need to buy specialized GPS hardware, not a phone. – Gabe Sechan Nov 28 '22 at 21:03
  • All in all it does not answer any of my questions.. I know for much better precision i need external Hardware. But i want to know how to get the same accuracy as i get when i'm walking. Or i want to know reason why i can't get this accuracy while riding.. I don't like to accept things without any explanantation... I want to understand why i get a less position updates at more speed. Hope you could understand and help me solving this one. Its realy okay for me if it is not possible to reach the 500ms while riding, but only if someone could explain why.. – Nicooost Nov 28 '22 at 21:27
  • If you want to get into that type of nitty gritty, you need to start by fixing your thinking. Getting more updates is frequency. Not accuracy. The two are not the same thing. Accuracy of an update is actually one of the pieces of data that the software will return as part of the result, and will be lower at higher speeds. More frequent does not mean more accurate. Generally the reverse when dealing with hardware. – Gabe Sechan Nov 28 '22 at 21:31
  • Yes, this was an error by translating from my self.. – Nicooost Nov 29 '22 at 07:55

0 Answers0