23 #include <Eigen/Dense>    35 uint8_t 
CBeacon::serializeGetVersion()
 const { 
return 0; }
    39     uint32_t j = m_typePDF;
    40     out << i << j << m_locationMC << m_locationGauss << m_locationSOG;
    50             in >> i >> j >> m_locationMC >> m_locationGauss >> m_locationSOG;
    52             m_typePDF = 
static_cast<TTypePDF>(j);
    69             m_locationMC.getMean(p);
    72             m_locationGauss.getMean(p);
    75             m_locationSOG.getMean(p);
    89             return m_locationMC.getCovarianceAndMean();
    91             return m_locationGauss.getCovarianceAndMean();
    93             return m_locationSOG.getCovarianceAndMean();
   105     const double minMahalanobisDistToDrop)
   111             m_locationMC.bayesianFusion(p1, p2, minMahalanobisDistToDrop);
   114             m_locationGauss.bayesianFusion(p1, p2, minMahalanobisDistToDrop);
   117             m_locationSOG.bayesianFusion(p1, p2, minMahalanobisDistToDrop);
   134             m_locationMC.drawSingleSample(outSample);
   137             m_locationGauss.drawSingleSample(outSample);
   140             m_locationSOG.drawSingleSample(outSample);
   157             m_locationMC.copyFrom(o);
   160             m_locationGauss.copyFrom(o);
   163             m_locationSOG.copyFrom(o);
   180             return m_locationMC.saveToTextFile(file);
   183             return m_locationGauss.saveToTextFile(file);
   186             return m_locationSOG.saveToTextFile(file);
   203             m_locationMC.changeCoordinatesReference(newReferenceBase);
   206             m_locationGauss.changeCoordinatesReference(newReferenceBase);
   209             m_locationSOG.changeCoordinatesReference(newReferenceBase);
   229                 std::make_shared<opengl::CPointCloud>();
   230             obj->setColor(1, 0, 0);
   232             obj->setPointSize(2.5);
   234             const size_t N = m_locationMC.m_particles.size();
   237             for (
size_t i = 0; i < N; i++)
   239                     i, m_locationMC.m_particles[i].d->x,
   240                     m_locationMC.m_particles[i].d->y,
   241                     m_locationMC.m_particles[i].d->z);
   249                 std::make_shared<opengl::CEllipsoid3D>();
   251             obj->setPose(m_locationGauss.mean);
   252             obj->setLineWidth(3);
   255             obj->setCovMatrix(C);
   257             obj->setQuantiles(3);
   258             obj->enableDrawSolid3D(
false);
   260             obj->setColor(1, 0, 0, 0.85f);
   266             m_locationSOG.getAs3DObject(outObj);
   274     obj2->setString(
format(
"#%d", static_cast<int>(m_ID)));
   277     this->getMean(meanP);
   278     obj2->setLocation(meanP.
x() + 0.10, meanP.
y() + 0.10, meanP.z());
   279     outObj->insert(obj2);
   301             size_t i, N = m_locationMC.m_particles.size();
   306             for (i = 0; i < N; i++)
   309                     auxStr, 
sizeof(auxStr), 
"%.3f%c",
   310                     m_locationMC.m_particles[i].d->x, (i == N - 1) ? 
' ' : 
',');
   311                 sx = sx + std::string(auxStr);
   313                     auxStr, 
sizeof(auxStr), 
"%.3f%c",
   314                     m_locationMC.m_particles[i].d->y, (i == N - 1) ? 
' ' : 
',');
   315                 sy = sy + std::string(auxStr);
   319             out_Str.emplace_back(sx);
   320             out_Str.emplace_back(sy);
   321             out_Str.emplace_back(
"plot(xs,ys,'k.','MarkerSize',4);");
   331                 auxStr, 
sizeof(auxStr), 
"m=[%.3f %.3f];",
   332                 m_locationGauss.mean.x(), m_locationGauss.mean.y());
   333             out_Str.emplace_back(auxStr);
   335                 auxStr, 
sizeof(auxStr), 
"C=[%e %e;%e %e];",
   336                 m_locationGauss.cov(0, 0), m_locationGauss.cov(0, 1),
   337                 m_locationGauss.cov(1, 0), m_locationGauss.cov(1, 1));
   338             out_Str.emplace_back(auxStr);
   340             out_Str.emplace_back(
   341                 "error_ellipse(C,m,'conf',0.997,'style','k');");
   346             for (
const auto& it : m_locationSOG)
   349                     auxStr, 
