31 double resolution_XYZ,
double resolution_YPR)
35 uniformDistribution();
40 if (
this == &o)
return;
50 for (
size_t cR = 0; cR < m_sizeRoll; cR++)
51 for (
size_t cP = 0; cP < m_sizePitch; cP++)
52 for (
size_t cY = 0; cY < m_sizeYaw; cY++)
53 for (
size_t cz = 0; cz < m_sizeZ; cz++)
54 for (
size_t cy = 0; cy < m_sizeY; cy++)
55 for (
size_t cx = 0; cx < m_sizeX; cx++)
58 *getByIndex(cx, cy, cz, cY, cP, cR);
61 idx2x(cx), idx2y(cy), idx2z(cz),
62 idx2yaw(cY), idx2pitch(cP), idx2roll(cR)),
68 std::tuple<CMatrixDouble66, CPose3D> CPose3DPDFGrid::getCovarianceAndMean()
75 for (
size_t cR = 0; cR < m_sizeRoll; cR++)
76 for (
size_t cP = 0; cP < m_sizePitch; cP++)
77 for (
size_t cY = 0; cY < m_sizeYaw; cY++)
78 for (
size_t cz = 0; cz < m_sizeZ; cz++)
79 for (
size_t cy = 0; cy < m_sizeY; cy++)
80 for (
size_t cx = 0; cx < m_sizeX; cx++)
83 *getByIndex(cx, cy, cz, cY, cP, cR);
86 idx2x(cx), idx2y(cy), idx2z(cz), idx2yaw(cY),
87 idx2pitch(cP), idx2roll(cR));
94 uint8_t CPose3DPDFGrid::serializeGetVersion()
const {
return 0; }
98 out << m_bb_min << m_bb_max << m_resolutionXYZ << m_resolutionYPR;
105 out << m_sizeX << m_sizeY << m_sizeZ << m_sizeYaw << m_sizePitch
107 out << m_min_cidX << m_min_cidY << m_min_cidZ << m_min_cidYaw
108 << m_min_cidPitch << m_min_cidRoll;
113 void CPose3DPDFGrid::serializeFrom(
120 in >> m_bb_min >> m_bb_max >> m_resolutionXYZ >> m_resolutionYPR;
127 in >> m_sizeX >> m_sizeY >> m_sizeZ >> m_sizeYaw >> m_sizePitch >>
129 in >> m_min_cidX >> m_min_cidY >> m_min_cidZ >> m_min_cidYaw >>
130 m_min_cidPitch >> m_min_cidRoll;
135 update_cached_size_products();
145 bool CPose3DPDFGrid::saveToTextFile(
const std::string& dataFile)
const 152 void CPose3DPDFGrid::changeCoordinatesReference(
const CPose3D& newReferenceBase)
171 void CPose3DPDFGrid::drawSingleSample(
CPose3D& outPart)
const 177 void CPose3DPDFGrid::drawManySamples(
178 size_t N, std::vector<CVectorDouble>& outSamples)
const 191 for (
auto it = m_data.begin(); it != m_data.end(); ++it) SUM += *it;
195 const auto f = 1.0 / SUM;
196 for (
double& it : m_data) it *= f;
200 void CPose3DPDFGrid::uniformDistribution()
202 const double val = 1.0 / m_data.size();
204 for (
double& it : m_data) it =
val;
void append(const mrpt::poses::CPose3D &p)
Adds a new pose to the computation.
#define THROW_EXCEPTION(msg)
CParticleList m_particles
The array of particles.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void WriteAs(const TYPE_FROM_ACTUAL &value)
This is a template class for storing a 6-dimensional grid, with components corresponding to Euler ang...
GLubyte GLubyte GLubyte GLubyte w
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
This base provides a set of functions for maths stuff.
void normalize(CONTAINER &c, Scalar valMin, Scalar valMax)
Scales all elements such as the minimum & maximum values are shifted to the given values...
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
STORED_TYPE ReadAs()
De-serialize a variable and returns it by value.
Eigen::Matrix< dataType, 4, 4 > inverse(Eigen::Matrix< dataType, 4, 4 > &pose)
GLsizei const GLchar ** string
std::tuple< cov_mat_t, type_value > getCovarianceAndMean() const override
Returns an estimate of the pose covariance matrix (6x6 cov matrix) and the mean, both at once...
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Computes weighted and un-weighted averages of SE(3) poses.
Virtual base class for "archives": classes abstracting I/O streams.
void get_average(mrpt::poses::CPose3D &out_mean) const
Returns the average pose.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Declares a class that represents a Probability Distribution function (PDF) of a SE(3) pose (x...
void resetDeterministic(const mrpt::math::TPose3D &location, size_t particlesCount=0)
Reset the PDF to a single point: All m_particles will be set exactly to the supplied pose...
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually)...
Declares a class that represents a Probability Density function (PDF) of a 3D pose.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.