English 中文(简体)
Android: GPS 时间戳(GPS) vs. Sensor Event Timertamp(GPS)
原标题:Android: GPS timestamp vs. SensorEvent Timestamp

我刚刚意识到,从GPS更新的位置中,你从GPS上和机体上得到的时间戳是自古以来的毫秒,而SensorEvent更新的时间戳(例如加速计)则是自启动以来的ns。

我想把GPS时间戳 转换成传感器Event时间戳的格式 有人知道这样做的好方法吗?

I tried the following: I measured once the time of system startup since epoch:

startupTime = System.currentTimeMillis() - SystemClock.uptimeMillis();

对于每个 GPS 更新的位置, 我减去启动时间 :

timestamp = loc.getTime() - startupTime;

但那些转换的时标仍不符合感应器Event时标,

问题回答

不要使用 < code> SystemClock. uptimeMillis () , 因为它测量了启动后的时间, 没有设备在睡眠模式中的时间 。 相反, 使用 < code> SystemClock. erounddRealtime () 。

目前我正在研究压力传感器事件的反应,报告的时间戳显示,自这个时代以来,纳米秒中似乎存在。如果你除以1000,000,你应该得到一个类似的值;这就是我在探究传感器值在毫秒中的年龄时所看到的情况。

我会将感应器日间时间印数除以1000000, 这应该能给您一个与定位天体提供的 GPS 相仿的数值 。

参考文献:

http://developer.android.com/reference/android/hardware/SensorEvent.html#timestamp (但不说明使用什么时钟)

http://developer.android.com/reference/java/lang/System.html#timeMillis()

http://developer.android.com/reference/android/location/location.html#getTime ()

个人而言,我只要在有 GPS 位置或传感器事件时打电话给 < code> System. putimeTimeMillis () , 并记录作为比较这些事件的适当时间戳。 它应该准确到几毫秒之内, 相对而言, 意思是, 除非感官事件发生在GPS固定的毫秒左右之内, 否则使用这个方法你总是能得到正确的“ 之前” 和“ 之后” 关系。 此外, 很难想象这些时间比几毫秒更准确的实际重要的任何应用, 所以这应该是一个简单而良好的技术 。

Loc.getTime () 与 gps 接收器不同, 与 System. puttenTimeMillis () 非常不同。 除非您试图设置您的电话时钟与所谓的“ gps time” 同步, 否则我会完全忽略 Loc. getTime () 。





相关问题
Change the date format in kibana

I am working for my internship on the implementation of the ElasticSearch family (ElasticSearch+ Kibana+ logstash). Here is my question: I have a field "@ timestamp" with the following format: 2014-05-...

Quickly getting to YYYY-mm-dd HH:MM:SS in Perl

When writing Perl scripts I frequently find the need to obtain the current time represented as a string formatted as YYYY-mm-dd HH:MM:SS (say 2009-11-29 14:28:29). In doing this I find myself taking ...

Sorting by unknown column type in mysql

So I ve got a users table; storing things like username, email, etc. I then have a user_settings table. Instead of standard columns like timestamp_logged_in, profile_views, etc., I have it organized ...

timestamp date today

Hi guys could you please help me with this. I know it is silly but can t find unswer anywhere: I have a query that shows events from the today time_stamp but I want to include today as well. How do I ...

connection time zone issue with jOra eclipse plugin

I started using the jOra eclipse plugin. The plugin seems pretty robust and I m hoping to stop using SQLDeveloper for 95% of my database needs. Many of our tables have columns of type TIMESTAMP ...

How to get a UNIVERSAL Windows batch file timestamp

I m having trouble generating a timestamp in a Windows batch file, because I get diferent date formats on different Windows versions. My machine: >echo %date% >Tue 11/17/2009 Friends machine: ...

热门标签