class mola::KeyframeDecider

Overview

Decides whether a new keyframe should be created at a given pose, and stores the poses of those already created.

One instance exists per “map” whose keyframe density is governed independently (the local metric map, and the simplemap / central-mapper keyframe backbone), each with its own KeyframeDecisionOptions.

The two distance thresholds are passed in at every check() call rather than held: they may be dynamic expressions (e.g. a distance that shrinks with angular velocity), re-evaluated by mp2p_icp::Parameterizable before each scan. The two policy selectors (measure_from_last_kf_only and nearby_keyframe_time_window) are instead read once, by the constructor, and pick which of the two mutually exclusive storages is maintained.

#include <KeyframeDecider.h>

class KeyframeDecider
{
public:
    // structs

    struct Decision;

    // construction

    KeyframeDecider(const KeyframeDecisionOptions& opts);

    // methods

    Decision check(const KeyframeDecisionOptions& opts, const mrpt::poses::CPose3D& pose, double timestamp);
    void insert(const mrpt::poses::CPose3D& pose, double timestamp);
    void removeAllFartherThan(const mrpt::poses::CPose3D& pose, double maxTranslation);
    size_t size() const;
    bool empty() const;
    size_t activeSize() const;
};

Construction

KeyframeDecider(const KeyframeDecisionOptions& opts)

There is no default constructor on purpose: the options select which policy, and which storage, the instance uses for its whole lifetime.

Methods

Decision check(const KeyframeDecisionOptions& opts, const mrpt::poses::CPose3D& pose, double timestamp)

Evaluates the policy for a candidate keyframe pose. Does NOT store the queried pose; call insert() if the keyframe is actually created (it does drop stored poses that fell out of the time window, though).

Parameters:

timestamp

Observation timestamp [s], only used under the temporal policy.

void insert(const mrpt::poses::CPose3D& pose, double timestamp)

Stores an actually-created keyframe pose.

void removeAllFartherThan(const mrpt::poses::CPose3D& pose, double maxTranslation)

Drops stored poses farther than the given distance (local map cleanup)

size_t size() const

Re-expresses every stored keyframe pose in a new reference frame, i.e. each stored p becomes b + p. Relative distances are preserved, so no past decision changes; only the frame the poses live in moves.

Needs SearchablePoseList::transform_left_multiply(), so it is compiled out against an older mola_pose_list. Callers must guard on MOLA_POSE_LIST_HAS_TRANSFORM_LEFT_MULTIPLY. Number of keyframes created so far (minus those dropped by removeAllFartherThan). This is what the GUI reports: under the temporal policy, keyframes that aged out of the window still count, since they remain in the map and merely stopped taking part in the decision.

size_t activeSize() const

Number of keyframes currently taking part in the decision, i.e. those inside the time window under the temporal policy. Equals size() under the spatial one.