Sublimis / UrbanBiker

Urban Biker issue tracker and Knowledge Base
https://urban-bike-computer.com/
18 stars 4 forks source link

Issue: Altitude offset #145

Open birgander2 opened 3 years ago

birgander2 commented 3 years ago

Super cool app, I use it a lot since 2 years! But now I have the problem, that on my new phone the altitude shown in Urban Biker is always about 40-45m too high, while other apps like e.g. osmand or GPStest show the correct height. My phone has a barometer, but switching it on or off doesn't change much, so I assume this is GPS-related. Strangely enough, this "bug" was (and is) not present on my former phone, so quite likely it has something to do with the new phone or its firmware. Interestingly, the offset roughly corresponds to my local geoid height, is there maybe a correction missing somewhere? Apart from the altitude offset, everything is fine, so ascent / descent values seem to be correct.

Device: Umidigi Bison Pro, Android 11

Sublimis commented 3 years ago

Hi! Kudos for knowing about geoid etc., it will make things a lot easier. Yes, those symptoms are exactly what happens when altitudes are not corrected for geoid undulation.

Urban Biker tries to "automagically" (automatically and completely transparent to user) correct for geoid undulation by listening to NMEA sentences from the GNSS hardware in your device. NMEA sentences contain geoid height for the current area, and this number is then subtracted from the altitude that comes with every location update to get a more accurate value.

It seems there may be some problems with receiving NMEA on your device. If possible, please update the app to the latest version (v6.10) and try again. We've relaxed a few conditions on accuracy when processing NMEA, so it might simply work now if this was the culprit. Also yes, the problem could be solved by a future update to the devices' firmware.

If nothing helps (or you don't want to wait for a firmware update), you can try to manually set the geoid height by editing a config file. We say "try" because this won't work if the device is indeed providing NMEA sentences but with a wrong geoid height (e.g. a constant zero). To manually set the height, open the /Documents/UrbanBiker/config/config.json file with some text editor, and insert the following line somewhere around the middle of the file:

"GeoidUndulation": 40,

Please note the trailing comma, needed for the file to remain a valid JSON. Restart the app afterwards by swiping it from the recents screen.

You're right, barometer presence doesn't play any role in this. Barometer makes ascent/descent values accurate, but it can't correct for absolute altitude error. Only GNSS can provide absolute altitude information (and usually not very accurate, but that's another story). That being said, your track will still have a correct altitude profile thanks to the barometer, but as you noticed, it will simply be offset by ~40 meters as a whole.

There are other ways to correct altitudes for geoid, most notably a file with geoid data, or an Internet service. Other apps you mention might be using this approach. Our NMEA processing procedure worked like a charm for all these years. It doesn't require the Internet nor inclusion of more data with the app, so hopefully this will be resolved.

Thanks for the detailed feedback!

birgander2 commented 3 years ago

Wow, this is what I call feedback! I work professionally with (very expensive) navigation systems, so I can follow your explanations perfectly. Indeed, in some my own code, used to process aircraft trajectories, I use a 360x180 pixel map (one for every degree) to interpolate local geoid undulations worldwide. Just for curiosity: Using the accelerometer instead of the barometer is too imprecise in case of mobile phone, or not? This is what we do, but I'm talking about >100k€ devices.

Anyway, the hack you describe above works like a charm. I won't go that far with the bike that changes in undulation will play a role :smile:. The new version alone was not enough btw.

I'm pretty sure that the firmware of this phone is crappy. It is a cheap 150€ Chinese phone, and I don't really expect any firmware update ever. But that's ok, because I got it mainly because it's waterproof and has a barometer - perfect for use as a bike speedo with UrbanBiker. Thanks again for this cool app and the quick help!

Sublimis commented 3 years ago

So it appears to be a problem with the device's GNSS firmware in the end, that's too bad. Hopefully this won't become a more widespread problem over time (currently yours is the only such report in several years). 🤞 The 360x180 pixel map sounds like a practical solution that wouldn't take up much space, we'll keep this in mind for the future.

If I got it right, you're using an accelerometer to obtain altitude differences instead of a barometer, by doing dead reckoning? This is much easier to accomplish in aircrafts with their smooth trajectories (esp. for large aircrafts) and near-constant vibrations, for small vehicles like a bike that drives over the ground I'm not sure it would be plausible. Even if one manages to filter out terrain-based accelerations (vibrations) perfectly, the accuracy of the remaining data would be doubtful with such small and cheap accelerometers. The error accumulation would become dominant probably in a matter of minutes.

Anyway, the hack you describe above works like a charm. I won't go that far with the bike that changes in undulation will play a role 😄. The new version alone was not enough btw.

Exactly this 🙂 Once determined, geoid height can be considered constant for all practical purposes, except maybe if you travel between continents.

Thank you once more!

birgander2 commented 3 years ago

We are using a low-drift IMUs mostly for precision and to have a much faster sampling (to track vibrations and such). The altitude is not so much of a problem due to DGPS processing and excellent satellite visibility on a plane. The result are trajectories with about 1-2cm absolute precision, in my case this is needed for correction of motion errors in remote sensing imagery. The GPS is somehow "only" there to compensate for the IMU drift and to have an absolute reference.

I could at least imagine that an accelerometer could be used to stabilize GPS heights. But as you say, this for sure highly depends on its specs, the vibration spectrum, and so on. It might very well be that this is not a good idea on a phone with low-cost components...