MRPT  1.9.9
gnss_messages_ascii_nmea.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "obs-precomp.h" // Precompiled headers
11 
13 #include <iostream>
14 
15 using namespace std;
16 using namespace mrpt::obs::gnss;
17 
18 // ---------------------------------------
19 Message_NMEA_GGA::content_t::content_t() : UTCTime() {}
20 void Message_NMEA_GGA::dumpToStream(std::ostream& out) const
21 {
22  out << "[NMEA GGA datum]\n";
23  out << mrpt::format(
24  " Longitude: %.09f deg Latitude: %.09f deg Height: %.03f m\n",
27 
28  out << mrpt::format(
29  " Geoidal distance: %.03f m Orthometric alt.: %.03f m Corrected "
30  "ort. alt.: %.03f m\n",
33 
34  out << mrpt::format(
35  " UTC time-stamp: %02u:%02u:%02.03f #sats=%2u ", fields.UTCTime.hour,
37 
38  out << mrpt::format("Fix mode: %u ", fields.fix_quality);
39 
40  const char* fix_names[] = {"0:Invalid",
41  "1:GPS fix",
42  "2:DGPS fix",
43  "3:PPS fix",
44  "4:RTK Fixed",
45  "5:RTK Float",
46  "6:Dead Reckoning",
47  "7:Manual",
48  "8:Simulation",
49  "9:mmGPS + RTK Fixed",
50  "10: mmGPS + RTK Float"};
51 
52  if (fields.fix_quality < sizeof(fix_names) / sizeof(fix_names[0]))
53  out << "(" << fix_names[fields.fix_quality] << ")\n";
54  else
55  out << "(UNKNOWN!)\n";
56 
57  out << " HDOP (Horizontal Dilution of Precision): ";
58  if (fields.thereis_HDOP)
59  out << mrpt::format(" %f\n", fields.HDOP);
60  else
61  out << " N/A\n";
62 }
63 
64 bool Message_NMEA_GGA::getAllFieldDescriptions(std::ostream& o) const
65 {
66  o << "lon_deg lat_deg hgt_m undulation_m hour min sec num_sats fix_quality "
67  "hdop";
68  return true;
69 }
70 bool Message_NMEA_GGA::getAllFieldValues(std::ostream& o) const
71 {
72  o << mrpt::format(
73  "%.09f %.09f %.04f %.04f %02u %02u %02.03f %2u %u %f",
78  return true;
79 }
80 
81 // ---------------------------------------
83 void Message_NMEA_GLL::dumpToStream(std::ostream& out) const
84 {
85  out << "[NMEA GLL datum]\n";
86  out << mrpt::format(
87  " Longitude: %.09f deg Latitude: %.09f deg Validity: '%c'\n",
90  out << mrpt::format(
91  " UTC time-stamp: %02u:%02u:%02.03f\n", fields.UTCTime.hour,
93 }
94 
95 bool Message_NMEA_GLL::getAllFieldDescriptions(std::ostream& o) const
96 {
97  o << "lon_deg lat_deg hour min sec validity";
98  return true;
99 }
100 bool Message_NMEA_GLL::getAllFieldValues(std::ostream& o) const
101 {
102  o << mrpt::format(
103  "%.09f %.09f %02u %02u %02.03f %u", fields.longitude_degrees,
106  static_cast<unsigned int>(fields.validity_char == 'A' ? 1 : 0));
107  return true;
108 }
109 
110 // ---------------------------------------
112 
113  = default;
114 
115 void Message_NMEA_VTG::dumpToStream(std::ostream& out) const
116 {
117  out << "[NMEA VTG datum]\n";
118  out << mrpt::format(
119  " True track: %.03f deg Magnetic track: %.03f deg\n",
120  fields.true_track, fields.magnetic_track);
121  out << mrpt::format(
122  " Ground speed: %.03f knots %.03f km/h\n", fields.ground_speed_knots,
123  fields.ground_speed_kmh);
124 }
125 
126 bool Message_NMEA_VTG::getAllFieldDescriptions(std::ostream& o) const
127 {
128  o << "true_track mag_track gnd_speed_knots gnd_speed_kmh";
129  return true;
130 }
131 bool Message_NMEA_VTG::getAllFieldValues(std::ostream& o) const
132 {
133  o << mrpt::format(
134  "%.09f %.09f %.09f %.09f", fields.true_track, fields.magnetic_track,
135  fields.ground_speed_knots, fields.ground_speed_kmh);
136  return true;
137 }
138 
139 // ---------------------------------------
141 /** Build an MRPT timestamp with the year/month/day of this observation. */
142 
144 {
145  using namespace mrpt::system;
146 
147  // Detect current century:
148  uint16_t years_century;
149  {
150  TTimeParts dec_parts;
151  timestampToParts(now(), dec_parts);
152  years_century = (dec_parts.year / 100) * 100;
153  }
154 
155  TTimeParts parts;
156  parts.second = parts.minute = parts.hour = 0;
157 
158  parts.day = fields.date_day;
159  parts.month = fields.date_month;
160  parts.year = years_century + fields.date_year;
161 
162  return buildTimestampFromParts(parts);
163 }
164 
165 void Message_NMEA_RMC::dumpToStream(std::ostream& out) const
166 {
167  out << "[NMEA RMC datum]\n";
168  out << mrpt::format(" Positioning mode: `%c`\n ", fields.positioning_mode);
169  out << mrpt::format(
170  " UTC time-stamp: %02u:%02u:%02.03f\n", fields.UTCTime.hour,
172  out << mrpt::format(
173  " Date (DD/MM/YY): %02u/%02u/%02u\n ",
174  static_cast<unsigned>(fields.date_day), (unsigned)fields.date_month,
175  static_cast<unsigned>(fields.date_year));
176  out << mrpt::format(
177  " Longitude: %.09f deg Latitude: %.09f deg Valid?: '%c'\n",
180  out << mrpt::format(
181  " Speed: %.05f knots Direction:%.03f deg.\n ", fields.speed_knots,
183  out << mrpt::format(
184  " Magnetic variation direction: %.04f deg\n ", fields.magnetic_dir);
185 }
186 
187 bool Message_NMEA_RMC::getAllFieldDescriptions(std::ostream& o) const
188 {
189  o << "lon_deg lat_deg hour min sec speed_knots direction_deg year month "
190  "day";
191  return true;
192 }
193 bool Message_NMEA_RMC::getAllFieldValues(std::ostream& o) const
194 {
195  o << mrpt::format(
196  "%.09f %.09f %02u %02u %02.03f %.05f %.03f %02u %02u %02u",
200  fields.date_day);
201  return true;
202 }
203 
204 // ---------------------------------------
206 {
207  for (int i = 0; i < 12; i++) PRNs[i][0] = PRNs[i][1] = '\0';
208 }
209 void Message_NMEA_GSA::dumpToStream(std::ostream& out) const
210 {
211  out << "[NMEA GSA datum]\n";
212  out << "auto_selection_fix: " << fields.auto_selection_fix
213  << "\n"
214  "fix_2D_3D: "
215  << fields.fix_2D_3D << "\n";
216  for (int i = 0; i < 12; i++)
217  out << mrpt::format("PRNs[%i]=%5.02s\n", i, fields.PRNs[i]);
218 
219  out << "PDOP: " << fields.PDOP
220  << "\n"
221  "HDOP: "
222  << fields.HDOP
223  << "\n"
224  "VDOP: "
225  << fields.VDOP << "\n";
226 }
227 
228 bool Message_NMEA_GSA::getAllFieldDescriptions(std::ostream& o) const
229 {
230  o << "auto_selection_fix fix_2D_3D PRN[0] PRN[1] PRN[2] PRN[3] PRN[4] "
231  "PRN[5] PRN[6] PRN[7] PRN[8] PRN[9] PRN[10] PRN[11] PDOP HDOP VDOP";
232  return true;
233 }
234 bool Message_NMEA_GSA::getAllFieldValues(std::ostream& o) const
235 {
236  o << mrpt::format(
237  "%04c %02c %07.2s %07.2s %07.2s %07.2s %07.2s %07.2s %07.2s %07.2s "
238  "%07.2s %07.2s %07.2s "
239  "%07.2s %.05f %.05f %.05f",
240  fields.auto_selection_fix, fields.fix_2D_3D, fields.PRNs[0],
241  fields.PRNs[1], fields.PRNs[2], fields.PRNs[3], fields.PRNs[4],
242  fields.PRNs[5], fields.PRNs[6], fields.PRNs[7], fields.PRNs[8],
243  fields.PRNs[9], fields.PRNs[10], fields.PRNs[11], fields.PDOP,
244  fields.HDOP, fields.VDOP);
245  return true;
246 }
247 
248 // ---------------------------------------
250 void Message_NMEA_ZDA::dumpToStream(std::ostream& out) const
251 {
252  out << "[NMEA ZDA datum]\n";
253  out << mrpt::format(
254  " UTC time-stamp: %02u:%02u:%02.03f\n", fields.UTCTime.hour,
256  out << mrpt::format(
257  " Date (DD/MM/YY): %02u/%02u/%04u\n ", (unsigned)fields.date_day,
258  (unsigned)fields.date_month, (unsigned)fields.date_year);
259 }
260 
261 bool Message_NMEA_ZDA::getAllFieldDescriptions(std::ostream& o) const
262 {
263  o << "year month day hour minute second";
264  return true;
265 }
266 bool Message_NMEA_ZDA::getAllFieldValues(std::ostream& o) const
267 {
268  o << mrpt::format(
269  "%04u %02u %02u %02u %02u %.05f", fields.date_year, fields.date_month,
271  fields.UTCTime.sec);
272  return true;
273 }
274 
276 {
278 }
279 
280 /** Build an MRPT timestamp with the year/month/day of this observation. */
281 
283 {
284  using namespace mrpt::system;
285  TTimeParts parts;
286  parts.second = parts.minute = parts.hour = 0;
287  parts.day = fields.date_day;
288  parts.month = fields.date_month;
289  parts.year = fields.date_year;
290  return buildTimestampFromParts(parts);
291 }
void dumpToStream(std::ostream &out) const override
Dumps the contents of the observation in a human-readable form to a given output stream.
double longitude_degrees
The measured longitude, in degrees (East:+ , West:-)
void timestampToParts(TTimeStamp t, TTimeParts &p, bool localTime=false)
Gets the individual parts of a date/time (days, hours, minutes, seconds) - UTC time or local time...
Definition: datetime.cpp:50
uint8_t fix_quality
NMEA standard values: 0 = invalid, 1 = GPS fix (SPS), 2 = DGPS fix, 3 = PPS fix, 4 = Real Time Kinema...
content_t fields
Message content, accesible by individual fields.
bool getAllFieldValues(std::ostream &o) const override
double latitude_degrees
The measured latitude, in degrees (North:+ , South:-)
double longitude_degrees
The measured longitude, in degrees (East:+ , West:-)
mrpt::system::TTimeStamp getAsTimestamp(const mrpt::system::TTimeStamp &date) const
Build an MRPT timestamp with the hour/minute/sec of this structure and the date from the given timest...
bool getAllFieldValues(std::ostream &o) const override
double latitude_degrees
The measured latitude, in degrees (North:+ , South:-)
std::string std::string format(std::string_view fmt, ARGS &&... args)
Definition: format.h:26
content_t fields
Message content, accesible by individual fields.
mrpt::system::TTimeStamp buildTimestampFromParts(const mrpt::system::TTimeParts &p)
Builds a timestamp from the parts (Parts are in UTC)
Definition: datetime.cpp:74
uint32_t satellitesUsed
The number of satelites used to compute this estimation.
bool getAllFieldDescriptions(std::ostream &o) const override
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:86
UTC_time UTCTime
The GPS sensor measured timestamp (in UTC time)
STL namespace.
int8_t validity_char
This will be: &#39;A&#39;=OK or &#39;V&#39;=void.
UTC_time UTCTime
The GPS sensor measured timestamp (in UTC time)
double orthometric_altitude
The measured orthometric altitude, in meters (A)+(B).
bool getAllFieldValues(std::ostream &o) const override
bool getAllFieldDescriptions(std::ostream &o) const override
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:40
double altitude_meters
The measured altitude, in meters (A).
bool thereis_HDOP
This states whether to take into account the value in the HDOP field.
UTC_time UTCTime
The GPS sensor measured timestamp (in UTC time)
double corrected_orthometric_altitude
The corrected (only for TopCon mmGPS) orthometric altitude, in meters mmGPS(A+B). ...
mrpt::system::TTimeStamp getDateAsTimestamp() const
Build an MRPT timestamp with the year/month/day of this observation.
bool getAllFieldDescriptions(std::ostream &o) const override
The parts of a date/time (it&#39;s like the standard &#39;tm&#39; but with fractions of seconds).
Definition: datetime.h:49
uint8_t date_day
Date: day (1-31), month (1-12), two-digits year (00-99)
content_t fields
Message content, accesible by individual fields.
float HDOP
The HDOP (Horizontal Dilution of Precision) as returned by the sensor.
void dumpToStream(std::ostream &out) const override
Dumps the contents of the observation in a human-readable form to a given output stream.
uint8_t day
Month (1-12)
Definition: datetime.h:53
double longitude_degrees
The measured longitude, in degrees (East:+ , West:-)
bool getAllFieldValues(std::ostream &o) const override
bool getAllFieldValues(std::ostream &o) const override
bool getAllFieldDescriptions(std::ostream &o) const override
GNSS (GPS) data structures, mainly for use within mrpt::obs::CObservationGPS.
void dumpToStream(std::ostream &out) const override
Dumps the contents of the observation in a human-readable form to a given output stream.
double second
Minute (0-59)
Definition: datetime.h:56
double geoidal_distance
Undulation: Difference between the measured altitude and the geoid, in meters (B).
double magnetic_dir
Magnetic variation direction (East:+, West:-)
mrpt::system::TTimeStamp getDateAsTimestamp() const
Build an MRPT timestamp with the year/month/day of this observation.
mrpt::system::TTimeStamp getDateTimeAsTimestamp() const
Build an MRPT UTC timestamp with the year/month/day + hour/minute/sec of this observation.
bool getAllFieldValues(std::ostream &o) const override
bool getAllFieldDescriptions(std::ostream &o) const override
uint8_t minute
Hour (0-23)
Definition: datetime.h:55
void dumpToStream(std::ostream &out) const override
Dumps the contents of the observation in a human-readable form to a given output stream.
bool getAllFieldDescriptions(std::ostream &o) const override
mrpt::vision::TStereoCalibResults out
void dumpToStream(std::ostream &out) const override
Dumps the contents of the observation in a human-readable form to a given output stream.
double direction_degrees
Measured speed direction (in degrees)
void dumpToStream(std::ostream &out) const override
Dumps the contents of the observation in a human-readable form to a given output stream.
char positioning_mode
&#39;A&#39;: Autonomous, &#39;D&#39;: Differential, &#39;N&#39;: Not valid, &#39;E&#39;: Estimated, &#39;M&#39;: Manual
content_t fields
Message content, accesible by individual fields.
uint8_t month
The year.
Definition: datetime.h:52
double latitude_degrees
The measured latitude, in degrees (North:+ , South:-)
int8_t validity_char
This will be: &#39;A&#39;=OK or &#39;V&#39;=void.
uint8_t hour
Day (1-31)
Definition: datetime.h:54
UTC_time UTCTime
The GPS sensor measured timestamp (in UTC time)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 3a26b90fd Wed Mar 25 20:17:03 2020 +0100 at miƩ mar 25 23:05:41 CET 2020