sizeof(auxStr), 
"m=[%.3f %.3f];", it.val.mean.x(),
   351                 out_Str.emplace_back(auxStr);
   353                     auxStr, 
sizeof(auxStr), 
"C=[%e %e;%e %e];",
   354                     it.val.cov(0, 0), it.val.cov(0, 1), it.val.cov(1, 0),
   356                 out_Str.emplace_back(auxStr);
   357                 out_Str.emplace_back(
   358                     "error_ellipse(C,m,'conf',0.997,'style','k');");
   371         auxStr, 
sizeof(auxStr), 
"text(%f,%f,'#%i');", meanP.
x(), meanP.
y(),
   372         static_cast<int>(m_ID));
   373     out_Str.emplace_back(auxStr);
   398     float maxDistanceFromCenter)
 const   402     std::unique_ptr<CPointPDFSOG> beaconPos;
   405     if (m_typePDF == pdfGauss)
   408         auto new_beaconPos = std::make_unique<CPointPDFSOG>(1);
   410         new_beaconPos->get(0).log_w = 0;
   411         new_beaconPos->get(0).val = m_locationGauss;
   412         beaconPos = std::move(new_beaconPos);
   413         beaconPosToUse = beaconPos.
get();
   418         beaconPosToUse = 
static_cast<const CPointPDFSOG*
>(&m_locationSOG);
   423     for (
const auto& beaconPo : *beaconPosToUse)
   427             beaconPo.val.mean.x() - sensorPntOnRobot.
x(),
   428             beaconPo.val.mean.y() - sensorPntOnRobot.
y(),
   429             beaconPo.val.mean.z() - sensorPntOnRobot.z());
   431         size_t startIdx = outPDF.
size();
   443             maxDistanceFromCenter  
   447         for (
size_t k = startIdx; k < outPDF.
size(); k++)
   448             outPDF.
get(k).
log_w = beaconPo.log_w;
   461     bool clearPreviousContentsOutPDF, 
const CPoint3D& centerPoint,
   462     float maxDistanceFromCenter)
   477     double el, th, A_ang;
   478     const float maxDistBetweenGaussians =
   482     size_t B = (size_t)(
M_2PIf * 
R / maxDistBetweenGaussians) + 1;
   485     B = max(B, (
size_t)30);
   497     S(1, 1) = S(2, 2) = 
