class mrpt::obs::CObservationIMU

Overview

This class stores measurements from an Inertial Measurement Unit (IMU) (attitude estimation, raw gyroscope and accelerometer values), altimeters or magnetometers.

The order of the values in each entry of mrpt::obs::CObservationIMU::rawMeasurements is defined as symbolic names in the enum mrpt::obs::TIMUDataIndex. Check it out also for reference on the unit and the coordinate frame used for each value.

See also:

CObservation

#include <mrpt/obs/CObservationIMU.h>

class CObservationIMU: public mrpt::obs::CObservation
{
public:
    // typedefs

    typedef std::shared_ptr<mrpt::obs ::CObservationIMU> Ptr;
    typedef std::shared_ptr<const mrpt::obs ::CObservationIMU> ConstPtr;
    typedef std::unique_ptr<mrpt::obs ::CObservationIMU> UniquePtr;
    typedef std::unique_ptr<const mrpt::obs ::CObservationIMU> ConstUniquePtr;

    // fields

    static constexpr const char* className = "mrpt::obs" "::" "CObservationIMU";
    mrpt::poses::CPose3D sensorPose;
    std::array<bool, mrpt::obs::COUNT_IMU_DATA_FIELDS> dataIsPresent;
    std::array<double, mrpt::obs::COUNT_IMU_DATA_FIELDS> rawMeasurements;

    // construction

    CObservationIMU();

    // methods

    static constexpr auto getClassName();
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    static std::shared_ptr<CObject> CreateObject();

    template <typename... Args>
    static Ptr Create(Args&&... args);

    template <typename Alloc, typename... Args>
    static Ptr CreateAlloc(
        const Alloc& alloc,
        Args&&... args
        );

    template <typename... Args>
    static UniquePtr CreateUnique(Args&&... args);

    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual mrpt::rtti::CObject* clone() const;
    void set(TIMUDataIndex idx, double value);
    double get(TIMUDataIndex idx) const;
    bool has(TIMUDataIndex idx) const;
    virtual mrpt::poses::CPose3D getSensorPose() const;
    virtual void setSensorPose(const mrpt::poses::CPose3D& newSensorPose);
    virtual void getDescriptionAsText(std::ostream& o) const;
    virtual bool exportTxtSupported() const;
    virtual std::string exportTxtHeader() const;
    virtual std::string exportTxtDataRow() const;
};

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<CObject> Ptr;
    typedef std::shared_ptr<const CObject> ConstPtr;
    typedef std::shared_ptr<CSerializable> Ptr;
    typedef std::shared_ptr<const CSerializable> ConstPtr;
    typedef std::shared_ptr<CObservation> Ptr;
    typedef std::shared_ptr<const CObservation> ConstPtr;

    // fields

    mrpt::system::TTimeStamp timestamp {mrpt::Clock::now()};
    std::string sensorLabel;

    // methods

    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    mrpt::system::TTimeStamp getTimeStamp() const;
    virtual mrpt::system::TTimeStamp getOriginalReceivedTimeStamp() const;
    void load() const;
    virtual void unload() const;
    virtual bool exportTxtSupported() const;
    virtual std::string exportTxtHeader() const;
    virtual std::string exportTxtDataRow() const;

    template <class METRICMAP>
    bool insertObservationInto(
        METRICMAP& theMap,
        const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt
        ) const;

    virtual mrpt::poses::CPose3D getSensorPose() const = 0;
    void getSensorPose(mrpt::poses::CPose3D& out_sensorPose) const;
    void getSensorPose(mrpt::math::TPose3D& out_sensorPose) const;
    mrpt::math::TPose3D sensorPose() const;
    virtual void setSensorPose(const mrpt::poses::CPose3D& newSensorPose) = 0;
    void setSensorPose(const mrpt::math::TPose3D& newSensorPose);
    virtual void getDescriptionAsText(std::ostream& o) const;
    virtual std::string asString() const;

Typedefs

typedef std::shared_ptr<mrpt::obs ::CObservationIMU> Ptr

A type for the associated smart pointer.

Fields

mrpt::poses::CPose3D sensorPose

The pose of the sensor on the robot.

std::array<bool, mrpt::obs::COUNT_IMU_DATA_FIELDS> dataIsPresent

Each entry in this vector is true if the corresponding data index contains valid data (the IMU unit supplies that kind of data).

See the top of this page for the meaning of the indices. Initial value: all set to false.

std::array<double, mrpt::obs::COUNT_IMU_DATA_FIELDS> rawMeasurements

The accelerometer and/or gyroscope measurements taken by the IMU at the given timestamp.

See also:

dataIsPresent, CObservation::timestamp Initial value: all zeros.

Methods

virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const

Returns information about the class of an object in runtime.

virtual mrpt::rtti::CObject* clone() const

Returns a deep copy (clone) of the object, indepently of its class.

void set(TIMUDataIndex idx, double value)

Sets a given data type, and mark it as present.

See also:

has(), set()

double get(TIMUDataIndex idx) const

Gets a given data type, throws if not set.

See also:

has(), get()

bool has(TIMUDataIndex idx) const

Returns true if the given data type is set.

See also:

set(), get()

virtual mrpt::poses::CPose3D getSensorPose() const

A general method to retrieve the sensor pose on the robot.

Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases.

See also:

setSensorPose A general method to retrieve the sensor pose on the robot, returning it by value.

setSensorPose

virtual void setSensorPose(const mrpt::poses::CPose3D& newSensorPose)

A general method to change the sensor pose on the robot.

Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases.

See also:

getSensorPose

virtual void getDescriptionAsText(std::ostream& o) const

Build a detailed, multi-line textual description of the observation contents and dump it to the output stream.

If overried by derived classes, call base CObservation::getDescriptionAsText() first to show common information.

This is the text that appears in RawLogViewer when selecting an object in the dataset

virtual bool exportTxtSupported() const

Must return true if the class is exportable to TXT/CSV files, in which case the other virtual methods in this group must be redefined too.

virtual std::string exportTxtHeader() const

Returns the description of the data columns.

Timestamp is automatically included as the first column, do not list it. See example implementations if interested in enabling this in custom CObservation classes. Do not include newlines.

virtual std::string exportTxtDataRow() const

Returns one row of data with the data stored in this particular object.

Do not include newlines.