Apollo 10.0
自动驾驶开放平台
gnss_compensator.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
19
20namespace apollo {
21namespace localization {
22
23LocalizationGnssCompensator::LocalizationGnssCompensator() {}
24
26
28 const uint64_t& current_send_tf_time, uint64_t* measurement_time) {
29 // Sometimes GNSS does not return valid timestamp
30 // The following logic is to compensate the invalid timestamp of GNSS
31 // we use 3 variables to make this compensation
32 // last_valid_gnss_time_: Time parsed from last valid GNSS data
33 // last_send_tf_time_: Time of the last tf sent
34 // last_compensated_gnss_time_: Time of compensated gnss time
35 uint64_t compensated_delta;
36 if (last_valid_gnss_time_ != 0 && last_send_tf_time_ != 0) {
37 // calculate delta
38 compensated_delta = current_send_tf_time - last_send_tf_time_;
39 // If exceed the tolerance range and the measurement time
40 // is less than or equal to the last valid GNSS time, the
41 // GNSS data is considered invalid.
42 if (compensated_delta >=
43 static_cast<uint64_t>(FLAGS_gps_imu_compensate_ns_tolerance) &&
44 *measurement_time <= last_valid_gnss_time_) {
45 // Record the time of compensation for use in case
46 // the next GNSS data is also invalid
47 last_compensated_gnss_time_ =
48 last_compensated_gnss_time_+ compensated_delta;
49 AINFO << "enter compensator: " << "last valid gnss time: " <<
50 last_valid_gnss_time_ << ", " << "measurement time: " <<
51 *measurement_time << ", " << "measurement time after compensated: " <<
52 last_compensated_gnss_time_;
53 // only compensate when the flag is true
54 if (FLAGS_enable_gps_imu_compensate)
55 *measurement_time = last_compensated_gnss_time_;
56 } else {
57 // If the GNSS data is valid, simply record it
58 last_valid_gnss_time_ = *measurement_time;
59 last_compensated_gnss_time_ = *measurement_time;
60 }
61 } else {
62 // Initialize
63 last_valid_gnss_time_ = *measurement_time;
64 last_compensated_gnss_time_ = *measurement_time;
65 }
66 last_send_tf_time_ = current_send_tf_time;
67}
68
69} // namespace localization
70} // namespace apollo
void ProcessCompensation(const uint64_t &current_send_tf_time, uint64_t *measurement_time)
compensate the time parsed from invalid GNSS data
The gflags used by localization module
#define AINFO
Definition log.h:42
class register implement
Definition arena_queue.h:37