I need to make an app to find the orientation of the phone. Some use case which I want to test are
- how much of the time the phone is used in reading position (held flat)
- how much of the time it is used for making calls (vertical).
- How much of the time it is held in pocket.
I assume I should be able to get all this from orientation sensors. I need to mention here that I have recently started andriod development so I would prefer that the solution assumes raw data from sensors such that it can be processed in Matlab later. Infact a colleague is helping me in andriod development.
I used the standard way of doing it. Method :1
if (SensorManager.getRotationMatrix(rotationMatrix, null, accelerationValues, geoMagnetValues)) {
SensorManager.getOrientation(rotationMatrix, orientation);
Roll and azimuth were OK in the range -pi to pi but as pointed in Android Compass that can Compensate for Tilt and Pitch pitch was in the range -pi/2 to pi/2 and I was having problem handling this. So I bumped into the code at Android Compass that can Compensate for Tilt and Pitch. I have just used it without the screen rotation adjustment. I have a few queries. Pitch as defined in Android Compass that can Compensate for Tilt and Pitch is different than what I get by method:1 in that when I tilt the phone right-wards the pitch value changes whereas it should not change. In fact it corresponds to roll value of method 1. However when I turn my phone left the pitch by the method in Android Compass that can Compensate for Tilt and Pitch gives roll value but with a different sign. Azimuth is OK. Finally m_pitch_axis_radians I could totally not comprehend. I know I am having some problem in interpreting this different coordinate system but if I could get a hint as to how the pitch , roll and azimuth in Method :1 relate to the method in Android Compass that can Compensate for Tilt and Pitch I shall be thankful