Main MRPT website > C++ reference for MRPT 1.9.9
gnss_messages_ascii_nmea.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "obs-precomp.h" // Precompiled headers
11 
13 
14 using namespace std;
15 using namespace mrpt::obs::gnss;
16 
17 // ---------------------------------------
18 Message_NMEA_GGA::content_t::content_t()
19  : UTCTime(),
20  latitude_degrees(0),
21  longitude_degrees(0),
22  fix_quality(0),
23  altitude_meters(0),
24  geoidal_distance(),
25  orthometric_altitude(),
26  corrected_orthometric_altitude(),
27  satellitesUsed(0),
28  thereis_HDOP(false),
29  HDOP(0)
30 {
31 }
32 
34 {
35  out.printf("[NMEA GGA datum]\n");
36  out.printf(
37  " Longitude: %.09f deg Latitude: %.09f deg Height: %.03f m\n",
40 
41  out.printf(
42  " Geoidal distance: %.03f m Orthometric alt.: %.03f m Corrected "
43  "ort. alt.: %.03f m\n",
46 
47  out.printf(
48  " UTC time-stamp: %02u:%02u:%02.03f #sats=%2u ", fields.UTCTime.hour,
50 
51  out.printf("Fix mode: %u ", fields.fix_quality);
52  switch (fields.fix_quality)
53  {
54  case 0:
55  out.printf("(Invalid)\n");
56  break;
57  case 1:
58  out.printf("(GPS fix)\n");
59  break;
60  case 2:
61  out.printf("(DGPS fix)\n");
62  break;
63  case 3:
64  out.printf("(PPS fix)\n");
65  break;
66  case 4:
67  out.printf("(Real Time Kinematic/RTK Fixed)\n");
68  break;
69  case 5:
70  out.printf("(Real Time Kinematic/RTK Float)\n");
71  break;
72  case 6:
73  out.printf("(Dead Reckoning)\n");
74  break;
75  case 7:
76  out.printf("(Manual)\n");
77  break;
78  case 8:
79  out.printf("(Simulation)\n");
80  break;
81  case 9:
82  out.printf("(mmGPS + RTK Fixed)\n");
83  break;
84  case 10:
85  out.printf("(mmGPS + RTK Float)\n");
86  break;
87  default:
88  out.printf("(UNKNOWN!)\n");
89  break;
90  };
91 
92  out.printf(" HDOP (Horizontal Dilution of Precision): ");
93  if (fields.thereis_HDOP)
94  out.printf(" %f\n", fields.HDOP);
95  else
96  out.printf(" N/A\n");
97 }
98 
99 bool Message_NMEA_GGA::getAllFieldDescriptions(std::ostream& o) const
100 {
101  o << "lon_deg lat_deg hgt_m undulation_m hour min sec num_sats fix_quality "
102  "hdop";
103  return true;
104 }
105 bool Message_NMEA_GGA::getAllFieldValues(std::ostream& o) const
106 {
107  o << mrpt::format(
108  "%.09f %.09f %.04f %.04f %02u %02u %02.03f %2u %u %f",
113  return true;
114 }
115 
116 // ---------------------------------------
118  : UTCTime(), latitude_degrees(0), longitude_degrees(0), validity_char('V')
119 {
120 }
121 
123 {
124  out.printf("[NMEA GLL datum]\n");
125  out.printf(
126  " Longitude: %.09f deg Latitude: %.09f deg Validity: '%c'\n",
129  out.printf(
130  " UTC time-stamp: %02u:%02u:%02.03f\n", fields.UTCTime.hour,
132 }
133 
134 bool Message_NMEA_GLL::getAllFieldDescriptions(std::ostream& o) const
135 {
136  o << "lon_deg lat_deg hour min sec validity";
137  return true;
138 }
139 bool Message_NMEA_GLL::getAllFieldValues(std::ostream& o) const
140 {
141  o << mrpt::format(
142  "%.09f %.09f %02u %02u %02.03f %u", fields.longitude_degrees,
145  static_cast<unsigned int>(fields.validity_char == 'A' ? 1 : 0));
146  return true;
147 }
148 
149 // ---------------------------------------
151  : true_track(), magnetic_track(), ground_speed_knots(), ground_speed_kmh()
152 {
153 }
154 
156 {
157  out.printf("[NMEA VTG datum]\n");
158  out.printf(
159  " True track: %.03f deg Magnetic track: %.03f deg\n",
161  out.printf(
162  " Ground speed: %.03f knots %.03f km/h\n", fields.ground_speed_knots,
164 }
165 
166 bool Message_NMEA_VTG::getAllFieldDescriptions(std::ostream& o) const
167 {
168  o << "true_track mag_track gnd_speed_knots gnd_speed_kmh";
169  return true;
170 }
171 bool Message_NMEA_VTG::getAllFieldValues(std::ostream& o) const
172 {
173  o << mrpt::format(
174  "%.09f %.09f %.09f %.09f", fields.true_track, fields.magnetic_track,
176  return true;
177 }
178 
179 // ---------------------------------------
181  : UTCTime(),
182  validity_char('V'),
183  latitude_degrees(0),
184  longitude_degrees(0),
185  speed_knots(0),
186  direction_degrees(0),
187  date_day(0),
188  date_month(0),
189  date_year(0),
190  magnetic_dir(),
191  positioning_mode('N')
192 {
193 }
194 
195 /** Build an MRPT timestamp with the year/month/day of this observation. */
196 
198 {
199  using namespace mrpt::system;
200 
201  // Detect current century:
202  uint16_t years_century;
203  {
204  TTimeParts dec_parts;
205  timestampToParts(now(), dec_parts);
206  years_century = (dec_parts.year / 100) * 100;
207  }
208 
209  TTimeParts parts;
210  parts.second = parts.minute = parts.hour = 0;
211 
212  parts.day = fields.date_day;
213  parts.month = fields.date_month;
214  parts.year = years_century + fields.date_year;
215 
216  return buildTimestampFromParts(parts);
217 }
218 
220 {
221  out.printf("[NMEA RMC datum]\n");
222  out.printf(" Positioning mode: `%c`\n ", (char)fields.positioning_mode);
223  out.printf(
224  " UTC time-stamp: %02u:%02u:%02.03f\n", fields.UTCTime.hour,
226  out.printf(
227  " Date (DD/MM/YY): %02u/%02u/%02u\n ", (unsigned)fields.date_day,
228  (unsigned)fields.date_month, (unsigned)fields.date_year);
229  out.printf(
230  " Longitude: %.09f deg Latitude: %.09f deg Valid?: '%c'\n",
233  out.printf(
234  " Speed: %.05f knots Direction:%.03f deg.\n ", fields.speed_knots,
236  out.printf(
237  " Magnetic variation direction: %.04f deg\n ", fields.magnetic_dir);
238 }
239 
240 bool Message_NMEA_RMC::getAllFieldDescriptions(std::ostream& o) const
241 {
242  o << "lon_deg lat_deg hour min sec speed_knots direction_deg year month "
243  "day";
244  return true;
245 }
246 bool Message_NMEA_RMC::getAllFieldValues(std::ostream& o) const
247 {
248  o << mrpt::format(
249  "%.09f %.09f %02u %02u %02.03f %.05f %.03f %02u %02u %02u",
253  fields.date_day);
254  return true;
255 }
256 
257 // ---------------------------------------
259  : UTCTime(), date_day(), date_month(), date_year()
260 {
261 }
262 
264 {
265  out.printf("[NMEA ZDA datum]\n");
266  out.printf(
267  " UTC time-stamp: %02u:%02u:%02.03f\n", fields.UTCTime.hour,
269  out.printf(
270  " Date (DD/MM/YY): %02u/%02u/%04u\n ", (unsigned)fields.date_day,
271  (unsigned)fields.date_month, (unsigned)fields.date_year);
272 }
273 
274 bool Message_NMEA_ZDA::getAllFieldDescriptions(std::ostream& o) const
275 {
276  o << "year month day hour minute second";
277  return true;
278 }
279 bool Message_NMEA_ZDA::getAllFieldValues(std::ostream& o) const
280 {
281  o << mrpt::format(
282  "%04u %02u %02u %02u %02u %.05f", fields.date_year, fields.date_month,
284  fields.UTCTime.sec);
285  return true;
286 }
287 
289 {
291 }
292 
293 /** Build an MRPT timestamp with the year/month/day of this observation. */
294 
296 {
297  using namespace mrpt::system;
298  TTimeParts parts;
299  parts.second = parts.minute = parts.hour = 0;
300  parts.day = fields.date_day;
301  parts.month = fields.date_month;
302  parts.year = fields.date_year;
303  return buildTimestampFromParts(parts);
304 }
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:32
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:103
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
Dumps a line with the sequence of all field values (without a line feed at the end).
double latitude_degrees
The measured latitude, in degrees (North:+ , South:-)
double longitude_degrees
The measured longitude, in degrees (East:+ , West:-)
unsigned __int16 uint16_t
Definition: rptypes.h:44
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
Dumps a line with the sequence of all field values (without a line feed at the end).
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
double latitude_degrees
The measured latitude, in degrees (North:+ , South:-)
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:30
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:127
uint32_t satellitesUsed
The number of satelites used to compute this estimation.
bool getAllFieldDescriptions(std::ostream &o) const override
Dumps a header for getAllFieldValues()
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:76
void dumpToStream(mrpt::utils::CStream &out) const override
Dumps the contents of the observation in a human-readable form to a given output stream.
content_t fields
Message content, accesible by individual fields.
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
Dumps a line with the sequence of all field values (without a line feed at the end).
bool getAllFieldDescriptions(std::ostream &o) const override
Dumps a header for getAllFieldValues()
double altitude_meters
The measured altitude, in meters (A).
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
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). ...
void dumpToStream(mrpt::utils::CStream &out) const override
Dumps the contents of the observation in a human-readable form to a given output stream.
mrpt::system::TTimeStamp getDateAsTimestamp() const
Build an MRPT timestamp with the year/month/day of this observation.
bool getAllFieldDescriptions(std::ostream &o) const override
Dumps a header for getAllFieldValues()
The parts of a date/time (it&#39;s like the standard &#39;tm&#39; but with fractions of seconds).
Definition: datetime.h:38
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(mrpt::utils::CStream &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:42
double longitude_degrees
The measured longitude, in degrees (East:+ , West:-)
bool getAllFieldValues(std::ostream &o) const override
Dumps a line with the sequence of all field values (without a line feed at the end).
void dumpToStream(mrpt::utils::CStream &out) const override
Dumps the contents of the observation in a human-readable form to a given output stream.
bool getAllFieldValues(std::ostream &o) const override
Dumps a line with the sequence of all field values (without a line feed at the end).
bool getAllFieldDescriptions(std::ostream &o) const override
Dumps a header for getAllFieldValues()
GNSS (GPS) data structures, mainly for use within mrpt::obs::CObservationGPS.
double second
Minute (0-59)
Definition: datetime.h:45
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 getAllFieldDescriptions(std::ostream &o) const override
Dumps a header for getAllFieldValues()
uint8_t minute
Hour (0-23)
Definition: datetime.h:44
double direction_degrees
Measured speed direction (in degrees)
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:41
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:43
void dumpToStream(mrpt::utils::CStream &out) const override
Dumps the contents of the observation in a human-readable form to a given output stream.
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
Definition: CStream.cpp:597
UTC_time UTCTime
The GPS sensor measured timestamp (in UTC time)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019