21 #include <Eigen/Dense> 39 :
mean(init_Mean),
cov(init_Cov)
99 if (
this == &o)
return;
113 if (!f)
return false;
129 const CPose3D& newReferenceBase)
149 const auto C1_inv = p1.
cov.
asEigen().inverse();
150 const auto C2_inv = p2.
cov.
asEigen().inverse();
152 const Eigen::Matrix2d L = C1_inv + C2_inv;
156 const Eigen::Vector2d x1{p1.
mean.
x(), p1.
mean.
y()};
157 const Eigen::Vector2d x2{p2.
mean.
x(), p2.
mean.
y()};
159 const Eigen::Vector2d
x =
cov.
asEigen() * (C1_inv * x1 + C2_inv * x2);
181 const auto C_inv = C.inverse();
183 const Eigen::Vector2d MU{
mean.
x() -
p.mean.x(),
mean.
y() -
p.mean.y()};
186 (1.0 / std::sqrt(C.determinant())) *
187 exp(-0.5 * MU.transpose() * C_inv * MU);
214 outSample.
x(
mean.
x() + vec[0]);
215 outSample.
y(
mean.
y() + vec[1]);
225 const double minMahalanobisDistToDrop)
246 const Eigen::Vector2d deltaX{other.
mean.
x() -
mean.
x(),
257 const double x,
const double y)
const 260 const Eigen::Vector2d deltaX{
x -
mean.
x(),
y -
mean.
y()};
263 return std::sqrt(deltaX.transpose() *
cov.
asEigen().inverse() * deltaX);
A namespace of pseudo-random numbers generators of diferent distributions.
double productIntegralNormalizedWith(const CPoint2DPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
CPoint2D mean
The mean value.
A compile-time fixed-size numeric matrix container.
double productIntegralWith(const CPoint2DPDFGaussian &p) const
Computes the "correspondence likelihood" of this PDF with another one: This is implemented as the int...
This class is a "CSerializable" wrapper for "CMatrixDynamic<double>".
#define THROW_EXCEPTION(msg)
A gaussian distribution for 2D points.
int void fclose(FILE *f)
An OS-independent version of fclose.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void copyFrom(const CPoint2DPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
bool saveToTextFile(const std::string &file) const override
Save PDF's particles to a text file, containing the 2D pose in the first line, then the covariance ma...
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
Virtual base class for "schematic archives" (JSON, XML,...)
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
T square(const T x)
Inline function for the square of a number.
#define ASSERT_(f)
Defines an assertion mechanism.
void drawSingleSample(CPoint2D &outSample) const override
Draw a sample from the pdf.
This base provides a set of functions for maths stuff.
#define CLASS_ID(T)
Access to runtime class ID for a defined class name.
CPoint2DPDFGaussian()
Default constructor.
void bayesianFusion(const CPoint2DPDFGaussian &p1, const CPoint2DPDFGaussian &p2)
Bayesian fusion of two points gauss.
virtual const mrpt::rtti::TRuntimeClassId * GetRuntimeClass() const override
Returns information about the class of an object in runtime.
Eigen::Matrix< dataType, 4, 4 > inverse(Eigen::Matrix< dataType, 4, 4 > &pose)
Declares a class that represents a Probability Distribution function (PDF) of a 2D point (x...
double x() const
Common members of all points & poses classes.
double mahalanobisDistanceToPoint(const double x, const double y) const
Returns the Mahalanobis distance from this PDF to some point.
CMatrixDouble cov(const MATRIX &v)
Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample...
GLsizei const GLchar ** string
A class used to store a 2D point.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
#define SCHEMA_DESERIALIZE_DATATYPE_VERSION()
For use inside serializeFrom(CSchemeArchiveBase) methods.
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
static constexpr size_t state_length
The length of the variable, for example, 3 for a 3D point, 6 for a 3D pose (x y z yaw pitch roll)...
Virtual base class for "archives": classes abstracting I/O streams.
void drawGaussianMultivariate(std::vector< T > &out_result, const MATRIX &cov, const std::vector< T > *mean=nullptr)
Generate multidimensional random samples according to a given covariance matrix.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
virtual std::tuple< cov_mat_t, type_value > getCovarianceAndMean() const =0
Returns an estimate of the pose covariance matrix (STATE_LENxSTATE_LEN cov matrix) and the mean...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
This file implements matrix/vector text and binary serialization.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
double mean(const CONTAINER &v)
Computes the mean value of a vector.
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object.
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
#define SCHEMA_SERIALIZE_DATATYPE_VERSION(ser_version)
For use inside all serializeTo(CSchemeArchiveBase) methods.
void getRotationMatrix(mrpt::math::CMatrixDouble33 &ROT) const
Get the 3x3 rotation matrix.
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
mrpt::math::CMatrixDouble22 cov
The 2x2 covariance matrix.
double mahalanobisDistanceTo(const CPoint2DPDFGaussian &other) const
Returns the Mahalanobis distance from this PDF to another PDF, that is, it's evaluation at (0...
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.