Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compass accuracy dilemma

I need to build compass for my application.

From reading the documentation it seems there are two reasonable ways of doing this:

  • Sensor.TYPE_ORIENTATION method: This is the easy way of doing it. The problem with this is it is not accurate. When I compare my reading with Snaptic Compass it is about 10-15 degress off which for my purposes is unacceptable.
  • Sensor.TYPE_ACCELEROMETER, Sensor.TYPE_MAGNETIC_FIELD and getRotationMatrix() in conjunction with remapCoordinateSystem() and getOrientation() method: The documentation says this "is usually more accurate". The problem is regardless of the delay I register with listener the compass goes crazy even when the device is stationary on flat surface.

Any suggestions for solving this problem will be greatly appreciated.

like image 734
mob1lejunkie Avatar asked May 04 '10 22:05

mob1lejunkie


2 Answers

Looks like mob1lejunkie has figured this out already, but just for future reference, let me mention that the issue here is magnetic declination (the difference between magnetic north and true north). You can try out an online model from NOAA to get a sense for what the difference is in your part of the world.

Android includes a model called GeomagneticField that can be used to compute the approximate declination given a latitude, longitude, and altitude. So, what I believe you need to do to compute true north is read out the azimuth value from Sensor.TYPE_ORIENTATION and then add to that GeomagneticField.getDeclination().

like image 150
Drew Dara-Abrams Avatar answered Oct 16 '22 08:10

Drew Dara-Abrams


It's the downside of compact parts made for phones. A $5000 IMU that we're using right now has an error of +/- 2 degrees and in that range it seems to go crazy as well.

Try stepping away from interference, metal surfaces, and see if it improves. If not, I hate to break the bad news, but that's the hardware.

Have you seen these?

http://developer.android.com/reference/android/hardware/SensorManager.html

http://groups.google.com/group/android-developers/browse_thread/thread/bbb0e8b97c673cf9/5c16bc2e49f6e972?lnk=raot

like image 37
Phil Salesses Avatar answered Oct 16 '22 07:10

Phil Salesses