Main MRPT website > C++ reference
MRPT logo
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-2014, 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/slam/CAction.h>
13 #include <mrpt/poses/CPose2D.h>
14 //#include <mrpt/poses/CPosePDFGaussian.h>
15 //#include <mrpt/poses/CPosePDFParticles.h>
16 #include <mrpt/poses/CPosePDF.h>
17 
18 namespace mrpt
19 {
20  namespace slam
21  {
22  using namespace mrpt::math;
23  using namespace mrpt::poses;
24 
25  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CActionRobotMovement2D, CAction, OBS_IMPEXP )
26 
27  /** Represents a probabilistic 2D movement of the robot mobile base
28  *
29  * See the tutorial on <a href="http://www.mrpt.org/Probabilistic_Motion_Models" >probabilistic motion models</a>.
30  *
31  * \sa CAction
32  * \ingroup mrpt_obs_grp
33  */
35  {
36  // This must be added to any CSerializable derived class:
38 
39  public:
40  /** A list of posible ways for estimating the content of a CActionRobotMovement2D object.
41  */
43  {
44  emOdometry = 0,
45  emScan2DMatching
46  };
47 
48  /** Constructor
49  */
51 
52  /** Copy constructor
53  */
55 
56  /** Copy operator
57  */
58  CActionRobotMovement2D & operator =(const CActionRobotMovement2D &o);
59 
60  /** Destructor
61  */
63 
64  /** The 2D pose change probabilistic estimation.
65  */
66  CPosePDFPtr poseChange;
67 
68  /** This is the raw odometry reading, and only is used when "estimationMethod" is "TEstimationMethod::emOdometry"
69  */
71 
72  /** This fields indicates the way this estimation was obtained.
73  */
75 
76  /** If "true" means that "encoderLeftTicks" and "encoderRightTicks" contain valid values.
77  */
79 
80  /** For odometry only: the ticks count for each wheel FROM the last reading (positive means FORWARD, for both wheels);
81  * \sa hasEncodersInfo
82  */
83  int32_t encoderLeftTicks,encoderRightTicks;
84 
85  /** If "true" means that "velocityLin" and "velocityAng" contain valid values.
86  */
88 
89  /** The velocity of the robot, linear in meters/sec and angular in rad/sec.
90  */
91  float velocityLin, velocityAng;
92 
94  {
95  mmGaussian = 0,
96  mmThrun
97  };
98  /** The parameter to be passed to "computeFromOdometry".
99  */
101  {
102  /** Default values loader.
103  */
105 
106  /** The model to be used.
107  */
109 
110  /** Options for the gaussian model, which generates a CPosePDFGaussian object in poseChange
111  */
113  {
114  float a1,a2,a3,a4,minStdXY,minStdPHI;
115  } gausianModel;
116 
117  /** Options for the Thrun's model, which generates a CPosePDFParticles object in poseChange
118  */
120  {
121  /** The default number of particles to generate in a internal representation (anyway you can draw as many samples as you want through CActionRobotMovement2D::drawSingleSample)
122  */
123  uint32_t nParticlesCount;
124 
129 
130  /** An additional noise added to the thrun model (std. dev. in meters and radians).
131  */
132  float additional_std_XY, additional_std_phi;
133  } thrunModel;
134 
135  } motionModelConfiguration;
136 
137  /** 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).
138  * According to the parameters in the passed struct, it will be called one the private sampling functions (see "see also" next).
139  * \sa computeFromOdometry_modelGaussian, computeFromOdometry_modelThrun
140  */
141  void computeFromOdometry(
142  const CPose2D &odometryIncrement,
143  const TMotionModelOptions &options);
144 
145  /** 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).
146  *
147  * \param K_left The meters / tick ratio for the left encoder.
148  * \param K_right The meters / tick ratio for the right encoder.
149  * \param D The distance between both wheels, in meters.
150  */
151  void computeFromEncoders(
152  double K_left,
153  double K_right,
154  double D );
155 
156  /** Using this method instead of "poseChange->drawSingleSample()" may be more efficient in most situations.
157  * \sa CPosePDF::drawSingleSample
158  */
159  void drawSingleSample( CPose2D &outSample ) const;
160 
161  /** Call this before calling a high number of times "fastDrawSingleSample", which is much faster than "drawSingleSample"
162  */
163  void prepareFastDrawSingleSamples() const;
164 
165  /** Faster version than "drawSingleSample", but requires a previous call to "prepareFastDrawSingleSamples"
166  */
167  void fastDrawSingleSample( CPose2D &outSample ) const;
168 
169  protected:
170  /** Computes the PDF of the pose increment from an odometry reading, using a Gaussian approximation as the motion model.
171  * \sa computeFromOdometry
172  */
173  void computeFromOdometry_modelGaussian(
174  const CPose2D &odometryIncrement,
175  const TMotionModelOptions &o
176  );
177 
178  /** Computes the PDF of the pose increment from an odometry reading, using the motion model from Thrun's book.
179  * This model is discussed in "Probabilistic Robotics", Thrun, Burgard, and Fox, 2006, pp.136.
180  * \sa computeFromOdometry
181  */
182  void computeFromOdometry_modelThrun(
183  const CPose2D &odometryIncrement,
184  const TMotionModelOptions &o
185  );
186 
187  /** The sample generator for the model "computeFromOdometry_modelGaussian", internally called when the user invokes "drawSingleSample".
188  */
189  void drawSingleSample_modelGaussian( CPose2D &outSample ) const;
190 
191  /** The sample generator for the model "computeFromOdometry_modelThrun", internally called when the user invokes "drawSingleSample".
192  */
193  void drawSingleSample_modelThrun( CPose2D &outSample ) const;
194 
195  /** Internal use
196  */
197  void prepareFastDrawSingleSample_modelGaussian() const;
198 
199  /** Internal use
200  */
201  void prepareFastDrawSingleSample_modelThrun() const;
202 
203  /** Internal use
204  */
205  void fastDrawSingleSample_modelGaussian( CPose2D &outSample ) const;
206 
207  /** Internal use
208  */
209  void fastDrawSingleSample_modelThrun( CPose2D &outSample ) const;
210 
211  /** Auxiliary matrix
212  */
215 
216 
217  }; // End of class def.
219 
220 
221  } // End of namespace
222 } // End of namespace
223 
224 #endif
Options for the gaussian model, which generates a CPosePDFGaussian object in poseChange.
The parameter to be passed to "computeFromOdometry".
float velocityLin
The velocity of the robot, linear in meters/sec and angular in rad/sec.
TEstimationMethod
A list of posible ways for estimating the content of a CActionRobotMovement2D object.
uint32_t nParticlesCount
The default number of particles to generate in a internal representation (anyway you can draw as many...
TEstimationMethod estimationMethod
This fields indicates the way this estimation was obtained.
float additional_std_XY
An additional noise added to the thrun model (std.
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
Definition: CArray.h:18
#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...
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
CPosePDFPtr poseChange
The 2D pose change probabilistic estimation.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Options for the Thrun's model, which generates a CPosePDFParticles object in poseChange.
Represents a probabilistic 2D movement of the robot mobile base.
A class used to store a 2D pose.
Definition: CPose2D.h:36
bool hasEncodersInfo
If "true" means that "encoderLeftTicks" and "encoderRightTicks" contain valid values.
TDrawSampleMotionModel modelSelection
The model to be used.
CMatrixDouble33 m_fastDrawGauss_Z
Auxiliary matrix.
bool hasVelocities
If "true" means that "velocityLin" and "velocityAng" contain valid values.
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
CPose2D rawOdometryIncrementReading
This is the raw odometry reading, and only is used when "estimationMethod" is "TEstimationMethod::emO...
Declares a class for storing a robot action.
Definition: CAction.h:33



Page generated by Doxygen 1.8.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014