class mrpt::obs::CSensoryFrame¶
Declares a class for storing a “sensory frame”, a set of “observations” taken by the robot approximately at the same time as one “snapshot” of the environment.
It can contain “observations” of many different kinds.
New observations can be added using:
CObservationXXX::Ptr o = std::make_shared<CObservationXXX>(); // Create a smart pointer containing an object of class "CObservationXXX" o->(...) 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.
Notice that contained observations objects are automatically deleted on this object’s destruction or clear.
See also:
#include <mrpt/obs/CSensoryFrame.h> class CSensoryFrame: public mrpt::serialization::CSerializable { public: // typedefs typedef std::deque<CObservation::Ptr>::iterator iterator; typedef std::deque<CObservation::Ptr>::const_iterator const_iterator; // construction CSensoryFrame(); CSensoryFrame(const CSensoryFrame& o); // methods template <class POINTSMAP> const POINTSMAP* getAuxPointsMap() const; template <class POINTSMAP> const POINTSMAP* buildAuxPointsMap(const void* options = nullptr) const; CSensoryFrame& operator = (const CSensoryFrame& o); void clear(); bool insertObservationsInto(mrpt::maps::CMetricMap* theMap, const mrpt::poses::CPose3D* robotPose = nullptr) const; bool insertObservationsInto(mrpt::maps::CMetricMap::Ptr& theMap, const mrpt::poses::CPose3D* robotPose = nullptr) 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::Ptr getObservationByClass(size_t ith = 0) const; 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); const CObservation::Ptr& getObservationByIndex(size_t idx) const; CObservation::Ptr& getObservationByIndex(size_t idx); template <typename T> T getObservationByIndexAs(size_t idx) const; CObservation::Ptr getObservationBySensorLabel(const std::string& label, size_t idx = 0) const; template <typename T> T getObservationBySensorLabelAs(const std::string& label, size_t idx = 0) const; void swap(CSensoryFrame& sf); };
Typedefs¶
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 constructor.
CSensoryFrame(const CSensoryFrame& o)
Copy constructor.
Methods¶
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:
CSensoryFrame& operator = (const CSensoryFrame& o)
Copy.
void clear()
Clear all current observations.
bool insertObservationsInto(mrpt::maps::CMetricMap* theMap, const mrpt::poses::CPose3D* robotPose = nullptr) 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 (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:
mrpt::maps::CMetricMap, CObservation::insertObservationInto, CMetricMap::insertObservation
bool insertObservationsInto(mrpt::maps::CMetricMap::Ptr& theMap, const mrpt::poses::CPose3D* robotPose = nullptr) 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 (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:
mrpt::maps::CMetricMap, CObservation::insertObservationInto, CMetricMap::insertObservation
void operator += (const CSensoryFrame& sf)
You can use “sf1+=sf2;” to add observations in sf2 to sf1.
Objects are copied, not referenced, thus the source can be safely deleted next.
void operator += (const CObservation::Ptr& obs)
You can use “sf+=obs;” to add the observation “obs” to the “sf1”.
Objects are copied, using the smart pointer, thus the original pointer can be safely deleted next.
void push_back(const CObservation::Ptr& obs)
Inserts a new observation to the list: The pointer to the objects is copied, thus DO NOT delete the passed object, this class will do at destructor or when appropriate.
void insert(const CObservation::Ptr& obs)
Inserts a new observation to the list: The pointer to the objects is copied, thus DO NOT delete the passed object, this class will do at destructor or when appropriate.
template <typename T> 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.
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.
const CObservation::Ptr& getObservationByIndex(size_t idx) const
Returns the i’th observation in the list (0=first).
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> 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:
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).
Returns:
The observation, or nullptr if not found.
See also:
template <typename T> 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:
void swap(CSensoryFrame& sf)
Efficiently swaps the contents of two objects.