68 out << i << j << m_locationMC << m_locationGauss << m_locationSOG;
84 in >> i >> j >> m_locationMC >> m_locationGauss >> m_locationSOG;
86 m_typePDF =
static_cast<TTypePDF>(j);
103 case pdfMonteCarlo: m_locationMC.getMean(
p);
break;
104 case pdfGauss: m_locationGauss.getMean(
p);
break;
105 case pdfSOG: m_locationSOG.getMean(
p);
break;
119 case pdfMonteCarlo: m_locationMC.getCovarianceAndMean(COV,
p);
break;
120 case pdfGauss: m_locationGauss.getCovarianceAndMean(COV,
p);
break;
121 case pdfSOG: m_locationSOG.getCovarianceAndMean(COV,
p);
break;
135 case pdfMonteCarlo: m_locationMC.bayesianFusion(p1,p2,minMahalanobisDistToDrop);
break;
136 case pdfGauss: m_locationGauss.bayesianFusion(p1,p2,minMahalanobisDistToDrop);
break;
137 case pdfSOG: m_locationSOG.bayesianFusion(p1,p2,minMahalanobisDistToDrop);
break;
152 case pdfMonteCarlo: m_locationMC.drawSingleSample(outSample);
break;
153 case pdfGauss: m_locationGauss.drawSingleSample(outSample);
break;
154 case pdfSOG: m_locationSOG.drawSingleSample(outSample);
break;
169 case pdfMonteCarlo: m_locationMC.copyFrom(o);
break;
170 case pdfGauss: m_locationGauss.copyFrom(o);
break;
171 case pdfSOG: m_locationSOG.copyFrom(o);
break;
185 case pdfMonteCarlo: m_locationMC.saveToTextFile(file);
break;
186 case pdfGauss: m_locationGauss.saveToTextFile(file);
break;
187 case pdfSOG: m_locationSOG.saveToTextFile(file);
break;
201 case pdfMonteCarlo: m_locationMC.changeCoordinatesReference(newReferenceBase);
break;
202 case pdfGauss: m_locationGauss.changeCoordinatesReference(newReferenceBase);
break;
203 case pdfSOG: m_locationSOG.changeCoordinatesReference(newReferenceBase);
break;
221 obj->setColor(1,0,0);
223 obj->setPointSize(2.5);
225 const size_t N = m_locationMC.m_particles.size();
228 for (
size_t i=0;i<N;i++)
230 m_locationMC.m_particles[i].d->x,
231 m_locationMC.m_particles[i].d->y,
232 m_locationMC.m_particles[i].d->z );
234 outObj->insert(
obj );
241 obj->setPose(m_locationGauss.mean);
242 obj->setLineWidth(3);
245 if (C(2,2)==0) C.setSize(2,2);
246 obj->setCovMatrix(C);
248 obj->setQuantiles(3);
249 obj->enableDrawSolid3D(
false);
251 obj->setColor(1,0,0, 0.85);
252 outObj->insert(
obj );
257 m_locationSOG.getAs3DObject( outObj );
264 obj2->setString(
format(
"#%d",static_cast<int>(m_ID)) );
267 this->getMean(meanP);
268 obj2->setLocation( meanP.
x()+0.10, meanP.
y()+0.10, meanP.z() );
269 outObj->insert( obj2 );
292 size_t i,N = m_locationMC.m_particles.size();
299 os::sprintf(auxStr,
sizeof(auxStr),
"%.3f%c",m_locationMC.m_particles[i].d->x, (i==N-1) ?
' ':
',' );
301 os::sprintf(auxStr,
sizeof(auxStr),
"%.3f%c",m_locationMC.m_particles[i].d->y, (i==N-1) ?
' ':
',' );
317 os::sprintf(auxStr,
sizeof(auxStr),
"m=[%.3f %.3f];",m_locationGauss.mean.x(),m_locationGauss.mean.y());
319 os::sprintf(auxStr,
sizeof(auxStr),
"C=[%e %e;%e %e];",
320 m_locationGauss.cov(0,0),m_locationGauss.cov(0,1),
321 m_locationGauss.cov(1,0),m_locationGauss.cov(1,1) );
324 out_Str.
add(
std::string(
"error_ellipse(C,m,'conf',0.997,'style','k');"));
331 os::sprintf(auxStr,
sizeof(auxStr),
"m=[%.3f %.3f];",(it)->
val.mean.x(),(it)->
val.mean.y());
333 os::sprintf(auxStr,
sizeof(auxStr),
"C=[%e %e;%e %e];",
334 (it)->
val.cov(0,0),(it)->
val.cov(0,1),
335 (it)->
val.cov(1,0),(it)->
val.cov(1,1) );
337 out_Str.
add(
std::string(
"error_ellipse(C,m,'conf',0.997,'style','k');"));
348 os::sprintf(auxStr,
sizeof(auxStr),
"text(%f,%f,'#%i');",meanP.
x(),meanP.
y(),
static_cast<int>(m_ID) );
367 const float &sensedRange,
372 const float &maxDistanceFromCenter)
const 379 if ( m_typePDF==pdfGauss )
385 new_beaconPos->
get(0).
val = m_locationGauss;
386 beaconPos = new_beaconPos;
391 beaconPos =
static_cast<const CPointPDFSOG*
> (&m_locationSOG );
400 (it)->
val.mean.x() - sensorPntOnRobot.
x(),
401 (it)->
val.mean.y() - sensorPntOnRobot.
y(),
402 (it)->
val.mean.z() - sensorPntOnRobot.z() ) ;
404 size_t startIdx = outPDF.
size();
414 maxDistanceFromCenter
418 for (
size_t k=startIdx;k<outPDF.
size();k++)
422 if ( m_typePDF==pdfGauss )
438 bool clearPreviousContentsOutPDF,
440 const float &maxDistanceFromCenter
456 size_t B = (size_t)(
M_2PIf *
R / maxDistBetweenGaussians ) + 1;
459 B = max(B, (
size_t)30);
477 if (clearPreviousContentsOutPDF)
486 modeIdx = outPDF.
size();
492 for (idxEl=0;idxEl<=(1+B/2);idxEl++)
494 el = minEl + idxEl*A_ang;
495 if (el>(maxEl+0.5*A_ang))
continue;
499 if (fabs(cos(el))<1e-4)
504 for (idxTh=0;idxTh<nThSteps;idxTh++)
509 dir.
x( (sensorPnt.
x() +
R*cos(th)*cos(el)) );
510 dir.
y( (sensorPnt.
y() +
R*sin(th)*cos(el)) );
511 dir.z( (sensorPnt.z() +
R*sin(el)) );
514 bool reallyCreateIt =
true;
515 if (maxDistanceFromCenter>0)
516 reallyCreateIt = dir.
distanceTo( centerPoint ) < maxDistanceFromCenter;
527 dir = dir - sensorPnt;
537 C33.get_unsafe(0,2)=C33.get_unsafe(2,0)=
538 C33.get_unsafe(1,2)=C33.get_unsafe(2,1)=
539 C33.get_unsafe(2,2)=0;
543 if (covarianceCompositionToAdd)
544 outPDF.
get(modeIdx).
val.
cov += *covarianceCompositionToAdd;
double x() const
Common members of all points & poses classes.
static CEllipsoidPtr Create()
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
double distanceTo(const CPoseOrPoint< OTHERCLASS > &b) const
Returns the Euclidean distance to another pose/point:
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
The virtual base class which provides a unified interface for all persistent objects in MRPT...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
CPoint3D mean
The mean value.
void resize(const size_t N)
Resize the number of SOG modes.
void getMean(mrpt::poses::CPoint3D &mean_point) const MRPT_OVERRIDE
Returns an estimate of the point, (the mean, or mathematical expectation of the PDF).
Declares a class that represents a Probability Density function (PDF) of a 3D point ...
#define THROW_EXCEPTION(msg)
The struct for each mode:
void clear()
Clear all the gaussian modes.
GLsizei GLsizei GLuint * obj
T square(const T x)
Inline function for the square of a number.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
A class for storing a list of text lines.
This base provides a set of functions for maths stuff.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
static void generateRingSOG(const float &sensedRange, mrpt::poses::CPointPDFSOG &outPDF, const CBeaconMap *myBeaconMap, const mrpt::poses::CPoint3D &sensorPnt, const mrpt::math::CMatrixDouble33 *covarianceCompositionToAdd=NULL, bool clearPreviousContentsOutPDF=true, const mrpt::poses::CPoint3D ¢erPoint=mrpt::poses::CPoint3D(0, 0, 0), const float &maxDistanceFromCenter=0)
This static method returns a SOG with ring-shape (or as a 3D sphere) that can be used to initialize a...
void push_back(const TGaussianMode &m)
Inserts a copy of the given mode into the SOG.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix.
CMatrixTemplateNumeric< double > CMatrixDouble
Declares a matrix of double numbers (non serializable).
float SOG_maxDistBetweenGaussians
A parameter for initializing 2D/3D SOGs.
std::deque< TGaussianMode >::const_iterator const_iterator
void getAsMatlabDrawCommands(utils::CStringList &out_Str) const
Gets a set of MATLAB commands which draw the current state of the beacon:
float rangeStd
The standard deviation used for Beacon ranges likelihood (default=0.08m).
void clear()
Clear the whole list.
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).
void drawSingleSample(mrpt::poses::CPoint3D &outSample) const MRPT_OVERRIDE
Draw a sample from the pdf.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
float SOG_separationConstant
Constant used to compute the std.
CMatrixFixedNumeric< double, 3, 3 > CMatrixDouble33
const TGaussianMode & get(size_t i) const
Access to individual beacons.
float maxElevation_deg
Minimum and maximum elevation angles (in degrees) for inserting new beacons at the first observation:...
GLsizei const GLchar ** string
A class used to store a 3D point.
Classes for 2D/3D geometry representation, both of single values and probability density 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...
#define INVALID_BEACON_ID
Used for CObservationBeaconRange, CBeacon, etc.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
CMatrixTemplateNumeric< T > generateAxisBaseFromDirection(T dx, T dy, T dz)
Computes an axis base (a set of three 3D normal vectors) with the given vector being the first of the...
void changeCoordinatesReference(const mrpt::poses::CPose3D &newReferenceBase) MRPT_OVERRIDE
this = p (+) this.
void saveToTextFile(const std::string &file) const MRPT_OVERRIDE
Save PDF's particles to a text file.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
OPENGL_SETOFOBJECTSPTR getAs3DObject() const
Returns a 3D representation of this PDF.
size_t size() const
Return the number of Gaussian modes.
mrpt::maps::CBeaconMap::TLikelihoodOptions likelihoodOptions
int BASE_IMPEXP sprintf(char *buf, size_t bufSize, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
double log_w
The log-weight.
static CPointCloudPtr Create()
mrpt::maps::CBeaconMap::TInsertionOptions insertionOptions
unsigned __int32 uint32_t
Declares a class that represents a Probability Distribution function (PDF) of a 3D point (x...
void bayesianFusion(const CPointPDF &p1, const CPointPDF &p2, const double &minMahalanobisDistToDrop=0) MRPT_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!)
The class for storing individual "beacon landmarks" under a variety of 3D position PDF distributions...
void generateObservationModelDistribution(const 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), const 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...
void copyFrom(const mrpt::poses::CPointPDF &o) MRPT_OVERRIDE
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
void add(const std::string &str)
Appends a new string at the end of the string list.
virtual ~CBeacon()
Virtual destructor.
void getCovarianceAndMean(mrpt::math::CMatrixDouble33 &cov, mrpt::poses::CPoint3D &mean_point) const MRPT_OVERRIDE
Returns an estimate of the point covariance matrix (3x3 cov matrix) and the mean, both at once...