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-2019, 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 << mrpt::format("[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 << mrpt::format("[NMEA RMC datum]\n");
168  out << mrpt::format(
169  " Positioning mode: `%c`\n ", (char)fields.positioning_mode);
170  out << mrpt::format(
171  " UTC time-stamp: %02u:%02u:%02.03f\n", fields.UTCTime.hour,
173  out << mrpt::format(
174  " Date (DD/MM/YY): %02u/%02u/%02u\n ", (unsigned)fields.date_day,
175  (unsigned)fields.date_month, (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 void Message_NMEA_ZDA::dumpToStream(std::ostream& out) const
207 {
208  out << mrpt::format("[NMEA ZDA datum]\n");
209  out << mrpt::format(
210  " UTC time-stamp: %02u:%02u:%02.03f\n", fields.UTCTime.hour,
212  out << mrpt::format(
213  " Date (DD/MM/YY): %02u/%02u/%04u\n ", (unsigned)fields.date_day,
214  (unsigned)fields.date_month, (unsigned)fields.date_year);
215 }
216 
217 bool Message_NMEA_ZDA::getAllFieldDescriptions(std::ostream& o) const
218 {
219  o << "year month day hour minute second";
220  return true;
221 }
222 bool Message_NMEA_ZDA::getAllFieldValues(std::ostream& o) const
223 {
224  o << mrpt::format(
225  "%04u %02u %02u %02u %02u %.05f", fields.date_year, fields.date_month,
227  fields.UTCTime.sec);
228  return true;
229 }
230 
232 {
234 }
235 
236 /** Build an MRPT timestamp with the year/month/day of this observation. */
237 
239 {
240  using namespace mrpt::system;
241  TTimeParts parts;
242  parts.second = parts.minute = parts.hour = 0;
243  parts.day = fields.date_day;
244  parts.month = fields.date_month;
245  parts.year = fields.date_year;
246  return buildTimestampFromParts(parts);
247 }
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
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:47
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:74
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: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
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: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019