New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow down automatic rotation of 3d View #2465
Comments
Related: #2191 |
It is already slowed down. The quality or noise of the compass sensor is very much dependent on the device and probably whether the compass is calibrated a lot. Try calibrating your compass. I think it is calibrated automatically by Android when you make invisible eights in the air with your smartphone in the hand. |
The code is here: https://github.com/streetcomplete/StreetComplete/blob/master/app/src/main/java/de/westnordost/streetcomplete/map/Compass.kt Maybe instead of a static factor, it could be adaptive, based on how much noise is experienced. But what would be the algorithm that detects the amount of noise? That algorithm must be able to distinguish a fast rotation of the device from other noise. |
That didn't help for me. |
So I'd mark this as help wanted, currently I have no idea how to build an algorithm that adapts the " Maybe define a "max rotation speed" and adapt the factor somehow based on whether the current speed is above it or not... don't know. Keywords to search for in the web would probably include "adaptive low-pass filter" |
Just to note that it's very jittery for me too in SC on Huawei P30 Pro, but I almost always run in static north-is-up (or manually rotated) birds-eye view, so not quite a big deal here. You might want to look is |
what else than the magnetic sensor is used?? |
I have no idea, one would have to look into OsmAnd source. But AFAIR that was some directional API introduced in some android version that was also using more stuff like gyros and accelerators, so perhaps they meant that it is used instead of direct magnetic sensor reading? |
After some searching:
perhaps this helps explain it? |
Here's the relevant source: Registering — looks like they use both magnetic and accelerometer, if available Receiving updates — didn't read through this edit: math for updating values / kalman filter here: Android SensorManager docs: https://developer.android.com/reference/android/hardware/SensorManager |
Okay, thanks @smichel17. I don't get why there is even a setting for that in OsmAnd. The orientation sensor is software only (i.e. actually uses a combination of the geomagnetic and acceleration sensor in the background) and has been deprecated since Android 2.2 (Froyo)! The algorithm to smoothen the orientation in OsmAnd is exactly the same as in StreetComplete. The formula looks different, but just rearrange it and it is the same - minus the constant factor and the number of times per second it is called: With StreetComplete: // called 30 times per second
newValue = previousValue + 0.1 * (sensorValue - previousValue) OsmAnd: // called as many times per second as the sensor reports that the sensor value changed (much higher than 30 FPS)
newValue = (1 - 0.04) * previousValue + 0.04 * sensorValue In StreetComplete, it is limited to 30 FPS because every change in rotation can trigger a rerender of the map view (especially in the "uatomatic rotation 3d view") and we don't want to do that much more often than necessary. |
Maybe it'd just help then to reduce the constant to something around 0.04 like OSMAnd does? |
See
|
But anyway, the original request was not to smoothen the compass in general, but the rotation in that "follow my orientation view". So I added more smoothing for that. |
Use case
When I use the 3d view when locked to location, the map automatically rotates according to magnetic compass but this is reacting too fast / reacts to very small movements. This makes it difficult to tap on specific tasks since they move too quick.
Proposed Solution
Create a maximum rotation speed to slow down the rotation / make it rotate more smoothly.
The text was updated successfully, but these errors were encountered: