class mola::SharedKeyframeMap¶
Overview¶
Mixin interface for a central-map backend (e.g. mola_mapper_3d) that accepts keyframe-insertion requests from front ends (LIO/VIO), decoupled from the front end’s own internal local map / odometry frame.
A front end detects this sink the same way it detects a NavStateFilter (ExecutableBase::findService<SharedKeyframeMap>()) and, when present, pushes keyframes using its own existing keyframing/sparsity criteria, in addition to (or instead of) writing its own .simplemap.
Implementations are required to be thread-safe.
Optionally, a central map also gives read access to its keyframes and their current pose estimates (keyframe_map_snapshot()), e.g. for a module that annotates the map as it grows and as its poses are corrected.
#include <SharedKeyframeMap.h> class SharedKeyframeMap { public: // typedefs typedef uint64_t KeyFrameID; // structs struct KeyframeInsertRequest; struct KeyframeMapSnapshot; // construction SharedKeyframeMap(); SharedKeyframeMap(const SharedKeyframeMap&); SharedKeyframeMap(SharedKeyframeMap&&); // methods virtual std::optional<KeyframeMapSnapshot> keyframe_map_snapshot(] KeyFrameID firstId) const; virtual bool set_keyframe_metadata( ] const std::string& key, ] const std::map<KeyFrameID, mrpt::containers::yaml>& values, ] bool lastValues ); SharedKeyframeMap& operator = (const SharedKeyframeMap&); SharedKeyframeMap& operator = (SharedKeyframeMap&&); virtual std::optional<KeyFrameID> requestInsertKeyframe(const KeyframeInsertRequest& req) = 0; };
Methods¶
virtual std::optional<KeyframeMapSnapshot> keyframe_map_snapshot(] KeyFrameID firstId) const
A snapshot of the map: the poses of all keyframes, and the observations of those from firstId on (none if there are no such keyframes). Thread-safe; providers hold their locks only to copy, so it can be called periodically from any thread, also before the map module is initialized. Nothing if the map does not offer read access (the default) or is not ready yet.
virtual bool set_keyframe_metadata( ] const std::string& key, ] const std::map<KeyFrameID, mrpt::containers::yaml>& values, ] bool lastValues )
Sets the top-level key of the metadata of some keyframes, by id: the per-keyframe YAML map stored in the simple-map (see “MOLA keyframe
metadata” in the docs). When the map saves its keyframes, it writes the values current at that time into each keyframe’s metadata comment, next to what is there already; a key the comment already has (written by the keyframe’s front end) is kept as it is. Later values replace earlier ones, and a null value withdraws the one this API set for that keyframe.
The end of the run:
A writer registers its key early, with a call with no values and
lastValues = false, as soon as it finds the map (before the map becomes final).lastValues = truemeans “this writer sends nothing more for thiskey”. A writer sends it once its values are final (normally after it has seen KeyframeMapSnapshot::is_final, or at once if they do not depend on the final poses), and also whenever it stops for any other reason (an error, shutdown).
Before saving, the map waits until every registered key got its last values, up to a timeout that every write extends. It waits only for keys registered before it starts saving, and refuses every call from then on: a writer that registers late loses its values.
Thread-safe.
Returns:
false, and nothing is stored, if the map does not keep keyframe metadata (the default), is not ready yet, the key is not valid (empty, not made of letters, digits and ‘_’, or reserved, e.g. version), an id is not a keyframe of the map, or the map was already saved.
virtual std::optional<KeyFrameID> requestInsertKeyframe(const KeyframeInsertRequest& req) = 0
Requests inserting one keyframe into the central map.
Returns:
The central-map keyframe id, or std::nullopt if the request was rejected. Ids are 0, 1, 2… in insertion order, and are never removed nor renumbered.