Apollo  6.0
Open source self driving car software
localization_gnss_process.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 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 
22 #pragma once
23 
24 #include <map>
25 
26 #include "Eigen/Core"
27 #include "Eigen/Geometry"
28 
29 #include "localization_msf/gnss_solver.h"
31 #include "modules/drivers/gnss/proto/gnss_raw_observation.pb.h"
33 
38 namespace apollo {
39 namespace localization {
40 namespace msf {
41 
42 union LeverArm {
43  double arm[3];
44  struct {
45  double arm_x;
46  double arm_y;
47  double arm_z;
48  };
49 };
50 
51 struct EphKey {
52  apollo::drivers::gnss::GnssType gnss_type;
53  unsigned int sat_prn;
54  // toe = eph.toe + eph.week_num * sec_per_week
55  double eph_toe;
56  static const int second_per_week = 604800;
57  EphKey(const apollo::drivers::gnss::GnssType type, const unsigned int prn,
58  double toe) {
59  gnss_type = type;
60  sat_prn = prn;
61  eph_toe = toe;
62  }
63  EphKey(const apollo::drivers::gnss::GnssType type, const unsigned int prn,
64  const unsigned int week_num, double toe) {
65  gnss_type = type;
66  sat_prn = prn;
67  eph_toe = toe + week_num * second_per_week;
68  }
69  EphKey() {
70  gnss_type = apollo::drivers::gnss::SYS_UNKNOWN;
71  sat_prn = 0;
72  eph_toe = -0.1;
73  }
74  bool operator<(const EphKey &key2) const {
75  if (gnss_type < key2.gnss_type) {
76  return true;
77  }
78  if (gnss_type == key2.gnss_type) {
79  if (sat_prn < key2.sat_prn) {
80  return true;
81  }
82  if (sat_prn == key2.sat_prn) {
83  return eph_toe < key2.eph_toe;
84  }
85  return false;
86  }
87  return false;
88  }
89  bool operator==(const EphKey &key2) const {
90  return (gnss_type == key2.gnss_type) && (sat_prn == key2.sat_prn) &&
91  (eph_toe == key2.eph_toe);
92  }
93  EphKey &operator=(const EphKey &key2) {
94  gnss_type = key2.gnss_type;
95  sat_prn = key2.sat_prn;
96  eph_toe = key2.eph_toe;
97  return *this;
98  }
99 };
100 
102  public:
106  // callback function for rostopic
107  // raw data' field "receiver_id" differs rover (= 0) from baser (= 1)
108  void RawObservationProcess(const drivers::gnss::EpochObservation &raw_obs);
109  void RawEphemerisProcess(const drivers::gnss::GnssEphemeris &gnss_orbit);
110  void IntegSinsPvaProcess(const InsPva &sins_pva, const double variance[9][9]);
111  LocalizationMeasureState GetResult(MeasureData *gnss_measure);
112 
113  private:
114  void SetDefaultOption();
115  // bool LoadHistoryEph(const std::string &nav_file);
116  bool DuplicateEph(const drivers::gnss::GnssEphemeris &raw_eph);
117 
118  inline void LogPnt(const GnssPntResultMsg &rover_pnt, double ratio);
119  bool GnssPosition(EpochObservationMsg *raw_rover_obs);
120 
121  private:
122  GnssSolver *gnss_solver_;
123  GnssPntResultMsg gnss_pnt_result_;
124 
125  bool enable_ins_aid_rtk_ = true;
126 
127  std::map<EphKey, drivers::gnss::GnssEphemeris> map_gnss_eph_;
128 
129  // from imu to gnss antenna
130  LeverArm gnss_lever_arm_;
131  // integrated-ins indicator
132  bool sins_align_finish_ = false;
133 
134  // deploy simple short-baseline to resolve heading
135  GnssSolver *double_antenna_solver_;
136 
137  // newest obs time
138  double current_obs_time_ = 0.0;
139 
140  LocalizationMeasureState gnss_state_;
141 };
142 
143 } // namespace msf
144 } // namespace localization
145 } // namespace apollo
bool operator==(const EphKey &key2) const
Definition: localization_gnss_process.h:89
Definition: localization_gnss_process.h:42
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
EphKey & operator=(const EphKey &key2)
Definition: localization_gnss_process.h:93
EphKey()
Definition: localization_gnss_process.h:69
double arm_z
Definition: localization_gnss_process.h:47
double arm_x
Definition: localization_gnss_process.h:45
LocalizationMeasureState
Definition: localization_params.h:129
unsigned int sat_prn
Definition: localization_gnss_process.h:53
apollo::drivers::gnss::GnssType gnss_type
Definition: localization_gnss_process.h:52
EphKey(const apollo::drivers::gnss::GnssType type, const unsigned int prn, double toe)
Definition: localization_gnss_process.h:57
Definition: localization_gnss_process.h:51
The class of LocalizationIntegParam.
bool operator<(const EphKey &key2) const
Definition: localization_gnss_process.h:74
bool Init(const char *binary_name)
double arm[3]
Definition: localization_gnss_process.h:43
Definition: localization_params.h:60
A general class to denote the return status of an API call. It can either be an OK status for success...
Definition: status.h:43
double eph_toe
Definition: localization_gnss_process.h:55
double arm_y
Definition: localization_gnss_process.h:46
Definition: localization_gnss_process.h:101
EphKey(const apollo::drivers::gnss::GnssType type, const unsigned int prn, const unsigned int week_num, double toe)
Definition: localization_gnss_process.h:63