47 template <
typename OP>
53 std::for_each(mmm.maps.begin(), mmm.maps.end(), op);
67 : obs(_obs), can(_can)
72 template <
typename PTR>
75 can = can || ptr->canComputeObservationLikelihood(obs);
83 template <
typename PTR>
86 if (ptr) ptr->auxParticleFilterCleanUp();
94 MapIsEmpty(
bool& _is_empty) : is_empty(_is_empty) { is_empty =
true; }
95 template <
typename PTR>
98 if (ptr) is_empty = is_empty && ptr->isEmpty();
121 for (
const auto& i : inits)
124 auto* theMap = mmr.factoryMapObjectFromDefinition(*i.get());
134 std::for_each(maps.begin(), maps.end(), [](
auto ptr) {
135 if (ptr) ptr->clear();
142 const auto n =
static_cast<uint32_t>(maps.size());
144 for (
uint32_t i = 0; i <
n; i++) out << *maps[i];
165 this->maps.resize(
n);
167 maps.begin(), maps.end(),
181 double ret_log_lik = 0;
183 std::for_each(maps.begin(), maps.end(), [&](
auto& ptr) {
184 ret_log_lik += ptr->computeObservationLikelihood(obs, takenFrom);
195 bool can_comp =
false;
196 std::for_each(maps.begin(), maps.end(), [&](
auto& ptr) {
197 can_comp = can_comp || ptr->canComputeObservationLikelihood(obs);
205 int total_insert = 0;
207 std::for_each(maps.begin(), maps.end(), [&](
auto& ptr) {
208 const bool ret = ptr->insertObservation(obs, robotPose);
209 if (ret) total_insert++;
211 return total_insert != 0;
220 const auto numPointsMaps = countMapsByClass<CSimplePointsMap>();
224 "There is not exactly 1 points maps in the multimetric map.");
225 mapByClass<CSimplePointsMap>()->determineMatching2D(
226 otherMap, otherMapPose, correspondences,
params, extraResults);
243 for (
size_t idx = 0; idx < maps.size(); idx++)
250 static_cast<unsigned int>(idx));
261 std::for_each(maps.begin(), maps.end(), [&](
auto& ptr) {
262 ptr->getAs3DObject(outObj);
275 float accumResult = 0;
277 for (
const auto& map : maps)
286 const size_t nMapsComputed = maps.size();
287 if (nMapsComputed) accumResult /= nMapsComputed;
296 std::for_each(maps.begin(), maps.end(), [](
auto& ptr) {
297 ptr->auxParticleFilterCleanUp();
305 const auto numPointsMaps = countMapsByClass<CSimplePointsMap>();
306 ASSERT_(numPointsMaps == 1 || numPointsMaps == 0);
310 return this->mapByClass<CSimplePointsMap>(0).
get();
317 return maps.at(idx).get_ptr();
virtual void saveMetricMapRepresentationToFile(const std::string &filNamePrefix) const =0
This virtual method saves the map to a file "filNamePrefix"+< some_file_extension >...
void auxParticleFilterCleanUp() override
This method is called at the end of each "prediction-update-map insertion" cycle within "mrpt::slam::...
void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr &outObj) const override
Returns a 3D object representing the map.
Parameters for CMetricMap::compute3DMatchingRatio()
void operator()(PTR &ptr)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
bool internal_insertObservation(const mrpt::obs::CObservation &obs, const mrpt::poses::CPose3D *robotPose=nullptr) override
Internal method called by insertObservation()
void operator()(PTR &ptr)
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans. ...
void determineMatching2D(const mrpt::maps::CMetricMap *otherMap, const mrpt::poses::CPose2D &otherMapPose, mrpt::tfest::TMatchingPairList &correspondences, const mrpt::maps::TMatchingParams ¶ms, mrpt::maps::TMatchingExtraResults &extraResults) const override
Computes the matching between this and another 2D point map, which includes finding: ...
A set of TMetricMapInitializer structures, passed to the constructor CMultiMetricMap::CMultiMetricMap...
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
MapCanComputeLikelihood(const CMultiMetricMap &m, const CObservation *_obs, bool &_can)
bool isEmpty() const override
Returns true if all maps returns true in their isEmpty() method.
#define ASSERT_(f)
Defines an assertion mechanism.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
float compute3DMatchingRatio(const mrpt::maps::CMetricMap *otherMap, const mrpt::poses::CPose3D &otherMapPose, const TMatchingRatioParams ¶ms) const override
Computes the ratio in [0,1] of correspondences between "this" and the "otherMap" map, whose 6D pose relative to "this" is "otherMapPose" In the case of a multi-metric map, this returns the average between the maps.
void internal_clear() override
Internal method called by clear()
static TMetricMapTypesRegistry & Instance()
This namespace contains representation of robot actions and observations.
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
CMultiMetricMap()=default
Default ctor: empty list of maps.
bool internal_canComputeObservationLikelihood(const mrpt::obs::CObservation &obs) const override
Internal method called by canComputeObservationLikelihood()
GLsizei const GLchar ** string
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
virtual const mrpt::rtti::TRuntimeClassId * GetRuntimeClass() const override
Returns information about the class of an object in runtime.
Virtual base class for "archives": classes abstracting I/O streams.
double internal_computeObservationLikelihood(const mrpt::obs::CObservation &obs, const mrpt::poses::CPose3D &takenFrom) override
Internal method called by computeObservationLikelihood()
Declares a virtual base class for all metric maps storage classes.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
const mrpt::maps::CSimplePointsMap * getAsSimplePointsMap() const override
If the map is a simple points map or it's a multi-metric map that contains EXACTLY one simple points ...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Declares a class that represents any robot's observation.
MapIsEmpty(bool &_is_empty)
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
mrpt::maps::CMetricMap::Ptr mapByIndex(size_t idx) const
Gets the i-th map On out-of-bounds.
This class stores any customizable set of metric maps.
Parameters for the determination of matchings between point clouds, etc.
unsigned __int32 uint32_t
Functions for estimating the optimal transformation between two frames of references given measuremen...
GLenum const GLfloat * params
virtual float compute3DMatchingRatio(const mrpt::maps::CMetricMap *otherMap, const mrpt::poses::CPose3D &otherMapPose, const TMatchingRatioParams ¶ms) const
Computes the ratio in [0,1] of correspondences between "this" and the "otherMap" map, whose 6D pose relative to "this" is "otherMapPose" In the case of a multi-metric map, this returns the average between the maps.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
void saveMetricMapRepresentationToFile(const std::string &filNamePrefix) const override
This virtual method saves the map to a file "filNamePrefix"+< some_file_extension >...
void setListOfMaps(const mrpt::maps::TSetOfMetricMapInitializers &init)
Sets the list of internal map according to the passed list of map initializers (current maps will be ...
void operator()(PTR &ptr)
static void run(const CMultiMetricMap &_mmm, OP op)