67 for (
size_t i=0;i<3;i++)
69 const size_t ii= (i==2) ? 3 : i;
70 for (
size_t j=0;j<3;j++)
72 const size_t jj= (j==2) ? 3 : j;
96 q.rpy(OUT[2],OUT[1],OUT[0]);
103 y[0]=
x[0];
y[1]=
x[1];
y[2]=
x[2];
106 q.rpy(
y[5],
y[4],
y[3]);
145 for (
int i=0;i<4;i++)
x[i] = o.
mean.
quat()[i];
149 cout <<
"num:" <<endl <<H << endl << endl;
155 cout <<
"lin:" <<endl<< J*NJ << endl << endl;
168 dr_dq_sub.multiply(dr_dq_sub_aux,dnorm_dq);
177 o.
cov.extractMatrix(3,3,cov_Q);
178 o.
cov.extractMatrix(0,0,cov_T);
179 o.
cov.extractMatrix(0,3,cov_TQ);
186 this->
cov.insertMatrix(0,0,cov_T);
190 cov_TR.multiply_ABt(cov_TQ,dr_dq_sub);
191 this->
cov.insertMatrix (0,3,cov_TR);
192 this->
cov.insertMatrixTranspose(3,0,cov_TR);
196 dr_dq_sub.multiply_HCHt(cov_Q,cov_r);
197 this->
cov.insertMatrix(3,3,cov_r);
205 static const bool elements_do_wrapPI[6] = {
false,
false,
false,
true,
true,
true};
207 static const double dummy=0;
216 this->
mean.
setFromValues(y_mean[0],y_mean[1],y_mean[2],y_mean[3],y_mean[4],y_mean[5]);
232 out <<
cov.get_unsafe(
r,
r);
235 out <<
cov.get_unsafe(
r,
c);
283 if (
this == &o)
return;
298 cov.get_unsafe(0,0)= C.get_unsafe(0,0);
299 cov.get_unsafe(1,1)= C.get_unsafe(1,1);
300 cov.get_unsafe(3,3)= C.get_unsafe(2,2);
303 cov.get_unsafe(1,0)= C.get_unsafe(0,1);
306 cov.get_unsafe(3,0)= C.get_unsafe(0,2);
309 cov.get_unsafe(3,1)= C.get_unsafe(1,2);
323 for (
unsigned int i=0;i<6;i++)
324 os::fprintf(f,
"%e %e %e %e %e %e\n",
cov(i,0),
cov(i,1),
cov(i,2),
cov(i,3),
cov(i,4),
cov(i,5));
348 df_du.multiply_HCHt( OLD_COV,
cov );
375 cov.saveToTextFile(
"__DEBUG_EXC_DUMP_drawSingleSample_COV.txt"); \
384 vector<CVectorDouble> &outSamples )
const 392 (*it)[0] +=
mean.
x();
393 (*it)[1] +=
mean.
y();
394 (*it)[2] +=
mean.z();
459 out = p_zero - *
this;
479 df_dx.multiply_HCHt( OLD_COV,
cov );
594 for (
unsigned int i=0;i<
size(
cov,1)-1;i++)
595 for (
unsigned int j=i+1;j<
size(
cov,1);j++)
596 cov.get_unsafe(i,j) =
cov.get_unsafe(j,i);
609 for (
int i=0;i<6;i++)
611 if (COV_.get_unsafe(i,i)==0)
613 if (MU.get_unsafe(i,0)!=0)
614 return std::numeric_limits<double>::infinity();
615 else COV_.get_unsafe(i,i) = 1;
619 return std::sqrt( MU.multiply_HtCH_scalar(COV_.inv()) );
631 out <<
"Mean: " <<
obj.mean <<
"\n";
632 out <<
"Covariance:\n" <<
obj.cov <<
"\n";
642 out_cov.setSize(3,3);
644 for (
int i=0;i<3;i++)
647 for (
int j=i;j<3;j++)
650 double f =
cov.get_unsafe(
a,
b);
651 out_cov.set_unsafe(i,j, f);
652 out_cov.set_unsafe(j,i, f);
A namespace of pseudo-random numbers genrators of diferent distributions.
mrpt::math::CQuaternionDouble & quat()
Read/Write access to the quaternion representing the 3D rotation.
double x() const
Common members of all points & poses classes.
FILE BASE_IMPEXP * fopen(const char *fileName, const char *mode) MRPT_NO_THROWS
An OS-independent version of fopen.
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) MRPT_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 BASE_IMPEXP void BASE_IMPEXP 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.
void drawManySamples(size_t N, std::vector< mrpt::math::CVectorDouble > &outSamples) const MRPT_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.
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
BASE_IMPEXP CRandomGenerator randomGenerator
A static instance of a CRandomGenerator class, for use in single-thread applications.
void bayesianFusion(const CPose3DPDF &p1, const CPose3DPDF &p2) MRPT_OVERRIDE
Bayesian fusion of two points gauss.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
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)
int BASE_IMPEXP fprintf(FILE *fil, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(2
An OS-independent version of fprintf.
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 drawGaussianMultivariateMany(VECTOR_OF_VECTORS &ret, size_t desiredSamples, const COVMATRIX &cov, const typename VECTOR_OF_VECTORS::value_type *mean=NULL)
Generate a given number of multidimensional random samples according to a given covariance matrix...
Declares a class that represents a Probability Density function (PDF) of a 3D pose using a quaternion...
BASE_IMPEXP bool USE_SUT_QUAT2EULER_CONVERSION
If set to true (false), a Scaled Unscented Transform is used instead of a linear approximation with J...
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.
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
#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...
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...
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 changeCoordinatesReference(const CPose3D &newReferenceBase) MRPT_OVERRIDE
this = p (+) this.
void operator+=(const CPose3D &Ap)
Makes: thisPDF = thisPDF + Ap, where "+" is pose composition (both the mean, and the covariance matri...
CPose3DPDFGaussian()
Default constructor.
GLsizei const GLchar ** string
T wrapToPi(T a)
Modifies the given angle to translate it into the ]-pi,pi] range.
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)
mrpt::math::CMatrixDouble66 cov
The 6x6 covariance matrix.
#define CLASS_ID(class_name)
Access to runtime class ID for a defined class name.
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).
void jacob_numeric_estimate(const VECTORLIKE &x, void(*functor)(const VECTORLIKE &x, const USERPARAM &y, VECTORLIKE3 &out), 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 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...
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
void drawSingleSample(CPose3D &outPart) const MRPT_OVERRIDE
Draws a single sample from the distribution.
void drawGaussianMultivariate(std::vector< T > &out_result, const mrpt::math::CMatrixTemplateNumeric< T > &cov, const std::vector< T > *mean=NULL)
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 ...
void rpy_and_jacobian(T &roll, T &pitch, T &yaw, MATRIXLIKE *out_dr_dq=NULL, bool resize_out_dr_dq_to3x4=true) const
Return the yaw, pitch & roll angles associated to quaternion, and (optionally) the 3x4 Jacobian of th...
std::string asString() const
CMatrixFixedNumeric< double, 6, 6 > CMatrixDouble66
GLubyte GLubyte GLubyte a
void inverse(CPose3DPDF &o) const MRPT_OVERRIDE
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually)...
CMatrixFixedNumeric< double, 6, 1 > CMatrixDouble61
EIGEN_STRONG_INLINE double mean() const
Computes the mean of the entire matrix.
void saveToTextFile(const std::string &file) const MRPT_OVERRIDE
Save the PDF to a text file, containing the 3D pose in the first line, then the covariance matrix in ...
std::ostream & operator<<(std::ostream &o, const CPoint< DERIVEDCLASS > &p)
Dumps a point as a string [x,y] or [x,y,z].
virtual const mrpt::utils::TRuntimeClassId * GetRuntimeClass() const
Returns information about the class of an object in runtime.