Compass for android (orientation in 3D space)

by mboehmer » Mon, 29 Dec 2008 18:19:14 GMT


Sponsored Links
 Hello,

mobile phones usually show the point of the compass, when people are
on the move (estimation of a vector from gps track). The API says,
that android is also able to get the point of the compass. How is this
done? Is this done by software (estimating the vector) or has the G1
an build-in magnetic hardware compass? If not, does anyone know, if it
is possible to connect a magnetic compass via USB or bluetooth?

I am interested in the orientation of the phone in 3D space, while the
user is standing still. Does anyone know, how wikitude (http://
www.youtube.com/watch?v=8EA8xlicmT8) does this?

Best regards
mboehmer

--~--~---------~--~----~------------~-------~--~----~



Compass for android (orientation in 3D space)

by DSmith » Mon, 29 Dec 2008 23:44:16 GMT


 The easiest way is to use SENSOR_ORIENTATION ( http://code.google.com/ 
android/reference/android/hardware/
SensorManager.html#SENSOR_ORIENTATION).  It does all the necessary
calculations on the magnetometer and accelerometer values, throws in
some low-pass filtering, and spits out azimuth, pitch, and roll.  The
calculations aren't perfect - you'll see some strange things at the
branch cuts, like the az spinning backwards through the entire range
when you raise the phone over your head, but it's pretty good for most
practical uses.
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Resuming activity occurs WindowManager$BadTokenException

Dears,
    This case isn't easy to reprocude, but it is really happened. It
seems onDestroy called before onResume. Would you please have some
advices? Thanks

08-21 01:16:10.648 W/WindowManager(   63): Attempted to add
application window with unknown token HistoryRecord{43c1f000
{com.android.mytest/com.android.mytest.TestActivity}}.  Aborting.
...
08-21 01:16:14.387 D/AndroidRuntime(11190): Shutting down VM
...
08-21 01:16:22.048 E/AndroidRuntime(11190): android.view.WindowManager
$BadTokenException: Unable to add window -- token
android.os.binderpr...@43a9ba30 is not valid; is your activity
running?
08-21 01:16:22.048 E/AndroidRuntime(11190):     at
android.view.ViewRoot.setView(ViewRoot.java:428)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at
android.view.WindowManagerImpl.addView(WindowManagerImpl.java:178)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at
android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at android.view.Window
$LocalWindowManager.addView(Window.java:392)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at
android.app.ActivityThread.handleResumeActivity(ActivityThread.java:
2674)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2287)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at
android.app.ActivityThread.access$1800(ActivityThread.java:112)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at
android.os.Handler.dispatchMessage(Handler.java:99)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at android.os.Looper.loop
(Looper.java:123)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at
android.app.ActivityThread.main(ActivityThread.java:3948)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at
java.lang.reflect.Method.invokeNative(Native Method)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at
java.lang.reflect.Method.invoke(Method.java:521)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:782)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
08-21 01:16:22.048 E/AndroidRuntime(11190):     at
dalvik.system.NativeStart.main(Native Method)

--~--~---------~--~----~------------~-------~--~----~

2. Auto Reply from David Kang of Crucialtec

someone stuck in recursive loop ?

2009/8/25 <da...@crucialtec.com>


--~--~---------~--~----~------------~-------~--~----~

3. backgroundservice

4. Error Publishing Upgrade of an Application

5. Minor in Android Developer Challenge

6. OMAP3 U-Boot problem

7. How to make WebView do a Vertical Scroll ?