UAVCAN GNSS bridge: proper handling of various time bases

This commit is contained in:
Pavel Kirienko
2017-04-05 16:33:44 +03:00
committed by Lorenz Meier
parent 8e61ed9b77
commit 098b57534d
+27 -1
View File
@@ -319,7 +319,33 @@ void UavcanGnssBridge::process_fixx(const uavcan::ReceivedDataStructure<FixType>
report.vel_ned_valid = true;
report.timestamp_time_relative = 0;
report.time_utc_usec = uavcan::UtcTime(msg.gnss_timestamp).toUSec(); // Convert to microseconds
const std::uint64_t gnss_ts_usec = uavcan::UtcTime(msg.gnss_timestamp).toUSec();
switch (msg.gnss_time_standard) {
case FixType::GNSS_TIME_STANDARD_UTC: {
report.time_utc_usec = gnss_ts_usec;
break;
}
case FixType::GNSS_TIME_STANDARD_GPS: {
if (msg.num_leap_seconds > 0) {
report.time_utc_usec = gnss_ts_usec - msg.num_leap_seconds + 9;
}
break;
}
case FixType::GNSS_TIME_STANDARD_TAI: {
if (msg.num_leap_seconds > 0) {
report.time_utc_usec = gnss_ts_usec - msg.num_leap_seconds - 10;
}
break;
}
default: {
break;
}
}
report.satellites_used = msg.sats_used;