Main MRPT website > C++ reference for MRPT 1.5.6
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 
33 {
34  out.printf("[NMEA GGA datum]\n");
35  out.printf(" Longitude: %.09f deg Latitude: %.09f deg Height: %.03f m\n",
39 
40  out.printf(" Geoidal distance: %.03f m Orthometric alt.: %.03f m Corrected ort. alt.: %.03f m\n",
44 
45  out.printf(" UTC time-stamp: %02u:%02u:%02.03f #sats=%2u ",
50 
51  out.printf("Fix mode: %u ",fields.fix_quality);
52  switch( fields.fix_quality )
53  {
54  case 0: out.printf("(Invalid)\n"); break;
55  case 1: out.printf("(GPS fix)\n"); break;
56  case 2: out.printf("(DGPS fix)\n"); break;
57  case 3: out.printf("(PPS fix)\n"); break;
58  case 4: out.printf("(Real Time Kinematic/RTK Fixed)\n"); break;
59  case 5: out.printf("(Real Time Kinematic/RTK Float)\n"); break;
60  case 6: out.printf("(Dead Reckoning)\n"); break;
61  case 7: out.printf("(Manual)\n"); break;
62  case 8: out.printf("(Simulation)\n"); break;
63  case 9: out.printf("(mmGPS + RTK Fixed)\n"); break;
64  case 10: out.printf("(mmGPS + RTK Float)\n"); break;
65  default: out.printf("(UNKNOWN!)\n"); break;
66  };
67 
68  out.printf(" HDOP (Horizontal Dilution of Precision): ");
69  if (fields.thereis_HDOP)
70  out.printf(" %f\n", fields.HDOP);
71  else out.printf(" N/A\n");
72 }
73 
74 bool Message_NMEA_GGA::getAllFieldDescriptions( std::ostream &o ) const
75 {
76  o << "lon_deg lat_deg hgt_m undulation_m hour min sec num_sats fix_quality hdop";
77  return true;
78 }
79 bool Message_NMEA_GGA::getAllFieldValues( std::ostream &o ) const
80 {
81  o << mrpt::format("%.09f %.09f %.04f %.04f %02u %02u %02.03f %2u %u %f",
91  fields.HDOP
92  );
93  return true;
94 }
95 
96 // ---------------------------------------
98  UTCTime(),
99  latitude_degrees(0),
100  longitude_degrees(0),
101  validity_char('V')
102 { }
103 
105 {
106  out.printf("[NMEA GLL datum]\n");
107  out.printf(" Longitude: %.09f deg Latitude: %.09f deg Validity: '%c'\n",
111  out.printf(" UTC time-stamp: %02u:%02u:%02.03f\n",
114  fields.UTCTime.sec);
115 }
116 
117 bool Message_NMEA_GLL::getAllFieldDescriptions( std::ostream &o ) const
118 {
119  o << "lon_deg lat_deg hour min sec validity";
120  return true;
121 }
122 bool Message_NMEA_GLL::getAllFieldValues( std::ostream &o ) const
123 {
124  o << mrpt::format("%.09f %.09f %02u %02u %02.03f %u",
130  static_cast<unsigned int>(fields.validity_char=='A' ? 1:0)
131  );
132  return true;
133 }
134 
135 // ---------------------------------------
137  true_track(), magnetic_track(),ground_speed_knots(), ground_speed_kmh()
138 { }
139 
141 {
142  out.printf("[NMEA VTG datum]\n");
143  out.printf(" True track: %.03f deg Magnetic track: %.03f deg\n",fields.true_track, fields.magnetic_track);
144  out.printf(" Ground speed: %.03f knots %.03f km/h\n",fields.ground_speed_knots, fields.ground_speed_kmh);
145 }
146 
147 bool Message_NMEA_VTG::getAllFieldDescriptions( std::ostream &o ) const
148 {
149  o << "true_track mag_track gnd_speed_knots gnd_speed_kmh";
150  return true;
151 }
152 bool Message_NMEA_VTG::getAllFieldValues( std::ostream &o ) const
153 {
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 //!< Build an MRPT timestamp with the year/month/day of this observation.
175 {
176  using namespace mrpt::system;
177 
178  // Detect current century:
179  uint16_t years_century; {
180  TTimeParts dec_parts;
181  timestampToParts(now(), dec_parts);
182  years_century = (dec_parts.year/100)*100;
183  }
184 
185  TTimeParts parts;
186  parts.second =
187  parts.minute =
188  parts.hour = 0;
189 
190  parts.day = fields.date_day;
191  parts.month = fields.date_month;
192  parts.year = years_century + fields.date_year;
193 
194  return buildTimestampFromParts(parts);
195 }
196 
198 {
199  out.printf("[NMEA RMC datum]\n");
200  out.printf(" Positioning mode: `%c`\n ", (char)fields.positioning_mode);
201  out.printf(" UTC time-stamp: %02u:%02u:%02.03f\n",
205  );
206  out.printf(" Date (DD/MM/YY): %02u/%02u/%02u\n ",
207  (unsigned)fields.date_day,(unsigned)fields.date_month, (unsigned)fields.date_year);
208  out.printf(" Longitude: %.09f deg Latitude: %.09f deg Valid?: '%c'\n",
212  );
213  out.printf(" Speed: %.05f knots Direction:%.03f deg.\n ",
216  );
217  out.printf(" 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 day";
223  return true;
224 }
225 bool Message_NMEA_RMC::getAllFieldValues( std::ostream &o ) const
226 {
227  o << mrpt::format("%.09f %.09f %02u %02u %02.03f %.05f %.03f %02u %02u %02u",
238  );
239  return true;
240 }
241 
242 // ---------------------------------------
244  UTCTime(), date_day(),date_month(),date_year()
245 { }
246 
248 {
249  out.printf("[NMEA ZDA datum]\n");
250  out.printf(" UTC time-stamp: %02u:%02u:%02.03f\n",
254  );
255  out.printf(" Date (DD/MM/YY): %02u/%02u/%04u\n ",
256  (unsigned)fields.date_day,(unsigned)fields.date_month, (unsigned)fields.date_year);
257 }
258 
259 bool Message_NMEA_ZDA::getAllFieldDescriptions( std::ostream &o ) const
260 {
261  o << "year month day hour minute second";
262  return true;
263 }
264 bool Message_NMEA_ZDA::getAllFieldValues( std::ostream &o ) const
265 {
266  o << mrpt::format("%04u %02u %02u %02u %02u %.05f",
272  fields.UTCTime.sec);
273  return true;
274 }
275 
277 {
279 }
280 
281 //!< Build an MRPT timestamp with the year/month/day of this observation.
283 {
284  using namespace mrpt::system;
285  TTimeParts parts;
286  parts.second =
287  parts.minute =
288  parts.hour = 0;
289  parts.day = fields.date_day;
290  parts.month = fields.date_month;
291  parts.year = fields.date_year;
292  return buildTimestampFromParts(parts);
293 }
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:30
void dumpToStream(mrpt::utils::CStream &out) const MRPT_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 BASE_IMPEXP 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:101
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.
double latitude_degrees
The measured latitude, in degrees (North:+ , South:-)
double longitude_degrees
The measured longitude, in degrees (East:+ , West:-)
content_t()
Build an MRPT timestamp with the year/month/day of this observation.
unsigned __int16 uint16_t
Definition: rptypes.h:46
double latitude_degrees
The measured latitude, in degrees (North:+ , South:-)
content_t fields
Message content, accesible by individual fields.
bool getAllFieldDescriptions(std::ostream &o) const MRPT_OVERRIDE
Dumps a header for getAllFieldValues()
mrpt::system::TTimeStamp BASE_IMPEXP 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.
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:70
content_t fields
Message content, accesible by individual fields.
UTC_time UTCTime
The GPS sensor measured timestamp (in UTC time)
mrpt::system::TTimeStamp getDateAsTimestamp() const
Build an MRPT timestamp with the year/month/day of this observation.
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...
int8_t validity_char
This will be: 'A'=OK or 'V'=void.
UTC_time UTCTime
The GPS sensor measured timestamp (in UTC time)
double orthometric_altitude
The measured orthometric altitude, in meters (A)+(B).
bool getAllFieldDescriptions(std::ostream &o) const MRPT_OVERRIDE
Dumps a header for getAllFieldValues()
bool getAllFieldDescriptions(std::ostream &o) const MRPT_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:38
bool thereis_HDOP
This states whether to take into account the value in the HDOP field.
bool getAllFieldDescriptions(std::ostream &o) const MRPT_OVERRIDE
Dumps a header for getAllFieldValues()
void dumpToStream(mrpt::utils::CStream &out) const MRPT_OVERRIDE
Dumps the contents of the observation in a human-readable form to a given output stream.
bool getAllFieldValues(std::ostream &o) const MRPT_OVERRIDE
Dumps a line with the sequence of all field values (without a line feed at the end).
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). ...
The parts of a date/time (it's like the standard 'tm' but with fractions of seconds).
Definition: datetime.h:35
content_t fields
Message content, accesible by individual fields.
float HDOP
The HDOP (Horizontal Dilution of Precision) as returned by the sensor.
double longitude_degrees
The measured longitude, in degrees (East:+ , West:-)
mrpt::system::TTimeStamp getDateAsTimestamp() const
Build an MRPT timestamp with the year/month/day of this observation.
bool getAllFieldValues(std::ostream &o) const MRPT_OVERRIDE
Dumps a line with the sequence of all field values (without a line feed at the end).
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
uint8_t date_year
Date: day (1-31), month (1-12), two-digits year (00-99)
double second
Minute (0-59)
Definition: datetime.h:42
void dumpToStream(mrpt::utils::CStream &out) const MRPT_OVERRIDE
Dumps the contents of the observation in a human-readable form to a given output stream.
mrpt::system::TTimeStamp getDateTimeAsTimestamp() const
Build an MRPT UTC timestamp with the year/month/day + hour/minute/sec of this observation.
double geoidal_distance
Undulation: Difference between the measured altitude and the geoid, in meters (B).
double magnetic_dir
Magnetic variation direction (East:+, West:-)
bool getAllFieldDescriptions(std::ostream &o) const MRPT_OVERRIDE
Dumps a header for getAllFieldValues()
void dumpToStream(mrpt::utils::CStream &out) const MRPT_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)
bool getAllFieldValues(std::ostream &o) const MRPT_OVERRIDE
Dumps a line with the sequence of all field values (without a line feed at the end).
char positioning_mode
'A': Autonomous, 'D': Differential, 'N': Not valid, 'E': Estimated, 'M': Manual
content_t fields
Message content, accesible by individual fields.
void dumpToStream(mrpt::utils::CStream &out) const MRPT_OVERRIDE
Dumps the contents of the observation in a human-readable form to a given output stream.
double latitude_degrees
The measured latitude, in degrees (North:+ , South:-)
int8_t validity_char
This will be: 'A'=OK or 'V'=void.
bool getAllFieldValues(std::ostream &o) const MRPT_OVERRIDE
Dumps a line with the sequence of all field values (without a line feed at the end).
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
Definition: CStream.cpp:507
bool getAllFieldValues(std::ostream &o) const MRPT_OVERRIDE
Dumps a line with the sequence of all field values (without a line feed at the end).
UTC_time UTCTime
The GPS sensor measured timestamp (in UTC time)



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018