class mrpt::obs::CSensoryFrame
Overview
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:
CSensoryFrame::getObservationByClass : Looks for some specific observation class.
CSensoryFrame::begin : To iterate over all observations.
CSensoryFrame::getObservationByIndex : To query by index.
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:
#include <mrpt/obs/CSensoryFrame.h> class CSensoryFrame: public mrpt::serialization::CSerializable { public: // typedefs typedef std::shared_ptr<mrpt::obs ::CSensoryFrame> Ptr; typedef std::shared_ptr<const mrpt::obs ::CSensoryFrame> ConstPtr; typedef std::unique_ptr<mrpt::obs ::CSensoryFrame> UniquePtr; typedef std::unique_ptr<const mrpt::obs ::CSensoryFrame> ConstUniquePtr; typedef std::deque<CObservation::Ptr>::iterator iterator; typedef std::deque<CObservation::Ptr>::const_iterator const_iterator; // fields static constexpr const char* className = "mrpt::obs" "::" "CSensoryFrame"; // construction CSensoryFrame(); // 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; template <class POINTSMAP> const POINTSMAP* getAuxPointsMap() const; template <class POINTSMAP> const POINTSMAP* buildAuxPointsMap(const void* options = nullptr) const; void clear(); bool insertObservationsInto(mrpt::maps::CMetricMap& theMap, const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt) const; bool insertObservationsInto(mrpt::maps::CMetricMap::Ptr& theMap, const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt) const; void operator += (const CSensoryFrame& sf); void operator += (const CObservation::Ptr& obs); void push_back(const CObservation::Ptr& obs); void insert(const CObservation::Ptr& obs); template <typename T> T::ConstPtr getObservationByClass(size_t ith = 0) const; template <typename T> T::Ptr getObservationByClass(size_t ith = 0); const_iterator begin() const; const_iterator end() const; iterator begin(); iterator end(); size_t size() const; bool empty() const; void eraseByIndex(size_t idx); iterator erase(const iterator& it); void eraseByLabel(const std::string& label); CObservation::ConstPtr getObservationByIndex(size_t idx) const; CObservation::Ptr& getObservationByIndex(size_t idx); template <typename T> std::shared_ptr<const typename T::element_type> getObservationByIndexAs(size_t idx) const; template <typename T> std::shared_ptr<typename T::element_type> getObservationByIndexAs(size_t idx); CObservation::ConstPtr getObservationBySensorLabel(const std::string& label, size_t idx = 0) const; CObservation::Ptr getObservationBySensorLabel( const std::string& label, size_t idx = 0 ); template <typename T> std::shared_ptr<const typename T::element_type> getObservationBySensorLabelAs( const std::string& label, size_t idx = 0 ) const; template <typename T> std::shared_ptr<typename T::element_type> getObservationBySensorLabelAs( const std::string& label, size_t idx = 0 ); void swap(CSensoryFrame& sf); };
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; // 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();
Typedefs
typedef std::shared_ptr<mrpt::obs ::CSensoryFrame> Ptr
A type for the associated smart pointer.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
typedef std::deque<CObservation::Ptr>::iterator iterator
You can use CSensoryFrame::begin to get a iterator to the first element.
typedef std::deque<CObservation::Ptr>::const_iterator const_iterator
You can use CSensoryFrame::begin to get a iterator to the first element.
Construction
CSensoryFrame()
Default ctor.
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.
template <class POINTSMAP> 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>();
See also:
template <class POINTSMAP> const POINTSMAP* buildAuxPointsMap(const void* options = nullptr) const
Returns a cached points map representing this laser scan, building it upon the first call.
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); |
See also:
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.
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).
See also:
mrpt::maps::CMetricMap, CObservation::insertObservationInto, CMetricMap::insertObservation
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.
void insert(const CObservation::Ptr& obs)
Synonym with push_back()
template <typename T> T::ConstPtr 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.
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*" }
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*" }
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*" }
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*" }
size_t size() const
Returns the number of observations in the list.
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.
CObservation::ConstPtr getObservationByIndex(size_t idx) const
Returns the i’th observation in the list (0=first).
Parameters:
std::exception |
If out of range. |
See also:
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> std::shared_ptr<const typename T::element_type> 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:
CObservation::ConstPtr getObservationBySensorLabel(const std::string& label, size_t idx = 0) const
Returns the i’th observation in the list with the given “sensorLabel” (0=first).
Returns:
The observation, or nullptr if not found.
See also:
template <typename T> std::shared_ptr<const typename T::element_type> 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:
void swap(CSensoryFrame& sf)
Efficiently swaps the contents of two objects.