Class CSensoryFrame

Inheritance Relationships

Base Type

  • public mrpt::serialization::CSerializable

Class Documentation

class CSensoryFrame : public mrpt::serialization::CSerializable

A “sensory frame” is a set of observations taken by the robot approximately at the same time, so they can be considered as a multi-sensor “snapshot” of the environment. It can contain “observations” of many different kinds.

New observations can be added using:

// Create a smart pointer containing an object of class "CObservationXXX"
CObservationXXX::Ptr    o = std::make_shared<CObservationXXX>();
// o->... // fill it...
CSensoryFrame sf;
sf.insert(o);

The following methods are equivalent for adding new observations to a “sensory frame”:

To examine the objects within a sensory frame, the following methods exist:

Note that shared_ptr<>s to the observations are stored, so a copy of a CSensoryFrame will contain references to the same objects, i.e. copies are shallows copies, not deep copies.

See also

CObservation

Cached points map

template<class POINTSMAP>
inline const POINTSMAP *getAuxPointsMap() const

Returns the cached points map representation of the scan, if already build with buildAuxPointsMap(), or nullptr otherwise. Usage:

   mrpt::maps::CPointsMap *map =
obs->getAuxPointsMap<mrpt::maps::CPointsMap>();

template<class POINTSMAP>
inline const POINTSMAP *buildAuxPointsMap(const void *options = nullptr) const

Returns a cached points map representing this laser scan, building it upon the first call.

See also

getAuxPointsMap

Parameters:

options – Can be nullptr to use default point maps’ insertion options, or a pointer to a “CPointsMap::TInsertionOptions” structure to override some params. Usage:

   mrpt::maps::CPointsMap *map =
sf->buildAuxPointsMap<mrpt::maps::CPointsMap>(&options or nullptr);

Public Types

using iterator = std::deque<CObservation::Ptr>::iterator

You can use CSensoryFrame::begin to get a iterator to the first element.

using const_iterator = std::deque<CObservation::Ptr>::const_iterator

You can use CSensoryFrame::begin to get a iterator to the first element.

Public Functions

CSensoryFrame() = default

Default ctor.

void clear()

Clear the container, so it holds no observations.

bool insertObservationsInto(mrpt::maps::CMetricMap &theMap, const std::optional<const mrpt::poses::CPose3D> &robotPose = std::nullopt) const

Insert all the observations in this SF into a metric map or any kind (see mrpt::maps::CMetricMap). It calls CObservation::insertObservationInto for all stored observation.

See also

mrpt::maps::CMetricMap, CObservation::insertObservationInto, CMetricMap::insertObservation

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 SE(3) identity, i.e. the origin.

Returns:

Returns true if the map has been updated, or false if this observations have nothing to do with the metric map (e.g. trying to insert an image into a gridmap).

inline bool insertObservationsInto(mrpt::maps::CMetricMap::Ptr &theMap, const std::optional<const mrpt::poses::CPose3D> &robotPose = std::nullopt) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void operator+=(const CSensoryFrame &sf)

You can use “sf1+=sf2;” to add all observations in sf2 to sf1.

void operator+=(const CObservation::Ptr &obs)

You can use “sf+=obs;” to add the observation “obs” to the “sf1”.

void push_back(const CObservation::Ptr &obs)

Insert a new observation to the sensory frame.

inline void insert(const CObservation::Ptr &obs)

Synonym with push_back()

template<typename T>
inline T::Ptr getObservationByClass(size_t ith = 0) const

Returns the i’th observation of a given class (or of a descendant class), or nullptr if there is no such observation in the array. Example:

   CObservationImage::Ptr obs =
m_SF->getObservationByClass<CObservationImage>();
By default (ith=0), the first observation is returned.

inline const_iterator begin() const

Returns a constant iterator to the first observation: this is an example of usage:

CSensoryFrame  sf;
...
for (CSensoryFrame::const_iterator it=sf.begin();it!=sf.end();++it)
   {
   (*it)->... // (*it) is a "CObservation*"
}

inline const_iterator end() const

Returns a constant iterator to the end of the list of observations: this is an example of usage:

CSensoryFrame  sf;
...
for (CSensoryFrame::const_iterator it=sf.begin();it!=sf.end();++it)
   {
   (*it)->... // (*it) is a "CObservation*"
}

inline iterator begin()

Returns a iterator to the first observation: this is an example of usage:

CSensoryFrame  sf;
...
for (CSensoryFrame::iterator it=sf.begin();it!=sf.end();++it)
   {
   (*it)->... // (*it) is a "CObservation*"
}

inline iterator end()

Returns a iterator to the end of the list of observations: this is an example of usage:

CSensoryFrame  sf;
...
for (CSensoryFrame::iterator it=sf.begin();it!=sf.end();++it)
   {
   (*it)->... // (*it) is a "CObservation*"
}

inline size_t size() const

Returns the number of observations in the list.

inline bool empty() const

Returns true if there are no observations in the list.

void eraseByIndex(size_t idx)

Removes the i’th observation in the list (0=first).

iterator erase(const iterator &it)

Removes the given observation in the list, and return an iterator to the next element (or this->end() if it was the last one).

void eraseByLabel(const std::string &label)

Removes all the observations that match a given sensorLabel.

const CObservation::Ptr &getObservationByIndex(size_t idx) const

Returns the i’th observation in the list (0=first).

See also

begin, size

Throws:

std::exception – If out of range.

CObservation::Ptr &getObservationByIndex(size_t idx)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T>
inline T getObservationByIndexAs(size_t idx) const

Returns the i’th observation in the list (0=first), and as a different smart pointer type:

sf.getObservationByIndexAs<CObservationStereoImages::Ptr>(i);

See also

begin, size

CObservation::Ptr getObservationBySensorLabel(const std::string &label, size_t idx = 0) const

Returns the i’th observation in the list with the given “sensorLabel” (0=first).

See also

begin, size

Returns:

The observation, or nullptr if not found.

template<typename T>
inline T getObservationBySensorLabelAs(const std::string &label, size_t idx = 0) const

Returns the i’th observation in the list with the given “sensorLabel” (0=first), and as a different smart pointer type:

sf.getObservationBySensorLabelAs<CObservationStereoImages::Ptr>(i);

See also

begin, size

void swap(CSensoryFrame &sf)

Efficiently swaps the contents of two objects.

Protected Functions

void internal_buildAuxPointsMap(const void *options = nullptr) const

Internal method, used from buildAuxPointsMap()

Protected Attributes

std::deque<CObservation::Ptr> m_observations

The set of observations taken at the same time instant. See the top of this page for instructions on accessing this.

mutable mrpt::maps::CMetricMap::Ptr m_cachedMap

A point cloud map, build only under demand by the methods getAuxPointsMap() and buildAuxPointsMap(). It’s a generic smart pointer to avoid depending here in the library mrpt-obs on classes on other libraries.