64 :
mean(init_Mean),
cov(init_Cov)
74 for (
size_t i = 0; i < 3; i++)
76 const size_t ii = (i == 2) ? 3 : i;
77 for (
size_t j = 0; j < 3; j++)
79 const size_t jj = (j == 2) ? 3 : j;
102 q.rpy(OUT[2], OUT[1], OUT[0]);
115 q.rpy(
y[5],
y[4],
y[3]);
154 for (
int i = 0; i < 4; i++)
x[i] = o.
mean.
quat()[i];
159 cout <<
"num:" << endl << H << endl << endl;
165 cout <<
"lin:" << endl << J * NJ << endl << endl;
178 dr_dq_sub.multiply(dr_dq_sub_aux, dnorm_dq);
188 o.
cov.extractMatrix(3, 3, cov_Q);
189 o.
cov.extractMatrix(0, 0, cov_T);
190 o.
cov.extractMatrix(0, 3, cov_TQ);
197 this->
cov.insertMatrix(0, 0, cov_T);
201 cov_TR.multiply_ABt(cov_TQ, dr_dq_sub);
202 this->
cov.insertMatrix(0, 3, cov_TR);
203 this->
cov.insertMatrixTranspose(3, 0, cov_TR);
207 dr_dq_sub.multiply_HCHt(cov_Q, cov_r);
208 this->
cov.insertMatrix(3, 3, cov_r);
216 static const bool elements_do_wrapPI[6] = {
217 false,
false,
false,
true,
true,
true};
219 static const double dummy = 0;
224 y_mean[0], y_mean[1], y_mean[2], y_mean[3], y_mean[4], y_mean[5]);
243 out <<
cov.get_unsafe(
r,
c);
291 if (
this == &o)
return;
306 cov.get_unsafe(0, 0) = C.get_unsafe(0, 0);
307 cov.get_unsafe(1, 1) = C.get_unsafe(1, 1);
308 cov.get_unsafe(3, 3) = C.get_unsafe(2, 2);
310 cov.get_unsafe(0, 1) =
cov.get_unsafe(1, 0) = C.get_unsafe(0, 1);
312 cov.get_unsafe(0, 3) =
cov.get_unsafe(3, 0) = C.get_unsafe(0, 2);
314 cov.get_unsafe(1, 3) =
cov.get_unsafe(3, 1) = C.get_unsafe(1, 2);
329 for (
unsigned int i = 0; i < 6; i++)
331 f,
"%e %e %e %e %e %e\n",
cov(i, 0),
cov(i, 1),
cov(i, 2),
341 const CPose3D& newReferenceBase)
356 df_du.multiply_HCHt(OLD_COV,
cov);
379 cov.saveToTextFile(
"__DEBUG_EXC_DUMP_drawSingleSample_COV.txt"););
386 size_t N, vector<CVectorDouble>& outSamples)
const 393 it != outSamples.end(); ++it)
395 (*it)[0] +=
mean.
x();
396 (*it)[1] +=
mean.
y();
397 (*it)[2] +=
mean.z();
463 out = p_zero - *
this;
481 df_dx.multiply_HCHt(OLD_COV,
cov);
597 for (
unsigned int i = 0; i <
size(
cov, 1) - 1; i++)
598 for (
unsigned int j = i + 1; j <
size(
cov, 1); j++)
599 cov.get_unsafe(i, j) =
cov.get_unsafe(j, i);
613 for (
int i = 0; i < 6; i++)
615 if (COV_.get_unsafe(i, i) == 0)
617 if (MU.get_unsafe(i, 0) != 0)
618 return std::numeric_limits<double>::infinity();
620 COV_.get_unsafe(i, i) = 1;
626 return std::sqrt(MU.multiply_HtCH_scalar(COV_.inv()));
636 out <<
"Mean: " <<
obj.mean <<
"\n";
637 out <<
"Covariance:\n" <<
obj.cov <<
"\n";
647 out_cov.setSize(3, 3);
649 for (
int i = 0; i < 3; i++)
651 int a = i == 2 ? 3 : i;
652 for (
int j = i; j < 3; j++)
654 int b = j == 2 ? 3 : j;
655 double f =
cov.get_unsafe(
a,
b);
656 out_cov.set_unsafe(i, j, f);
657 out_cov.set_unsafe(j, i, f);
A namespace of pseudo-random numbers genrators of diferent distributions.
void rpy_and_jacobian(T &roll, T &pitch, T &yaw, MATRIXLIKE *out_dr_dq=nullptr, bool resize_out_dr_dq_to3x4=true) const
Return the yaw, pitch & roll angles associated to quaternion, and (optionally) the 3x4 Jacobian of th...
mrpt::math::CQuaternionDouble & quat()
Read/Write access to the quaternion representing the 3D rotation.
double x() const
Common members of all points & poses classes.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
CPose3D mean
The mean value.
#define MRPT_END_WITH_CLEAN_UP(stuff)
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
void copyFrom(const CPose3DPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
double mahalanobisDistanceTo(const CPose3DPDFGaussian &theOther)
Computes the Mahalanobis distance between the centers of two Gaussians.
int void fclose(FILE *f)
An OS-independent version of fclose.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
CPose3DQuat mean
The mean value.
static void jacobiansPoseComposition(const CPose3D &x, const CPose3D &u, mrpt::math::CMatrixDouble66 &df_dx, mrpt::math::CMatrixDouble66 &df_du)
This static method computes the pose composition Jacobians.
#define THROW_EXCEPTION(msg)
GLdouble GLdouble GLdouble GLdouble q
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
mrpt::math::CMatrixDouble77 cov
The 7x7 covariance matrix.
double pitch() const
Get the PITCH angle (in radians)
double yaw() const
Get the YAW angle (in radians)
void assureSymmetry()
Assures the symmetry of the covariance matrix (eventually certain operations in the math-coprocessor ...
GLsizei GLsizei GLuint * obj
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix.
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...
Declares a class that represents a Probability Density function (PDF) of a 3D pose using a quaternion...
void jacob_numeric_estimate(const VECTORLIKE &x, std::function< void(const VECTORLIKE &x, const USERPARAM &y, VECTORLIKE3 &out)> functor, const VECTORLIKE2 &increments, const USERPARAM &userParam, MATRIXLIKE &out_Jacobian)
Numerical estimation of the Jacobian of a user-supplied function - this template redirects to mrpt::m...
virtual const mrpt::utils::TRuntimeClassId * GetRuntimeClass() const override
Returns information about the class of an object in runtime.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
#define CLASS_ID(T)
Access to runtime class ID for a defined class name.
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
void USE_SUT_QUAT2EULER_CONVERSION(bool value)
If set to true (false), a Scaled Unscented Transform is used instead of a linear approximation with J...
void saveToTextFile(const std::string &file) const override
Save the PDF to a text file, containing the 3D pose in the first line, then the covariance matrix in ...
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
void composeFrom(const CPose3D &A, const CPose3D &B)
Makes "this = A (+) B"; this method is slightly more efficient than "this= A + B;" since it avoids th...
double evaluatePDF(const CPose3D &x) const
Evaluates the PDF at a given point.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
void drawGaussianMultivariateMany(VECTOR_OF_VECTORS &ret, size_t desiredSamples, const COVMATRIX &cov, const typename VECTOR_OF_VECTORS::value_type *mean=nullptr)
Generate a given number of multidimensional random samples according to a given covariance matrix...
void inverse(CPose3DPDF &o) const override
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
void operator+=(const CPose3D &Ap)
Makes: thisPDF = thisPDF + Ap, where "+" is pose composition (both the mean, and the covariance matri...
CPose3DPDFGaussian()
Default constructor.
void drawManySamples(size_t N, std::vector< mrpt::math::CVectorDouble > &outSamples) const override
Draws a number of samples from the distribution, and saves as a list of 1x6 vectors, where each row contains a (x,y,phi) datum.
GLsizei const GLchar ** string
T wrapToPi(T a)
Modifies the given angle to translate it into the ]-pi,pi] range.
void bayesianFusion(const CPose3DPDF &p1, const CPose3DPDF &p2) override
Bayesian fusion of two points gauss.
Declares a class that represents a probability density function (pdf) of a 2D pose (x...
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
double roll() const
Get the ROLL angle (in radians)
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
mrpt::math::CMatrixDouble66 cov
The 6x6 covariance matrix.
double evaluateNormalizedPDF(const CPose3D &x) const
Evaluates the ratio PDF(x) / PDF(MEAN), that is, the normalized PDF in the range [0,1].
void getCovSubmatrix2D(mrpt::math::CMatrixDouble &out_cov) const
Returns a 3x3 matrix with submatrix of the covariance for the variables (x,y,yaw) only...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLdouble GLdouble GLdouble r
void normalizationJacobian(MATRIXLIKE &J) const
Calculate the 4x4 Jacobian of the normalization operation of this quaternion.
bool operator==(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
void aux_posequat2poseypr(const CArrayDouble< 7 > &x, const double &dummy, CArrayDouble< 6 > &y)
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void setFromValues(const double x0, const double y0, const double z0, const double yaw=0, const double pitch=0, const double roll=0)
Set the pose from a 3D position (meters) and yaw/pitch/roll angles (radians) - This method recomputes...
A partial specialization of CArrayNumeric for double numbers.
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
void operator-=(const CPose3DPDFGaussian &Ap)
Makes: thisPDF = thisPDF - Ap, where "-" is pose inverse composition (both the mean, and the covariance matrix are updated).
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
virtual void getCovarianceAndMean(mrpt::math::CMatrixFixedNumeric< double, STATE_LEN, STATE_LEN > &cov, TDATA &mean_point) const =0
Returns an estimate of the pose covariance matrix (STATE_LENxSTATE_LEN cov matrix) and the mean...
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...
GLsizei const GLfloat * value
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
void drawGaussianMultivariate(std::vector< T > &out_result, const mrpt::math::CMatrixTemplateNumeric< T > &cov, const std::vector< T > *mean=nullptr)
Generate multidimensional random samples according to a given covariance matrix.
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
std::string asString() const
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
GLubyte GLubyte GLubyte a
void drawSingleSample(CPose3D &outPart) const override
Draws a single sample from the distribution.
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually)...
CMatrixFixedNumeric< double, 6, 6 > CMatrixDouble66
bool USE_SUT_QUAT2EULER_CONVERSION_value
EIGEN_STRONG_INLINE double mean() const
Computes the mean of the entire matrix.
CMatrixFixedNumeric< double, 6, 1 > CMatrixDouble61
std::ostream & operator<<(std::ostream &o, const CPoint< DERIVEDCLASS > &p)
Dumps a point as a string [x,y] or [x,y,z].