umer0586 / SensorServer

Android app which let you stream various phone's sensors to websocket clients
GNU General Public License v3.0
278 stars 31 forks source link

Timestamps are different for gps and accelerometer data. #27

Closed davidribs closed 1 year ago

davidribs commented 1 year ago

For context, I'm trying to capture location and accelerometer data at the same time (separate packets) but the timestamp for accelerometer data is nanoseconds since reboot and the time associated with location is unix time. Most importantly, the sampling rate is different so I get about 1 gps coord for every 50 accelerometer reading. I would like for my data to be perfectly synced (I don't need perfect unix time just for both data to be taken at the same time)

TLDR is there some way (that isn't a boge on my end; not lazy btw I just trust a solution you make is more accurate in the end than mine) to get the same timestamp for both gps and accelerometer data (i.e. both unix or both nanoseconds since reboot) in a way that would be precise?

Appreciate your work btw 👍

umer0586 commented 1 year ago

Unfortunately, it's not possible to have the exact same timestamp for GPS and accelerometer data in the context you described. Android uses different APIs and callbacks for reading location sensors (such as GPS) and motion sensors (such as accelerometer), resulting in different timestamp and sampling rates.

davidribs commented 1 year ago

Thanks for explaining it isn't possible, hopefully my boge works well enough.