Main MRPT website > C++ reference for MRPT 1.9.9
CActionRobotMovement2D.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 <mrpt/utils/CStream.h>
16 #include <mrpt/random.h>
18 #include <mrpt/math/wrap2pi.h>
19 
20 using namespace mrpt::obs;
21 using namespace mrpt::utils;
22 using namespace mrpt::poses;
23 using namespace mrpt::math;
24 using namespace mrpt::random;
25 using namespace std;
26 
28 
29 /*---------------------------------------------------------------
30  Constructor
31  ---------------------------------------------------------------*/
33  : poseChange(mrpt::make_aligned_shared<CPosePDFGaussian>()),
34  rawOdometryIncrementReading(),
35  estimationMethod(emOdometry),
36  hasEncodersInfo(false),
37  encoderLeftTicks(0),
38  encoderRightTicks(0),
39  hasVelocities(false),
40  velocityLocal(.0, .0, .0),
41  motionModelConfiguration(),
42  m_fastDrawGauss_Z(),
43  m_fastDrawGauss_M()
44 {
45 }
46 
47 /*---------------------------------------------------------------
48  Implements the writing to a CStream capability of CSerializable objects
49  ---------------------------------------------------------------*/
51  mrpt::utils::CStream& out, int* version) const
52 {
53  if (version)
54  *version = 7;
55  else
56  {
57  uint32_t i = static_cast<uint32_t>(estimationMethod);
58 
59  out << i;
60 
61  // Added in version 2:
62  // If the estimation method is emOdometry, save the rawOdo + config data
63  // instead of
64  // the PDF itself:
65  if (estimationMethod == emOdometry)
66  {
67  // The odometry data:
68  out << rawOdometryIncrementReading;
69 
70  i = static_cast<uint32_t>(motionModelConfiguration.modelSelection);
71  out << i;
72  out << motionModelConfiguration.gaussianModel.a1
73  << motionModelConfiguration.gaussianModel.a2
74  << motionModelConfiguration.gaussianModel.a3
75  << motionModelConfiguration.gaussianModel.a4
76  << motionModelConfiguration.gaussianModel.minStdXY
77  << motionModelConfiguration.gaussianModel.minStdPHI;
78 
79  out << motionModelConfiguration.thrunModel.nParticlesCount
80  << motionModelConfiguration.thrunModel.alfa1_rot_rot
81  << motionModelConfiguration.thrunModel.alfa2_rot_trans
82  << motionModelConfiguration.thrunModel.alfa3_trans_trans
83  << motionModelConfiguration.thrunModel.alfa4_trans_rot
84  << motionModelConfiguration.thrunModel.additional_std_XY
85  << motionModelConfiguration.thrunModel.additional_std_phi;
86  }
87  else
88  {
89  // The PDF:
90  out << (*poseChange);
91  }
92 
93  // Added in version 1:
94  out << hasVelocities;
95  if (hasVelocities) out << velocityLocal; // v7
96 
97  out << hasEncodersInfo;
98  if (hasEncodersInfo)
99  out << encoderLeftTicks << encoderRightTicks; // added if() in v7
100 
101  // Added in version 6
102  out << timestamp;
103  }
104 }
105 
106 /*---------------------------------------------------------------
107  Implements the reading from a CStream capability of CSerializable objects
108  ---------------------------------------------------------------*/
110  mrpt::utils::CStream& in, int version)
111 {
112  switch (version)
113  {
114  case 4:
115  case 5:
116  case 6:
117  case 7:
118  {
119  int32_t i;
120 
121  // Read the estimation method first:
122  in >> i;
123  estimationMethod = static_cast<TEstimationMethod>(i);
124 
125  // If the estimation method is emOdometry, save the rawOdo + config
126  // data instead of
127  // the PDF itself:
128  if (estimationMethod == emOdometry)
129  {
130  // The odometry data:
131  in >> rawOdometryIncrementReading;
132 
133  in >> i;
134  motionModelConfiguration.modelSelection =
135  static_cast<TDrawSampleMotionModel>(i);
136 
137  in >> motionModelConfiguration.gaussianModel.a1 >>
138  motionModelConfiguration.gaussianModel.a2 >>
139  motionModelConfiguration.gaussianModel.a3 >>
140  motionModelConfiguration.gaussianModel.a4 >>
141  motionModelConfiguration.gaussianModel.minStdXY >>
142  motionModelConfiguration.gaussianModel.minStdPHI;
143 
144  in >> i;
145  motionModelConfiguration.thrunModel.nParticlesCount = i;
146  in >> motionModelConfiguration.thrunModel.alfa1_rot_rot >>
147  motionModelConfiguration.thrunModel.alfa2_rot_trans >>
148  motionModelConfiguration.thrunModel.alfa3_trans_trans >>
149  motionModelConfiguration.thrunModel.alfa4_trans_rot;
150 
151  if (version >= 5)
152  {
153  in >>
154  motionModelConfiguration.thrunModel.additional_std_XY >>
155  motionModelConfiguration.thrunModel.additional_std_phi;
156  }
157  else
158  {
159  motionModelConfiguration.thrunModel.additional_std_XY =
160  motionModelConfiguration.thrunModel.additional_std_phi =
161  0;
162  }
163 
164  // Re-build the PDF:
165  computeFromOdometry(
166  rawOdometryIncrementReading, motionModelConfiguration);
167  }
168  else
169  {
170  // Read the PDF directly from the stream:
171  CPosePDF::Ptr pc;
172  in >> pc;
173  poseChange = pc;
174  }
175 
176  in >> hasVelocities;
177  if (version >= 7)
178  {
179  if (hasVelocities) in >> velocityLocal;
180  }
181  else
182  {
183  float velocityLin, velocityAng;
184  in >> velocityLin >> velocityAng;
185  velocityLocal.vx = velocityLin;
186  velocityLocal.vy = .0f;
187  velocityLocal.omega = velocityAng;
188  }
189  in >> hasEncodersInfo;
190  if (version < 7 || hasEncodersInfo)
191  {
192  in >> i;
193  encoderLeftTicks = i;
194  in >> i;
195  encoderRightTicks = i;
196  }
197  else
198  {
199  encoderLeftTicks = 0;
200  encoderRightTicks = 0;
201  }
202 
203  if (version >= 6)
204  in >> timestamp;
205  else
206  timestamp = INVALID_TIMESTAMP;
207  }
208  break;
209 
210  case 3:
211  {
212  int32_t i;
213 
214  // Read the estimation method first:
215  in >> i;
216  estimationMethod = static_cast<TEstimationMethod>(i);
217 
218  // If the estimation method is emOdometry, save the rawOdo + config
219  // data instead of
220  // the PDF itself:
221  if (estimationMethod == emOdometry)
222  {
223  // The odometry data:
224  in >> rawOdometryIncrementReading;
225 
226  in >> i;
227  motionModelConfiguration.modelSelection =
228  static_cast<TDrawSampleMotionModel>(i);
229 
230  float dum1, dum2, dum3;
231 
232  in >> dum1 >> dum2 >> dum3 >>
233  motionModelConfiguration.gaussianModel.minStdXY >>
234  motionModelConfiguration.gaussianModel.minStdPHI;
235 
236  // Leave the default values for a1,a2,a3,a4:
237  in >> i;
238  motionModelConfiguration.thrunModel.nParticlesCount = i;
239  in >> motionModelConfiguration.thrunModel.alfa1_rot_rot;
240  in >> motionModelConfiguration.thrunModel.alfa2_rot_trans >>
241  motionModelConfiguration.thrunModel.alfa3_trans_trans >>
242  motionModelConfiguration.thrunModel.alfa4_trans_rot;
243 
244  // Re-build the PDF:
245  computeFromOdometry(
246  rawOdometryIncrementReading, motionModelConfiguration);
247  }
248  else
249  {
250  // Read the PDF directly from the stream:
251  CPosePDF::Ptr pc;
252  in >> pc;
253  poseChange = pc;
254  }
255 
256  in >> hasVelocities;
257  {
258  float velocityLin, velocityAng;
259  in >> velocityLin >> velocityAng;
260  velocityLocal.vx = velocityLin;
261  velocityLocal.vy = .0f;
262  velocityLocal.omega = velocityAng;
263  }
264  in >> hasEncodersInfo;
265 
266  in >> i;
267  encoderLeftTicks = i;
268  in >> i;
269  encoderRightTicks = i;
270  }
271  break;
272 
273  case 2:
274  {
275  int32_t i;
276 
277  // Read the estimation method first:
278  in >> i;
279  estimationMethod = static_cast<TEstimationMethod>(i);
280 
281  // If the estimation method is emOdometry, save the rawOdo + config
282  // data instead of
283  // the PDF itself:
284  if (estimationMethod == emOdometry)
285  {
286  // The odometry data:
287  in >> rawOdometryIncrementReading;
288 
289  // TMotionModelOptions_OLD_VERSION_2 dummy;
290  // in.ReadBuffer( &dummy,
291  // sizeof(TMotionModelOptions_OLD_VERSION_2) );
292  uint8_t dummy[44];
293  in.ReadBuffer(&dummy, sizeof(dummy));
294 
295  motionModelConfiguration = TMotionModelOptions();
296 
297  // Re-build the PDF:
298  computeFromOdometry(
299  rawOdometryIncrementReading, motionModelConfiguration);
300  }
301  else
302  {
303  // Read the PDF directly from the stream:
304  CPosePDF::Ptr pc;
305  in >> pc;
306  poseChange = pc;
307  }
308 
309  in >> hasVelocities;
310  {
311  float velocityLin, velocityAng;
312  in >> velocityLin >> velocityAng;
313  velocityLocal.vx = velocityLin;
314  velocityLocal.vy = .0f;
315  velocityLocal.omega = velocityAng;
316  }
317  in >> hasEncodersInfo;
318  in >> i;
319  encoderLeftTicks = i;
320  in >> i;
321  encoderRightTicks = i;
322  }
323  break;
324  case 0:
325  case 1:
326  {
327  int32_t i;
328  {
329  CPosePDF::Ptr pc;
330  in >> pc;
331  poseChange = pc;
332  }
333  in >> i;
334 
335  // copy:
336  estimationMethod = static_cast<TEstimationMethod>(i);
337 
338  // Simulate the "rawOdometryIncrementReading" as the mean value:
339  if (estimationMethod == emOdometry)
340  poseChange->getMean(rawOdometryIncrementReading);
341  else
342  rawOdometryIncrementReading = CPose2D(0, 0, 0);
343 
344  if (version >= 1)
345  {
346  in >> hasVelocities;
347  {
348  float velocityLin, velocityAng;
349  in >> velocityLin >> velocityAng;
350  velocityLocal.vx = velocityLin;
351  velocityLocal.vy = .0f;
352  velocityLocal.omega = velocityAng;
353  }
354  in >> hasEncodersInfo;
355  in >> i;
356  encoderLeftTicks = i;
357  in >> i;
358  encoderRightTicks = i;
359  }
360  else
361  {
362  // Default values:
363  hasVelocities = hasEncodersInfo = false;
364  encoderLeftTicks = encoderRightTicks = 0;
365  velocityLocal = mrpt::math::TTwist2D(.0, .0, .0);
366  }
367  }
368  break;
369  default:
371  };
372 }
373 
374 /*---------------------------------------------------------------
375  computeFromEncoders
376  ---------------------------------------------------------------*/
378  double K_left, double K_right, double D)
379 {
380  if (hasEncodersInfo)
381  {
382  const double As =
383  0.5 * (K_right * encoderRightTicks + K_left * encoderLeftTicks);
384  const double Aphi =
385  (K_right * encoderRightTicks - K_left * encoderLeftTicks) / D;
386 
387  double x, y;
388  if (Aphi != 0)
389  {
390  const double R = As / Aphi;
391  x = R * sin(Aphi);
392  y = R * (1 - cos(Aphi));
393  }
394  else
395  {
396  x = As;
397  y = 0;
398  }
399 
400  // Build the whole PDF with the current parameters:
401  computeFromOdometry(CPose2D(x, y, Aphi), motionModelConfiguration);
402  }
403 }
404 
405 /*---------------------------------------------------------------
406  computeFromOdometry
407  ---------------------------------------------------------------*/
409  const CPose2D& odometryIncrement, const TMotionModelOptions& options)
410 {
411  // Set the members data:
412  estimationMethod = emOdometry;
413  rawOdometryIncrementReading = odometryIncrement;
414  motionModelConfiguration = options;
415 
416  if (options.modelSelection == mmGaussian)
417  computeFromOdometry_modelGaussian(odometryIncrement, options);
418  else
419  computeFromOdometry_modelThrun(odometryIncrement, options);
420 }
421 
422 /*---------------------------------------------------------------
423  TMotionModelOptions
424  ---------------------------------------------------------------*/
426  : modelSelection(CActionRobotMovement2D::mmGaussian),
427  gaussianModel(),
428  thrunModel()
429 {
430  gaussianModel.a1 = 0.01f;
431  gaussianModel.a2 = RAD2DEG(0.001f);
432  gaussianModel.a3 = DEG2RAD(1.0f);
433  gaussianModel.a4 = 0.05f;
434 
435  gaussianModel.minStdXY = 0.01f;
437 
439  thrunModel.alfa1_rot_rot = 0.05f;
443  thrunModel.additional_std_XY = 0.001f;
445 }
446 
447 /*---------------------------------------------------------------
448  computeFromOdometry_modelGaussian
449  ---------------------------------------------------------------*/
451  const CPose2D& odometryIncrement, const TMotionModelOptions& o)
452 {
453  // The Gaussian PDF:
454  // ---------------------------
455  poseChange = mrpt::make_aligned_shared<CPosePDFGaussian>();
456  CPosePDFGaussian* aux;
457  aux = static_cast<CPosePDFGaussian*>(poseChange.get());
458 
459  // See http://www.mrpt.org/Probabilistic_Motion_Models
460  // -----------------------------------
461 
462  // Build the odometry noise matrix:
463  double Al = odometryIncrement.norm();
464  CMatrixDouble31 ODO_INCR = CMatrixDouble31(odometryIncrement);
465  CMatrixDouble33 C_ODO;
466  C_ODO(0, 0) = square(
468  o.gaussianModel.a2 * fabs(odometryIncrement.phi()));
469  C_ODO(1, 1) = square(
471  o.gaussianModel.a2 * fabs(odometryIncrement.phi()));
472  C_ODO(2, 2) = square(
474  o.gaussianModel.a4 * fabs(odometryIncrement.phi()));
475 
476  // Build the transformation matrix:
477  CMatrixDouble33 H;
478 
479  double cos_Aphi_2 = cos(odometryIncrement.phi() / 2);
480  double sin_Aphi_2 = sin(odometryIncrement.phi() / 2);
481 
482  H(0, 0) = H(1, 1) = cos_Aphi_2;
483  H(0, 1) = -(H(1, 0) = sin_Aphi_2);
484  H(2, 2) = 1;
485 
486  // Build the Jacobian matrix:
487  CMatrixDouble33 J = H;
488  J(0, 2) = -sin_Aphi_2 * ODO_INCR(0, 0) - cos_Aphi_2 * ODO_INCR(1, 0);
489  J(1, 2) = cos_Aphi_2 * ODO_INCR(0, 0) - sin_Aphi_2 * ODO_INCR(1, 0);
490 
491  // The mean:
492  aux->mean = odometryIncrement;
493 
494  // The covariance:
495  J.multiply_HCHt(C_ODO, aux->cov);
496 }
497 
498 /*---------------------------------------------------------------
499  computeFromOdometry_modelThrun
500  ---------------------------------------------------------------*/
502  const CPose2D& odometryIncrement, const TMotionModelOptions& o)
503 {
504  // The Gaussian PDF:
505  // ---------------------------
506  CPosePDFParticles* aux;
507  static CPose2D nullPose(0, 0, 0);
508 
509  poseChange = mrpt::make_aligned_shared<CPosePDFParticles>();
510  aux = static_cast<CPosePDFParticles*>(poseChange.get());
511 
512  // Set the number of particles:
514 
515  // ---------------------------------------------------------------------------------------------
516  // The following is an implementation from Thrun et al.'s book
517  // (Probabilistic Robotics),
518  // page 136. Here "odometryIncrement" actually represents the incremental
519  // odometry difference.
520  // ---------------------------------------------------------------------------------------------
521 
522  // The increments in odometry:
523  float Arot1 = (odometryIncrement.y() != 0 || odometryIncrement.x() != 0)
524  ? atan2(odometryIncrement.y(), odometryIncrement.x())
525  : 0;
526  float Atrans = odometryIncrement.norm();
527  float Arot2 = math::wrapToPi(odometryIncrement.phi() - Arot1);
528 
529  // Draw samples:
530  for (size_t i = 0; i < o.thrunModel.nParticlesCount; i++)
531  {
532  float Arot1_draw = Arot1 -
533  (o.thrunModel.alfa1_rot_rot * fabs(Arot1) +
534  o.thrunModel.alfa2_rot_trans * Atrans) *
536  float Atrans_draw =
537  Atrans -
538  (o.thrunModel.alfa3_trans_trans * Atrans +
539  o.thrunModel.alfa4_trans_rot * (fabs(Arot1) + fabs(Arot2))) *
541  float Arot2_draw = Arot2 -
542  (o.thrunModel.alfa1_rot_rot * fabs(Arot2) +
543  o.thrunModel.alfa2_rot_trans * Atrans) *
545 
546  // Output:
547  aux->m_particles[i].d->x(
548  Atrans_draw * cos(Arot1_draw) +
550  getRandomGenerator().drawGaussian1D_normalized());
551  aux->m_particles[i].d->y(
552  Atrans_draw * sin(Arot1_draw) +
554  getRandomGenerator().drawGaussian1D_normalized());
555  aux->m_particles[i].d->phi(
556  Arot1_draw + Arot2_draw +
558  getRandomGenerator().drawGaussian1D_normalized());
559  aux->m_particles[i].d->normalizePhi();
560  }
561 }
562 
563 /*---------------------------------------------------------------
564  drawSingleSample
565  ---------------------------------------------------------------*/
567 {
568  // Only in the case of "emOdometry" we have the rawOdometryMeasurement and
569  // the parameters to draw new samples:
571  {
574  else
575  drawSingleSample_modelThrun(outSample);
576  }
577  else
578  {
579  // If is not odometry, just employ the stored distribution:
580  poseChange->drawSingleSample(outSample);
581  }
582 }
583 
584 /*---------------------------------------------------------------
585  drawSingleSample_modelGaussian
586  ---------------------------------------------------------------*/
588  CPose2D& outSample) const
589 {
590  // In the Gaussian case it is more efficient just to
591  // draw a sample from the already computed PDF:
592  poseChange->drawSingleSample(outSample);
593 }
594 
595 /*---------------------------------------------------------------
596  drawSingleSample_modelThrun
597  ---------------------------------------------------------------*/
599  CPose2D& outSample) const
600 {
601  // ---------------------------------------------------------------------------------------------
602  // The following is an implementation from Thrun et al.'s book
603  // (Probabilistic Robotics),
604  // page 136. Here "odometryIncrement" actually represents the incremental
605  // odometry difference.
606  // ---------------------------------------------------------------------------------------------
607 
608  // The increments in odometry:
609  float Arot1 = (rawOdometryIncrementReading.y() != 0 ||
611  ? atan2(
614  : 0;
615  float Atrans = rawOdometryIncrementReading.norm();
616  float Arot2 = math::wrapToPi(rawOdometryIncrementReading.phi() - Arot1);
617 
618  float Arot1_draw =
619  Arot1 -
623  float Atrans_draw =
624  Atrans -
627  (fabs(Arot1) + fabs(Arot2))) *
629  float Arot2_draw =
630  Arot2 -
634 
635  // Output:
636  outSample.x(
637  Atrans_draw * cos(Arot1_draw) +
639  getRandomGenerator().drawGaussian1D_normalized());
640  outSample.y(
641  Atrans_draw * sin(Arot1_draw) +
643  getRandomGenerator().drawGaussian1D_normalized());
644  outSample.phi(
645  Arot1_draw + Arot2_draw +
647  getRandomGenerator().drawGaussian1D_normalized());
648  outSample.normalizePhi();
649 }
650 
651 /*---------------------------------------------------------------
652  prepareFastDrawSingleSamples
653  ---------------------------------------------------------------*/
655 {
656  // Only in the case of "emOdometry" we have the rawOdometryMeasurement and
657  // the parameters to draw new samples:
659  {
662  else
664  }
665 }
666 
667 /*---------------------------------------------------------------
668  fastDrawSingleSample
669  ---------------------------------------------------------------*/
671 {
672  // Only in the case of "emOdometry" we have the rawOdometryMeasurement and
673  // the parameters to draw new samples:
675  {
678  else
680  }
681  else
682  {
683  // If is not odometry, just employ the stored distribution:
684  poseChange->drawSingleSample(outSample);
685  }
686 }
687 
688 /*---------------------------------------------------------------
689  prepareFastDrawSingleSample_modelGaussian
690  ---------------------------------------------------------------*/
692 {
693  MRPT_START
694 
696 
697  CMatrixDouble33 D;
698 
699  const CPosePDFGaussian* gPdf =
700  static_cast<const CPosePDFGaussian*>(poseChange.get());
701  const CMatrixDouble33& cov = gPdf->cov;
702 
703  m_fastDrawGauss_M = gPdf->mean;
704 
705  /** Computes the eigenvalues/eigenvector decomposition of this matrix,
706  * so that: M = Z · D · Z<sup>T</sup>, where columns in Z are the
707  * eigenvectors and the diagonal matrix D contains the eigenvalues
708  * as diagonal elements, sorted in <i>ascending</i> order.
709  */
710  cov.eigenVectors(m_fastDrawGauss_Z, D);
711 
712  // Scale eigenvectors with eigenvalues:
713  D = D.array().sqrt().matrix();
715 
716  MRPT_END
717 }
718 
719 /*---------------------------------------------------------------
720  prepareFastDrawSingleSample_modelThrun
721  ---------------------------------------------------------------*/
723 /*---------------------------------------------------------------
724  prepareFastDrawSingleSample_modelThrun
725  ---------------------------------------------------------------*/
727  CPose2D& outSample) const
728 {
729  CVectorFloat rndVector(3, 0);
730  for (size_t i = 0; i < 3; i++)
731  {
733  for (size_t d = 0; d < 3; d++)
734  rndVector[d] += (m_fastDrawGauss_Z.get_unsafe(d, i) * rnd);
735  }
736 
737  outSample = CPose2D(
738  m_fastDrawGauss_M.x() + rndVector[0],
739  m_fastDrawGauss_M.y() + rndVector[1],
740  m_fastDrawGauss_M.phi() + rndVector[2]);
741 }
742 
743 /*---------------------------------------------------------------
744  prepareFastDrawSingleSample_modelThrun
745  ---------------------------------------------------------------*/
747  CPose2D& outSample) const
748 {
749  drawSingleSample_modelThrun(outSample);
750 }
A namespace of pseudo-random numbers genrators of diferent distributions.
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:135
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
CPose2D mean
The mean value.
TEstimationMethod estimationMethod
This fields indicates the way in which this estimation was obtained.
void drawSingleSample(mrpt::poses::CPose2D &outSample) const
Using this method instead of "poseChange->drawSingleSample()" may be more efficient in most situation...
void drawSingleSample_modelThrun(mrpt::poses::CPose2D &outSample) const
The sample generator for the model "computeFromOdometry_modelThrun", internally called when the user ...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:42
void computeFromOdometry(const mrpt::poses::CPose2D &odometryIncrement, const TMotionModelOptions &options)
Computes the PDF of the pose increment from an odometry reading and according to the given motion mod...
STL namespace.
The parameter to be passed to "computeFromOdometry".
void computeFromOdometry_modelGaussian(const mrpt::poses::CPose2D &odometryIncrement, const TMotionModelOptions &o)
Computes the PDF of the pose increment from an odometry reading, using a Gaussian approximation as th...
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix.
void drawSingleSample_modelGaussian(mrpt::poses::CPose2D &outSample) const
The sample generator for the model "computeFromOdometry_modelGaussian", internally called when the us...
T square(const T x)
Inline function for the square of a number.
Definition: bits.h:55
unsigned char uint8_t
Definition: rptypes.h:41
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
Represents a probabilistic 2D movement of the robot mobile base.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
std::shared_ptr< CPosePDF > Ptr
Definition: CPosePDF.h:44
mrpt::math::CMatrixDouble33 m_fastDrawGauss_Z
Auxiliary matrix.
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
#define MRPT_END
void fastDrawSingleSample(mrpt::poses::CPose2D &outSample) const
Faster version than "drawSingleSample", but requires a previous call to "prepareFastDrawSingleSamples...
double norm() const
Returns the euclidean norm of vector: .
Definition: CPoseOrPoint.h:252
mrpt::utils::poly_ptr_ptr< mrpt::poses::CPosePDF::Ptr > poseChange
The 2D pose change probabilistic estimation.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
float additional_std_XY
An additional noise added to the thrun model (std.
void computeFromOdometry_modelThrun(const mrpt::poses::CPose2D &odometryIncrement, const TMotionModelOptions &o)
Computes the PDF of the pose increment from an odometry reading, using the motion model from Thrun&#39;s ...
void fastDrawSingleSample_modelThrun(mrpt::poses::CPose2D &outSample) const
Internal use.
This namespace contains representation of robot actions and observations.
void computeFromEncoders(double K_left, double K_right, double D)
If "hasEncodersInfo"=true, this method updates the pose estimation according to the ticks from both e...
TEstimationMethod
A list of posible ways for estimating the content of a CActionRobotMovement2D object.
Declares a class that represents a Probability Density Function (PDF) over a 2D pose (x...
#define DEG2RAD
T wrapToPi(T a)
Modifies the given angle to translate it into the ]-pi,pi] range.
Definition: wrap2pi.h:53
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
TDrawSampleMotionModel modelSelection
The model to be used.
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
Definition: datetime.h:16
void fastDrawSingleSample_modelGaussian(mrpt::poses::CPose2D &outSample) const
Internal use.
struct mrpt::obs::CActionRobotMovement2D::TMotionModelOptions::TOptions_GaussianModel gaussianModel
Declares a class for storing a robot action.
Definition: CAction.h:28
void prepareFastDrawSingleSamples() const
Call this before calling a high number of times "fastDrawSingleSample", which is much faster than "dr...
#define MRPT_START
__int32 int32_t
Definition: rptypes.h:46
#define RAD2DEG
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void prepareFastDrawSingleSample_modelGaussian() const
Internal use.
struct mrpt::obs::CActionRobotMovement2D::TMotionModelOptions::TOptions_ThrunModel thrunModel
void prepareFastDrawSingleSample_modelThrun() const
Internal use.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:40
const float R
void resetDeterministic(const CPose2D &location, size_t particlesCount=0)
Reset the PDF to a single point: All m_particles will be set exactly to the supplied pose...
const double & phi() const
Get the phi angle of the 2D pose (in radians)
Definition: CPose2D.h:91
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::utils::CSerializable) is of t...
Definition: CObject.h:103
uint32_t nParticlesCount
The default number of particles to generate in a internal representation (anyway you can draw as many...
GLuint in
Definition: glext.h:7274
#define ASSERT_(f)
GLenum GLint GLint y
Definition: glext.h:3538
std::shared_ptr< T > make_aligned_shared(Args &&... args)
Creates a shared_ptr with 16-byte aligned memory.
Eigen::Matrix< typename MATRIX::Scalar, MATRIX::ColsAtCompileTime, MATRIX::ColsAtCompileTime > cov(const MATRIX &v)
Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample...
Definition: ops_matrices.h:148
GLenum GLint x
Definition: glext.h:3538
unsigned __int32 uint32_t
Definition: rptypes.h:47
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
T::element_type * get()
Definition: poly_ptr_ptr.h:71
struct mrpt::obs::CActionRobotMovement2D::TMotionModelOptions motionModelConfiguration
void normalizePhi()
Forces "phi" to be in the range [-pi,pi];.
Definition: CPose2D.cpp:305
CMatrixFixedNumeric< double, 3, 1 > CMatrixDouble31
Definition: eigen_frwds.h:60
mrpt::poses::CPose2D rawOdometryIncrementReading
This is the raw odometry reading, and only is used when "estimationMethod" is "TEstimationMethod::emO...
double drawGaussian1D_normalized()
Generate a normalized (mean=0, std=1) normally distributed sample.



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