streetcomplete / StreetComplete

Easy to use OpenStreetMap editor for Android
https://streetcomplete.app
GNU General Public License v3.0
3.88k stars 355 forks source link

Map rotates nervously in compass mode #636

Closed cyclingcat closed 4 years ago

cyclingcat commented 7 years ago

Hi there,

first of all, congratulations to this brilliant idea to make some OSM editing more convenient, especially for people who do this rarely in their spare free time. Since I discovered your app a few weeks ago, I have used it on my bicycle on my way to work, for shopping or just for recreational purposes. My own neighbourhood gets more and more complete (at least concerning road surfaces and opening times).

Now for my issue: v2.0 introduced the compass mode, which I was eagerly awaiting, but sadly it's quite unusable on my smartphone (BQ Aquaris M4.5, Android 5.1)! If I switch compass mode on, the map display rotates quite wildly, even if I ride a straight road with 20 km/h. It almost looks as if I rode my bike totally drunk... If I switch off compass mode (north is at the top), the circular sector pointing to the viewing direction jitters, which could also be a hint of GPS reacting too "nervously".

I haven't seen this behaviour with other apps and double-checked it today with OsmAnd - no problem there, the map doesn't rotate while cycling on a straight road.

I recorded a video clip, you will see immediately what's happening: https://we.tl/54i6MjcVOi (6 MB)

