33 double xMin,
double xMax,
double yMin,
double yMax,
double resolutionXY,
34 double resolutionPhi,
double phiMin,
double phiMax)
36 xMin, xMax, yMin, yMax, resolutionXY, resolutionPhi, phiMin, phiMax)
38 uniformDistribution();
43 if (
this == &o)
return;
51 CPosePDFGrid::~CPosePDFGrid() {}
62 for (
size_t phiInd = 0; phiInd < m_sizePhi; phiInd++)
63 for (
size_t y = 0;
y < m_sizeY;
y++)
64 for (
size_t x = 0;
x < m_sizeX;
x++)
66 const double w = *getByIndex(
x,
y, phiInd);
68 CPose2D(idx2x(
x), idx2y(
y), idx2phi(phiInd)),
w);
80 CPose2D(0, 0, 0), m_sizePhi * m_sizeY * m_sizeX);
82 for (
size_t phiInd = 0; phiInd < m_sizePhi; phiInd++)
84 for (
size_t y = 0;
y < m_sizeY;
y++)
85 for (
size_t x = 0;
x < m_sizeX;
x++)
88 log(*getByIndex(
x,
y, phiInd));
90 CPose2D(idx2x(
x), idx2y(
y), idx2phi(phiInd));
106 out << m_xMin << m_xMax << m_yMin << m_yMax << m_phiMin << m_phiMax
107 << m_resolutionXY << m_resolutionPhi
108 <<
static_cast<int32_t>(m_sizeX) << static_cast<int32_t>(m_sizeY)
109 <<
static_cast<int32_t>(m_sizePhi) << static_cast<int32_t>(m_sizeXY)
110 <<
static_cast<int32_t>(m_idxLeftX)
111 << static_cast<int32_t>(m_idxLeftY)
112 <<
static_cast<int32_t>(m_idxLeftPhi);
129 in >> m_xMin >> m_xMax >> m_yMin >> m_yMax >> m_phiMin >>
130 m_phiMax >> m_resolutionXY >> m_resolutionPhi;
132 int32_t sizeX, sizeY, sizePhi, sizeXY, idxLeftX, idxLeftY,
135 in >> sizeX >> sizeY >> sizePhi >> sizeXY >> idxLeftX >> idxLeftY >>
142 m_idxLeftX = idxLeftX;
143 m_idxLeftY = idxLeftY;
144 m_idxLeftPhi = idxLeftPhi;
161 os::sprintf(dimsFile, 1000,
"%s_dims.txt", dataFile.c_str());
163 FILE* f_d =
os::fopen(dataFile.c_str(),
"wt");
175 f_s,
"%u %u %u %f %f %f %f %f %f\n", (
unsigned)m_sizeX,
176 (
unsigned)m_sizeY, (
unsigned)m_sizePhi, m_xMin, m_xMax, m_yMin, m_yMax,
180 for (
unsigned int phiInd = 0; phiInd < m_sizePhi; phiInd++)
182 for (
unsigned int y = 0;
y < m_sizeY;
y++)
184 for (
unsigned int x = 0;
x < m_sizeX;
x++)
198 void CPosePDFGrid::changeCoordinatesReference(
const CPose3D& newReferenceBase)
207 void CPosePDFGrid::bayesianFusion(
209 const double& minMahalanobisDistToDrop)
229 void CPosePDFGrid::drawSingleSample(
CPose2D& outPart)
const 238 void CPosePDFGrid::drawManySamples(
239 size_t N, std::vector<CVectorDouble>& outSamples)
const 271 void CPosePDFGrid::uniformDistribution()
273 double val = 1.0f / m_data.size();
Computes weighted and un-weighted averages of SE(2) poses.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
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.
#define THROW_EXCEPTION(msg)
void getCovarianceAndMean(mrpt::math::CMatrixDouble33 &cov, CPose2D &mean_point) const override
Returns an estimate of the pose covariance matrix (3x3 cov matrix) and the mean, both at once...
void saveToTextFile(const std::string &file, mrpt::math::TMatrixTextFileFormat fileFormat=mrpt::math::MATRIX_FORMAT_ENG, bool appendMRPTHeader=false, const std::string &userHeader=std::string()) const
Save matrix to a text file, compatible with MATLAB text format (see also the methods of matrix classe...
const Scalar * const_iterator
void append(const mrpt::poses::CPose2D &p)
Adds a new pose to the computation.
GLubyte GLubyte GLubyte GLubyte w
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
CParticleList m_particles
The array of particles.
This base provides a set of functions for maths stuff.
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Eigen::Matrix< dataType, 4, 4 > inverse(Eigen::Matrix< dataType, 4, 4 > &pose)
Declares a class that represents a Probability Density Function (PDF) over a 2D pose (x...
GLsizei const GLchar ** string
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...
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
void normalize(Scalar valMin, Scalar valMax)
Scales all elements such as the minimum & maximum values are shifted to the given values...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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).
void resetDeterministic(const CPose2D &location, size_t particlesCount=0)
Reset the PDF to a single point: All m_particles will be set exactly to the supplied pose...
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
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...
Declares a class that represents a Probability Distribution function (PDF) of a 2D pose (x...
This is a template class for storing a 3D (2D+heading) grid containing any kind of data...
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 get_average(mrpt::poses::CPose2D &out_mean) const
Returns the average pose.