Main MRPT website > C++ reference for MRPT 1.9.9
path_from_rtk_gps.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 "topography-precomp.h" // Precompiled headers
11 
12 #include <mrpt/tfest/se3.h>
14 #include <mrpt/math/data_utils.h>
18 
19 #include <memory>
20 
21 #if MRPT_HAS_WXWIDGETS
22 #include <wx/app.h>
23 #include <wx/msgdlg.h>
24 #include <wx/string.h>
25 #include <wx/progdlg.h>
26 #include <wx/busyinfo.h>
27 #include <wx/log.h>
28 #endif // MRPT_HAS_WXWIDGETS
29 
30 using namespace std;
31 using namespace mrpt;
32 using namespace mrpt::obs;
33 using namespace mrpt::math;
34 using namespace mrpt::poses;
35 using namespace mrpt::system;
36 using namespace mrpt::tfest;
37 using namespace mrpt::config;
38 using namespace mrpt::topography;
39 
40 template <class T>
41 std::set<T> make_set(const T& v0, const T& v1)
42 {
43  std::set<T> s;
44  s.insert(v0);
45  s.insert(v1);
46  return s;
47 }
48 
49 /*---------------------------------------------------------------
50  path_from_rtk_gps
51  ---------------------------------------------------------------*/
54  const mrpt::obs::CRawlog& rawlog, size_t first, size_t last, bool isGUI,
55  bool disableGPSInterp, int PATH_SMOOTH_FILTER, TPathFromRTKInfo* outInfo)
56 {
58 
59 #if MRPT_HAS_WXWIDGETS
60  // Use a smart pointer so we are safe against exceptions:
61  std::unique_ptr<wxBusyCursor> waitCursorPtr;
62  if (isGUI)
63  waitCursorPtr = std::unique_ptr<wxBusyCursor>(new wxBusyCursor());
64 #else
65  MRPT_UNUSED_PARAM(isGUI);
66 #endif
67 
68  // Go: generate the map:
69  ASSERT_(first <= last);
70  ASSERT_(last <= rawlog.size() - 1);
71 
72  set<string> lstGPSLabels;
73 
74  size_t count = 0;
75 
76  robot_path.clear();
77  robot_path.setMaxTimeInterpolation(
78  3.0); // Max. seconds of GPS blackout not to interpolate.
80 
81  TPathFromRTKInfo outInfoTemp;
82  if (outInfo) *outInfo = outInfoTemp;
83 
84  map<string, map<TTimeStamp, TPoint3D>>
85  gps_paths; // label -> (time -> 3D local coords)
86 
87  bool abort = false;
88  bool ref_valid = false;
89 
90  // Load configuration block:
91  CConfigFileMemory memFil;
92  rawlog.getCommentTextAsConfigFile(memFil);
93 
95  memFil.read_double("GPS_ORIGIN", "lat_deg", 0),
96  memFil.read_double("GPS_ORIGIN", "lon_deg", 0),
97  memFil.read_double("GPS_ORIGIN", "height", 0));
98 
99  ref_valid = !ref.isClear();
100 
101  // Do we have info for the consistency test?
102  const double std_0 = memFil.read_double("CONSISTENCY_TEST", "std_0", 0);
103  bool doConsistencyCheck = std_0 > 0;
104 
105  // Do we have the "reference uncertainty" matrix W^\star ??
106  memFil.read_matrix("UNCERTAINTY", "W_star", outInfoTemp.W_star);
107  const bool doUncertaintyCovs = outInfoTemp.W_star.rows() != 0;
108  if (doUncertaintyCovs &&
109  (outInfoTemp.W_star.rows() != 6 || outInfoTemp.W_star.cols() != 6))
111  "ERROR: W_star matrix for uncertainty estimation is provided but "
112  "it's not a 6x6 matrix.");
113 
114 // ------------------------------------------
115 // Look for the 2 observations:
116 // ------------------------------------------
117 #if MRPT_HAS_WXWIDGETS
118  wxProgressDialog* progDia = nullptr;
119  if (isGUI)
120  {
121  progDia = new wxProgressDialog(
122  wxT("Building map"), wxT("Getting GPS observations..."),
123  (int)(last - first + 1), // range
124  nullptr, // parent
125  wxPD_CAN_ABORT | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_AUTO_HIDE |
126  wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME);
127  }
128 #endif
129 
130  // The list with all time ordered gps's in valid RTK mode
131  using TListGPSs = std::map<
132  mrpt::system::TTimeStamp, std::map<std::string, CObservationGPS::Ptr>>;
133  TListGPSs list_gps_obs;
134 
135  map<string, size_t> GPS_RTK_reads; // label-># of RTK readings
136  map<string, TPoint3D>
137  GPS_local_coords_on_vehicle; // label -> local pose on the vehicle
138 
139  for (size_t i = first; !abort && i <= last; i++)
140  {
141  switch (rawlog.getType(i))
142  {
143  default:
144  break;
145 
146  case CRawlog::etObservation:
147  {
148  CObservation::Ptr o = rawlog.getAsObservation(i);
149 
150  if (o->GetRuntimeClass() == CLASS_ID(CObservationGPS))
151  {
153  std::dynamic_pointer_cast<CObservationGPS>(o);
154 
155  if (obs->has_GGA_datum &&
156  obs->getMsgByClass<gnss::Message_NMEA_GGA>()
157  .fields.fix_quality == 4)
158  {
159  // Add to the list:
160  list_gps_obs[obs->timestamp][obs->sensorLabel] = obs;
161 
162  lstGPSLabels.insert(obs->sensorLabel);
163  }
164 
165  // Save to GPS paths:
166  if (obs->has_GGA_datum &&
167  (obs->getMsgByClass<gnss::Message_NMEA_GGA>()
168  .fields.fix_quality == 4 ||
169  obs->getMsgByClass<gnss::Message_NMEA_GGA>()
170  .fields.fix_quality == 5))
171  {
172  GPS_RTK_reads[obs->sensorLabel]++;
173 
174  // map<string,TPoint3D> GPS_local_coords_on_vehicle; //
175  // label -> local pose on the vehicle
176  if (GPS_local_coords_on_vehicle.find(
177  obs->sensorLabel) ==
178  GPS_local_coords_on_vehicle.end())
179  GPS_local_coords_on_vehicle[obs->sensorLabel] =
180  TPoint3D(obs->sensorPose.asTPose());
181 
182  // map<string, map<TTimeStamp,TPoint3D> > gps_paths;
183  // //
184  // label -> (time -> 3D local coords)
185  gps_paths[obs->sensorLabel][obs->timestamp] = TPoint3D(
186  obs->getMsgByClass<gnss::Message_NMEA_GGA>()
188  obs->getMsgByClass<gnss::Message_NMEA_GGA>()
190  obs->getMsgByClass<gnss::Message_NMEA_GGA>()
192  }
193  }
194  }
195  break;
196  } // end switch type
197 
198  // Show progress:
199  if ((count++ % 100) == 0)
200  {
201 #if MRPT_HAS_WXWIDGETS
202  if (progDia)
203  {
204  if (!progDia->Update((int)(i - first))) abort = true;
205  wxTheApp->Yield();
206  }
207 #endif
208  }
209  } // end for i
210 
211 #if MRPT_HAS_WXWIDGETS
212  if (progDia)
213  {
214  delete progDia;
215  progDia = nullptr;
216  }
217 #endif
218 
219  // -----------------------------------------------------------
220  // At this point we already have the sensor positions, thus
221  // we can estimate the covariance matrix D:
222  //
223  // TODO: Generalize equations for # of GPS > 3
224  // -----------------------------------------------------------
225  map<set<string>, double> Ad_ij; // InterGPS distances in 2D
226  map<set<string>, double>
227  phi_ij; // Directions on XY of the lines between i-j
228  map<string, size_t>
229  D_cov_indexes; // Sensor label-> index in the matrix (first=0, ...)
230  map<size_t, string> D_cov_rev_indexes; // Reverse of D_cov_indexes
231 
232  CMatrixDouble D_cov; // square distances cov
233  CMatrixDouble D_cov_1; // square distances cov (inverse)
234  CVectorDouble D_mean; // square distances mean
235 
236  if (doConsistencyCheck && GPS_local_coords_on_vehicle.size() == 3)
237  {
238  unsigned int cnt = 0;
240  GPS_local_coords_on_vehicle.begin();
241  i != GPS_local_coords_on_vehicle.end(); ++i)
242  {
243  // Index tables:
244  D_cov_indexes[i->first] = cnt;
245  D_cov_rev_indexes[cnt] = i->first;
246  cnt++;
247 
249  j != GPS_local_coords_on_vehicle.end(); ++j)
250  {
251  if (i != j)
252  {
253  const TPoint3D& pi = i->second;
254  const TPoint3D& pj = j->second;
255  Ad_ij[make_set(i->first, j->first)] = pi.distanceTo(pj);
256  phi_ij[make_set(i->first, j->first)] =
257  atan2(pj.y - pi.y, pj.x - pi.x);
258  }
259  }
260  }
261  ASSERT_(D_cov_indexes.size() == 3 && D_cov_rev_indexes.size() == 3);
262 
263  D_cov.setSize(D_cov_indexes.size(), D_cov_indexes.size());
264  D_mean.resize(D_cov_indexes.size());
265 
266  // See paper for the formulas!
267  // TODO: generalize for N>3
268 
269  D_cov(0, 0) =
270  2 *
271  square(Ad_ij[make_set(D_cov_rev_indexes[0], D_cov_rev_indexes[1])]);
272  D_cov(1, 1) =
273  2 *
274  square(Ad_ij[make_set(D_cov_rev_indexes[0], D_cov_rev_indexes[2])]);
275  D_cov(2, 2) =
276  2 *
277  square(Ad_ij[make_set(D_cov_rev_indexes[1], D_cov_rev_indexes[2])]);
278 
279  D_cov(1, 0) =
280  Ad_ij[make_set(D_cov_rev_indexes[0], D_cov_rev_indexes[1])] *
281  Ad_ij[make_set(D_cov_rev_indexes[0], D_cov_rev_indexes[2])] *
282  cos(phi_ij[make_set(D_cov_rev_indexes[0], D_cov_rev_indexes[1])] -
283  phi_ij[make_set(D_cov_rev_indexes[0], D_cov_rev_indexes[2])]);
284  D_cov(0, 1) = D_cov(1, 0);
285 
286  D_cov(2, 0) =
287  -Ad_ij[make_set(D_cov_rev_indexes[0], D_cov_rev_indexes[1])] *
288  Ad_ij[make_set(D_cov_rev_indexes[1], D_cov_rev_indexes[2])] *
289  cos(phi_ij[make_set(D_cov_rev_indexes[0], D_cov_rev_indexes[1])] -
290  phi_ij[make_set(D_cov_rev_indexes[1], D_cov_rev_indexes[2])]);
291  D_cov(0, 2) = D_cov(2, 0);
292 
293  D_cov(2, 1) =
294  Ad_ij[make_set(D_cov_rev_indexes[0], D_cov_rev_indexes[2])] *
295  Ad_ij[make_set(D_cov_rev_indexes[1], D_cov_rev_indexes[2])] *
296  cos(phi_ij[make_set(D_cov_rev_indexes[0], D_cov_rev_indexes[2])] -
297  phi_ij[make_set(D_cov_rev_indexes[1], D_cov_rev_indexes[2])]);
298  D_cov(1, 2) = D_cov(2, 1);
299 
300  D_cov *= 4 * square(std_0);
301 
302  D_cov_1 = D_cov.inv();
303 
304  // cout << D_cov.inMatlabFormat() << endl;
305 
306  D_mean[0] =
307  square(Ad_ij[make_set(D_cov_rev_indexes[0], D_cov_rev_indexes[1])]);
308  D_mean[1] =
309  square(Ad_ij[make_set(D_cov_rev_indexes[0], D_cov_rev_indexes[2])]);
310  D_mean[2] =
311  square(Ad_ij[make_set(D_cov_rev_indexes[1], D_cov_rev_indexes[2])]);
312  }
313  else
314  doConsistencyCheck = false;
315 
316  // ------------------------------------------
317  // Look for the 2 observations:
318  // ------------------------------------------
319  int N_GPSs = list_gps_obs.size();
320 
321  if (N_GPSs)
322  {
323  // loop interpolate 1-out-of-5: this solves the issue with JAVAD GPSs
324  // that skip some readings at some times .0 .2 .4 .6 .8
325  if (list_gps_obs.size() > 4)
326  {
327  TListGPSs::iterator F = list_gps_obs.begin();
328  ++F;
329  ++F;
330  TListGPSs::iterator E = list_gps_obs.end();
331  --E;
332  --E;
333 
334  for (TListGPSs::iterator it = F; it != E; ++it)
335  {
336  // Now check if we have 3 gps with the same time stamp:
337  // const size_t N = i->second.size();
338  std::map<std::string, CObservationGPS::Ptr>& GPS = it->second;
339 
340  // Check if any in "lstGPSLabels" is missing here:
341  for (set<string>::iterator l = lstGPSLabels.begin();
342  l != lstGPSLabels.end(); ++l)
343  {
344  // For each GPS in the current timestamp:
345  bool fnd = (GPS.find(*l) != GPS.end());
346 
347  if (fnd) continue; // this one is present.
348 
349  // Ok, we have "*l" missing in the set "*i".
350  // Try to interpolate from neighbors:
351  TListGPSs::iterator i_b1 = it;
352  --i_b1;
353  TListGPSs::iterator i_a1 = it;
354  ++i_a1;
355 
356  CObservationGPS::Ptr GPS_b1, GPS_a1;
357 
358  if (i_b1->second.find(*l) != i_b1->second.end())
359  GPS_b1 = i_b1->second.find(*l)->second;
360 
361  if (i_a1->second.find(*l) != i_a1->second.end())
362  GPS_a1 = i_a1->second.find(*l)->second;
363 
364  if (!disableGPSInterp && GPS_a1 && GPS_b1)
365  {
367  GPS_b1->timestamp, GPS_a1->timestamp) < 0.5)
368  {
370  new CObservationGPS(*GPS_a1));
371  new_gps->sensorLabel = *l;
372 
373  // cout <<
374  // mrpt::system::timeLocalToString(GPS_b1->timestamp)
375  // << " " <<
376  // mrpt::system::timeLocalToString(GPS_a1->timestamp)
377  // << " " << *l;
378  // cout << endl;
379 
380  new_gps->getMsgByClass<gnss::Message_NMEA_GGA>()
381  .fields.longitude_degrees =
382  0.5 *
383  (GPS_a1->getMsgByClass<gnss::Message_NMEA_GGA>()
385  GPS_b1->getMsgByClass<gnss::Message_NMEA_GGA>()
386  .fields.longitude_degrees);
387  new_gps->getMsgByClass<gnss::Message_NMEA_GGA>()
388  .fields.latitude_degrees =
389  0.5 *
390  (GPS_a1->getMsgByClass<gnss::Message_NMEA_GGA>()
392  GPS_b1->getMsgByClass<gnss::Message_NMEA_GGA>()
393  .fields.latitude_degrees);
394  new_gps->getMsgByClass<gnss::Message_NMEA_GGA>()
395  .fields.altitude_meters =
396  0.5 *
397  (GPS_a1->getMsgByClass<gnss::Message_NMEA_GGA>()
399  GPS_b1->getMsgByClass<gnss::Message_NMEA_GGA>()
400  .fields.altitude_meters);
401 
402  new_gps->timestamp =
403  (GPS_a1->timestamp + GPS_b1->timestamp) / 2;
404 
405  it->second[new_gps->sensorLabel] = new_gps;
406  }
407  }
408  }
409  } // end loop interpolate 1-out-of-5
410  }
411 
412 #if MRPT_HAS_WXWIDGETS
413  wxProgressDialog* progDia3 = nullptr;
414  if (isGUI)
415  {
416  progDia3 = new wxProgressDialog(
417  wxT("Building map"), wxT("Estimating 6D path..."),
418  N_GPSs, // range
419  nullptr, // parent
420  wxPD_CAN_ABORT | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_AUTO_HIDE |
421  wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME |
422  wxPD_REMAINING_TIME);
423  }
424 #endif
425 
426  int idx_in_GPSs = 0;
427 
428  for (TListGPSs::iterator i = list_gps_obs.begin();
429  i != list_gps_obs.end(); ++i, idx_in_GPSs++)
430  {
431  // Now check if we have 3 gps with the same time stamp:
432  if (i->second.size() >= 3)
433  {
434  const size_t N = i->second.size();
435  std::map<std::string, CObservationGPS::Ptr>& GPS = i->second;
436  CVectorDouble X(N), Y(N), Z(N); // Global XYZ coordinates
437  std::map<string, size_t>
438  XYZidxs; // Sensor label -> indices in X Y Z
439 
440  if (!ref_valid) // get the reference lat/lon, if it's not set
441  // from rawlog configuration block.
442  {
443  ref_valid = true;
444  ref = GPS.begin()
445  ->second->getMsgByClass<gnss::Message_NMEA_GGA>()
446  .getAsStruct<TGeodeticCoords>();
447  }
448 
449  // Compute the XYZ coordinates of all sensors:
450  TMatchingPairList corrs;
451  unsigned int k;
453 
454  for (k = 0, g_it = GPS.begin(); g_it != GPS.end(); ++g_it, ++k)
455  {
456  TPoint3D P;
458  g_it->second->getMsgByClass<gnss::Message_NMEA_GGA>()
460  P, ref);
461 
462  // Correction of offsets:
463  const string sect =
464  string("OFFSET_") + g_it->second->sensorLabel;
465  P.x += memFil.read_double(sect, "x", 0);
466  P.y += memFil.read_double(sect, "y", 0);
467  P.z += memFil.read_double(sect, "z", 0);
468 
469  XYZidxs[g_it->second->sensorLabel] =
470  k; // Save index correspondence
471 
472  // Create the correspondence:
473  corrs.push_back(TMatchingPair(
474  k, k, // Indices
475  P.x, P.y, P.z, // "This"/Global coords
476  g_it->second->sensorPose.x(),
477  g_it->second->sensorPose.y(),
478  g_it->second->sensorPose
479  .z() // "other"/local coordinates
480  ));
481 
482  X[k] = P.x;
483  Y[k] = P.y;
484  Z[k] = P.z;
485  }
486 
487  if (doConsistencyCheck && GPS.size() == 3)
488  {
489  // XYZ[k] have the k'd final coordinates of each GPS
490  // GPS[k] are the CObservations:
491 
492  // Compute the inter-GPS square distances:
493  CVectorDouble iGPSdist2(3);
494 
495  // [0]: sq dist between:
496  // D_cov_rev_indexes[0],D_cov_rev_indexes[1]
497  TPoint3D P0(
498  X[XYZidxs[D_cov_rev_indexes[0]]],
499  Y[XYZidxs[D_cov_rev_indexes[0]]],
500  Z[XYZidxs[D_cov_rev_indexes[0]]]);
501  TPoint3D P1(
502  X[XYZidxs[D_cov_rev_indexes[1]]],
503  Y[XYZidxs[D_cov_rev_indexes[1]]],
504  Z[XYZidxs[D_cov_rev_indexes[1]]]);
505  TPoint3D P2(
506  X[XYZidxs[D_cov_rev_indexes[2]]],
507  Y[XYZidxs[D_cov_rev_indexes[2]]],
508  Z[XYZidxs[D_cov_rev_indexes[2]]]);
509 
510  iGPSdist2[0] = P0.sqrDistanceTo(P1);
511  iGPSdist2[1] = P0.sqrDistanceTo(P2);
512  iGPSdist2[2] = P1.sqrDistanceTo(P2);
513 
514  double mahaD = mrpt::math::mahalanobisDistance(
515  iGPSdist2, D_mean, D_cov_1);
516  outInfoTemp.mahalabis_quality_measure[i->first] = mahaD;
517 
518  // cout << "x: " << iGPSdist2 << " MU: " << D_mean << " ->
519  // " << mahaD << endl;
520  } // end consistency
521 
522  // Use a 6D matching method to estimate the location of the
523  // vehicle:
524  CPose3DQuat optimal_pose;
525  double optimal_scale;
526 
527  // "this" (reference map) -> GPS global coordinates
528  // "other" -> GPS local coordinates on the vehicle
530  corrs, optimal_pose, optimal_scale, true); // Force scale=1
531  // cout << "optimal pose: " << optimal_pose << " " <<
532  // optimal_scale << endl;
533  MRPT_CHECK_NORMAL_NUMBER(optimal_pose.x());
534  MRPT_CHECK_NORMAL_NUMBER(optimal_pose.y());
535  MRPT_CHECK_NORMAL_NUMBER(optimal_pose.z());
536  MRPT_CHECK_NORMAL_NUMBER(optimal_pose.quat().x());
537  MRPT_CHECK_NORMAL_NUMBER(optimal_pose.quat().y());
538  MRPT_CHECK_NORMAL_NUMBER(optimal_pose.quat().z());
539  MRPT_CHECK_NORMAL_NUMBER(optimal_pose.quat().r());
540 
541  // Final vehicle pose:
542  const CPose3D veh_pose = CPose3D(optimal_pose);
543 
544  // Add to the interpolator:
545  robot_path.insert(i->first, veh_pose);
546 
547  // If we have W_star, compute the pose uncertainty:
548  if (doUncertaintyCovs)
549  {
550  CPose3DPDFGaussian final_veh_uncert;
551  final_veh_uncert.mean.setFromValues(0, 0, 0, 0, 0, 0);
552  final_veh_uncert.cov = outInfoTemp.W_star;
553 
554  // Rotate the covariance according to the real vehicle pose:
555  final_veh_uncert.changeCoordinatesReference(veh_pose);
556 
557  outInfoTemp.vehicle_uncertainty[i->first] =
558  final_veh_uncert.cov;
559  }
560  }
561 
562  // Show progress:
563  if ((count++ % 100) == 0)
564  {
565 #if MRPT_HAS_WXWIDGETS
566  if (progDia3)
567  {
568  if (!progDia3->Update(idx_in_GPSs)) abort = true;
569  wxTheApp->Yield();
570  }
571 #endif
572  }
573  } // end for i
574 
575 #if MRPT_HAS_WXWIDGETS
576  if (progDia3)
577  {
578  delete progDia3;
579  progDia3 = nullptr;
580  }
581 #endif
582 
583  if (PATH_SMOOTH_FILTER > 0 && robot_path.size() > 1)
584  {
585  CPose3DInterpolator filtered_robot_path = robot_path;
586 
587  // Do Angles smoother filter of the path:
588  // ---------------------------------------------
589  const double MAX_DIST_TO_FILTER = 4.0;
590 
591  for (auto i = robot_path.begin(); i != robot_path.end(); ++i)
592  {
593  mrpt::math::TPose3D p = i->second;
594 
595  CVectorDouble pitchs, rolls; // The elements to average
596 
597  pitchs.push_back(p.pitch);
598  rolls.push_back(p.roll);
599 
601  for (int k = 0;
602  k < PATH_SMOOTH_FILTER && q != robot_path.begin(); k++)
603  {
604  --q;
605  if (abs(mrpt::system::timeDifference(q->first, i->first)) <
606  MAX_DIST_TO_FILTER)
607  {
608  pitchs.push_back(q->second.pitch);
609  rolls.push_back(q->second.roll);
610  }
611  }
612  q = i;
613  for (int k = 0;
614  k < PATH_SMOOTH_FILTER && q != (--robot_path.end()); k++)
615  {
616  ++q;
617  if (abs(mrpt::system::timeDifference(q->first, i->first)) <
618  MAX_DIST_TO_FILTER)
619  {
620  pitchs.push_back(q->second.pitch);
621  rolls.push_back(q->second.roll);
622  }
623  }
624 
625  p.pitch = mrpt::math::averageWrap2Pi(pitchs);
626  p.roll = mrpt::math::averageWrap2Pi(rolls);
627 
628  // save in filtered path:
629  filtered_robot_path.insert(i->first, p);
630  }
631  // Replace:
632  robot_path = filtered_robot_path;
633 
634  } // end PATH_SMOOTH_FILTER
635 
636  } // end step generate 6D path
637 
638  // Here we can set best_gps_path (that with the max. number of RTK
639  // fixed/foat readings):
640  if (outInfo)
641  {
642  string bestLabel;
643  size_t bestNum = 0;
644  for (map<string, size_t>::iterator i = GPS_RTK_reads.begin();
645  i != GPS_RTK_reads.end(); ++i)
646  {
647  if (i->second > bestNum)
648  {
649  bestNum = i->second;
650  bestLabel = i->first;
651  }
652  }
653  outInfoTemp.best_gps_path = gps_paths[bestLabel];
654 
655  // and transform to XYZ:
656  // Correction of offsets:
657  const string sect = string("OFFSET_") + bestLabel;
658  const double off_X = memFil.read_double(sect, "x", 0);
659  const double off_Y = memFil.read_double(sect, "y", 0);
660  const double off_Z = memFil.read_double(sect, "z", 0);
661 
662  // map<TTimeStamp,TPoint3D> best_gps_path; // time -> 3D local
663  // coords
665  outInfoTemp.best_gps_path.begin();
666  i != outInfoTemp.best_gps_path.end(); ++i)
667  {
668  TPoint3D P;
669  TPoint3D& pl = i->second;
672  pl.x, pl.y, pl.z), // i->second.x,i->second.y,i->second.z,
673  // // lat, lon, heigh
674  P, // X Y Z
675  ref);
676 
677  pl.x = P.x + off_X;
678  pl.y = P.y + off_Y;
679  pl.z = P.z + off_Z;
680  }
681  } // end best_gps_path
682 
683  if (outInfo) *outInfo = outInfoTemp;
684 
685  MRPT_END
686 }
mrpt::math::CQuaternionDouble & quat()
Read/Write access to the quaternion representing the 3D rotation.
Definition: CPose3DQuat.h:61
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:140
This class implements a config file-like interface over a memory-stored string list.
Scalar * iterator
Definition: eigen_plugins.h:26
GLuint GLuint GLsizei count
Definition: glext.h:3528
double averageWrap2Pi(const CVectorDouble &angles)
Computes the average of a sequence of angles in radians taking into account the correct wrapping in t...
Definition: math.cpp:313
uint8_t fix_quality
NMEA standard values: 0 = invalid, 1 = GPS fix (SPS), 2 = DGPS fix, 3 = PPS fix, 4 = Real Time Kinema...
#define MRPT_START
Definition: exceptions.h:262
CPose3D mean
The mean value.
double latitude_degrees
The measured latitude, in degrees (North:+ , South:-)
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:25
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:41
GLenum GLint ref
Definition: glext.h:4050
T y() const
Return y coordinate of the quaternion.
Definition: CQuaternion.h:91
GLint * first
Definition: glext.h:3827
void read_matrix(const std::string &section, const std::string &name, MATRIX_TYPE &outMatrix, const MATRIX_TYPE &defaultMatrix=MATRIX_TYPE(), bool failIfNotFound=false) const
Reads a configuration parameter as a matrix written in a matlab-like format - for example: "[2 3 4 ; ...
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3721
A set of geodetic coordinates: latitude, longitude and height, defined over a given geoid (typically...
Definition: data_types.h:195
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:44
STL namespace.
GLdouble s
Definition: glext.h:3676
void geodeticToENU_WGS84(const TGeodeticCoords &in_coords, mrpt::math::TPoint3D &out_ENU_point, const TGeodeticCoords &in_coords_origin)
Coordinates transformation from longitude/latitude/height to ENU (East-North-Up) X/Y/Z coordinates Th...
void setInterpolationMethod(TInterpolatorMethod method)
Change the method used to interpolate the robot path.
Used to return optional information from mrpt::topography::path_from_rtk_gps.
T square(const T x)
Inline function for the square of a number.
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
double altitude_meters
The measured altitude, in meters (A).
This base provides a set of functions for maths stuff.
void insert(mrpt::system::TTimeStamp t, const pose_t &p)
Inserts a new pose in the sequence.
T r() const
Return r coordinate of the quaternion.
Definition: CQuaternion.h:87
std::map< mrpt::system::TTimeStamp, double > mahalabis_quality_measure
A measure of the quality at each point (may be empty if not there is no enough information).
#define CLASS_ID(T)
Access to runtime class ID for a defined class name.
Definition: CObject.h:85
#define MRPT_CHECK_NORMAL_NUMBER(v)
Throws an exception if the number is NaN, IND, or +/-INF, or return the same number otherwise...
Definition: exceptions.h:118
CObservation::Ptr getAsObservation(size_t index) const
Returns the i&#39;th element in the sequence, as being an observation, where index=0 is the first object...
Definition: CRawlog.cpp:105
double distanceTo(const TPoint3D &p) const
Point-to-point distance.
A list of TMatchingPair.
Definition: TMatchingPair.h:83
double longitude_degrees
The measured longitude, in degrees (East:+ , West:-)
This class stores a rawlog (robotic datasets) in one of two possible formats:
Definition: CRawlog.h:68
This namespace contains representation of robot actions and observations.
double x
X,Y,Z coordinates.
double read_double(const std::string &section, const std::string &name, double defaultValue, bool failIfNotFound=false) const
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:48
void setMaxTimeInterpolation(double time)
Set value of the maximum time to consider interpolation.
GLsizei const GLchar ** string
Definition: glext.h:4101
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
A structure for holding correspondences between two sets of points or points-like entities in 2D or 3...
Definition: TMatchingPair.h:33
mrpt::math::CMatrixDouble66 cov
The 6x6 covariance matrix.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
T x() const
Return x coordinate of the quaternion.
Definition: CQuaternion.h:89
GLfloat GLfloat v1
Definition: glext.h:4105
void clear()
Clears the current sequence of poses.
void path_from_rtk_gps(mrpt::poses::CPose3DInterpolator &robot_path, const mrpt::obs::CRawlog &rawlog, size_t rawlog_first, size_t rawlog_last, bool isGUI=false, bool disableGPSInterp=false, int path_smooth_filter_size=2, TPathFromRTKInfo *outInfo=nullptr)
Reconstruct the path of a vehicle equipped with 3 RTK GPSs.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
double sqrDistanceTo(const TPoint3D &p) const
Point-to-point distance, squared.
GLfloat v0
Definition: glext.h:4103
std::set< T > make_set(const T &v0, const T &v1)
mrpt::math::CMatrixDouble W_star
The reference covariance matrix used to compute vehicle_uncertainty.
#define MRPT_END
Definition: exceptions.h:266
VECTORLIKE1::Scalar mahalanobisDistance(const VECTORLIKE1 &X, const VECTORLIKE2 &MU, const MAT &COV)
Computes the mahalanobis distance of a vector X given the mean MU and the covariance inverse COV_inv ...
Definition: data_utils.h:57
TGEODETICCOORDS getAsStruct() const
Return the geodetic coords as a mrpt::topography::TGeodeticCoords structure (requires linking against...
void setFromValues(const double x0, const double y0, const double z0, const double yaw=0, const double pitch=0, const double roll=0)
Set the pose from a 3D position (meters) and yaw/pitch/roll angles (radians) - This method recomputes...
Definition: CPose3D.cpp:239
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:31
content_t fields
Message content, accesible by individual fields.
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
bool se3_l2(const mrpt::tfest::TMatchingPairList &in_correspondences, mrpt::poses::CPose3DQuat &out_transform, double &out_scale, bool forceScaleToUnity=false)
Least-squares (L2 norm) solution to finding the optimal SE(3) transform between two reference frames ...
Definition: se3_l2.cpp:221
This class stores a time-stamped trajectory in SE(3) (CPose3D poses).
TEntryType getType(size_t index) const
Returns the type of a given element.
Definition: CRawlog.cpp:130
mrpt::aligned_std_map< mrpt::system::TTimeStamp, mrpt::math::CMatrixDouble66 > vehicle_uncertainty
The 6x6 covariance matrix for the uncertainty of each vehicle pose (may be empty if there is no W_sta...
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
double timeDifference(const mrpt::system::TTimeStamp t_first, const mrpt::system::TTimeStamp t_later)
Returns the time difference from t1 to t2 (positive if t2 is posterior to t1), in seconds...
Definition: datetime.cpp:209
Lightweight 3D point.
This namespace provides topography helper functions, coordinate transformations.
Definition: conversions.h:22
This class stores messages from GNSS or GNSS+IMU devices, from consumer-grade inexpensive GPS receive...
T z() const
Return z coordinate of the quaternion.
Definition: CQuaternion.h:93
size_t size() const
Returns the number of actions / observations object in the sequence.
Definition: CRawlog.cpp:88
Functions for estimating the optimal transformation between two frames of references given measuremen...
GLfloat GLfloat p
Definition: glext.h:6305
void getCommentTextAsConfigFile(mrpt::config::CConfigFileMemory &memCfg) const
Saves the block of comment text for the rawlog into the passed config file object.
Definition: CRawlog.cpp:550
std::map< mrpt::system::TTimeStamp, mrpt::math::TPoint3D > best_gps_path
the path of the "best" GPS.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019