Orientation Sensor and getRotationMatrix() problems.

Put your problem here if it does not fit any of the other categories.

Orientation Sensor and getRotationMatrix() problems.

Postby lgmcben » Sat Aug 01, 2009 11:57 am

Orientation Sensor return false values. And getRotationMatrix() also doesn't work. May be my ADP1 broke?

I have 2 main questions:

Question 1. Orientation Sensor return false values. Or my dev phone 1
broke?

The 'pitch' value skip between around 70 to 110.

Please take a look at the log:

08-01 15:37:38.170: DEBUG/onSensorChanged(1653): Pitch: -67.0
08-01 15:37:38.210: DEBUG/onSensorChanged(1653): Pitch: -67.0
08-01 15:37:38.250: DEBUG/onSensorChanged(1653): Pitch: -67.0
08-01 15:37:38.290: DEBUG/onSensorChanged(1653): Pitch: -68.0
08-01 15:37:38.330: DEBUG/onSensorChanged(1653): Pitch: -69.0
08-01 15:37:38.420: DEBUG/onSensorChanged(1653): Pitch: -110.0
08-01 15:37:38.460: DEBUG/onSensorChanged(1653): Pitch: -111.0
08-01 15:37:38.500: DEBUG/onSensorChanged(1653): Pitch: -111.0
08-01 15:37:38.590: DEBUG/onSensorChanged(1653): Pitch: -111.0
08-01 15:37:38.750: DEBUG/onSensorChanged(1653): Pitch: -112.0
08-01 15:37:38.790: DEBUG/onSensorChanged(1653): Pitch: -112.0
08-01 15:37:38.830: DEBUG/onSensorChanged(1653): Pitch: -112.0
08-01 15:37:38.880: DEBUG/onSensorChanged(1653): Pitch: -112.0
08-01 15:37:38.920: DEBUG/onSensorChanged(1653): Pitch: -69.0
08-01 15:37:39.000: DEBUG/onSensorChanged(1653): Pitch: -68.0
08-01 15:37:39.040: DEBUG/onSensorChanged(1653): Pitch: -68.0
08-01 15:37:39.120: DEBUG/onSensorChanged(1653): Pitch: -68.0
08-01 15:37:39.200: DEBUG/onSensorChanged(1653): Pitch: -68.0

my code does nothing but to print out the values:
//
public void onSensorChanged(SensorEvent event) {
int type = event.sensor.getType();
switch(type){
case Sensor.TYPE_ORIENTATION:
Log.d("onSensorChanged", "Azimuth: " + event.values[0] + ", Pitch: " +
event.values[1] + ", Roll: " + event.values[2]);
}

//


Question 2. How to get the "getRotationMatrix()" to work?

I read the SensorEvent docs and notice this:
"Note: It is preferable to use getRotationMatrix() in conjunction with
remapCoordinateSystem() and getOrientation() to compute these values;
while it may be more expensive, it is usually more accurate."

So I think may be this can help me with my sensor problem in question
1.

So I tried using it and it always return false. (not successful and
nothing is filled in R[])

I made sure I give it correct set of parameters. (R[], I[],
valuesFromAccelSensor[], valuesFromMagneticSensor[])

I tried both 9 and 16 sizes arrays for both R and I. The method still
return false.

Thank you in advance! =)
lgmcben
Junior Developer
Junior Developer
 
Posts: 24
Joined: Mon Nov 17, 2008 5:06 am

Top

*** Solved ***

Postby lgmcben » Sun Aug 02, 2009 5:45 am

*** Solved ***

I read this blog:
http://mysticlakesoftware.blogspot.com/

and try what he suggested:

changing

case Sensor.TYPE_MAGNETIC_FIELD:
mag = event.values;

to

case Sensor.TYPE_MAGNETIC_FIELD:
mag = event.values.clone();

for all sensor types. Now the getRotationMatrix works. Thank you. =)
lgmcben
Junior Developer
Junior Developer
 
Posts: 24
Joined: Mon Nov 17, 2008 5:06 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 11 guests