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-2018, 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 #include <iostream>
14 
15 using namespace std;
16 using namespace mrpt::obs::gnss;
17 
18 // ---------------------------------------
19 Message_NMEA_GGA::content_t::content_t()
20  : UTCTime(),
21  latitude_degrees(0),
22  longitude_degrees(0),
23  fix_quality(0),
24  altitude_meters(0),
25  geoidal_distance(),
26  orthometric_altitude(),
27  corrected_orthometric_altitude(),
28  satellitesUsed(0),
29  thereis_HDOP(false),
30  HDOP(0)
31 {
32 }
33 
34 void Message_NMEA_GGA::dumpToStream(std::ostream& out) const
35 {
36  out << "[NMEA GGA datum]\n";
37  out << mrpt::format(
38  " Longitude: %.09f deg Latitude: %.09f deg Height: %.03f m\n",
41 
42  out << mrpt::format(
43  " Geoidal distance: %.03f m Orthometric alt.: %.03f m Corrected "
44  "ort. alt.: %.03f m\n",
47 
48  out << mrpt::format(
49  " UTC time-stamp: %02u:%02u:%02.03f #sats=%2u ", fields.UTCTime.hour,
51 
52  out << mrpt::format("Fix mode: %u ", fields.fix_quality);
53 
54  const char* fix_names[] = {"0:Invalid",
55  "1:GPS fix",
56  "2:DGPS fix",
57  "3:PPS fix",
58  "4:RTK Fixed",
59  "5:RTK Float",
60  "6:Dead Reckoning",
61  "7:Manual",
62  "8:Simulation",
63  "9:mmGPS + RTK Fixed",
64  "10: mmGPS + RTK Float"};
65 
66  if (fields.fix_quality < sizeof(fix_names) / sizeof(fix_names[0]))
67  out << "(" << fix_names[fields.fix_quality] << ")\n";
68  else
69  out << "(UNKNOWN!)\n";
70 
71  out << " HDOP (Horizontal Dilution of Precision): ";
72  if (fields.thereis_HDOP)
73  out << mrpt::format(" %f\n", fields.HDOP);
74  else
75  out << " N/A\n";
76 }
77 
78 bool Message_NMEA_GGA::getAllFieldDescriptions(std::ostream& o) const
79 {
80  o << "lon_deg lat_deg hgt_m undulation_m hour min sec num_sats fix_quality "
81  "hdop";
82  return true;
83 }
84 bool Message_NMEA_GGA::getAllFieldValues(std::ostream& o) const
85 {
86  o << mrpt::format(
87  "%.09f %.09f %.04f %.04f %02u %02u %02.03f %2u %u %f",
92  return true;
93 }
94 
95 // ---------------------------------------
97  : UTCTime(), latitude_degrees(0), longitude_degrees(0), validity_char('V')
98 {
99 }
100 
101 void Message_NMEA_GLL::dumpToStream(std::ostream& out) const
102 {
103  out << "[NMEA GLL datum]\n";
104  out << mrpt::format(
105  " Longitude: %.09f deg Latitude: %.09f deg Validity: '%c'\n",
108  out << mrpt::format(
109  " UTC time-stamp: %02u:%02u:%02.03f\n", fields.UTCTime.hour,
111 }
112 
113 bool Message_NMEA_GLL::getAllFieldDescriptions(std::ostream& o) const
114 {
115  o << "lon_deg lat_deg hour min sec validity";
116  return true;
117 }
118 bool Message_NMEA_GLL::getAllFieldValues(std::ostream& o) const
119 {
120  o << mrpt::format(
121  "%.09f %.09f %02u %02u %02.03f %u", fields.longitude_degrees,
124  static_cast<unsigned int>(fields.validity_char == 'A' ? 1 : 0));
125  return true;
126 }
127 
128 // ---------------------------------------
130  : true_track(), magnetic_track(), ground_speed_knots(), ground_speed_kmh()
131 {
132 }
133 
134 void Message_NMEA_VTG::dumpToStream(std::ostream& out) const
135 {
136  out << mrpt::format("[NMEA VTG datum]\n");
137  out << mrpt::format(
138  " True track: %.03f deg Magnetic track: %.03f deg\n",
140  out << mrpt::format(
141  " Ground speed: %.03f knots %.03f km/h\n", fields.ground_speed_knots,
143 }
144 
145 bool Message_NMEA_VTG::getAllFieldDescriptions(std::ostream& o) const
146 {
147  o << "true_track mag_track gnd_speed_knots gnd_speed_kmh";
148  return true;
149 }
150 bool Message_NMEA_VTG::getAllFieldValues(std::ostream& o) const
151 {
152  o << mrpt::format(
153  "%.09f %.09f %.09f %.09f", fields.true_track, fields.magnetic_track,
155  return true;
156 }
157 
158 // ---------------------------------------
160  : UTCTime(),
161  validity_char('V'),
162  latitude_degrees(0),
163  longitude_degrees(0),
164  speed_knots(0),
165  direction_degrees(0),
166  date_day(0),
167  date_month(0),
168  date_year(0),
169  magnetic_dir(),
170  positioning_mode('N')
171 {
172 }
173 
174 /** Build an MRPT timestamp with the year/month/day of this observation. */
175 
177 {
178  using namespace mrpt::system;
179 
180  // Detect current century:
181  uint16_t years_century;
182  {
183  TTimeParts dec_parts;
184  timestampToParts(now(), dec_parts);
185  years_century = (dec_parts.year / 100) * 100;
186  }
187 
188  TTimeParts parts;
189  parts.second = parts.minute = parts.hour = 0;
190 
191  parts.day = fields.date_day;
192  parts.month = fields.date_month;
193  parts.year = years_century + fields.date_year;
194 
195  return buildTimestampFromParts(parts);
196 }
197 
198 void Message_NMEA_RMC::dumpToStream(std::ostream& out) const
199 {
200  out << mrpt::format("[NMEA RMC datum]\n");
201  out << mrpt::format(
202  " Positioning mode: `%c`\n ", (char)fields.positioning_mode);
203  out << mrpt::format(
204  " UTC time-stamp: %02u:%02u:%02.03f\n", fields.UTCTime.hour,
206  out << mrpt::format(
207  " Date (DD/MM/YY): %02u/%02u/%02u\n ", (unsigned)fields.date_day,
208  (unsigned)fields.date_month, (unsigned)fields.date_year);
209  out << mrpt::format(
210  " Longitude: %.09f deg Latitude: %.09f deg Valid?: '%c'\n",
213  out << mrpt::format(
214  " Speed: %.05f knots Direction:%.03f deg.\n ", fields.speed_knots,
216  out << mrpt::format(
217  " Magnetic variation direction: %.04f deg\n ", fields.magnetic_dir);
218 }
219 
220 bool Message_NMEA_RMC::getAllFieldDescriptions(std::ostream& o) const
221 {
222  o << "lon_deg lat_deg hour min sec speed_knots direction_deg year month "
223  "day";
224  return true;
225 }
226 bool Message_NMEA_RMC::getAllFieldValues(std::ostream& o) const
227 {
228  o << mrpt::format(
229  "%.09f %.09f %02u %02u %02.03f %.05f %.03f %02u %02u %02u",
233  fields.date_day);
234  return true;
235 }
236 
237 // ---------------------------------------
239  : UTCTime(), date_day(), date_month(), date_year()
240 {
241 }
242 
243 void Message_NMEA_ZDA::dumpToStream(std::ostream& out) const
244 {
245  out << mrpt::format("[NMEA ZDA datum]\n");
246  out << mrpt::format(
247  " UTC time-stamp: %02u:%02u:%02.03f\n", fields.UTCTime.hour,
249  out << mrpt::format(
250  " Date (DD/MM/YY): %02u/%02u/%04u\n ", (unsigned)fields.date_day,
251  (unsigned)fields.date_month, (unsigned)fields.date_year);
252 }
253 
254 bool Message_NMEA_ZDA::getAllFieldDescriptions(std::ostream& o) const
255 {
256  o << "year month day hour minute second";
257  return true;
258 }
259 bool Message_NMEA_ZDA::getAllFieldValues(std::ostream& o) const
260 {
261  o << mrpt::format(
262  "%04u %02u %02u %02u %02u %.05f", fields.date_year, fields.date_month,
264  fields.UTCTime.sec);
265  return true;
266 }
267 
269 {
271 }
272 
273 /** Build an MRPT timestamp with the year/month/day of this observation. */
274 
276 {
277  using namespace mrpt::system;
278  TTimeParts parts;
279  parts.second = parts.minute = parts.hour = 0;
280  parts.day = fields.date_day;
281  parts.month = fields.date_month;
282  parts.year = fields.date_year;
283  return buildTimestampFromParts(parts);
284 }
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:61
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).
double latitude_degrees
The measured latitude, in degrees (North:+ , South:-)
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:85
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:87
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()
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
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: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.
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
Dumps a line with the sequence of all field values (without a line feed at the end).
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.
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 getAllFieldDescriptions(std::ostream &o) const override
Dumps a header for getAllFieldValues()
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.
void dumpToStream(std::ostream &out) const override
Dumps the contents of the observation in a human-readable form to a given output stream.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020