class mola::LocalMapCorrectionSource
Overview
Virtual interface for modules that estimate the poses of the keyframes inserted by front ends (e.g. a global mapper with loop closures), so a front end can rebuild its local map with the corrected poses, and reuse what was mapped in earlier visits of the same place.
Consumers find providers with ExecutableBase::findService<LocalMapCorrectionSource>(), subscribe to corrections, and, when one arrives, query the keyframes around one of their own keyframes (the reference) with local_map_keyframes(), from any thread. Poses are relative to the reference, so the front end can anchor them at its own estimate of the reference, and its own pose does not jump. Callbacks run in the provider thread, one at a time, and must return quickly (e.g. only wake up a worker thread).
Providers implement local_map_keyframes_impl(), thread-safe, and call advertise_local_map_correction() after each correction, without holding the lock that local_map_keyframes_impl() takes.
Downstream code can detect this interface with __has_include(<mola_kernel/interfaces/LocalMapCorrectionSource.h>).
#include <LocalMapCorrectionSource.h> class LocalMapCorrectionSource { public: // typedefs typedef std::function<void(const LocalMapCorrection&)> correction_callback_t; typedef std::uint64_t subscription_id_t; // construction LocalMapCorrectionSource(); LocalMapCorrectionSource(const LocalMapCorrectionSource&); LocalMapCorrectionSource(LocalMapCorrectionSource&&); // methods LocalMapCorrectionSource& operator = (const LocalMapCorrectionSource&); LocalMapCorrectionSource& operator = (LocalMapCorrectionSource&&); std::optional<std::vector<LocalMapKeyframe>> local_map_keyframes(SharedKeyframeMap::KeyFrameID reference, double radius) const; subscription_id_t subscribe_to_local_map_corrections(const correction_callback_t& callback); void unsubscribe_from_local_map_corrections(subscription_id_t id); };
Methods
std::optional<std::vector<LocalMapKeyframe>> local_map_keyframes(SharedKeyframeMap::KeyFrameID reference, double radius) const
The keyframes whose current position is within radius [m] of keyframe reference (included), from any front end, oldest first. Nothing if reference is unknown to this provider.
subscription_id_t subscribe_to_local_map_corrections(const correction_callback_t& callback)
Registers a callback invoked after every correction.
Parameters:
std::invalid_argument |
if the callback is empty. |
Returns:
an id for unsubscribe_from_local_map_corrections().
void unsubscribe_from_local_map_corrections(subscription_id_t id)
Removes a callback. Once this returns, the callback is neither running nor started again: it waits for a correction being advertised in another thread, so do not call it while holding a lock that the callback takes. It can be called from within the callback itself. Unknown ids are ignored.