Observation classes for all kinds of robot sensors.

Library mrpt-obs

This library is part of MRPT and can be installed in Debian-based systems with:

sudo apt install libmrpt-obs-dev

Read also how to import MRPT into your CMake scripts.

Key concepts:

Sensor observations: All sensor observations share a common virtual base class (mrpt::obs::CObservation). There are classes to store laser scanners, 3D range images, monocular and stereo images, GPS data, odometry, etc. A concept very related to observations is a mrpt::obs::CSensoryFrame, a set of observations which were collected approximately at the same instant.

Rawlogs (datasets): A robotics dataset can be loaded, edited and explored by means of the class mrpt::obs::CRawlog. See also: https://www.mrpt.org/Rawlog_Format

Actions: For convenience in many Bayesian filtering algorithms, robot actions (like 2D displacement characterized by an odometry increment) can be represented by means of “actions”. See mrpt::obs::CAction.

“Simple maps”: In MRPT, a “simple map” is a set of pairs: “position”, “sensory frames” (read above). The advantage of maintaining such a “simple map” instead a metric map is that the metric maps can be rebuilt when needed with different parameters from the raw observations, which are never lost.

CARMEN logs tools: Utilities to read from CARMEN log files and load the observations there as MRPT observations. See mrpt::obs::carmen_log_parse_line and the applications: carmen2rawlog, carmen2simplemap.

Library contents

// namespaces

namespace mrpt::obs;
    namespace mrpt::obs::detail;
    namespace mrpt::obs::gnss;
        namespace mrpt::obs::gnss::nv_oem6_ins_status_type;
        namespace mrpt::obs::gnss::nv_oem6_position_type;
        namespace mrpt::obs::gnss::nv_oem6_solution_status;
    namespace mrpt::obs::stock_observations;
    namespace mrpt::obs::utils;
namespace mrpt::obs::stock_observations;

// enums

enum mrpt::obs::TIMUDataIndex;

// structs

struct mrpt::obs::T2DScanProperties;
struct mrpt::obs::T3DPointsProjectionParams;
struct mrpt::obs::T3DPointsTo2DScanParams;
struct mrpt::maps::TMetricMapInitializer;

template <unsigned int BYTES_REQUIRED_>
struct mrpt::obs::TPixelLabelInfo;

struct mrpt::obs::TPixelLabelInfoBase;
struct mrpt::obs::VelodyneCalibration;

// classes

class mrpt::obs::CAction;
class mrpt::obs::CActionCollection;
class mrpt::obs::CActionRobotMovement2D;
class mrpt::obs::CActionRobotMovement3D;
class mrpt::maps::CMetricMap;
class mrpt::obs::CObservation2DRangeScan;
class mrpt::obs::CObservation3DRangeScan;
class mrpt::obs::CObservation3DScene;
class mrpt::obs::CObservation6DFeatures;
class mrpt::obs::CObservationBatteryState;
class mrpt::obs::CObservationBeaconRanges;
class mrpt::obs::CObservationBearingRange;
class mrpt::obs::CObservationCANBusJ1939;
class mrpt::obs::CObservationComment;
class mrpt::obs::CObservationGPS;
class mrpt::obs::CObservationGasSensors;
class mrpt::obs::CObservationIMU;
class mrpt::obs::CObservationImage;
class mrpt::obs::CObservationOdometry;
class mrpt::obs::CObservationRFID;
class mrpt::obs::CObservationRGBD360;
class mrpt::obs::CObservationRange;
class mrpt::obs::CObservationRawDAQ;
class mrpt::obs::CObservationReflectivity;
class mrpt::obs::CObservationRobotPose;
class mrpt::obs::CObservationRotatingScan;
class mrpt::obs::CObservationSkeleton;
class mrpt::obs::CObservationStereoImages;
class mrpt::obs::CObservationStereoImagesFeatures;
class mrpt::obs::CObservationVelodyneScan;
class mrpt::obs::CObservationWindSensor;
class mrpt::obs::CObservationWirelessPower;
class mrpt::obs::CRawlog;
class mrpt::obs::CSensoryFrame;
class mrpt::maps::CSimpleMap;
class mrpt::obs::CSinCosLookUpTableFor2DScans;
class mrpt::maps::TSetOfMetricMapInitializers;
class mrpt::maps::mrptEventMetricMapClear;
class mrpt::maps::mrptEventMetricMapInsert;

// global variables

static constexpr int mrpt::obs::INVALID_BEACON_ID = -1;
static constexpr int mrpt::obs::INVALID_LANDMARK_ID = -1;

