parsing_utils.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2017, Southwest Research Institute® (SwRI®)
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL SOUTHWEST RESEARCH INSTITUTE BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //
28 // *****************************************************************************
29 
30 #ifndef NOVATEL_GPS_DRIVER_BASE_PARSER_H
31 #define NOVATEL_GPS_DRIVER_BASE_PARSER_H
32 
33 #include <novatel_gps_msgs/NovatelMessageHeader.h>
34 
35 #include <novatel_gps_msgs/NovatelExtendedSolutionStatus.h>
36 
37 #include <novatel_gps_msgs/NovatelSignalMask.h>
38 
39 #include <stdint.h>
40 
45 namespace novatel_gps_driver
46 {
47  const size_t NOVATEL_MESSAGE_HEADER_LENGTH = 10;
48 
49  const size_t MAX_SOLUTION_STATUS = 22;
50  const std::string SOLUTION_STATUSES[] = {
51  "SOL_COMPUTED", "INSUFFICIENT_OBS", "NO_CONVERGENCE", "SINGULARITY", "COV_TRACE",
52  "TEST_DIST", "COLD_START", "V_H_LIMIT", "VARIANCE", "RESIDUALS",
53  "RESERVED", "RESERVED", "RESERVED", "INTEGRITY_WARNING", "RESERVED",
54  "RESERVED", "RESERVED", "RESERVED", "PENDING", "INVALID_FIX",
55  "UNAUTHORIZED", "RESERVED", "INVALID_RATE"};
56  const size_t MAX_POSITION_TYPE = 80;
57  const std::string POSITION_TYPES[] = {
58  "NONE", "FIXEDPOS", "FIXEDHEIGHT", "RESERVED", "FLOATCONV",
59  "WIDELANE", "NARROWLANE", "RESERVED", "DOPPLER_VELOCITY", "RESERVED",
60  "RESERVED", "RESERVED", "RESERVED", "RESERVED", "RESERVED",
61  "RESERVED", "SINGLE", "PSRDIFF", "WAAS", "PROPOGATED",
62  "RESERVED", "RESERVED", "RESERVED", "RESERVED", "RESERVED",
63  "RESERVED", "RESERVED", "RESERVED", "RESERVED", "RESERVED",
64  "RESERVED", "RESERVED", "L1_FLOAT", "IONOFREE_FLOAT", "NARROW_FLOAT",
65  "RESERVED", "RESERVED", "RESERVED", "RESERVED", "RESERVED",
66  "RESERVED", "RESERVED", "RESERVED", "RESERVED", "RESERVED",
67  "RESERVED", "RESERVED", "RESERVED", "L1_INT", "WIDE_INT",
68  "NARROW_INT", "RTK_DIRECT_INS", "INS_SBAS", "INS_PSRSP", "INS_PSRDIFF",
69  "INS_RTKFLOAT", "INS_RTKFIXED", "RESERVED", "RESERVED", "RESERVED",
70  "RESERVED", "RESERVED", "RESERVED", "RESERVED", "RESERVED", "RESERVED",
71  "RESERVED", "RESERVED", "RESERVED", "PPP_CONVERGING", "PPP",
72  "OPERATIONAL", "WARNING", "OUT_OF_BOUNDS", "INS_PPP_CONVERGING", "INS_PPP",
73  "UNKNOWN", "UNKNOWN", "PPP_BASIC_CONVERGING", "PPP_BASIC", "INS_PPP_BASIC",
74  "INS_PPP_BASIC_CONVERGING"};
75  const size_t MAX_DATUM = 86;
76  const std::string DATUMS[] = {
77  "BLANK",
78  "ADIND", "ARC50", "ARC60", "AGD66", "AGD84", "BUKIT", "ASTRO", "CHATM", "CARTH", "CAPE",
79  "DJAKA", "EGYPT", "ED50", "ED79", "GUNSG", "GEO49", "GRB36", "GUAM", "HAWAII", "KAUAI",
80  "MAUI", "OAHU", "HERAT", "HJORS", "HONGK", "HUTZU", "INDIA", "IRE65", "KERTA", "KANDA",
81  "LIBER", "LUZON", "MINDA", "MERCH", "NAHR", "NAD83", "CANADA", "ALASKA", "NAD27", "CARIBB",
82  "MEXICO", "CAMER", "MINNA", "OMAN", "PUERTO", "QORNO", "ROME", "CHUA", "SAM56", "SAM69",
83  "CAMPO", "SACOR", "YACAR", "TANAN", "TIMBA", "TOKYO", "TRIST", "VITI", "WAK60", "WGS72",
84  "WGS84", "ZANDE", "USER", "CSRS", "ADIM", "ARSM", "ENW", "HTN", "INDB", "INDI",
85  "IRL", "LUZA", "LUZB", "NAHC", "NASP", "OGBM", "OHAA", "OHAB", "OHAC", "OHAD",
86  "OHIA", "OHIB", "OHIC", "OHID", "TIL", "TOYM"};
87  const std::string PORT_IDENTIFIERS[] = {
88  "NO_PORTS", "COM1_ALL", "COM2_ALL", "COM3_ALL", "UNUSED", "UNUSED", "THISPORT_ALL", "FILE_ALL", "ALL_PORTS",
89  "XCOM1_ALL", "XCOM2_ALL", "UNUSED", "UNUSED", "USB1_ALL", "USB2_ALL", "USB3_ALL", "AUX_ALL", "XCOM3_ALL",
90  "UNUSED", "COM4_ALL", "ETH1_ALL", "IMU_ALL", "UNUSED", "ICOM1_ALL", "ICOM2_ALL", "ICOM3_ALL", "NCOM1_ALL",
91  "NCOM2_ALL", "NCOM3_ALL", "ICOM4_ALL", "WCOM1_ALL", "UNUSED", "COM1", "COM1_1", "COM1_2", "COM1_3", "COM1_4",
92  "COM1_5", "COM1_6", "COM1_7", "COM1_8", "COM1_9", "COM1_10", "COM1_11", "COM1_12", "COM1_13", "COM1_14",
93  "COM1_15", "COM1_16", "COM1_17", "COM1_18", "COM1_19", "COM1_20", "COM1_21", "COM1_22", "COM1_23", "COM1_24",
94  "COM1_25", "COM1_26", "COM1_27", "COM1_28", "COM1_29", "COM1_30", "COM1_31", "COM2", "COM2_1", "COM2_2", "COM2_3",
95  "COM2_4", "COM2_5", "COM2_6", "COM2_7", "COM2_8", "COM2_9", "COM2_10", "COM2_11", "COM2_12", "COM2_13", "COM2_14",
96  "COM2_15", "COM2_16", "COM2_17", "COM2_18", "COM2_19", "COM2_20", "COM2_21", "COM2_22", "COM2_23", "COM2_24",
97  "COM2_25", "COM2_26", "COM2_27", "COM2_28", "COM2_29", "COM2_30", "COM2_31", "COM3", "COM3_1", "COM3_2", "COM3_3",
98  "COM3_4", "COM3_5", "COM3_6", "COM3_7", "COM3_8", "COM3_9", "COM3_10", "COM3_11", "COM3_12", "COM3_13", "COM3_14",
99  "COM3_15", "COM3_16", "COM3_17", "COM3_18", "COM3_19", "COM3_20", "COM3_21", "COM3_22", "COM3_23", "COM3_24",
100  "COM3_25", "COM3_26", "COM3_27", "COM3_28", "COM3_29", "COM3_30", "COM3_31", "UNUSED", "UNUSED", "UNUSED",
101  "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED",
102  "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED",
103  "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "SPECIAL", "SPECIAL_1", "SPECIAL_2",
104  "SPECIAL_3", "SPECIAL_4", "SPECIAL_5", "SPECIAL_6", "SPECIAL_7", "SPECIAL_8", "SPECIAL_9", "SPECIAL_10",
105  "SPECIAL_11", "SPECIAL_12", "SPECIAL_13", "SPECIAL_14", "SPECIAL_15", "SPECIAL_16", "SPECIAL_17", "SPECIAL_18",
106  "SPECIAL_19", "SPECIAL_20", "SPECIAL_21", "SPECIAL_22", "SPECIAL_23", "SPECIAL_24", "SPECIAL_25", "SPECIAL_26",
107  "SPECIAL_27", "SPECIAL_28", "SPECIAL_29", "SPECIAL_30", "SPECIAL_31", "THISPORT", "THISPORT_1", "THISPORT_2",
108  "THISPORT_3", "THISPORT_4", "THISPORT_5", "THISPORT_6", "THISPORT_7", "THISPORT_8", "THISPORT_9", "THISPORT_10",
109  "THISPORT_11", "THISPORT_12", "THISPORT_13", "THISPORT_14", "THISPORT_15", "THISPORT_16", "THISPORT_17",
110  "THISPORT_18", "THISPORT_19", "THISPORT_20", "THISPORT_21", "THISPORT_22", "THISPORT_23", "THISPORT_24",
111  "THISPORT_25", "THISPORT_26", "THISPORT_27", "THISPORT_28", "THISPORT_29", "THISPORT_30", "THISPORT_31", "FILE",
112  "FILE_1", "FILE_2", "FILE_3", "FILE_4", "FILE_5", "FILE_6", "FILE_7", "FILE_8", "FILE_9", "FILE_10", "FILE_11",
113  "FILE_12", "FILE_13", "FILE_14", "FILE_15", "FILE_16", "FILE_17", "FILE_18", "FILE_19", "FILE_20", "FILE_21",
114  "FILE_22", "FILE_23", "FILE_24", "FILE_25", "FILE_26", "FILE_27", "FILE_28", "FILE_29", "FILE_30", "FILE_31"};
115 
116  double ConvertDmsToDegrees(double dms);
117 
119  uint32_t status,
120  novatel_gps_msgs::NovatelExtendedSolutionStatus& msg);
121 
122 
124  uint32_t status,
125  novatel_gps_msgs::NovatelReceiverStatus& receiver_status_msg);
126 
127  void GetSignalsUsed(
128  uint32_t mask,
129  novatel_gps_msgs::NovatelSignalMask& msg);
130 
140  double ParseDouble(const uint8_t* buffer);
141 
149  bool ParseDouble(const std::string& string, double& value);
150 
160  float ParseFloat(const uint8_t* buffer);
161 
169  bool ParseFloat(const std::string& string, float& value);
170 
180  int16_t ParseInt16(const uint8_t* buffer);
181 
190  bool ParseInt16(const std::string& string, int16_t& value, int32_t base = 10);
191 
201  int32_t ParseInt32(const uint8_t* buffer);
202 
211  bool ParseInt32(const std::string& string, int32_t& value, int32_t base = 10);
212 
221  bool ParseUInt8(const std::string& string, uint8_t& value, int32_t base = 10);
222 
232  uint16_t ParseUInt16(const uint8_t* buffer);
233 
242  bool ParseUInt16(const std::string& string, uint16_t& value, int32_t base = 10);
243 
253  uint32_t ParseUInt32(const uint8_t* buffer);
254 
263  bool ParseUInt32(const std::string& string, uint32_t& value, int32_t base = 10);
264 
265  double UtcFloatToSeconds(double utc_float);
266 }
267 
268 #endif //NOVATEL_GPS_DRIVER_BASE_PARSER_H
void GetNovatelReceiverStatusMessage(uint32_t status, novatel_gps_msgs::NovatelReceiverStatus &receiver_status_msg)
msg
uint16_t ParseUInt16(const uint8_t *buffer)
Converts a buffer containing 2 bytes into an unsigned 16-bit int.
const std::string PORT_IDENTIFIERS[]
Definition: parsing_utils.h:87
bool ParseUInt8(const std::string &string, uint8_t &value, int32_t base=10)
Parses a string containing an integer number into a uint16_t.
const size_t MAX_POSITION_TYPE
Definition: parsing_utils.h:56
const std::string DATUMS[]
Definition: parsing_utils.h:76
const size_t NOVATEL_MESSAGE_HEADER_LENGTH
Definition: parsing_utils.h:47
double ParseDouble(const uint8_t *buffer)
Converts a buffer containing 8 bytes into a double.
const std::string POSITION_TYPES[]
Definition: parsing_utils.h:57
uint32_t ParseUInt32(const uint8_t *buffer)
Converts a buffer containing 4 bytes into an unsigned 32-bit int.
float ParseFloat(const uint8_t *buffer)
Converts a buffer containing 4 bytes into a float.
const std::string SOLUTION_STATUSES[]
Definition: parsing_utils.h:50
void GetExtendedSolutionStatusMessage(uint32_t status, novatel_gps_msgs::NovatelExtendedSolutionStatus &msg)
int32_t ParseInt32(const uint8_t *buffer)
Converts a buffer containing 4 bytes into a signed 32-bit int.
void GetSignalsUsed(uint32_t mask, novatel_gps_msgs::NovatelSignalMask &msg)
const size_t MAX_SOLUTION_STATUS
Definition: parsing_utils.h:49
double UtcFloatToSeconds(double utc_float)
double ConvertDmsToDegrees(double dms)
const size_t MAX_DATUM
Definition: parsing_utils.h:75
int16_t ParseInt16(const uint8_t *buffer)
Converts a buffer containing 2 bytes into a signed 16-bit int.


novatel_gps_driver
Author(s):
autogenerated on Wed Jul 3 2019 19:36:46