Apollo  6.0
Open source self driving car software
rtcm_decode.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2017 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 
17 #pragma once
18 
19 #include <rtklib.h>
20 #include "modules/drivers/gnss/proto/gnss_raw_observation.pb.h"
21 
22 namespace apollo {
23 namespace drivers {
24 namespace gnss {
25 
26 static inline int baud_obs_num(int type) {
27  switch (type) {
28  case 1002: // gps L1 only
29  return 1;
30 
31  case 1004: // gps L1/L1
32  return 2;
33 
34  case 1010: // glonass L1 only
35  return 0;
36 
37  case 1012: // glonass L1 & L2
38  return 2;
39 
40  case 1125:
41  case 1005: // station arp, for pose, no antenna height
42  case 1006: // station arp, with antenna height
43  case 1007: // antenna descriptor
44  case 1008: // antenna descriptor& serial number
45  case 1019: // gps ephemerides
46  case 1020: // glonass ephemerides
47  case 1033: // receiver and antenna descriptor, for station
48  case 1044: // qzss ephemerides
49  case 1045: // galileo
50  default:
51  return 0;
52  }
53 }
54 
55 static inline bool gnss_sys(int message_type,
56  apollo::drivers::gnss::GnssType* gnss_type) {
57  switch (message_type) {
58  case 1019: // gps ephemerides
59  *gnss_type = apollo::drivers::gnss::GnssType::GPS_SYS;
60  break;
61 
62  case 1020: // glonass ephemerides
63  *gnss_type = apollo::drivers::gnss::GnssType::GLO_SYS;
64  break;
65 
66  case 1045: // galileo ephemerides
67  *gnss_type = apollo::drivers::gnss::GnssType::GAL_SYS;
68  break;
69 
70  case 1047: // beidou ephemerides
71  *gnss_type = apollo::drivers::gnss::GnssType::BDS_SYS;
72  break;
73 
74  case 1044: // qzss ephemerides
75  default:
76  return false;
77  }
78  return true;
79 }
80 
81 static inline bool gnss_sys_type(int sys_id,
82  apollo::drivers::gnss::GnssType* gnss_type) {
83  switch (sys_id) {
84  case SYS_GPS:
85  *gnss_type = apollo::drivers::gnss::GnssType::GPS_SYS;
86  break;
87 
88  case SYS_CMP:
89  *gnss_type = apollo::drivers::gnss::GnssType::BDS_SYS;
90  break;
91 
92  case SYS_GLO:
93  *gnss_type = apollo::drivers::gnss::GnssType::GLO_SYS;
94  break;
95 
96  case SYS_GAL:
97  *gnss_type = apollo::drivers::gnss::GnssType::GAL_SYS;
98  break;
99 
100  default:
101  AINFO << "Not support sys id: " << sys_id;
102  return false;
103  }
104  return true;
105 }
106 
107 static inline bool gnss_baud_id(apollo::drivers::gnss::GnssType sys_type,
108  int seq,
109  apollo::drivers::gnss::GnssBandID* baud_id) {
110  switch (sys_type) {
111  case apollo::drivers::gnss::GnssType::GPS_SYS:
112  if (seq == 0) {
113  *baud_id = apollo::drivers::gnss::GnssBandID::GPS_L1;
114  } else if (seq == 1) {
115  *baud_id = apollo::drivers::gnss::GnssBandID::GPS_L2;
116  } else if (seq == 2) {
117  *baud_id = apollo::drivers::gnss::GnssBandID::GPS_L5;
118  } else {
119  AINFO << "Not support gps baud seq : " << seq;
120  return false;
121  }
122  break;
123 
124  case apollo::drivers::gnss::GnssType::BDS_SYS:
125  if (seq == 0) {
126  *baud_id = apollo::drivers::gnss::GnssBandID::BDS_B1;
127  } else if (seq == 1) {
128  *baud_id = apollo::drivers::gnss::GnssBandID::BDS_B2;
129  } else if (seq == 2) {
130  *baud_id = apollo::drivers::gnss::GnssBandID::BDS_B3;
131  } else {
132  AINFO << "Not support beidou baud seq : " << seq;
133  return false;
134  }
135  break;
136 
137  case apollo::drivers::gnss::GnssType::GLO_SYS:
138  if (seq == 0) {
139  *baud_id = apollo::drivers::gnss::GnssBandID::GLO_G1;
140  } else if (seq == 1) {
141  *baud_id = apollo::drivers::gnss::GnssBandID::GLO_G2;
142  } else {
143  AINFO << "Not support beidou glonass seq : " << seq;
144  return false;
145  }
146  break;
147 
148  default:
149  AINFO << "Not support sys " << static_cast<int>(sys_type) << ", seq "
150  << seq;
151  return false;
152  }
153  return true;
154 }
155 
156 static inline bool gnss_time_type(
157  apollo::drivers::gnss::GnssType sys_type,
158  apollo::drivers::gnss::GnssTimeType* time_type) {
159  switch (sys_type) {
160  case apollo::drivers::gnss::GnssType::GPS_SYS:
161  *time_type = apollo::drivers::gnss::GnssTimeType::GPS_TIME;
162  break;
163 
164  case apollo::drivers::gnss::GnssType::BDS_SYS:
165  *time_type = apollo::drivers::gnss::GnssTimeType::BDS_TIME;
166  break;
167 
168  case apollo::drivers::gnss::GnssType::GLO_SYS:
169  *time_type = apollo::drivers::gnss::GnssTimeType::GLO_TIME;
170  break;
171 
172  case apollo::drivers::gnss::GnssType::GAL_SYS:
173  *time_type = apollo::drivers::gnss::GnssTimeType::GAL_TIME;
174  break;
175 
176  default:
177  AINFO << "Not support sys " << static_cast<int>(sys_type);
178  return false;
179  }
180  return true;
181 }
182 
183 } // namespace gnss
184 } // namespace drivers
185 } // namespace apollo
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
#define AINFO
Definition: log.h:42