class mola::ImuBiasSource

Overview

Virtual interface for modules that estimate the biases of one or more IMUs, so other modules can use them: e.g. a state estimator that tracks them, read by a LiDAR odometry front end to correct its IMU-based deskew or motion prior.

Consumers find providers with ExecutableBase::findService<ImuBiasSource>() (if several are found, which one to use is up to the consumer), and either query them with imu_bias() from any thread, or subscribe to their updates. Callbacks run in the provider thread, one advertised update at a time, and may call imu_bias() or (un)subscribe. They must return quickly.

Providers implement imu_bias_sensor_labels() and imu_bias_impl(), both thread-safe, and call advertise_updated_imu_bias() after each update, without holding the lock that imu_bias_impl() takes.

Downstream code can detect this interface with __has_include(<mola_kernel/interfaces/ImuBiasSource.h>).

#include <ImuBiasSource.h>

class ImuBiasSource
{
public:
    // construction

    ImuBiasSource();
    ImuBiasSource(const ImuBiasSource&);
    ImuBiasSource(ImuBiasSource&&);

    // methods

    ImuBiasSource& operator = (const ImuBiasSource&);
    ImuBiasSource& operator = (ImuBiasSource&&);
    virtual std::vector<std::string> imu_bias_sensor_labels() const = 0;

    std::optional<ImuBias> imu_bias(
        const std::string& sensorLabel,
        const std::optional<mrpt::Clock::time_point>& t = std::nullopt
        ) const;

    subscription_id_t subscribe_to_imu_bias_updates(const imu_bias_callback_t& callback);
    void unsubscribe_from_imu_bias_updates(subscription_id_t id);
};

// direct descendants

class MockBiasEstimator;

Methods

virtual std::vector<std::string> imu_bias_sensor_labels() const = 0

Sensor labels of the IMUs with a bias estimate.

std::optional<ImuBias> imu_bias(
    const std::string& sensorLabel,
    const std::optional<mrpt::Clock::time_point>& t = std::nullopt
    ) const

The current bias estimate of one IMU, or nothing if this provider does not know that sensor label. If t is given and not older than the estimate, the estimate is propagated to it by the provider’s bias model, and its timestamp is exactly t. Otherwise, timestamp is the time of the provider’s newest data for that IMU.

subscription_id_t subscribe_to_imu_bias_updates(const imu_bias_callback_t& callback)

Registers a callback invoked every time an IMU bias estimate is updated.

Parameters:

std::invalid_argument

if the callback is empty.

Returns:

an id for unsubscribe_from_imu_bias_updates().

void unsubscribe_from_imu_bias_updates(subscription_id_t id)

Removes a callback, e.g. before its captured objects are destroyed. Once this returns, the callback is neither running nor started again: it waits for an update 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.