MRPT  1.9.9
gnss_messages_novatel.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 #include <map>
15 
16 using namespace std;
17 using namespace mrpt::obs::gnss;
18 
19 // ------------
20 void Message_NV_OEM6_GENERIC_FRAME::dumpToStream(std::ostream& out) const
21 {
22  out << mrpt::format(
23  "[Novatel OEM6 GENERIC FRAME]\n"
24  " Message ID: %u\n",
25  (unsigned)this->header.msg_id);
26 }
27 void Message_NV_OEM6_GENERIC_FRAME::internal_writeToStream(
29 {
30  out.WriteBuffer(&header, sizeof(header));
31  out << static_cast<uint32_t>(msg_body.size());
32  if (!msg_body.empty()) out.WriteBuffer(&msg_body[0], msg_body.size());
33 }
34 void Message_NV_OEM6_GENERIC_FRAME::internal_readFromStream(
36 {
37  in.ReadBuffer(&header, sizeof(header));
38  uint32_t nBytesInStream;
39  in >> nBytesInStream;
40  msg_body.resize(nBytesInStream);
41  if (nBytesInStream) in.ReadBuffer(&msg_body[0], sizeof(nBytesInStream));
42 }
43 // ------------
44 void Message_NV_OEM6_GENERIC_SHORT_FRAME::dumpToStream(std::ostream& out) const
45 {
46  out << mrpt::format("[Novatel OEM6 GENERIC SHORT FRAME]\n");
47  out << mrpt::format(" Message ID: %u\n", (unsigned)this->header.msg_id);
48 }
49 void Message_NV_OEM6_GENERIC_SHORT_FRAME::internal_writeToStream(
51 {
52  out.WriteBuffer(&header, sizeof(header));
53  out << static_cast<uint32_t>(msg_body.size());
54  if (!msg_body.empty()) out.WriteBuffer(&msg_body[0], msg_body.size());
55 }
56 void Message_NV_OEM6_GENERIC_SHORT_FRAME::internal_readFromStream(
58 {
59  in.ReadBuffer(&header, sizeof(header));
60  uint32_t nBytesInStream;
61  in >> nBytesInStream;
62  msg_body.resize(nBytesInStream);
63  if (nBytesInStream) in.ReadBuffer(&msg_body[0], sizeof(nBytesInStream));
64 }
65 
66 // ------------
68 {
69  static bool init_map = false;
70  static std::map<int, std::string> val2str;
71  if (!init_map)
72  {
73  init_map = true;
74 #define DEF_TYPESTR(_NAME) val2str[nv_oem6_solution_status::_NAME] = #_NAME;
94 #undef DEF_TYPESTR
95  }
96  auto it = val2str.find(val);
97  static const std::string nullstr("???");
98  return (it == val2str.end()) ? nullstr : it->second;
99 }
100 
102 {
103  static bool init_map = false;
104  static std::map<int, std::string> val2str;
105  if (!init_map)
106  {
107  init_map = true;
108 #define DEF_TYPESTR(_NAME) val2str[nv_oem6_position_type::_NAME] = #_NAME;
137 #undef DEF_TYPESTR
138  }
139  auto it = val2str.find(val);
140  static const std::string nullstr("???");
141  return (it == val2str.end()) ? nullstr : it->second;
142 }
143 
145 {
146  static bool init_map = false;
147  static std::map<int, std::string> val2str;
148  if (!init_map)
149  {
150  init_map = true;
151 #define DEF_TYPESTR(_NAME) val2str[nv_oem6_ins_status_type::_NAME] = #_NAME;
160 #undef DEF_TYPESTR
161  }
162  auto it = val2str.find(val);
163  static const std::string nullstr("???");
164  return (it == val2str.end()) ? nullstr : it->second;
165 }
166 
168  const Message_NV_OEM6_BESTPOS::content_t& fields, std::ostream& out)
169 {
170  out << mrpt::format(
171  " GPS week: %u ms in week: %u\n", (unsigned)fields.header.week,
172  (unsigned)(fields.header.ms_in_week));
173  out << mrpt::format(
174  " Solution status: `%s`\n",
175  nv_oem6_solution_status::enum2str(fields.solution_stat).c_str());
176  out << mrpt::format(
177  " Position type : `%s`\n",
178  nv_oem6_position_type::enum2str(fields.position_type).c_str());
179  out << mrpt::format(
180  " Longitude: %.09f deg (std dev: %.06f m) Latitude: %.09f deg (std "
181  "dev: %.06f m)\n",
182  fields.lon, fields.lon_sigma, fields.lat, fields.lat_sigma);
183  out << mrpt::format(
184  " Height (sea level): %.06f m (std dev: %.06f m) Undulation: %.04f m "
185  "(Sum: %.04f m)\n",
186  fields.hgt, fields.hgt_sigma, fields.undulation,
187  fields.hgt + fields.undulation);
188  out << mrpt::format(
189  " Diff age: %.03f Solution age: %.03f\n", fields.diff_age,
190  fields.sol_age);
191  out << mrpt::format(
192  " Base station ID: `%.*s`\n", 4, fields.base_station_id);
193  out << mrpt::format(
194  " Num sat tracked: %u Num sat in solution: %u\n",
195  (unsigned)fields.num_sats_tracked, (unsigned)fields.num_sats_sol);
196 }
197 
198 void Message_NV_OEM6_BESTPOS::dumpToStream(std::ostream& out) const
199 {
200  out << "[Novatel OEM6 BESTPOS]\n";
201  generic_dump_BESTPOS(fields, out);
202 }
203 
204 bool Message_NV_OEM6_BESTPOS::getAllFieldDescriptions(std::ostream& o) const
205 {
206  o << "gps_week.gps_ms solution_stat position_type lon_deg lat_deg hgt_m "
207  "undulation_m lon_sigma_m lat_sigma_m hgt_sigma_m diff_age sol_age "
208  "num_sats_tracked num_sats_sol";
209  return true;
210 }
211 bool Message_NV_OEM6_BESTPOS::getAllFieldValues(std::ostream& o) const
212 {
213  o << mrpt::format(
214  "%u.%08u %u %u %.09f %.09f %.06f %.04f %.06f %.06f %.06f %.03f %.03f "
215  "%u %u",
216  (unsigned)fields.header.week, (unsigned)(fields.header.ms_in_week),
217  (unsigned)fields.solution_stat, (unsigned)fields.position_type,
218  fields.lon, fields.lat, fields.hgt, fields.undulation, fields.lon_sigma,
219  fields.lat_sigma, fields.hgt_sigma, fields.diff_age, fields.sol_age,
220  (unsigned)fields.num_sats_tracked, (unsigned)fields.num_sats_sol);
221  return true;
222 }
223 
224 // ------------
225 void Message_NV_OEM6_INSPVAS::dumpToStream(std::ostream& out) const
226 {
227  out << mrpt::format("[Novatel OEM6 INSPVAS]\n");
228  out << mrpt::format(
229  " GPS week: %u ms in week: %u\n", (unsigned)fields.header.week,
230  (unsigned)(fields.header.ms_in_week));
231  out << mrpt::format(
232  " INS status: `%s`\n",
233  nv_oem6_ins_status_type::enum2str(fields.ins_status).c_str());
234  out << mrpt::format(
235  " Longitude: %.09f deg Latitude: %.09f deg Height: %.03f m\n",
236  fields.lon, fields.lat, fields.hgt);
237  out << mrpt::format(
238  " Velocities: North: %.05f East: %.05f Up: %.05f\n", fields.vel_north,
239  fields.vel_east, fields.vel_up);
240  out << mrpt::format(
241  " Attitude: Roll: %.05f Pitch: %.05f Azimuth: %.05f\n", fields.roll,
242  fields.pitch, fields.azimuth);
243 }
244 
245 bool Message_NV_OEM6_INSPVAS::getAllFieldDescriptions(std::ostream& o) const
246 {
247  o << "gps_week.gps_ms ins_status lon_deg lat_deg ellip_height_WGS84 "
248  "vel_north vel_east vel_up roll_deg pitch_deg azimuth_deg";
249  return true;
250 }
251 bool Message_NV_OEM6_INSPVAS::getAllFieldValues(std::ostream& o) const
252 {
253  o << mrpt::format(
254  "%u.%08u %u %.09f %.09f %.06f %.05f %.05f %.05f %.05f %.05f %.05f",
255  (unsigned)fields.header.week, (unsigned)(fields.header.ms_in_week),
256  (unsigned)fields.ins_status, fields.lon, fields.lat, fields.hgt,
257  fields.vel_north, fields.vel_east, fields.vel_up, fields.roll,
258  fields.pitch, fields.azimuth);
259  return true;
260 }
261 
262 // ------------
263 void Message_NV_OEM6_INSCOVS::dumpToStream(std::ostream& out) const
264 {
265  out << mrpt::format("[Novatel OEM6 INSCOVS]\n");
266  out << mrpt::format(
267  " GPS week: %u ms in week: %u\n", (unsigned)fields.header.week,
268  (unsigned)(fields.header.ms_in_week));
269  out << mrpt::format(
270  " Position cov: %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f "
271  "%9.03f %9.03f\n",
272  fields.pos_cov[0], fields.pos_cov[1], fields.pos_cov[2],
273  fields.pos_cov[3], fields.pos_cov[4], fields.pos_cov[5],
274  fields.pos_cov[6], fields.pos_cov[7], fields.pos_cov[8]);
275  out << mrpt::format(
276  " Attitude cov: %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f "
277  "%9.03f %9.03f\n",
278  fields.att_cov[0], fields.att_cov[1], fields.att_cov[2],
279  fields.att_cov[3], fields.att_cov[4], fields.att_cov[5],
280  fields.att_cov[6], fields.att_cov[7], fields.att_cov[8]);
281  out << mrpt::format(
282  " Velocity cov: %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f "
283  "%9.03f %9.03f\n",
284  fields.vel_cov[0], fields.vel_cov[1], fields.vel_cov[2],
285  fields.vel_cov[3], fields.vel_cov[4], fields.vel_cov[5],
286  fields.vel_cov[6], fields.vel_cov[7], fields.vel_cov[8]);
287 }
288 
289 bool Message_NV_OEM6_INSCOVS::getAllFieldDescriptions(std::ostream& o) const
290 {
291  o << "gps_week.gps_ms pos_cov(*9) att-cov(*9) vel_cov(*9)";
292  return true;
293 }
294 bool Message_NV_OEM6_INSCOVS::getAllFieldValues(std::ostream& o) const
295 {
296  o << mrpt::format(
297  "%u.%08u "
298  "%9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f "
299  "%9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f "
300  "%9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f ",
301  (unsigned)fields.header.week, (unsigned)(fields.header.ms_in_week),
302  fields.pos_cov[0], fields.pos_cov[1], fields.pos_cov[2],
303  fields.pos_cov[3], fields.pos_cov[4], fields.pos_cov[5],
304  fields.pos_cov[6], fields.pos_cov[7], fields.pos_cov[8],
305  fields.att_cov[0], fields.att_cov[1], fields.att_cov[2],
306  fields.att_cov[3], fields.att_cov[4], fields.att_cov[5],
307  fields.att_cov[6], fields.att_cov[7], fields.att_cov[8],
308  fields.vel_cov[0], fields.vel_cov[1], fields.vel_cov[2],
309  fields.vel_cov[3], fields.vel_cov[4], fields.vel_cov[5],
310  fields.vel_cov[6], fields.vel_cov[7], fields.vel_cov[8]);
311  return true;
312 }
313 
314 // ------------
315 void Message_NV_OEM6_RANGECMP::dumpToStream(std::ostream& out) const
316 {
317  out << mrpt::format("[Novatel OEM6 RANGECMP]\n");
318  out << mrpt::format(
319  " Number of SAT observations: %u\n",
320  static_cast<unsigned int>(this->num_obs));
321 }
322 
323 void Message_NV_OEM6_RANGECMP::internal_writeToStream(
325 {
326  const uint32_t msg_len = sizeof(header) + header.msg_len + 4;
327  out << msg_len;
328  out.WriteBuffer(&header, sizeof(header));
329  out << num_obs;
330  ASSERT_EQUAL_(num_obs, obs_data.size());
331  if (num_obs)
332  out.WriteBuffer(&obs_data[0], sizeof(obs_data[0]) * obs_data.size());
333 }
334 
335 void Message_NV_OEM6_RANGECMP::internal_readFromStream(
337 {
338  uint32_t expected_msg_len;
339  in >> expected_msg_len;
340  in.ReadBuffer(&header, sizeof(header));
341  in >> num_obs;
342  ASSERT_BELOW_(num_obs, 2000);
343  obs_data.resize(num_obs);
344  if (num_obs)
345  in.ReadBuffer(&obs_data[0], sizeof(obs_data[0]) * obs_data.size());
346 }
347 
348 // ------------
349 void Message_NV_OEM6_RXSTATUS::dumpToStream(std::ostream& out) const
350 {
351  out << mrpt::format("[Novatel OEM6 RXSTATUS]\n");
352  out << mrpt::format(
353  " Error code: 0x%04X\n", static_cast<unsigned int>(this->fields.error));
354 }
355 
356 // ------------
357 void Message_NV_OEM6_RAWEPHEM::dumpToStream(std::ostream& out) const
358 {
359  out << mrpt::format("[Novatel OEM6 RAWEPHEM]\n");
360  out << mrpt::format(
361  " GPS week: %u ms in week: %u\n", (unsigned)fields.header.week,
362  (unsigned)(fields.header.ms_in_week));
363 }
364 
365 // ------------
366 void Message_NV_OEM6_VERSION::dumpToStream(std::ostream& out) const
367 {
368  out << mrpt::format("[Novatel OEM6 VERSION]\n");
369  out << mrpt::format(
370  " Number of components: %u\n",
371  static_cast<unsigned int>(this->num_comps));
372  for (unsigned i = 0; i < components.size(); i++)
373  {
374  out << mrpt::format(
375  " Component #%u:\n Model: `%.*s`\n Serial: `%.*s`\n SW "
376  "version:`%.*s`\n",
377  i, (int)sizeof(components[i].model), components[i].model,
378  (int)sizeof(components[i].serial), components[i].serial,
379  (int)sizeof(components[i].swversion), components[i].swversion);
380  }
381 }
382 
383 void Message_NV_OEM6_VERSION::internal_writeToStream(
385 {
386  const uint32_t msg_len = sizeof(header) + header.msg_len + 4;
387  out << msg_len;
388  out.WriteBuffer(&header, sizeof(header));
389  out << num_comps;
390  ASSERT_EQUAL_(num_comps, components.size());
391  if (num_comps)
392  out.WriteBuffer(
393  &components[0], sizeof(components[0]) * components.size());
394 }
395 
396 void Message_NV_OEM6_VERSION::internal_readFromStream(
398 {
399  uint32_t expected_msg_len;
400  in >> expected_msg_len;
401  in.ReadBuffer(&header, sizeof(header));
402  in >> num_comps;
403  ASSERT_BELOW_(num_comps, 2000);
404  components.resize(num_comps);
405  if (num_comps)
406  in.ReadBuffer(
407  &components[0], sizeof(components[0]) * components.size());
408 }
409 
410 // ------------
411 void Message_NV_OEM6_RAWIMUS::dumpToStream(std::ostream& out) const
412 {
413  out << mrpt::format("[Novatel OEM6 RAWIMUS]\n");
414  out << mrpt::format(
415  " GPS week: %u ms in week: %u\n", (unsigned)fields.header.week,
416  (unsigned)(fields.header.ms_in_week));
417  out << mrpt::format(" Status: 0x%08lu\n", (long)fields.imu_status);
418  out << mrpt::format(
419  " Acel: X=%li Y=%li Z=%li\n", (long)fields.accel_x,
420  -(long)fields.accel_y_neg, (long)fields.accel_z);
421  out << mrpt::format(
422  " Gyro: X=%li Y=%li Z=%li\n", (long)fields.gyro_x,
423  -(long)fields.gyro_y_neg, (long)fields.gyro_z);
424 }
425 
426 bool Message_NV_OEM6_RAWIMUS::getAllFieldDescriptions(std::ostream& o) const
427 {
428  o << "gps_week.gps_ms imu_status acc_x acc_y acc_z gyro_x gyro_y gyro_z";
429  return true;
430 }
431 bool Message_NV_OEM6_RAWIMUS::getAllFieldValues(std::ostream& o) const
432 {
433  o << mrpt::format(
434  "%u.%08u %u %li %li %li %li %li %li", (unsigned)fields.header.week,
435  (unsigned)(fields.header.ms_in_week), (unsigned)fields.imu_status,
436  (long)fields.accel_x, -(long)fields.accel_y_neg, (long)fields.accel_z,
437  (long)fields.gyro_x, -(long)fields.gyro_y_neg, (long)fields.gyro_z);
438  return true;
439 }
440 
441 // ------------
443  const Message_NV_OEM6_MARKTIME::content_t& fields, std::ostream& out)
444 {
445  out << mrpt::format(" Clock status: 0x%08lu\n", (long)fields.clock_status);
446  out << mrpt::format(
447  " GPS week: %lu Seconds: %f\n", (long)fields.week, fields.week_seconds);
448  out << mrpt::format(
449  " Clock offset: %f (std dev = %e)\n", fields.clock_offset,
450  fields.clock_offset_std);
451  out << mrpt::format(" UTC offset: %f\n", fields.utc_offset);
452 }
453 
454 void Message_NV_OEM6_MARKTIME::dumpToStream(std::ostream& out) const
455 {
456  out << mrpt::format("[Novatel OEM6 MARKTIME]\n");
457  generic_dump_MARKTIME(fields, out);
458 }
459 
460 bool Message_NV_OEM6_MARKTIME::getAllFieldDescriptions(std::ostream& o) const
461 {
462  o << "gps_week.gps_ms clock_status week week_seconds utc_offset";
463  return true;
464 }
466  const Message_NV_OEM6_MARKTIME::content_t& fields, std::ostream& o)
467 {
468  o << mrpt::format(
469  "%u.%08u %u %lu %f %f", (unsigned)fields.header.week,
470  (unsigned)(fields.header.ms_in_week), (unsigned)fields.clock_status,
471  (long unsigned)fields.week, fields.week_seconds, fields.utc_offset);
472 }
473 bool Message_NV_OEM6_MARKTIME::getAllFieldValues(std::ostream& o) const
474 {
476  return true;
477 }
478 // ------------
479 void Message_NV_OEM6_MARK2TIME::dumpToStream(std::ostream& out) const
480 {
481  out << mrpt::format("[Novatel OEM6 MARK2TIME]\n");
483  *reinterpret_cast<const Message_NV_OEM6_MARKTIME::content_t*>(&fields),
484  out);
485 }
486 bool Message_NV_OEM6_MARK2TIME::getAllFieldDescriptions(std::ostream& o) const
487 {
488  o << "gps_week.gps_ms clock_status week week_seconds utc_offset";
489  return true;
490 }
491 bool Message_NV_OEM6_MARK2TIME::getAllFieldValues(std::ostream& o) const
492 {
494  *reinterpret_cast<const Message_NV_OEM6_MARKTIME::content_t*>(&fields),
495  o);
496  return true;
497 }
498 
499 // ------------
500 void Message_NV_OEM6_MARKPOS::dumpToStream(std::ostream& out) const
501 {
502  out << mrpt::format("[Novatel OEM6 MARKPOSE]\n");
504  *reinterpret_cast<const Message_NV_OEM6_BESTPOS::content_t*>(&fields),
505  out);
506 }
507 
508 // ------------
509 void Message_NV_OEM6_IONUTC::dumpToStream(std::ostream& out) const
510 {
511  out << mrpt::format("[Novatel NV_OEM6_IONUTC]\n");
512  out << mrpt::format(
513  " GPS week: %u ms in week: %u\n", (unsigned)fields.header.week,
514  (unsigned)(fields.header.ms_in_week));
515  out << mrpt::format(
516  " UTC ref week: %u Tot: %u\n", (unsigned)fields.utc_wn,
517  (unsigned)fields.tot);
518  out << mrpt::format(
519  " Leap seconds delta_t: %u future: %u\n", (unsigned)fields.deltat_ls,
520  (unsigned)fields.deltat_lsf);
521 }
test distance exceeded (max of 3 rejections if distance > 10km)
#define ASSERT_BELOW_(__A, __B)
Definition: exceptions.h:149
when a fix position command is entered, the receiver computes its own position and determines if the ...
const std::string & enum2str(int val)
for nv_position_type_t
STL namespace.
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
Definition: CArchive.cpp:49
GLenum GLenum GLuint components
Definition: glext.h:7401
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
Definition: exceptions.h:137
_u8 model
Definition: rplidar_cmd.h:19
nv_oem6_header_t header
Novatel frame: NV_OEM6_BESTPOS.
void generic_dump_BESTPOS(const Message_NV_OEM6_BESTPOS::content_t &fields, std::ostream &out)
int val
Definition: mrpt_jpeglib.h:957
void generic_dump_MARKTIME(const Message_NV_OEM6_MARKTIME::content_t &fields, std::ostream &out)
GLsizei const GLchar ** string
Definition: glext.h:4116
GNSS (GPS) data structures, mainly for use within mrpt::obs::CObservationGPS.
bool getAllFieldDescriptions(std::ostream &o) const override
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:53
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
GLuint in
Definition: glext.h:7391
void generic_getFieldValues_MARKTIME(const Message_NV_OEM6_MARKTIME::content_t &fields, std::ostream &o)
covariance trace exceeds maximum (trace>1000m)
the fixed position entered using the fix position command is not valid
#define DEF_TYPESTR(_NAME)
unsigned __int32 uint32_t
Definition: rptypes.h:50
bool getAllFieldValues(std::ostream &o) const override



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