Main MRPT website > C++ reference for MRPT 1.4.0
obs/CActionRobotMovement2D.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2016, 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 #ifndef CActionRobotMovement2D_H
10 #define CActionRobotMovement2D_H
11 
12 #include <mrpt/obs/CAction.h>
13 #include <mrpt/poses/CPose2D.h>
14 #include <mrpt/poses/CPosePDF.h>
15 
16 namespace mrpt
17 {
18  namespace obs
19  {
20  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CActionRobotMovement2D, CAction, OBS_IMPEXP )
21 
22  /** Represents a probabilistic 2D movement of the robot mobile base
23  *
24  * See the tutorial on <a href="http://www.mrpt.org/Probabilistic_Motion_Models" >probabilistic motion models</a>.
25  *
26  * \sa CAction
27  * \ingroup mrpt_obs_grp
28  */
30  {
31  // This must be added to any CSerializable derived class:
33 
34  public:
35  /** A list of posible ways for estimating the content of a CActionRobotMovement2D object.
36  */
38  {
39  emOdometry = 0,
40  emScan2DMatching
41  };
42 
43  CActionRobotMovement2D(); //!< Constructor
44  CActionRobotMovement2D(const CActionRobotMovement2D &o); //!< Copy constructor
45  CActionRobotMovement2D & operator =(const CActionRobotMovement2D &o); //!< Copy operator
46  ~CActionRobotMovement2D(); //!< Destructor
47 
48  mrpt::poses::CPosePDFPtr poseChange; //!< The 2D pose change probabilistic estimation.
49  /** This is the raw odometry reading, and only is used when "estimationMethod" is "TEstimationMethod::emOdometry" */
51  TEstimationMethod estimationMethod; //!< This fields indicates the way in which this estimation was obtained.
52 
53  bool hasEncodersInfo; //!< If "true" means that "encoderLeftTicks" and "encoderRightTicks" contain valid values.
54  /** For odometry only: the ticks count for each wheel FROM the last reading (positive means FORWARD, for both wheels);
55  * \sa hasEncodersInfo
56  */
57  int32_t encoderLeftTicks,encoderRightTicks;
58 
59  bool hasVelocities; //!< If "true" means that "velocityLin" and "velocityAng" contain valid values.
60  float velocityLin, velocityAng; //!< The velocity of the robot, linear in meters/sec and angular in rad/sec.
61 
63  {
64  mmGaussian = 0,
65  mmThrun
66  };
67  /** The parameter to be passed to "computeFromOdometry". */
69  {
70  TMotionModelOptions(); //!< Default values loader.
71 
72  TDrawSampleMotionModel modelSelection; //!< The model to be used.
73 
74  /** Options for the gaussian model, which generates a CPosePDFGaussian object in poseChange
75  * See docs in : http://www.mrpt.org/tutorials/programming/odometry-and-motion-models/probabilistic_motion_models/
76  */
78  {
79  float a1,a2,a3,a4,minStdXY,minStdPHI;
80  } gausianModel;
81 
82  /** Options for the Thrun's model, which generates a CPosePDFParticles object in poseChange
83  * See docs in : http://www.mrpt.org/tutorials/programming/odometry-and-motion-models/probabilistic_motion_models/
84  */
86  {
87  /** The default number of particles to generate in a internal representation (anyway you can draw as many samples as you want through CActionRobotMovement2D::drawSingleSample) */
88  uint32_t nParticlesCount;
93 
94  /** An additional noise added to the thrun model (std. dev. in meters and radians). */
95  float additional_std_XY, additional_std_phi;
96  } thrunModel;
97 
98  } motionModelConfiguration;
99 
100  /** Computes the PDF of the pose increment from an odometry reading and according to the given motion model (speed and encoder ticks information is not modified).
101  * According to the parameters in the passed struct, it will be called one the private sampling functions (see "see also" next).
102  * \sa computeFromOdometry_modelGaussian, computeFromOdometry_modelThrun
103  */
104  void computeFromOdometry(
105  const mrpt::poses::CPose2D &odometryIncrement,
106  const TMotionModelOptions &options);
107 
108  /** If "hasEncodersInfo"=true, this method updates the pose estimation according to the ticks from both encoders and the passed parameters, which is passed internally to the method "computeFromOdometry" with the last used PDF options (or the defualt ones if not explicitly called by the user).
109  *
110  * \param K_left The meters / tick ratio for the left encoder.
111  * \param K_right The meters / tick ratio for the right encoder.
112  * \param D The distance between both wheels, in meters.
113  */
114  void computeFromEncoders(
115  double K_left,
116  double K_right,
117  double D );
118 
119  /** Using this method instead of "poseChange->drawSingleSample()" may be more efficient in most situations.
120  * \sa CPosePDF::drawSingleSample
121  */
122  void drawSingleSample( mrpt::poses::CPose2D &outSample ) const;
123 
124  /** Call this before calling a high number of times "fastDrawSingleSample", which is much faster than "drawSingleSample"
125  */
126  void prepareFastDrawSingleSamples() const;
127 
128  /** Faster version than "drawSingleSample", but requires a previous call to "prepareFastDrawSingleSamples"
129  */
130  void fastDrawSingleSample( mrpt::poses::CPose2D &outSample ) const;
131 
132  protected:
133  /** Computes the PDF of the pose increment from an odometry reading, using a Gaussian approximation as the motion model.
134  * \sa computeFromOdometry
135  */
136  void computeFromOdometry_modelGaussian(
137  const mrpt::poses::CPose2D &odometryIncrement,
138  const TMotionModelOptions &o
139  );
140 
141  /** Computes the PDF of the pose increment from an odometry reading, using the motion model from Thrun's book.
142  * This model is discussed in "Probabilistic Robotics", Thrun, Burgard, and Fox, 2006, pp.136.
143  * \sa computeFromOdometry
144  */
145  void computeFromOdometry_modelThrun(
146  const mrpt::poses::CPose2D &odometryIncrement,
147  const TMotionModelOptions &o
148  );
149 
150  /** The sample generator for the model "computeFromOdometry_modelGaussian", internally called when the user invokes "drawSingleSample".
151  */
152  void drawSingleSample_modelGaussian( mrpt::poses::CPose2D &outSample ) const;
153 
154  /** The sample generator for the model "computeFromOdometry_modelThrun", internally called when the user invokes "drawSingleSample".
155  */
156  void drawSingleSample_modelThrun( mrpt::poses::CPose2D &outSample ) const;
157 
158  /** Internal use
159  */
160  void prepareFastDrawSingleSample_modelGaussian() const;
161 
162  /** Internal use
163  */
164  void prepareFastDrawSingleSample_modelThrun() const;
165 
166  /** Internal use
167  */
168  void fastDrawSingleSample_modelGaussian( mrpt::poses::CPose2D &outSample ) const;
169 
170  /** Internal use
171  */
172  void fastDrawSingleSample_modelThrun( mrpt::poses::CPose2D &outSample ) const;
173 
174  /** Auxiliary matrix
175  */
178 
179 
180  }; // End of class def.
182 
183 
184  } // End of namespace
185 } // End of namespace
186 
187 #endif
mrpt::obs::CActionRobotMovement2D::m_fastDrawGauss_M
mrpt::poses::CPose2D m_fastDrawGauss_M
Definition: obs/CActionRobotMovement2D.h:177
mrpt::obs::gnss::a1
double a1
Definition: gnss_messages_novatel.h:367
mrpt::obs::CActionRobotMovement2D::TMotionModelOptions::TOptions_ThrunModel::alfa3_trans_trans
float alfa3_trans_trans
Definition: obs/CActionRobotMovement2D.h:91
mrpt::obs::CActionRobotMovement2D::TMotionModelOptions::modelSelection
TDrawSampleMotionModel modelSelection
The model to be used.
Definition: obs/CActionRobotMovement2D.h:72
mrpt::obs::CActionRobotMovement2D::TMotionModelOptions::TOptions_ThrunModel
Options for the Thrun's model, which generates a CPosePDFParticles object in poseChange See docs in :...
Definition: obs/CActionRobotMovement2D.h:85
mrpt::obs::CActionRobotMovement2D::hasVelocities
bool hasVelocities
If "true" means that "velocityLin" and "velocityAng" contain valid values.
Definition: obs/CActionRobotMovement2D.h:59
mrpt::obs::CActionRobotMovement2D::poseChange
mrpt::poses::CPosePDFPtr poseChange
The 2D pose change probabilistic estimation.
Definition: obs/CActionRobotMovement2D.h:48
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CParticleFilter.h:16
mrpt::obs::CActionRobotMovement2D
Represents a probabilistic 2D movement of the robot mobile base.
Definition: obs/CActionRobotMovement2D.h:29
CPose2D.h
mrpt::obs::CActionRobotMovement2D::m_fastDrawGauss_Z
mrpt::math::CMatrixDouble33 m_fastDrawGauss_Z
Auxiliary matrix.
Definition: obs/CActionRobotMovement2D.h:176
mrpt::obs::CActionRobotMovement2D::estimationMethod
TEstimationMethod estimationMethod
This fields indicates the way in which this estimation was obtained.
Definition: obs/CActionRobotMovement2D.h:51
CAction.h
mrpt::obs::CActionRobotMovement2D::TMotionModelOptions::TOptions_ThrunModel::alfa4_trans_rot
float alfa4_trans_rot
Definition: obs/CActionRobotMovement2D.h:92
mrpt::obs::gnss::a2
double a2
Definition: gnss_messages_novatel.h:367
mrpt::obs::CActionRobotMovement2D::rawOdometryIncrementReading
mrpt::poses::CPose2D rawOdometryIncrementReading
This is the raw odometry reading, and only is used when "estimationMethod" is "TEstimationMethod::emO...
Definition: obs/CActionRobotMovement2D.h:50
CPosePDF.h
mrpt::poses::CPose2D
A class used to store a 2D pose.
Definition: CPose2D.h:36
mrpt::obs::CActionRobotMovement2D::velocityLin
float velocityLin
Definition: obs/CActionRobotMovement2D.h:60
DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
Definition: CSerializable.h:174
mrpt::obs::CActionRobotMovement2D::encoderRightTicks
int32_t encoderRightTicks
Definition: obs/CActionRobotMovement2D.h:57
mrpt::obs::CActionRobotMovement2D::TMotionModelOptions::TOptions_ThrunModel::additional_std_XY
float additional_std_XY
An additional noise added to the thrun model (std.
Definition: obs/CActionRobotMovement2D.h:95
mrpt::obs::CActionRobotMovement2D::TMotionModelOptions::TOptions_GaussianModel
Options for the gaussian model, which generates a CPosePDFGaussian object in poseChange See docs in :...
Definition: obs/CActionRobotMovement2D.h:77
mrpt::math::CMatrixFixedNumeric
A numeric matrix of compile-time fixed size.
Definition: CMatrixFixedNumeric.h:34
DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
Definition: CSerializable.h:170
mrpt::obs::CActionRobotMovement2D::TMotionModelOptions::TOptions_ThrunModel::nParticlesCount
uint32_t nParticlesCount
The default number of particles to generate in a internal representation (anyway you can draw as many...
Definition: obs/CActionRobotMovement2D.h:88
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:147
mrpt::obs::CActionRobotMovement2D::TMotionModelOptions::TOptions_ThrunModel::alfa2_rot_trans
float alfa2_rot_trans
Definition: obs/CActionRobotMovement2D.h:90
mrpt::obs::CActionRobotMovement2D::TMotionModelOptions::TOptions_GaussianModel::minStdXY
float minStdXY
Definition: obs/CActionRobotMovement2D.h:79
mrpt::obs::CActionRobotMovement2D::hasEncodersInfo
bool hasEncodersInfo
If "true" means that "encoderLeftTicks" and "encoderRightTicks" contain valid values.
Definition: obs/CActionRobotMovement2D.h:53
mrpt::obs::gnss::a3
double a3
Definition: gnss_messages_novatel.h:367
mrpt::obs::CAction
Declares a class for storing a robot action.
Definition: obs/CAction.h:33
mrpt::obs::CActionRobotMovement2D::TMotionModelOptions::TOptions_ThrunModel::alfa1_rot_rot
float alfa1_rot_rot
Definition: obs/CActionRobotMovement2D.h:89
mrpt::obs::CActionRobotMovement2D::TMotionModelOptions
The parameter to be passed to "computeFromOdometry".
Definition: obs/CActionRobotMovement2D.h:68
mrpt::obs::CActionRobotMovement2D::TEstimationMethod
TEstimationMethod
A list of posible ways for estimating the content of a CActionRobotMovement2D object.
Definition: obs/CActionRobotMovement2D.h:37
mrpt::obs::CActionRobotMovement2D::TDrawSampleMotionModel
TDrawSampleMotionModel
Definition: obs/CActionRobotMovement2D.h:62



Page generated by Doxygen 1.8.16 for MRPT 1.4.0 SVN: at Mon Oct 14 22:32:58 UTC 2019