48 template <
typename OP>
54 std::for_each(mmm.maps.begin(), mmm.maps.end(), op);
68 : obs(_obs), can(_can)
73 template <
typename PTR>
76 can = can || ptr->canComputeObservationLikelihood(obs);
84 template <
typename PTR>
87 if (ptr) ptr->auxParticleFilterCleanUp();
95 MapIsEmpty(
bool& _is_empty) : is_empty(_is_empty) { is_empty =
true; }
96 template <
typename PTR>
99 if (ptr) is_empty = is_empty && ptr->isEmpty();
122 for (
const auto& i : inits)
125 auto* theMap = mmr.factoryMapObjectFromDefinition(*i.get());
135 std::for_each(maps.begin(), maps.end(), [](
auto ptr) {
136 if (ptr) ptr->clear();
143 const auto n =
static_cast<uint32_t
>(maps.size());
145 for (uint32_t i = 0; i < n; i++)
out << *maps[i];
166 this->maps.resize(n);
168 maps.begin(), maps.end(),
182 double ret_log_lik = 0;
184 std::for_each(maps.begin(), maps.end(), [&](
auto& ptr) {
185 ret_log_lik += ptr->computeObservationLikelihood(obs, takenFrom);
196 bool can_comp =
false;
197 std::for_each(maps.begin(), maps.end(), [&](
auto& ptr) {
198 can_comp = can_comp || ptr->canComputeObservationLikelihood(obs);
206 int total_insert = 0;
208 std::for_each(maps.begin(), maps.end(), [&](
auto& ptr) {
209 const bool ret = ptr->insertObservation(obs, robotPose);
210 if (ret) total_insert++;
212 return total_insert != 0;
221 const auto numPointsMaps = countMapsByClass<CSimplePointsMap>();
225 "There is not exactly 1 points maps in the multimetric map.");
226 mapByClass<CSimplePointsMap>()->determineMatching2D(
227 otherMap, otherMapPose, correspondences,
params, extraResults);
240 const std::string& filNamePrefix)
const 244 for (
size_t idx = 0; idx < maps.size(); idx++)
248 std::string fil = filNamePrefix;
254 static_cast<unsigned int>(idx));
265 std::for_each(maps.begin(), maps.end(), [&](
auto& ptr) {
266 ptr->getAs3DObject(outObj);
279 float accumResult = 0;
281 for (
const auto& map : maps)
290 const size_t nMapsComputed = maps.size();
291 if (nMapsComputed) accumResult /= nMapsComputed;
300 std::for_each(maps.begin(), maps.end(), [](
auto& ptr) {
301 ptr->auxParticleFilterCleanUp();
309 const auto numPointsMaps = countMapsByClass<CSimplePointsMap>();
310 ASSERT_(numPointsMaps == 1 || numPointsMaps == 0);
314 return this->mapByClass<CSimplePointsMap>(0).
get();
321 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)
std::string std::string format(std::string_view fmt, ARGS &&... args)
#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)
mrpt::vision::TStereoCalibParams params
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: ...
std::string fileNameStripInvalidChars(const std::string &filename, const char replacement_to_invalid_chars='_')
Replace invalid filename chars by underscores ('_') or any other user-given char. ...
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
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).
mrpt::vision::TStereoCalibResults out
Declares a class that represents any robot's observation.
MapIsEmpty(bool &_is_empty)
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.
Functions for estimating the optimal transformation between two frames of references given measuremen...
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)