Open aerostitch opened 10 years ago
AndroidCompasS.zip
(5.5 KiB)AndroidCompass.zip
(1.7 KiB)patch
AndroidCompass2.zip
(2.2 KiB)version 2 of android magn. compass
Hi, Untill someone (or myself) comes with a better solution, I made an entry in the Android popup menu (long tap) to toggle the magnetic compass on/off
attached version 2 patch
regards, Jan
Suggestion: how about falling back to the magnetic compass when the vehicle is moving slowly? That is, either slower than the threshold in navit.xml, or when the distance between the last two waypoints divided by error exceeds a certain value.
Replying to [comment:2 http://wiki.navit-project.org/index.php/user:mvglasow (2)]:
Suggestion: how about falling back to the magnetic compass when the vehicle is moving slowly? That is, either slower than the threshold in navit.xml, or when the distance between the last two waypoints divided by error exceeds a certain value.
This would be an ideal solution, but only if it can be controlled from the vehicleprofile. I want it enabled when profile bike is active, but when stopping in front of the traffic lights with my car I don't want the map to realign with magnetic compass, but other users may want to configure it in another way. The implementation should differ from the one that we already have in the pedestrian plugin, in the way that the processing of the raw magn. and accelero values should be done in the android layer, as my patch already does. Then if other platforms would want to implement a magnetic compass as well, the core C code does not have to be changed each time. Unfortunatly my knowledge of the navit code is not enough yet to do it all on my own, but it is slowly growing........
I agree that the vehicle code is best for handling the magnetic compass, as vehicle already incorporates the GPS code and is thus platform-specific anyway.
As for controlling compass use from
vehicleprofile
– fortunately, thestatic_speed
andstatic_distance
parameters (minimum speed and distance to previous position for Navit to process bearing from GPS) arevehicleprofile
-specific, so it shouldn't be too difficult to add another parameter here.However, I'd be interested to know why you don't want to fall back to the magnetic compass when stopping your car at a traffic light. Does that have to do with the reliability of the compass?
I know that the magnetic compass in a smartphone is not very reliable (I recently did a little experiment with a coworker in which we placed three phones on the table and compared compass readings, only to get three totally different ones.) GPS is reliable as long as the device is moving at a certain speed – in fact, even on a bike I find the GPS bearing is quite reliable as long as reception is good. It is only at walking speed that GPS bearing is of little use.
How about the following rudimentary calibration:
- Whenever we get a reliable bearing from the GPS (i.e. speed and distance to previous point exceeds the configured thresholds), compare it to the magnetic compass and store the difference.
- After a certain time without reliable bearing from GPS, use magnetic compass readings but apply the previously stored offset.
- If we never got a reliable bearing from GPS, assume the offset to be zero, i.e. use magnetic compass readings without compensation. (In this case we essentially have no choice.)
As long as the compass does not spontaneously drift or oscillate (i.e. change its bearing even when the device is not moving), this should prevent the map from suddenly jumping to some random orientation when you stop at a traffic light. Also, if you turn on the spot, the map orientation should update accordingly.
AndroidCompass3.diff
(7.0 KiB)third version of magnetic compass for Android Navit
Replying to [comment:4 http://wiki.navit-project.org/index.php/user:mvglasow (2)]:
However, I'd be interested to know why you don't want to fall back to the magnetic compass when stopping your car at a traffic light. Does that have to do with the reliability of the compass?
You more or less already gave the answer yourself :
I know that the magnetic compass in a smartphone is not very reliable (I recently did a little experiment with a coworker in which we placed three phones on the table and compared compass readings, only to get three totally different ones.) GPS is reliable as long as the device is moving at a certain speed – in fact, even on a bike I find the GPS bearing is quite reliable as long as reception is good. It is only at walking speed that GPS bearing is of little use.
How about the following rudimentary calibration:
- Whenever we get a reliable bearing from the GPS (i.e. speed and distance to previous point exceeds the configured thresholds), compare it to the magnetic compass and store the difference.
- After a certain time without reliable bearing from GPS, use magnetic compass readings but apply the previously stored offset.
- If we never got a reliable bearing from GPS, assume the offset to be zero, i.e. use magnetic compass readings without compensation. (In this case we essentially have no choice.)
As long as the compass does not spontaneously drift or oscillate (i.e. change its bearing even when the device is not moving), this should prevent the map from suddenly jumping to some random orientation when you stop at a traffic light. Also, if you turn on the spot, the map orientation should update accordingly.
But since it would be configurable from within the xml vehicleprofile, everyone could use it in his own way, but I would already be happy if a basic magnetic compass would be included. The calibration you propose would be nice as a project on it's own in follow- up of the basic magnetic compass.
In AndroidCompass3.diff I added a few lines to make the compass work in near-vertical positions as well. To use it: In the vehicle profile of your choice set static_speed en static_distance to zero. Run navit and select that profile. In the popup menu (long tap on Android screen), tap on 'enable magnetic compass' Now see the map align with the magnetic compass at each gps fix.
regards, Jan
I'm currently working on some logic to fuse locations from different sources. (Location, in this context, means position as well as speed, bearing and altitude.) My original intention was to have Navit fall back to network location when GPS becomes unavailable, but I have since come up with a skeleton which could use location information from any number of sources and is platform-independent.
The compass could, in this framework, just become another location source, supplying bearing but none of the other values.
Code is at: https://github.com/mvglasow/navit/tree/android-fused-location
Issue migrated from trac ticket # 1234
component: core | priority: minor | keywords: patches android compass
2014-08-13 01:58:22: @jandegr created the issue