square(
   506     if (clearPreviousContentsOutPDF)
   515         modeIdx = outPDF.
size();  
   521     for (idxEl = 0; idxEl <= (1 + B / 2); idxEl++)
   523         el = minEl + idxEl * A_ang;
   524         if (el > (maxEl + 0.5 * A_ang)) 
continue;
   528         if (fabs(cos(el)) < 1e-4)
   533         for (idxTh = 0; idxTh < nThSteps; idxTh++)
   538             dir.x((sensorPnt.
x() + 
R * cos(th) * cos(el)));
   539             dir.y((sensorPnt.
y() + 
R * sin(th) * cos(el)));
   540             dir.z((sensorPnt.z() + 
R * sin(el)));
   544             bool reallyCreateIt = 
true;
   545             if (maxDistanceFromCenter > 0)
   547                     dir.distanceTo(centerPoint) < maxDistanceFromCenter;
   566                 if (std::abs(minEl - maxEl) < 1e-6)
   570                     C33(0, 2) = C33(2, 0) = C33(1, 2) = C33(2, 1) = C33(2, 2) =
   575                 if (covarianceCompositionToAdd)
   576                     outPDF.
get(modeIdx).
val.
cov += *covarianceCompositionToAdd;
 std::tuple< cov_mat_t, type_value > getCovarianceAndMean() const override
Returns an estimate of the pose covariance matrix (STATE_LENxSTATE_LEN cov matrix) and the mean...
 
static void generateRingSOG(float sensedRange, mrpt::poses::CPointPDFSOG &outPDF, const CBeaconMap *myBeaconMap, const mrpt::poses::CPoint3D &sensorPnt, const mrpt::math::CMatrixDouble33 *covarianceCompositionToAdd=nullptr, bool clearPreviousContentsOutPDF=true, const mrpt::poses::CPoint3D ¢erPoint=mrpt::poses::CPoint3D(0, 0, 0), float maxDistanceFromCenter=0)
This static method returns a SOG with ring-shape (or as a 3D sphere) that can be used to initialize a...
 
#define THROW_EXCEPTION(msg)
 
std::string std::string format(std::string_view fmt, ARGS &&... args)
 
void copyFrom(const mrpt::poses::CPointPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
 
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive. 
 
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files. 
 
void getAsMatlabDrawCommands(std::vector< std::string > &out_Str) const
Gets a set of MATLAB commands which draw the current state of the beacon: 
 
CPoint3D mean
The mean value. 
 
void resize(const size_t N)
Resize the number of SOG modes. 
 
void changeCoordinatesReference(const mrpt::poses::CPose3D &newReferenceBase) override
this = p (+) this. 
 
Declares a class that represents a Probability Density function (PDF) of a 3D point ...
 
The struct for each mode: 
 
void clear()
Clear all the gaussian modes. 
 
This file implements miscelaneous matrix and matrix/vector operations, and internal functions in mrpt...
 
double maxElevation_deg
Minimum and maximum elevation angles (in degrees) for inserting new beacons at the first observation:...
 
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations. 
 
#define ASSERT_(f)
Defines an assertion mechanism. 
 
This base provides a set of functions for maths stuff. 
 
void push_back(const TGaussianMode &m)
Inserts a copy of the given mode into the SOG. 
 
constexpr double DEG2RAD(const double x)
Degrees to radians. 
 
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix. 
 
float SOG_maxDistBetweenGaussians
A parameter for initializing 2D/3D SOGs. 
 
This namespace contains representation of robot actions and observations. 
 
A class for storing a map of 3D probabilistic beacons, using a Montecarlo, Gaussian, or Sum of Gaussians (SOG) representation (for range-only SLAM). 
 
float SOG_separationConstant
Constant used to compute the std. 
 
const TGaussianMode & get(size_t i) const
Access to individual beacons. 
 
double x() const
Common members of all points & poses classes. 
 
A class used to store a 3D point. 
 
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
 
return_t square(const num_t x)
Inline function for the square of a number. 
 
bool saveToTextFile(const std::string &file) const override
Save PDF's particles to a text file. 
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
Virtual base class for "archives": classes abstracting I/O streams. 
 
void bayesianFusion(const CPointPDF &p1, const CPointPDF &p2, const double minMahalanobisDistToDrop=0) override
Bayesian fusion of two point distributions (product of two distributions->new distribution), then save the result in this object (WARNING: See implementing classes to see classes that can and cannot be mixtured!) 
 
A class used to store a 3D pose (a 3D translation + a rotation in 3D). 
 
mrpt::vision::TStereoCalibResults out
 
OPENGL_SETOFOBJECTSPTR getAs3DObject() const
Returns a 3D representation of this PDF. 
 
double rangeStd
The standard deviation used for Beacon ranges likelihood (default=0.08m). 
 
size_t size() const
Return the number of Gaussian modes. 
 
CMatrixDouble33 generateAxisBaseFromDirection(double dx, double dy, double dz)
Computes an axis base (a set of three 3D normal vectors) with the given vector being the first of the...
 
mrpt::maps::CBeaconMap::TLikelihoodOptions likelihoodOptions
 
double log_w
The log-weight. 
 
void drawSingleSample(mrpt::poses::CPoint3D &outSample) const override
Draw a sample from the pdf. 
 
mrpt::maps::CBeaconMap::TInsertionOptions insertionOptions
 
Declares a class that represents a Probability Distribution function (PDF) of a 3D point (x...
 
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive. 
 
void generateObservationModelDistribution(float sensedRange, mrpt::poses::CPointPDFSOG &outPDF, const CBeaconMap *myBeaconMap, const mrpt::poses::CPoint3D &sensorPntOnRobot, const mrpt::poses::CPoint3D ¢erPoint=mrpt::poses::CPoint3D(0, 0, 0), float maxDistanceFromCenter=0) const
Compute the observation model p(z_t|x_t) for a given observation (range value), and return it as an a...
 
The class for storing individual "beacon landmarks" under a variety of 3D position PDF distributions...
 
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
 
void getMean(mrpt::poses::CPoint3D &mean_point) const override
 
CMatrixDynamic< double > CMatrixDouble
Declares a matrix of double numbers (non serializable). 
 
void multiply_HCHt(const MAT_H &H, const MAT_C &C, MAT_R &R, bool accumResultInOutput=false)
R = H * C * H^t.