(During this recording, 9 satellites were receivable, so it shouldn't be a problem of poor GPS signal reception)

Is this a known problem? If it's not a bug in your app: Do you have an idea if it's fixable on my smartphone?

The cycling cat

westnordost commented 7 years ago

Hm, well, Streetcomplete is just reading the input data from the sensors and even smoothens it out. For compass-mode, it even smoothens it out further.

The sensors used are the magnetic compass and the gyroscope.

westnordost commented 7 years ago

Perhaps you could download some app with which you can see the current output of all the sensors and tell me which of the sensors is going topsy turvy for you.

MPoppinga commented 7 years ago

With a quick look at the code, it looks like you are using the accelerometer and not the gyroscope.

Aren't there libraries which can handle the smoothening? Other maps(eg. OsmAnd+) work way better, I also often have a way too shaky orientation with my phone(moto x style) in SC. I have the feeling, it depends on the way(pan/tilt) I currently hold my phone.

westnordost commented 7 years ago

Oh yeah, right, accelerometer. Anyway, I'd still first like to know what sensor is causing the jitter, if it is at all a sensor and not a bug in the code.

cyclingcat commented 7 years ago

Okay, I used SatStat and took this video today while reproducing the issue on a cycling path leading strictly straight ahead:

https://we.tl/ozQ8nWF3dQ (2 MB)

Another observation: The problem gets worse if the underground gets rougher: Today I rode some meters on a gravel path and the map jumped around even more than it did on asphalt. The smartphone is fixed at the handlebar of my city bike.

The cycling cat

westnordost commented 7 years ago

Hm, I have a (analog) compass on my bike. I cannot even hope to read the compass while cycling.

cyclingcat commented 7 years ago

With OsmAnd it works quite well. As this app is open source as well, could it be an idea to peek into its source code? They must have found a way to circumvent this problem.

The cycling cat

westnordost commented 7 years ago

Certainly, but for me, this has not such high priority right now. Perhaps someone else would like to look.

MPoppinga commented 7 years ago

OsmAnd uses a Kalman_filter ( https://github.com/osmandapp/Osmand/blob/1c9388a2c1b6739af04fd456bf89eed3e609279d/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java#L536 )

In SC the compass is in my case very sensitive if holding the smartphone upright (80-90° looking at it in front of you). And it also swaps the direction if it's over 90°. So this not only the sensor filtering, maybe also some other computation of the gravitational axis.

rugk commented 6 years ago

I just saw the "opposite issue" where the map does not rotate at all. See https://github.com/westnordost/StreetComplete/issues/828

Did anyone here try out the new beta?

HolgerJeromin commented 6 years ago

The play beta rotates correct on fairphone 2

hochwasser commented 6 years ago

I tried my luck on the compass. I simplified the implementation an put a low pass filter in. If this does not solve the issue, it should be easy to adapt it to a kalman filter. It does rotate on my device correct.

tangram.zip

ENT8R commented 6 years ago

Maybe you can simply create a PR for this? Or do you don't know how to do this and want this to be done by somebody else?

hochwasser commented 6 years ago

Hello ENT8R, what is a PR? This code should be tested with other devices. The tilt stuff was not clear to me. Maybe https://github.com/KalebKE/FSensor could be used to smooth the compas.

ENT8R commented 6 years ago

A PR is the short term for "Pull Request". I can try to test this on my devices

hochwasser commented 6 years ago

ENT8R it is not only done with a PR. A friend helped me with this (thanks elrond). You can find the PR here https://github.com/westnordost/StreetComplete/pull/982

westnordost commented 6 years ago

Ah, this is done

lightonflux commented 6 years ago

Using StreetComplete 8.2 on LineageOS 15.1 on Mido (Xiaomi Remi Note 4) and the problem still persists. Video

cyclingcat commented 6 years ago

I haven't used this feature for a while, but tested it today with StreetComplete v8.2 on my bq Aquaris M4.5 (Android 5.1): It's worse than ever! After switching to compass mode and cycling with approx. 15-20 km/h on a straight paved road the map was constantly turning in arbitrary directions. OsmAnd+ still didn't show this behaviour. I can record a screen video if you like (it would look a little worse than the one by @lightonflux above).

So there are at least two device on which the issue haven't been fixed yet. I would suggest to reopen this ticket in order to collect observations from other users and (hopefully) find some patterns behind them. Myself, I will try to test with some more smartphone models in the course of the next weeks.

The cycling cat

westnordost commented 6 years ago

Well, SC can't fix a broken sensor. Or are you on a bike?

You should try to calibrate your compass by waving your smartphone in an 8-shape

Am 21. Oktober 2018 19:34:36 MESZ schrieb lightonflux notifications@github.com:

Using StreetComplete 8.2 on LineageOS 15.1 on Mido (Xiaomi Remi Note 4) and the problem still persists. Video

matkoniecz commented 6 years ago

OsmAnd+ still didn't show this behaviour

So maybe there is some way to improve it. Or maybe OsmAnd method is worse on some devices and better on other.

westnordost commented 6 years ago

I suspect Osmand is using the gps movement direction and not the compass sensor.

I have a compass on my bike and it is also unusable while cycling.

Am 22. Oktober 2018 19:03:58 MESZ schrieb Mateusz Konieczny notifications@github.com:

OsmAnd+ still didn't show this behaviour

So maybe there is some way to improve it. Or maybe OsmAnd method is worse on some devices and better on other.

lightonflux commented 6 years ago

On foot. It is just the noise ratio that is higher with less good compass or drivers. Many drivers filter sensor data, maybe the driver lineages uses does forward raw data.

And it is not an unknown problem for other android devs and there are several solutions:

https://stackoverflow.com/questions/1884699/android-compass-noise-algorithm

westnordost commented 6 years ago

There is already a low pass filter in place

Am 22. Oktober 2018 22:18:34 MESZ schrieb lightonflux notifications@github.com:

On foot. It is just the noise ratio that is higher with less good compass or drivers. Many drivers filter sensor data, maybe the driver lineages uses does forward raw data.

And it is not an unknown problem for other android devs and there are several solutions:

https://stackoverflow.com/questions/1884699/android-compass-noise-algorithm

westnordost commented 6 years ago

But i can maybe review the parameters. Or, if you can, you do it and tell me for which parameters it feels good on your phone.

westnordost commented 4 years ago

Closing this now again. There is a filter in place that filters the noise.

cyclingcat commented 4 years ago

Hm... today I tried it with my two smartphones (SC v21.2 on Android 5.1, SC v20.2 on Android 9.0, both from F-Droid). No real improvement compared with the versions from two years ago and thus de facto unusable (tried it with the smartphone brackets mounted at the handlebar on two of my bicycles and holding the phones in my hand during a walk). Still no problem with OsmAnd on either phone.

Maybe it's actually unfixable with SC, but I'm curious: Is there any user who is able to use "compass mode" without having this hefty jitter? If someone is reading this: Which smartphone do you use and how do you use it?

The cycling cat