44 if (estimationMethod == emOdometry)
47 out << rawOdometryIncrementReading;
49 out << motionModelConfiguration.gaussianModel.a1
50 << motionModelConfiguration.gaussianModel.a2
51 << motionModelConfiguration.gaussianModel.a3
52 << motionModelConfiguration.gaussianModel.a4
53 << motionModelConfiguration.gaussianModel.minStdXY
54 << motionModelConfiguration.gaussianModel.minStdPHI;
56 out << motionModelConfiguration.thrunModel.nParticlesCount
57 << motionModelConfiguration.thrunModel.alfa1_rot_rot
58 << motionModelConfiguration.thrunModel.alfa2_rot_trans
59 << motionModelConfiguration.thrunModel.alfa3_trans_trans
60 << motionModelConfiguration.thrunModel.alfa4_trans_rot
61 << motionModelConfiguration.thrunModel.additional_std_XY
62 << motionModelConfiguration.thrunModel.additional_std_phi;
72 if (hasVelocities) out << velocityLocal;
74 out << hasEncodersInfo;
76 out << encoderLeftTicks << encoderRightTicks;
101 if (estimationMethod == emOdometry)
104 in >> rawOdometryIncrementReading;
107 motionModelConfiguration.modelSelection =
110 in >> motionModelConfiguration.gaussianModel.a1 >>
111 motionModelConfiguration.gaussianModel.a2 >>
112 motionModelConfiguration.gaussianModel.a3 >>
113 motionModelConfiguration.gaussianModel.a4 >>
114 motionModelConfiguration.gaussianModel.minStdXY >>
115 motionModelConfiguration.gaussianModel.minStdPHI;
118 motionModelConfiguration.thrunModel.nParticlesCount = i;
119 in >> motionModelConfiguration.thrunModel.alfa1_rot_rot >>
120 motionModelConfiguration.thrunModel.alfa2_rot_trans >>
121 motionModelConfiguration.thrunModel.alfa3_trans_trans >>
122 motionModelConfiguration.thrunModel.alfa4_trans_rot;
127 motionModelConfiguration.thrunModel.additional_std_XY >>
128 motionModelConfiguration.thrunModel.additional_std_phi;
132 motionModelConfiguration.thrunModel.additional_std_XY =
133 motionModelConfiguration.thrunModel.additional_std_phi =
139 rawOdometryIncrementReading, motionModelConfiguration);
152 if (hasVelocities)
in >> velocityLocal;
156 float velocityLin, velocityAng;
157 in >> velocityLin >> velocityAng;
158 velocityLocal.vx = velocityLin;
159 velocityLocal.vy = .0f;
160 velocityLocal.omega = velocityAng;
162 in >> hasEncodersInfo;
163 if (version < 7 || hasEncodersInfo)
166 encoderLeftTicks = i;
168 encoderRightTicks = i;
172 encoderLeftTicks = 0;
173 encoderRightTicks = 0;
194 if (estimationMethod == emOdometry)
197 in >> rawOdometryIncrementReading;
200 motionModelConfiguration.modelSelection =
203 float dum1, dum2, dum3;
205 in >> dum1 >> dum2 >> dum3 >>
206 motionModelConfiguration.gaussianModel.minStdXY >>
207 motionModelConfiguration.gaussianModel.minStdPHI;
211 motionModelConfiguration.thrunModel.nParticlesCount = i;
212 in >> motionModelConfiguration.thrunModel.alfa1_rot_rot;
213 in >> motionModelConfiguration.thrunModel.alfa2_rot_trans >>
214 motionModelConfiguration.thrunModel.alfa3_trans_trans >>
215 motionModelConfiguration.thrunModel.alfa4_trans_rot;
219 rawOdometryIncrementReading, motionModelConfiguration);
231 float velocityLin, velocityAng;
232 in >> velocityLin >> velocityAng;
233 velocityLocal.vx = velocityLin;
234 velocityLocal.vy = .0f;
235 velocityLocal.omega = velocityAng;
237 in >> hasEncodersInfo;
240 encoderLeftTicks = i;
242 encoderRightTicks = i;
257 if (estimationMethod == emOdometry)
260 in >> rawOdometryIncrementReading;
266 in.ReadBuffer(&dummy,
sizeof(dummy));
272 rawOdometryIncrementReading, motionModelConfiguration);
284 float velocityLin, velocityAng;
285 in >> velocityLin >> velocityAng;
286 velocityLocal.vx = velocityLin;
287 velocityLocal.vy = .0f;
288 velocityLocal.omega = velocityAng;
290 in >> hasEncodersInfo;
292 encoderLeftTicks = i;
294 encoderRightTicks = i;
312 if (estimationMethod == emOdometry)
313 poseChange->getMean(rawOdometryIncrementReading);
315 rawOdometryIncrementReading =
CPose2D(0, 0, 0);
321 float velocityLin, velocityAng;
322 in >> velocityLin >> velocityAng;
323 velocityLocal.vx = velocityLin;
324 velocityLocal.vy = .0f;
325 velocityLocal.omega = velocityAng;
327 in >> hasEncodersInfo;
329 encoderLeftTicks = i;
331 encoderRightTicks = i;
336 hasVelocities = hasEncodersInfo =
false;
337 encoderLeftTicks = encoderRightTicks = 0;
351 double K_left,
double K_right,
double D)
356 0.5 * (K_right * encoderRightTicks + K_left * encoderLeftTicks);
358 (K_right * encoderRightTicks - K_left * encoderLeftTicks) / D;
363 const double R = As / Aphi;
365 y =
R * (1 - cos(Aphi));
374 computeFromOdometry(
CPose2D(
x,
y, Aphi), motionModelConfiguration);
385 estimationMethod = emOdometry;
386 rawOdometryIncrementReading = odometryIncrement;
387 motionModelConfiguration = options;
390 computeFromOdometry_modelGaussian(odometryIncrement, options);
392 computeFromOdometry_modelThrun(odometryIncrement, options);
428 poseChange = mrpt::make_aligned_shared<CPosePDFGaussian>();
436 double Al = odometryIncrement.
norm();
452 double cos_Aphi_2 = cos(odometryIncrement.
phi() / 2);
453 double sin_Aphi_2 = sin(odometryIncrement.
phi() / 2);
455 H(0, 0) = H(1, 1) = cos_Aphi_2;
456 H(0, 1) = -(H(1, 0) = sin_Aphi_2);
461 J(0, 2) = -sin_Aphi_2 * ODO_INCR(0, 0) - cos_Aphi_2 * ODO_INCR(1, 0);
462 J(1, 2) = cos_Aphi_2 * ODO_INCR(0, 0) - sin_Aphi_2 * ODO_INCR(1, 0);
465 aux->
mean = odometryIncrement;
468 J.multiply_HCHt(C_ODO, aux->
cov);
482 poseChange = mrpt::make_aligned_shared<CPosePDFParticles>();
496 float Arot1 = (odometryIncrement.
y() != 0 || odometryIncrement.
x() != 0)
497 ? atan2(odometryIncrement.
y(), odometryIncrement.
x())
499 float Atrans = odometryIncrement.
norm();
505 float Arot1_draw = Arot1 -
514 float Arot2_draw = Arot2 -
521 Atrans_draw * cos(Arot1_draw) +
525 Atrans_draw * sin(Arot1_draw) +
529 Arot1_draw + Arot2_draw +
600 (fabs(Arot1) + fabs(Arot2))) *
610 Atrans_draw * cos(Arot1_draw) +
614 Atrans_draw * sin(Arot1_draw) +
618 Arot1_draw + Arot2_draw +
686 D = D.array().sqrt().matrix();
703 for (
size_t i = 0; i < 3; i++)
706 for (
size_t d = 0; d < 3; d++)
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::rtti::CObject) is of the give...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
CParticleList m_particles
The array of particles.
A numeric matrix of compile-time fixed size.
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
Declares a class for storing a robot action.
Represents a probabilistic 2D movement of the robot mobile base.
mrpt::poses::CPose2D rawOdometryIncrementReading
This is the raw odometry reading, and only is used when "estimationMethod" is "TEstimationMethod::emO...
void drawSingleSample_modelGaussian(mrpt::poses::CPose2D &outSample) const
The sample generator for the model "computeFromOdometry_modelGaussian", internally called when the us...
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
void prepareFastDrawSingleSamples() const
Call this before calling a high number of times "fastDrawSingleSample", which is much faster than "dr...
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's ...
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::containers::deepcopy_poly_ptr< mrpt::poses::CPosePDF::Ptr > poseChange
The 2D pose change probabilistic estimation.
void fastDrawSingleSample(mrpt::poses::CPose2D &outSample) const
Faster version than "drawSingleSample", but requires a previous call to "prepareFastDrawSingleSamples...
void prepareFastDrawSingleSample_modelThrun() const
Internal use.
void fastDrawSingleSample_modelThrun(mrpt::poses::CPose2D &outSample) const
Internal use.
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...
struct mrpt::obs::CActionRobotMovement2D::TMotionModelOptions motionModelConfiguration
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
void fastDrawSingleSample_modelGaussian(mrpt::poses::CPose2D &outSample) const
Internal use.
void drawSingleSample(mrpt::poses::CPose2D &outSample) const
Using this method instead of "poseChange->drawSingleSample()" may be more efficient in most situation...
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...
void drawSingleSample_modelThrun(mrpt::poses::CPose2D &outSample) const
The sample generator for the model "computeFromOdometry_modelThrun", internally called when the user ...
TEstimationMethod
A list of posible ways for estimating the content of a CActionRobotMovement2D object.
mrpt::math::CMatrixDouble33 m_fastDrawGauss_Z
Auxiliary matrix.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
mrpt::poses::CPose2D m_fastDrawGauss_M
void prepareFastDrawSingleSample_modelGaussian() const
Internal use.
TEstimationMethod estimationMethod
This fields indicates the way in which this estimation was obtained.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
void normalizePhi()
Forces "phi" to be in the range [-pi,pi];.
const double & phi() const
Get the phi angle of the 2D pose (in radians)
double x() const
Common members of all points & poses classes.
double norm() const
Returns the euclidean norm of vector: .
Declares a class that represents a Probability Density function (PDF) of a 2D pose .
CPose2D mean
The mean value.
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix.
std::shared_ptr< CPosePDF > Ptr
Declares a class that represents a Probability Density Function (PDF) over a 2D pose (x,...
void resetDeterministic(const mrpt::math::TPose2D &location, size_t particlesCount=0)
Reset the PDF to a single point: All m_particles will be set exactly to the supplied pose.
double drawGaussian1D_normalized()
Generate a normalized (mean=0, std=1) normally distributed sample.
Virtual base class for "archives": classes abstracting I/O streams.
void WriteAs(const TYPE_FROM_ACTUAL &value)
#define ASSERT_(f)
Defines an assertion mechanism.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
T wrapToPi(T a)
Modifies the given angle to translate it into the ]-pi,pi] range.
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
This base provides a set of functions for maths stuff.
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,...
CMatrixFixedNumeric< double, 3, 1 > CMatrixDouble31
This namespace contains representation of robot actions and observations.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
A namespace of pseudo-random numbers generators of diferent distributions.
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
T square(const T x)
Inline function for the square of a number.
double RAD2DEG(const double x)
Radians to degrees.
double DEG2RAD(const double x)
Degrees to radians.
unsigned __int32 uint32_t
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
float additional_std_XY
An additional noise added to the thrun model (std.
uint32_t nParticlesCount
The default number of particles to generate in a internal representation (anyway you can draw as many...
The parameter to be passed to "computeFromOdometry".
TDrawSampleMotionModel modelSelection
The model to be used.
struct mrpt::obs::CActionRobotMovement2D::TMotionModelOptions::TOptions_ThrunModel thrunModel
TMotionModelOptions()
Default values loader.
struct mrpt::obs::CActionRobotMovement2D::TMotionModelOptions::TOptions_GaussianModel gaussianModel