# class mrpt::obs::CObservation¶

Declares a class that represents any robot’s observation.

This is a base class for many types of sensor observations. Users can add new observation types creating a new class deriving from this one.

IMPORTANT : Observations don’t include any information about the robot pose, just raw sensory data and, where aplicable, information about the sensor position and orientation in the local frame of the robot.

CSensoryFrame, CMetricMap

#include <mrpt/obs/CObservation.h>

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

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

//
methods

mrpt::system::TTimeStamp getTimeStamp() const;

template <class METRICMAP>
bool insertObservationInto(
METRICMAP* theMap,
const mrpt::poses::CPose3D* robotPose = nullptr
) const;

virtual void getSensorPose(mrpt::poses::CPose3D& out_sensorPose) const = 0;
void getSensorPose(mrpt::math::TPose3D& out_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;
std::string getDescriptionAsTextValue() const;
};

// direct descendants

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

## Fields¶

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

The associated UTC time-stamp.

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

std::string sensorLabel

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

## Methods¶

mrpt::system::TTimeStamp getTimeStamp() const

Returns CObservation::timestamp for all kind of observations.

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.

getTimeStamp()

virtual 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.

virtual void unload()

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

template <class METRICMAP>
bool insertObservationInto(
METRICMAP* theMap,
const mrpt::poses::CPose3D* robotPose = nullptr
) const

This method is equivalent to:

map->insertObservation(this, robotPose)

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).

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.

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.

setSensorPose

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.

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.

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

std::string getDescriptionAsTextValue() const

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