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);
#define CLASS_ID(class_name)
Access to runtime class ID for a defined class name.
void aux_posequat2poseypr(const CArrayDouble< 7 > &x, const double &dummy, CArrayDouble< 6 > &y)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
A partial specialization of CArrayNumeric for double numbers.
A numeric matrix of compile-time fixed size.
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...
void normalizationJacobian(MATRIXLIKE &J) const
Calculate the 4x4 Jacobian of the normalization operation of this quaternion.
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
double pitch() const
Get the PITCH angle (in radians)
double roll() const
Get the ROLL angle (in radians)
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...
double yaw() const
Get the YAW angle (in radians)
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...
Declares a class that represents a Probability Density function (PDF) of a 3D pose .
double mahalanobisDistanceTo(const CPose3DPDFGaussian &theOther)
Computes the Mahalanobis distance between the centers of two Gaussians.
void drawSingleSample(CPose3D &outPart) const MRPT_OVERRIDE
Draws a single sample from the distribution.
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 inverse(CPose3DPDF &o) const MRPT_OVERRIDE
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
void operator-=(const CPose3DPDFGaussian &Ap)
Makes: thisPDF = thisPDF - Ap, where "-" is pose inverse composition (both the mean,...
CPose3DPDFGaussian()
Default constructor.
void getCovSubmatrix2D(mrpt::math::CMatrixDouble &out_cov) const
Returns a 3x3 matrix with submatrix of the covariance for the variables (x,y,yaw) only.
void changeCoordinatesReference(const CPose3D &newReferenceBase) MRPT_OVERRIDE
this = p (+) this.
double evaluateNormalizedPDF(const CPose3D &x) const
Evaluates the ratio PDF(x) / PDF(MEAN), that is, the normalized PDF in the range [0,...
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
double evaluatePDF(const CPose3D &x) const
Evaluates the PDF at a given point.
void bayesianFusion(const CPose3DPDF &p1, const CPose3DPDF &p2) MRPT_OVERRIDE
Bayesian fusion of two points gauss.
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 ...
void assureSymmetry()
Assures the symmetry of the covariance matrix (eventually certain operations in the math-coprocessor ...
std::string asString() const
CPose3D mean
The mean value.
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,...
void operator+=(const CPose3D &Ap)
Makes: thisPDF = thisPDF + Ap, where "+" is pose composition (both the mean, and the covariance matri...
void copyFrom(const CPose3DPDF &o) MRPT_OVERRIDE
Copy operator, translating if necesary (for example, between particles and gaussian representations)
mrpt::math::CMatrixDouble66 cov
The 6x6 covariance matrix.
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually).
virtual const mrpt::utils::TRuntimeClassId * GetRuntimeClass() const
Returns information about the class of an object in runtime.
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.
mrpt::math::CQuaternionDouble & quat()
Read/Write access to the quaternion representing the 3D rotation.
Declares a class that represents a Probability Density function (PDF) of a 3D pose using a quaternion...
mrpt::math::CMatrixDouble77 cov
The 7x7 covariance matrix.
CPose3DQuat mean
The mean value.
double x() const
Common members of all points & poses classes.
Declares a class that represents a Probability Density function (PDF) of a 2D pose .
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix.
Declares a class that represents a probability density function (pdf) of a 2D pose (x,...
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.
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.
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,...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
EIGEN_STRONG_INLINE double mean() const
Computes the mean of the entire matrix.
GLsizei GLsizei GLuint * obj
GLdouble GLdouble GLdouble r
GLubyte GLubyte GLubyte a
GLsizei const GLchar ** string
GLdouble GLdouble GLdouble GLdouble q
T wrapToPi(T a)
Modifies the given angle to translate it into the ]-pi,pi] range.
int BASE_IMPEXP fprintf(FILE *fil, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(2
An OS-independent version of fprintf.
FILE BASE_IMPEXP * fopen(const char *fileName, const char *mode) MRPT_NO_THROWS
An OS-independent version of fopen.
int BASE_IMPEXP void BASE_IMPEXP fclose(FILE *f)
An OS-independent version of fclose.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
#define MRPT_END_WITH_CLEAN_UP(stuff)
#define THROW_EXCEPTION(msg)
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
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...
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...
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, 6, 1 > CMatrixDouble61
CMatrixFixedNumeric< double, 6, 6 > CMatrixDouble66
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
std::ostream & operator<<(std::ostream &o, const CPoint< DERIVEDCLASS > &p)
Dumps a point as a string [x,y] or [x,y,z]
bool operator==(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
A namespace of pseudo-random numbers genrators of diferent distributions.
BASE_IMPEXP CRandomGenerator randomGenerator
A static instance of a CRandomGenerator class, for use in single-thread applications.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.