// global functions

bool mrpt::obs::carmen_log_parse_line(
    std::istream& in_stream,
    std::vector<mrpt::obs::CObservation::Ptr>& out_imported_observations,
    const mrpt::system::TTimeStamp& time_start_log

std::string mrpt::obs::format_externals_filename(const mrpt::obs::CObservation& obs, const std::string& fmt);
void mrpt::obs::registerAllClasses_mrpt_obs();
void mrpt::obs::stock_observations::example2DRangeScan(mrpt::obs::CObservation2DRangeScan& s, int i = 0);
void mrpt::obs::stock_observations::exampleImage(mrpt::img::CImage& im, int i = 0);

template <class OBSERVATION_T>
OBSERVATION_T::Ptr mrpt::obs::utils::getObservation(
    mrpt::obs::CSensoryFrame::Ptr& observations,
    mrpt::obs::CObservation::Ptr& observation,
    bool priority_to_sf = true

Global Variables

static constexpr int mrpt::obs::INVALID_BEACON_ID = -1

Used for CObservationBeaconRange, CBeacon, etc.

static constexpr int mrpt::obs::INVALID_LANDMARK_ID = -1

Used for CObservationBearingRange::TMeasurement::beaconID and others.

Global Functions

bool mrpt::obs::carmen_log_parse_line(
    std::istream& in_stream,
    std::vector<mrpt::obs::CObservation::Ptr>& out_imported_observations,
    const mrpt::system::TTimeStamp& time_start_log

Parse one line from an text input stream and interpret it as a CARMEN log entry, returning its MRPT observation representation.

The first word in each line determines the type of that entry. Supported line entries in this class are the following:

Note that the sensor position on the robot will be always deduced from the corresponding CARMEN log line automatically.

The following entry types will be IGNORED, since with the tags above will be enough in most applications.

  • “ODOM”


About the PARAM entries: This functions has an internal static status consisting on some PARAM values which have effects on the future read observations. When the function finds one of these, it stores the parameter value, return an empty vector of observations, and use those values for future laser entries of types FLASER or RLASER. Currently, only these parameters are processed:

  • “robot_front_laser_max”

  • “laser_front_laser_resolution”

  • “robot_rear_laser_max”

  • “laser_rear_laser_resolution”

References: http://carmen.sourceforge.net/doc/binary__loggerplayback.html



The real timestamp that corresponds to a “0” in the CARMEN log (you can get a mrpt::system::now() once and pass that same value with each call).


On any invalid line found.


true on success, false on end-of-file (EOF).

std::string mrpt::obs::format_externals_filename(
    const mrpt::obs::CObservation& obs,
    const std::string& fmt

Replaces format placeholders in a string according to an observation:

  • ${type} is replaced by: img, stereo, 3dcam for single images, stereo images and depth camera observations, respectively, or other otherwise.

  • ${label} is replaced by the observation sensorLabel field.

  • f with any standard printf() format modifiers will be replaced by UNIX timestamp (with fractions of seconds) of the observation.

  • Anything else will be left unmodified.

For example, the default format string used in rawlog-edit --rename-externals is "${type}_${label}_%.06%f".

(new in MRPT 2.4.1)

void mrpt::obs::registerAllClasses_mrpt_obs()

Forces manual RTTI registration of all serializable classes in this namespace.

Should never be required to be explicitly called by users, except if building MRPT as a static library.

void mrpt::obs::stock_observations::example2DRangeScan(mrpt::obs::CObservation2DRangeScan& s, int i = 0)

Example 2D lidar scans (form a venerable SICK LMS200).

Implemented indices: 0,1.

void mrpt::obs::stock_observations::exampleImage(mrpt::img::CImage& im, int i = 0)

Example images (an 800x640 image pair from a Bumblebee 1) Implemented indices: 0,1.

template <class OBSERVATION_T>
OBSERVATION_T::Ptr mrpt::obs::utils::getObservation(
    mrpt::obs::CSensoryFrame::Ptr& observations,
    mrpt::obs::CObservation::Ptr& observation,
    bool priority_to_sf = true

Given an mrpt::obs::CSensoryFrame and a mrpt::obs::CObservation pointer if a OBSERVATION_T type observation is included and return a pointer to that instance.

Pointer to a single instance is going to be returned. If a suitable observation exists in both the CSensoryFrame and CObservation the outcome is decided by the priority_to_sf flag


Pointer to the observation of the given type. Otherwise, an empty Ptr object is returned if a valid observation is not found.