class mrpt::obs::CObservation

Overview

#include <mrpt/obs/CObservation.h>

class CObservation:
    public mrpt::serialization::CSerializable,
    public mrpt::Stringifyable
{
public:
    // fields

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

    // construction

    CObservation();

    // methods

    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 void getSensorPose(mrpt::poses::CPose3D& out_sensorPose) const = 0;
    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;
};

// direct descendants

class CObservation2DRangeScan;
class CObservation3DRangeScan;
class CObservation3DScene;
class CObservation6DFeatures;
class CObservationBatteryState;
class CObservationBeaconRanges;
class CObservationBearingRange;
class CObservationCANBusJ1939;
class CObservationComment;
class CObservationGPS;
class CObservationGasSensors;
class CObservationIMU;
class CObservationImage;
class CObservationOdometry;
class CObservationPointCloud;
class CObservationRFID;
class CObservationRGBD360;
class CObservationRange;
class CObservationRawDAQ;
class CObservationReflectivity;
class CObservationRobotPose;
class CObservationRotatingScan;
class CObservationSkeleton;
class CObservationStereoImages;
class CObservationStereoImagesFeatures;
class CObservationVelodyneScan;
class CObservationVisualLandmarks;
class CObservationWindSensor;
class CObservationWirelessPower;

Fields

mrpt::system::TTimeStamp timestamp {mrpt::Clock::now()}

The associated UTC time-stamp.

Where available, this should contain the accurate satellite-based timestamp of the sensor reading.

See also:

getOriginalReceivedTimeStamp(), getTimeStamp()

std::string sensorLabel

An arbitrary label that can be used to identify the sensor.

Construction

CObservation()

Constructor: It sets the initial timestamp to current time.

Methods

mrpt::system::TTimeStamp getTimeStamp() const

Returns CObservation::timestamp for all kind of observations.

See also:

getOriginalReceivedTimeStamp()

virtual mrpt::system::TTimeStamp getOriginalReceivedTimeStamp() const

By default, returns CObservation::timestamp but in sensors capable of satellite (or otherwise) accurate UTC timing of readings, this contains the computer-based timestamp of reception, which may be slightly different than timestamp.

See also:

getTimeStamp()

void load() const

Makes sure all images and other fields which may be externally stored are loaded in memory.

Note that for all CImages, calling load() is not required since the images will be automatically loaded upon first access, so load() shouldn’t be needed to be called in normal cases by the user. If all the data were alredy loaded or this object has no externally stored data fields, calling this method has no effects.

See also:

unload

virtual void unload() const

Unload all images, for the case they being delayed-load images stored in external files (otherwise, has no effect).

See also:

load

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.

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

This method is equivalent to:

map->insertObservation(this, robotPose)

See: Maps and observations compatibility matrices

Parameters:

theMap

The map where this observation is to be inserted: the map will be updated.

robotPose

The pose of the robot base for this observation, relative to the target metric map. Set to nullptr (default) to use (0,0,0deg)

Returns:

Returns true if the map has been updated, or false if this observations has nothing to do with a metric map (for example, a sound observation).

See also:

CMetricMap, CMetricMap::insertObservation

virtual void getSensorPose(mrpt::poses::CPose3D& out_sensorPose) const = 0

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

void getSensorPose(mrpt::math::TPose3D& out_sensorPose) 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

mrpt::math::TPose3D sensorPose() const

synonym with getSensorPose()

(New in MRPT 2.3.1)

See also:

getSensorPose

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

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

void setSensorPose(const mrpt::math::TPose3D& 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 std::string asString() const

Return by value version of getDescriptionAsText(std::ostream&).