Thursday, 15 January 2015

Android SensorEvent Timestamp constant -



Android SensorEvent Timestamp constant -

i'm writing simple android application calculate biases of devices imu. while doing i've come across problem value of event.timestamp

using code:

float dt = (event.timestamp-accel_timestamp)*ns2s;

from illustration @ android reference guide calculate rotation matrix quaternion.

when run code using galaxy nexus-s dt of 0.06~0.07 sec between measurements when run same code on lg nexus 4 or nexus 7 dt 0. i'm aware of question, android sensorevent timestamp issue nexus 7 timestamp unix timestamp difference between successive measurements shouldn't zero. nexus 4 , nexus 7 both have same imu bug in how timestamp created imu?

wow, ok certainly bug!

the timestamp of each sensorevent beingness overwritten if static variable...

when record string of timestamp when event occurs, values different.

the events stored in array unchanged.

every sensorevent in array has same timestamp, values arrays still different (i.e., they're not same object , contain different information... except timestamp).

google/htc, please homecoming 3 hours of life!

i'll go file bug report, unless can explain behaviour. it's not documented in api.

in meantime, try out solution:

import android.hardware.sensor; import android.hardware.sensorevent; public class unbrokensensorevent { public long timestamp; public float[] values; public sensor sensor; public unbrokensensorevent(sensorevent event){ this.timestamp = event.timestamp; this.values = event.values; this.sensor = event.sensor; } }

then in listener:

arraylist<unbrokensensorevent> results = new arraylist<unbrokensensorevent>(); public void onsensorchanged(sensorevent event) { results.add(new unbrokensensorevent(event)); }

the refactoring should quite easy, since sensorevent , unbrokensensorevent have same public fields. if need utilize other sensorevent functionality, go ahead , chuck unbroken version.

it's hacky, imho quick hack improve waiting api updated!

android timestamp unix-timestamp android-sensors nexus-4

No comments:

Post a Comment