Main MRPT website > C++ reference for MRPT 1.9.9
gnss_messages_novatel.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 #include <map>
14 
15 using namespace std;
16 using namespace mrpt::obs::gnss;
17 
18 nv_oem6_header_t::nv_oem6_header_t()
19  : hdr_len(0),
20  msg_id(0),
21  msg_type(0),
22  port_addr(0),
23  msg_len(0),
24  seq_number(0),
25  idle_percent(0),
26  time_status(0),
27  week(0),
28  ms_in_week(0),
29  receiver_status(0),
30  reserved(0),
31  receiver_sw_version(0)
32 {
33  synch[0] = synch[1] = synch[2] = 0;
34 }
35 
37  : msg_len(), msg_id(), week(), ms_in_week()
38 {
39  synch[0] = synch[1] = synch[2] = 0;
40 }
41 
42 // ------------
44  mrpt::utils::CStream& out) const
45 {
46  out.printf("[Novatel OEM6 GENERIC FRAME]\n");
47  out.printf(" Message ID: %u\n", (unsigned)this->header.msg_id);
48 }
50  mrpt::utils::CStream& out) const
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 }
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 // ------------
67  mrpt::utils::CStream& out) const
68 {
69  out.printf("[Novatel OEM6 GENERIC SHORT FRAME]\n");
70  out.printf(" Message ID: %u\n", (unsigned)this->header.msg_id);
71 }
73  mrpt::utils::CStream& out) const
74 {
75  out.WriteBuffer(&header, sizeof(header));
76  out << static_cast<uint32_t>(msg_body.size());
77  if (!msg_body.empty()) out.WriteBuffer(&msg_body[0], msg_body.size());
78 }
81 {
82  in.ReadBuffer(&header, sizeof(header));
83  uint32_t nBytesInStream;
84  in >> nBytesInStream;
85  msg_body.resize(nBytesInStream);
86  if (nBytesInStream) in.ReadBuffer(&msg_body[0], sizeof(nBytesInStream));
87 }
88 
89 // ------------
91 {
92  static bool init_map = false;
93  static std::map<int, std::string> val2str;
94  if (!init_map)
95  {
96  init_map = true;
97 #define DEF_TYPESTR(_NAME) val2str[nv_oem6_solution_status::_NAME] = #_NAME;
117 #undef DEF_TYPESTR
118  }
120  static const std::string nullstr("???");
121  return (it == val2str.end()) ? nullstr : it->second;
122 }
123 
125 {
126  static bool init_map = false;
127  static std::map<int, std::string> val2str;
128  if (!init_map)
129  {
130  init_map = true;
131 #define DEF_TYPESTR(_NAME) val2str[nv_oem6_position_type::_NAME] = #_NAME;
160 #undef DEF_TYPESTR
161  }
163  static const std::string nullstr("???");
164  return (it == val2str.end()) ? nullstr : it->second;
165 }
166 
168 {
169  static bool init_map = false;
170  static std::map<int, std::string> val2str;
171  if (!init_map)
172  {
173  init_map = true;
174 #define DEF_TYPESTR(_NAME) val2str[nv_oem6_ins_status_type::_NAME] = #_NAME;
183 #undef DEF_TYPESTR
184  }
186  static const std::string nullstr("???");
187  return (it == val2str.end()) ? nullstr : it->second;
188 }
189 
191  const Message_NV_OEM6_BESTPOS::content_t& fields, mrpt::utils::CStream& out)
192 {
193  out.printf(
194  " GPS week: %u ms in week: %u\n", (unsigned)fields.header.week,
195  (unsigned)(fields.header.ms_in_week));
196  out.printf(
197  " Solution status: `%s`\n",
198  nv_oem6_solution_status::enum2str(fields.solution_stat).c_str());
199  out.printf(
200  " Position type : `%s`\n",
201  nv_oem6_position_type::enum2str(fields.position_type).c_str());
202  out.printf(
203  " Longitude: %.09f deg (std dev: %.06f m) Latitude: %.09f deg (std "
204  "dev: %.06f m)\n",
205  fields.lon, fields.lon_sigma, fields.lat, fields.lat_sigma);
206  out.printf(
207  " Height (sea level): %.06f m (std dev: %.06f m) Undulation: %.04f m "
208  "(Sum: %.04f m)\n",
209  fields.hgt, fields.hgt_sigma, fields.undulation,
210  fields.hgt + fields.undulation);
211  out.printf(
212  " Diff age: %.03f Solution age: %.03f\n", fields.diff_age,
213  fields.sol_age);
214  out.printf(" Base station ID: `%.*s`\n", 4, fields.base_station_id);
215  out.printf(
216  " Num sat tracked: %u Num sat in solution: %u\n",
217  (unsigned)fields.num_sats_tracked, (unsigned)fields.num_sats_sol);
218 }
219 
220 void Message_NV_OEM6_BESTPOS::dumpToStream(mrpt::utils::CStream& out) const
221 {
222  out.printf("[Novatel OEM6 BESTPOS]\n");
223  generic_dump_BESTPOS(fields, out);
224 }
225 
226 bool Message_NV_OEM6_BESTPOS::getAllFieldDescriptions(std::ostream& o) const
227 {
228  o << "gps_week.gps_ms solution_stat position_type lon_deg lat_deg hgt_m "
229  "undulation_m lon_sigma_m lat_sigma_m hgt_sigma_m diff_age sol_age "
230  "num_sats_tracked num_sats_sol";
231  return true;
232 }
233 bool Message_NV_OEM6_BESTPOS::getAllFieldValues(std::ostream& o) const
234 {
235  o << mrpt::format(
236  "%u.%08u %u %u %.09f %.09f %.06f %.04f %.06f %.06f %.06f %.03f %.03f "
237  "%u %u",
238  (unsigned)fields.header.week, (unsigned)(fields.header.ms_in_week),
239  (unsigned)fields.solution_stat, (unsigned)fields.position_type,
240  fields.lon, fields.lat, fields.hgt, fields.undulation, fields.lon_sigma,
241  fields.lat_sigma, fields.hgt_sigma, fields.diff_age, fields.sol_age,
242  (unsigned)fields.num_sats_tracked, (unsigned)fields.num_sats_sol);
243  return true;
244 }
245 
246 // ------------
247 void Message_NV_OEM6_INSPVAS::dumpToStream(mrpt::utils::CStream& out) const
248 {
249  out.printf("[Novatel OEM6 INSPVAS]\n");
250  out.printf(
251  " GPS week: %u ms in week: %u\n", (unsigned)fields.header.week,
252  (unsigned)(fields.header.ms_in_week));
253  out.printf(
254  " INS status: `%s`\n",
255  nv_oem6_ins_status_type::enum2str(fields.ins_status).c_str());
256  out.printf(
257  " Longitude: %.09f deg Latitude: %.09f deg Height: %.03f m\n",
258  fields.lon, fields.lat, fields.hgt);
259  out.printf(
260  " Velocities: North: %.05f East: %.05f Up: %.05f\n", fields.vel_north,
261  fields.vel_east, fields.vel_up);
262  out.printf(
263  " Attitude: Roll: %.05f Pitch: %.05f Azimuth: %.05f\n", fields.roll,
264  fields.pitch, fields.azimuth);
265 }
266 
267 bool Message_NV_OEM6_INSPVAS::getAllFieldDescriptions(std::ostream& o) const
268 {
269  o << "gps_week.gps_ms ins_status lon_deg lat_deg ellip_height_WGS84 "
270  "vel_north vel_east vel_up roll_deg pitch_deg azimuth_deg";
271  return true;
272 }
273 bool Message_NV_OEM6_INSPVAS::getAllFieldValues(std::ostream& o) const
274 {
275  o << mrpt::format(
276  "%u.%08u %u %.09f %.09f %.06f %.05f %.05f %.05f %.05f %.05f %.05f",
277  (unsigned)fields.header.week, (unsigned)(fields.header.ms_in_week),
278  (unsigned)fields.ins_status, fields.lon, fields.lat, fields.hgt,
279  fields.vel_north, fields.vel_east, fields.vel_up, fields.roll,
280  fields.pitch, fields.azimuth);
281  return true;
282 }
283 
284 // ------------
285 void Message_NV_OEM6_INSCOVS::dumpToStream(mrpt::utils::CStream& out) const
286 {
287  out.printf("[Novatel OEM6 INSCOVS]\n");
288  out.printf(
289  " GPS week: %u ms in week: %u\n", (unsigned)fields.header.week,
290  (unsigned)(fields.header.ms_in_week));
291  out.printf(
292  " Position cov: %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f "
293  "%9.03f %9.03f\n",
294  fields.pos_cov[0], fields.pos_cov[1], fields.pos_cov[2],
295  fields.pos_cov[3], fields.pos_cov[4], fields.pos_cov[5],
296  fields.pos_cov[6], fields.pos_cov[7], fields.pos_cov[8]);
297  out.printf(
298  " Attitude cov: %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f "
299  "%9.03f %9.03f\n",
300  fields.att_cov[0], fields.att_cov[1], fields.att_cov[2],
301  fields.att_cov[3], fields.att_cov[4], fields.att_cov[5],
302  fields.att_cov[6], fields.att_cov[7], fields.att_cov[8]);
303  out.printf(
304  " Velocity cov: %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f "
305  "%9.03f %9.03f\n",
306  fields.vel_cov[0], fields.vel_cov[1], fields.vel_cov[2],
307  fields.vel_cov[3], fields.vel_cov[4], fields.vel_cov[5],
308  fields.vel_cov[6], fields.vel_cov[7], fields.vel_cov[8]);
309 }
310 
311 bool Message_NV_OEM6_INSCOVS::getAllFieldDescriptions(std::ostream& o) const
312 {
313  o << "gps_week.gps_ms pos_cov(*9) att-cov(*9) vel_cov(*9)";
314  return true;
315 }
316 bool Message_NV_OEM6_INSCOVS::getAllFieldValues(std::ostream& o) const
317 {
318  o << mrpt::format(
319  "%u.%08u "
320  "%9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f "
321  "%9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f "
322  "%9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f %9.03f ",
323  (unsigned)fields.header.week, (unsigned)(fields.header.ms_in_week),
324  fields.pos_cov[0], fields.pos_cov[1], fields.pos_cov[2],
325  fields.pos_cov[3], fields.pos_cov[4], fields.pos_cov[5],
326  fields.pos_cov[6], fields.pos_cov[7], fields.pos_cov[8],
327  fields.att_cov[0], fields.att_cov[1], fields.att_cov[2],
328  fields.att_cov[3], fields.att_cov[4], fields.att_cov[5],
329  fields.att_cov[6], fields.att_cov[7], fields.att_cov[8],
330  fields.vel_cov[0], fields.vel_cov[1], fields.vel_cov[2],
331  fields.vel_cov[3], fields.vel_cov[4], fields.vel_cov[5],
332  fields.vel_cov[6], fields.vel_cov[7], fields.vel_cov[8]);
333  return true;
334 }
335 
336 // ------------
338 {
339  out.printf("[Novatel OEM6 RANGECMP]\n");
340  out.printf(
341  " Number of SAT observations: %u\n",
342  static_cast<unsigned int>(this->num_obs));
343 }
344 
346  mrpt::utils::CStream& out) const
347 {
348  const uint32_t msg_len = sizeof(header) + header.msg_len + 4;
349  out << msg_len;
350  out.WriteBuffer(&header, sizeof(header));
351  out << num_obs;
352  ASSERT_EQUAL_(num_obs, obs_data.size());
353  if (num_obs)
354  out.WriteBuffer(&obs_data[0], sizeof(obs_data[0]) * obs_data.size());
355 }
356 
358 {
359  uint32_t expected_msg_len;
360  in >> expected_msg_len;
361  in.ReadBuffer(&header, sizeof(header));
362  in >> num_obs;
363  ASSERT_BELOW_(num_obs, 2000);
364  obs_data.resize(num_obs);
365  if (num_obs)
366  in.ReadBuffer(&obs_data[0], sizeof(obs_data[0]) * obs_data.size());
367 }
368 
369 // ------------
370 void Message_NV_OEM6_RXSTATUS::dumpToStream(mrpt::utils::CStream& out) const
371 {
372  out.printf("[Novatel OEM6 RXSTATUS]\n");
373  out.printf(
374  " Error code: 0x%04X\n", static_cast<unsigned int>(this->fields.error));
375 }
376 
377 // ------------
378 void Message_NV_OEM6_RAWEPHEM::dumpToStream(mrpt::utils::CStream& out) const
379 {
380  out.printf("[Novatel OEM6 RAWEPHEM]\n");
381  out.printf(
382  " GPS week: %u ms in week: %u\n", (unsigned)fields.header.week,
383  (unsigned)(fields.header.ms_in_week));
384 }
385 
386 // ------------
388 {
389  out.printf("[Novatel OEM6 VERSION]\n");
390  out.printf(
391  " Number of components: %u\n",
392  static_cast<unsigned int>(this->num_comps));
393  for (unsigned i = 0; i < components.size(); i++)
394  {
395  out.printf(
396  " Component #%u:\n Model: `%.*s`\n Serial: `%.*s`\n SW "
397  "version:`%.*s`\n",
398  i, (int)sizeof(components[i].model), components[i].model,
399  (int)sizeof(components[i].serial), components[i].serial,
400  (int)sizeof(components[i].swversion), components[i].swversion);
401  }
402 }
403 
405  mrpt::utils::CStream& out) const
406 {
407  const uint32_t msg_len = sizeof(header) + header.msg_len + 4;
408  out << msg_len;
409  out.WriteBuffer(&header, sizeof(header));
410  out << num_comps;
412  if (num_comps)
413  out.WriteBuffer(
414  &components[0], sizeof(components[0]) * components.size());
415 }
416 
418 {
419  uint32_t expected_msg_len;
420  in >> expected_msg_len;
421  in.ReadBuffer(&header, sizeof(header));
422  in >> num_comps;
423  ASSERT_BELOW_(num_comps, 2000);
424  components.resize(num_comps);
425  if (num_comps)
426  in.ReadBuffer(
427  &components[0], sizeof(components[0]) * components.size());
428 }
429 
430 // ------------
431 void Message_NV_OEM6_RAWIMUS::dumpToStream(mrpt::utils::CStream& out) const
432 {
433  out.printf("[Novatel OEM6 RAWIMUS]\n");
434  out.printf(
435  " GPS week: %u ms in week: %u\n", (unsigned)fields.header.week,
436  (unsigned)(fields.header.ms_in_week));
437  out.printf(" Status: 0x%08lu\n", (long)fields.imu_status);
438  out.printf(
439  " Acel: X=%li Y=%li Z=%li\n", (long)fields.accel_x,
440  -(long)fields.accel_y_neg, (long)fields.accel_z);
441  out.printf(
442  " Gyro: X=%li Y=%li Z=%li\n", (long)fields.gyro_x,
443  -(long)fields.gyro_y_neg, (long)fields.gyro_z);
444 }
445 
446 bool Message_NV_OEM6_RAWIMUS::getAllFieldDescriptions(std::ostream& o) const
447 {
448  o << "gps_week.gps_ms imu_status acc_x acc_y acc_z gyro_x gyro_y gyro_z";
449  return true;
450 }
451 bool Message_NV_OEM6_RAWIMUS::getAllFieldValues(std::ostream& o) const
452 {
453  o << mrpt::format(
454  "%u.%08u %u %li %li %li %li %li %li", (unsigned)fields.header.week,
455  (unsigned)(fields.header.ms_in_week), (unsigned)fields.imu_status,
456  (long)fields.accel_x, -(long)fields.accel_y_neg, (long)fields.accel_z,
457  (long)fields.gyro_x, -(long)fields.gyro_y_neg, (long)fields.gyro_z);
458  return true;
459 }
460 
461 // ------------
463  const Message_NV_OEM6_MARKTIME::content_t& fields,
465 {
466  out.printf(" Clock status: 0x%08lu\n", (long)fields.clock_status);
467  out.printf(
468  " GPS week: %lu Seconds: %f\n", (long)fields.week, fields.week_seconds);
469  out.printf(
470  " Clock offset: %f (std dev = %e)\n", fields.clock_offset,
471  fields.clock_offset_std);
472  out.printf(" UTC offset: %f\n", fields.utc_offset);
473 }
474 
475 void Message_NV_OEM6_MARKTIME::dumpToStream(mrpt::utils::CStream& out) const
476 {
477  out.printf("[Novatel OEM6 MARKTIME]\n");
478  generic_dump_MARKTIME(fields, out);
479 }
480 
481 bool Message_NV_OEM6_MARKTIME::getAllFieldDescriptions(std::ostream& o) const
482 {
483  o << "gps_week.gps_ms clock_status week week_seconds utc_offset";
484  return true;
485 }
487  const Message_NV_OEM6_MARKTIME::content_t& fields, std::ostream& o)
488 {
489  o << mrpt::format(
490  "%u.%08u %u %lu %f %f", (unsigned)fields.header.week,
491  (unsigned)(fields.header.ms_in_week), (unsigned)fields.clock_status,
492  (long unsigned)fields.week, fields.week_seconds, fields.utc_offset);
493 }
494 bool Message_NV_OEM6_MARKTIME::getAllFieldValues(std::ostream& o) const
495 {
497  return true;
498 }
499 // ------------
500 void Message_NV_OEM6_MARK2TIME::dumpToStream(mrpt::utils::CStream& out) const
501 {
502  out.printf("[Novatel OEM6 MARK2TIME]\n");
504  *reinterpret_cast<const Message_NV_OEM6_MARKTIME::content_t*>(&fields),
505  out);
506 }
507 bool Message_NV_OEM6_MARK2TIME::getAllFieldDescriptions(std::ostream& o) const
508 {
509  o << "gps_week.gps_ms clock_status week week_seconds utc_offset";
510  return true;
511 }
512 bool Message_NV_OEM6_MARK2TIME::getAllFieldValues(std::ostream& o) const
513 {
515  *reinterpret_cast<const Message_NV_OEM6_MARKTIME::content_t*>(&fields),
516  o);
517  return true;
518 }
519 
520 // ------------
521 void Message_NV_OEM6_MARKPOS::dumpToStream(mrpt::utils::CStream& out) const
522 {
523  out.printf("[Novatel OEM6 MARKPOSE]\n");
525  *reinterpret_cast<const Message_NV_OEM6_BESTPOS::content_t*>(&fields),
526  out);
527 }
528 
529 // ------------
530 void Message_NV_OEM6_IONUTC::dumpToStream(mrpt::utils::CStream& out) const
531 {
532  out.printf("[Novatel NV_OEM6_IONUTC]\n");
533  out.printf(
534  " GPS week: %u ms in week: %u\n", (unsigned)fields.header.week,
535  (unsigned)(fields.header.ms_in_week));
536  out.printf(
537  " UTC ref week: %u Tot: %u\n", (unsigned)fields.utc_wn,
538  (unsigned)fields.tot);
539  out.printf(
540  " Leap seconds delta_t: %u future: %u\n", (unsigned)fields.deltat_ls,
541  (unsigned)fields.deltat_lsf);
542 }
#define ASSERT_EQUAL_(__A, __B)
const std::string & enum2str(int val)
for nv_ins_status_type_t
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
void internal_readFromStream(mrpt::utils::CStream &in) override
Save to binary stream.
void internal_writeToStream(mrpt::utils::CStream &out) const override
Save to binary stream.
_u32 reserved
Definition: rplidar_cmd.h:21
test distance exceeded (max of 3 rejections if distance > 10km)
void dumpToStream(mrpt::utils::CStream &out) const override
Dumps the contents of the observation in a human-readable form to a given output stream.
when a fix position command is entered, the receiver computes its own position and determines if the ...
#define ASSERT_BELOW_(__A, __B)
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
Definition: CStream.cpp:64
const std::string & enum2str(int val)
for nv_position_type_t
STL namespace.
const Scalar * const_iterator
Definition: eigen_plugins.h:27
GLenum GLenum GLuint components
Definition: glext.h:7282
void internal_readFromStream(mrpt::utils::CStream &in) override
Save to binary stream.
const std::string & enum2str(int val)
for nv_solution_status_t
void dumpToStream(mrpt::utils::CStream &out) const override
Dumps the contents of the observation in a human-readable form to a given output stream.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
_u8 model
Definition: rplidar_cmd.h:20
void generic_dump_MARKTIME(const Message_NV_OEM6_MARKTIME::content_t &fields, mrpt::utils::CStream &out)
int val
Definition: mrpt_jpeglib.h:955
void internal_readFromStream(mrpt::utils::CStream &in) override
Save to binary stream.
void internal_writeToStream(mrpt::utils::CStream &out) const override
Save to binary stream.
void internal_readFromStream(mrpt::utils::CStream &in) override
Save to binary stream.
GLsizei const GLchar ** string
Definition: glext.h:4101
GNSS (GPS) data structures, mainly for use within mrpt::obs::CObservationGPS.
void generic_dump_BESTPOS(const Message_NV_OEM6_BESTPOS::content_t &fields, mrpt::utils::CStream &out)
std::vector< TCompressedRangeLog > obs_data
bool getAllFieldDescriptions(std::ostream &o) const override
void dumpToStream(mrpt::utils::CStream &out) const override
Dumps the contents of the observation in a human-readable form to a given output stream.
GLuint in
Definition: glext.h:7274
void generic_getFieldValues_MARKTIME(const Message_NV_OEM6_MARKTIME::content_t &fields, std::ostream &o)
void internal_writeToStream(mrpt::utils::CStream &out) const override
Save to binary stream.
covariance trace exceeds maximum (trace>1000m)
the fixed position entered using the fix position command is not valid
void internal_writeToStream(mrpt::utils::CStream &out) const override
Save to binary stream.
#define DEF_TYPESTR(_NAME)
unsigned __int32 uint32_t
Definition: rptypes.h:47
bool getAllFieldValues(std::ostream &o) const override
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



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