Open boyang9602 opened 3 months ago
Describe the bug There are multiple implementations of GPS and UNIX time conversion in Apollo. The first is in https://github.com/ApolloAuto/apollo/blob/master/modules/common/util/time_util.h, the second is in https://github.com/ApolloAuto/apollo/blob/master/modules/drivers/gnss/util/time_conversion.h, the third is in https://github.com/ApolloAuto/apollo/blob/master/cyber/common/time_conversion.h, the last is in https://github.com/ApolloAuto/apollo/blob/master/modules/localization/msf/common/util/time_conversion.h.
To Reproduce Steps to reproduce the behavior: I compared the first three implementations with GPS time 1001696182.543048
1001696182.543048
#include <iostream> #include "time_util.h" // https://github.com/ApolloAuto/apollo/blob/master/modules/common/util/time_util.h #include "time_conversion.h" // https://github.com/ApolloAuto/apollo/blob/master/modules/drivers/gnss/util/time_conversion.h #include "time_conversion_new.h" // https://github.com/ApolloAuto/apollo/blob/master/cyber/common/time_conversion.h int main() { double gps_time = 1001696182.543048; // https://github.com/ApolloAuto/apollo/blob/master/modules/common/util/time_util.h double unix_time = TimeUtil::Gps2unix(gps_time); std::cout << "TimeUtil::Gps2unix\n\tGPS time: " << GLOG_TIMESTAMP(gps_time) << " -> Unix time: " << GLOG_TIMESTAMP(unix_time) << std::endl; // https://github.com/ApolloAuto/apollo/blob/master/modules/drivers/gnss/util/time_conversion.h unix_time = gps2unix(gps_time); std::cout << "gps2unix\n\tGPS time: " << GLOG_TIMESTAMP(gps_time) << " -> Unix time: " << GLOG_TIMESTAMP(unix_time) << std::endl; // https://github.com/ApolloAuto/apollo/blob/master/cyber/common/time_conversion.h unix_time = GpsToUnixSeconds(gps_time); std::cout << "GpsToUnixSeconds\n\tGPS time: " << GLOG_TIMESTAMP(gps_time) << " -> Unix time: " << GLOG_TIMESTAMP(unix_time) << std::endl; return 0; }
There is a 2 seconds diff, between time_util.h and time_conversion.h, as shown below
time_util.h
time_conversion.h
(msfloc) bo@apollo:~/projects/time_conversion$ ./a.out TimeUtil::Gps2unix GPS time: 1001696182.543048024 -> Unix time: 1317660965.543047905 gps2unix GPS time: 1001696182.543048024 -> Unix time: 1317660967.543047905 GpsToUnixSeconds GPS time: 1001696182.543048024 -> Unix time: 1317660967.543047905
Which one is correct?
Describe the bug There are multiple implementations of GPS and UNIX time conversion in Apollo. The first is in https://github.com/ApolloAuto/apollo/blob/master/modules/common/util/time_util.h, the second is in https://github.com/ApolloAuto/apollo/blob/master/modules/drivers/gnss/util/time_conversion.h, the third is in https://github.com/ApolloAuto/apollo/blob/master/cyber/common/time_conversion.h, the last is in https://github.com/ApolloAuto/apollo/blob/master/modules/localization/msf/common/util/time_conversion.h.
To Reproduce Steps to reproduce the behavior: I compared the first three implementations with GPS time
1001696182.543048
There is a 2 seconds diff, between
time_util.h
andtime_conversion.h
, as shown belowWhich one is correct?