android phone facing direction after rotation with sensor info

28 Views Asked by At

I've got log files of android phones to analyze and I'm trying to find the facing direction of the phone. The log has 4 columns: log_entry, time, key, value. I removed some irrelevant entries, keeping the sensor data here:

1046    2015-10-27T17:37:12.126 sensor|magneticField|raw    20.5307,27.912903,-19.042969
1059    2015-10-27T17:37:12.682 sensor|gravity|raw  -3.44763,4.310282,8.105906
1060    2015-10-27T17:37:12.702 sensor|rotationVector|raw   0.2927694,-0.031621482,-0.6736214
1061    2015-10-27T17:37:12.703 sensor|orientation|raw  84.45444,-28.001629,-20.582787
1243    2015-10-27T17:37:13.704 sensor|gyroscope|window 5,0.3242262085071154,0.002710102285323411,0.018316363364503215,0.12471347618924414,0.040062330625930336
1245    2015-10-27T17:37:13.767 sensor|accelerometer|window 4,36.81831910465795,3.154611784990185E-4,9.183022166921088,9.226166408993787,9.204565264371539
2413    2015-10-27T17:41:39.841 sensor|magneticField|raw    26.080322,-127.63672,-39.442444
2596    2015-10-27T17:41:40.410 sensor|gravity|raw  -1.1501468,-0.40935522,9.730364
2597    2015-10-27T17:41:40.419 sensor|rotationVector|raw   -0.04232129,0.045808677,0.39225417
2598    2015-10-27T17:41:40.420 sensor|orientation|raw  313.85678,2.4090059,-6.735284
2604    2015-10-27T17:41:41.171 sensor|accelerometer|window 4,38.62983172205982,1.1600939884971153E-5,9.654755016756964,9.662419888064361,9.656328408619245
3097    2015-10-27T17:46:39.931 sensor|magneticField|raw    26.080322,-127.63672,-39.442444
3110    2015-10-27T17:46:40.537 sensor|gravity|raw  -0.8883529,-0.4162266,9.757458
3111    2015-10-27T17:46:40.544 sensor|rotationVector|raw   -0.048620816,0.012006509,0.77643335
3112    2015-10-27T17:46:40.548 sensor|orientation|raw  258.063,2.442601,-5.197365
3117    2015-10-27T17:46:41.250 sensor|accelerometer|window 4,38.623687629591316,1.0130627960113626E-5,9.65307327903755,9.660463074509671,9.655075638022051
3287    2015-10-27T17:46:41.471 sensor|gyroscope|window 5,0.006274198991127779,8.64517812319579E-8,0.0010331000292853245,0.00176118421374848,0.001177697815335539

I did some searching and it's said that the rotationVector could be enough. I read the answer in https://math.stackexchange.com/questions/2253071/convert-quaternion-to-vector/2253214 but the quaternion has 4 values (wxyz) while rotationVector here has 3 (xyz).

It also needs an initial position before the rotation to determine the final position. I can't find anything mentioning that in android API docs. I'm not sure whether the initial position will iterate or not. Is the second rotationVector taking the position after last rotation as reference or is there a fixed initial position?

Thanks for any help!

0

There are 0 best solutions below