MRPT
2.0.1
|
This class stores a rawlog (robotic datasets) in one of two possible formats:
Refer to the wiki page about <a href="http://www.mrpt.org/Rawlog_Format">rawlog files.
See also the application RawLogViewer for the GUI program that visualizes and manages rawlogs.
This class also publishes a static helper method for loading rawlog files in format #1: see CRawlog::readActionObservationPair
There is a field for comments and blocks of parameters (in ini-like format) accessible through getCommentText and setCommentText (introduced in MRPT 0.6.4). When serialized to a rawlog file, the comments are saved as an additional observation of the type CObservationComments at the beginning of the file, but this observation does not appear after loading for clarity.
#include <mrpt/obs/CRawlog.h>
Classes | |
class | const_iterator |
A normal iterator, plus the extra method "getType" to determine the type of each entry in the sequence. More... | |
class | iterator |
A normal iterator, plus the extra method "getType" to determine the type of each entry in the sequence. More... | |
Public Types | |
enum | TEntryType { etSensoryFrame = 0, etActionCollection, etObservation, etOther } |
The type of each entry in a rawlog. More... | |
Public Member Functions | |
CRawlog ()=default | |
virtual | ~CRawlog () override=default |
void | getCommentText (std::string &t) const |
Returns the block of comment text for the rawlog. More... | |
std::string | getCommentText () const |
Returns the block of comment text for the rawlog. More... | |
void | setCommentText (const std::string &t) |
Changes the block of comment text for the rawlog. More... | |
void | getCommentTextAsConfigFile (mrpt::config::CConfigFileMemory &memCfg) const |
Saves the block of comment text for the rawlog into the passed config file object. More... | |
void | clear () |
Clear the sequence of actions/observations. More... | |
void | insert (CAction &action) |
Add an action to the sequence: a collection of just one element is created. More... | |
void | insert (CActionCollection &action) |
Add a set of actions to the sequence; the object is duplicated, so the original one can be freed if desired. More... | |
void | insert (CSensoryFrame &observations) |
Add a set of observations to the sequence; the object is duplicated, so the original one can be free if desired. More... | |
void | insert (const mrpt::serialization::CSerializable::Ptr &obj) |
Generic add for a smart pointer to a CSerializable object: More... | |
bool | loadFromRawLogFile (const std::string &fileName, bool non_obs_objects_are_legal=false) |
Load the contents from a file containing one of these possibilities: More... | |
bool | saveToRawLogFile (const std::string &fileName) const |
Saves the contents to a rawlog-file, compatible with RawlogViewer (As the sequence of internal objects). More... | |
size_t | size () const |
Returns the number of actions / observations object in the sequence. More... | |
TEntryType | getType (size_t index) const |
Returns the type of a given element. More... | |
void | remove (size_t index) |
Delete the action or observation stored in the given index. More... | |
void | remove (size_t first_index, size_t last_index) |
Delete the elements stored in the given range of indices (including both the first and last one). More... | |
CActionCollection::Ptr | getAsAction (size_t index) const |
Returns the i'th element in the sequence, as being actions, where index=0 is the first object. More... | |
CSensoryFrame::Ptr | getAsObservations (size_t index) const |
Returns the i'th element in the sequence, as being an action, where index=0 is the first object. More... | |
mrpt::serialization::CSerializable::Ptr | getAsGeneric (size_t index) const |
Returns the i'th element in the sequence, being its class whatever. More... | |
CObservation::Ptr | getAsObservation (size_t index) const |
Returns the i'th element in the sequence, as being an observation, where index=0 is the first object. More... | |
template<class T > | |
T::ConstPtr | asObservation (size_t index) const |
Get the i'th observation as an observation of the given type. More... | |
template<class T > | |
T::Ptr | asObservation (size_t index) |
const_iterator | begin () const |
iterator | begin () |
const_iterator | end () const |
iterator | end () |
iterator | erase (const iterator &it) |
void | findObservationsByClassInRange (mrpt::system::TTimeStamp time_start, mrpt::system::TTimeStamp time_end, const mrpt::rtti::TRuntimeClassId *class_type, TListTimeAndObservations &out_found, size_t guess_start_position=0) const |
Returns the sub-set of observations of a given class whose time-stamp t fulfills time_start <= t < time_end. More... | |
void | swap (CRawlog &obj) |
Efficiently swap the contents of two existing objects. More... | |
bool | getActionObservationPair (CActionCollection::Ptr &action, CSensoryFrame::Ptr &observations, size_t &rawlogEntry) const |
Gets the next consecutive pair action / observation from the rawlog loaded into this object. More... | |
virtual mxArray * | writeToMatlab () const |
Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class. More... | |
RTTI classes and functions for polymorphic hierarchies | |
mrpt::rtti::CObject::Ptr | duplicateGetSmartPtr () const |
Makes a deep copy of the object and returns a smart pointer to it. More... | |
Static Public Member Functions | |
static bool | readActionObservationPair (mrpt::serialization::CArchive &inStream, CActionCollection::Ptr &action, CSensoryFrame::Ptr &observations, size_t &rawlogEntry) |
Reads a consecutive pair action / observation from the rawlog opened at some input stream. More... | |
static bool | getActionObservationPairOrObservation (mrpt::serialization::CArchive &inStream, CActionCollection::Ptr &action, CSensoryFrame::Ptr &observations, CObservation::Ptr &observation, size_t &rawlogEntry) |
Reads a consecutive pair action/sensory_frame OR an observation, depending of the rawlog format, from the rawlog opened at some input stream. More... | |
static std::string | detectImagesDirectory (const std::string &rawlogFilename) |
Tries to auto-detect the external-images directory of the given rawlog file. More... | |
Protected Member Functions | |
CSerializable virtual methods | |
uint8_t | serializeGetVersion () const override |
Must return the current versioning number of the object. More... | |
void | serializeTo (mrpt::serialization::CArchive &out) const override |
Pure virtual method for writing (serializing) to an abstract archive. More... | |
void | serializeFrom (mrpt::serialization::CArchive &in, uint8_t serial_version) override |
Pure virtual method for reading (deserializing) from an abstract archive. More... | |
CSerializable virtual methods | |
virtual void | serializeTo (CSchemeArchiveBase &out) const |
Virtual method for writing (serializing) to an abstract schema based archive. More... | |
virtual void | serializeFrom (CSchemeArchiveBase &in) |
Virtual method for reading (deserializing) from an abstract schema based archive. More... | |
Private Types | |
using | TListObjects = std::vector< mrpt::serialization::CSerializable::Ptr > |
Private Attributes | |
TListObjects | m_seqOfActObs |
The list where the objects really are in. More... | |
CObservationComment | m_commentTexts |
Comments of the rawlog. More... | |
RTTI stuff | |
using | Ptr = std::shared_ptr< mrpt::obs ::CRawlog > |
using | ConstPtr = std::shared_ptr< const mrpt::obs ::CRawlog > |
using | UniquePtr = std::unique_ptr< mrpt::obs ::CRawlog > |
using | ConstUniquePtr = std::unique_ptr< const mrpt::obs ::CRawlog > |
static const mrpt::rtti::TRuntimeClassId | runtimeClassId |
static constexpr const char * | className = "mrpt::obs" "::" "CRawlog" |
static const mrpt::rtti::TRuntimeClassId * | _GetBaseClass () |
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 override |
Returns information about the class of an object in runtime. More... | |
virtual mrpt::rtti::CObject * | clone () const override |
Returns a deep copy (clone) of the object, indepently of its class. More... | |
using mrpt::obs::CRawlog::ConstPtr = std::shared_ptr<const mrpt::obs :: CRawlog > |
using mrpt::obs::CRawlog::ConstUniquePtr = std::unique_ptr<const mrpt::obs :: CRawlog > |
using mrpt::obs::CRawlog::Ptr = std::shared_ptr< mrpt::obs :: CRawlog > |
|
private |
using mrpt::obs::CRawlog::UniquePtr = std::unique_ptr< mrpt::obs :: CRawlog > |
The type of each entry in a rawlog.
Enumerator | |
---|---|
etSensoryFrame | |
etActionCollection | |
etObservation | |
etOther |
|
default |
|
overridevirtualdefault |
|
staticprotected |
|
inline |
Get the i'th observation as an observation of the given type.
std::exception | If index is out of bounds, or type not compatible. |
Definition at line 208 of file CRawlog.h.
References ASSERTMSG_, getAsObservation(), MRPT_END, and MRPT_START.
Referenced by TEST().
|
inline |
Definition at line 218 of file CRawlog.h.
References ASSERTMSG_, getAsObservation(), MRPT_END, and MRPT_START.
|
inline |
Definition at line 336 of file CRawlog.h.
References m_seqOfActObs.
|
inline |
Definition at line 337 of file CRawlog.h.
References m_seqOfActObs.
void CRawlog::clear | ( | ) |
Clear the sequence of actions/observations.
Smart pointers to objects previously in the rawlog will remain being valid.
Definition at line 28 of file CRawlog.cpp.
Referenced by mrpt::detectors::CDetectorDoorCrossing::clear().
|
overridevirtual |
Returns a deep copy (clone) of the object, indepently of its class.
Implements mrpt::rtti::CObject.
|
inlinestatic |
|
inlinestatic |
|
static |
|
inlinestatic |
|
static |
Tries to auto-detect the external-images directory of the given rawlog file.
This searches for the existence of the directories:
The results from this function should be written into mrpt::img::CImage::getImagesPathBase() to enable automatic loading of extenrnally-stored images in rawlogs.
Definition at line 534 of file CRawlog.cpp.
References mrpt::system::extractFileDirectory(), mrpt::system::extractFileName(), and mrpt::system::fileExists().
|
inlineinherited |
Makes a deep copy of the object and returns a smart pointer to it.
Definition at line 204 of file CObject.h.
References mrpt::rtti::CObject::clone().
Referenced by insert().
|
inline |
Definition at line 338 of file CRawlog.h.
References m_seqOfActObs.
|
inline |
Definition at line 339 of file CRawlog.h.
References m_seqOfActObs.
Definition at line 340 of file CRawlog.h.
References mrpt::obs::CRawlog::iterator::erase(), and m_seqOfActObs.
void CRawlog::findObservationsByClassInRange | ( | mrpt::system::TTimeStamp | time_start, |
mrpt::system::TTimeStamp | time_end, | ||
const mrpt::rtti::TRuntimeClassId * | class_type, | ||
TListTimeAndObservations & | out_found, | ||
size_t | guess_start_position = 0 |
||
) | const |
Returns the sub-set of observations of a given class whose time-stamp t fulfills time_start <= t < time_end.
This method requires the timestamps of the sensors to be in strict ascending order (which should be the normal situation). Otherwise, the output is undeterminate.
Definition at line 411 of file CRawlog.cpp.
References ASSERT_, CLASS_ID, mrpt::math::distance(), INVALID_TIMESTAMP, MRPT_END, MRPT_START, and THROW_EXCEPTION.
bool CRawlog::getActionObservationPair | ( | CActionCollection::Ptr & | action, |
CSensoryFrame::Ptr & | observations, | ||
size_t & | rawlogEntry | ||
) | const |
Gets the next consecutive pair action / observation from the rawlog loaded into this object.
Previous contents of action and observations are discarded (using stlplus::smart_ptr::reset), and at exit they contain the new objects read from the rawlog file. The input/output variable "rawlogEntry" is just a counter of the last rawlog entry read, for logging or monitoring purposes.
Definition at line 492 of file CRawlog.cpp.
References mrpt::exception_to_str().
Referenced by run_test_pf_localization().
|
static |
Reads a consecutive pair action/sensory_frame OR an observation, depending of the rawlog format, from the rawlog opened at some input stream.
Previous contents of action and observations are discarded (using stlplus::smart_ptr::reset), and at exit they contain the new objects read from the rawlog file.
At return, one of this will happen:
The input/output variable "rawlogEntry" is just a counter of the last rawlog entry read, for logging or monitoring purposes.
Definition at line 349 of file CRawlog.cpp.
References CLASS_ID, mrpt::exception_to_str(), IS_CLASS, and IS_DERIVED.
Referenced by mrpt::apps::DataSourceRawlog::impl_get_next_observations().
CActionCollection::Ptr CRawlog::getAsAction | ( | size_t | index | ) | const |
Returns the i'th element in the sequence, as being actions, where index=0 is the first object.
If it is not a CActionCollection, it throws an exception. Do neighter modify nor delete the returned pointer.
std::exception | If index is out of bounds |
Definition at line 65 of file CRawlog.cpp.
References CLASS_ID, MRPT_END, MRPT_START, THROW_EXCEPTION, and THROW_EXCEPTION_FMT.
Referenced by mrpt::detectors::CDetectorDoorCrossing::process().
CSerializable::Ptr CRawlog::getAsGeneric | ( | size_t | index | ) | const |
Returns the i'th element in the sequence, being its class whatever.
std::exception | If index is out of bounds |
Definition at line 97 of file CRawlog.cpp.
References MRPT_END, MRPT_START, and THROW_EXCEPTION.
CObservation::Ptr CRawlog::getAsObservation | ( | size_t | index | ) | const |
Returns the i'th element in the sequence, as being an observation, where index=0 is the first object.
If it is not an CObservation, it throws an exception. Do neighter modify nor delete the returned pointer. This is the proper method to obtain the objects stored in a "only observations"-rawlog file (named "format #2" above.
std::exception | If index is out of bounds |
Definition at line 81 of file CRawlog.cpp.
References CLASS_ID, MRPT_END, MRPT_START, THROW_EXCEPTION, and THROW_EXCEPTION_FMT.
Referenced by asObservation(), and mrpt::topography::path_from_rtk_gps().
CSensoryFrame::Ptr CRawlog::getAsObservations | ( | size_t | index | ) | const |
Returns the i'th element in the sequence, as being an action, where index=0 is the first object.
If it is not an CSensoryFrame, it throws an exception. Do neighter modify nor delete the returned pointer.
std::exception | If index is out of bounds |
Definition at line 125 of file CRawlog.cpp.
References CLASS_ID, MRPT_END, MRPT_START, THROW_EXCEPTION, and THROW_EXCEPTION_FMT.
Referenced by mrpt::detectors::CDetectorDoorCrossing::process(), and TEST().
|
inlinestatic |
void CRawlog::getCommentText | ( | std::string & | t | ) | const |
Returns the block of comment text for the rawlog.
Definition at line 525 of file CRawlog.cpp.
std::string CRawlog::getCommentText | ( | ) | const |
Returns the block of comment text for the rawlog.
Definition at line 526 of file CRawlog.cpp.
void CRawlog::getCommentTextAsConfigFile | ( | mrpt::config::CConfigFileMemory & | memCfg | ) | const |
Saves the block of comment text for the rawlog into the passed config file object.
Definition at line 527 of file CRawlog.cpp.
References mrpt::config::CConfigFileMemory::setContent().
Referenced by mrpt::topography::path_from_rtk_gps().
|
overridevirtual |
Returns information about the class of an object in runtime.
Reimplemented from mrpt::serialization::CSerializable.
|
static |
CRawlog::TEntryType CRawlog::getType | ( | size_t | index | ) | const |
Returns the type of a given element.
Definition at line 106 of file CRawlog.cpp.
References CLASS_ID, MRPT_END, MRPT_START, and THROW_EXCEPTION.
Referenced by mrpt::topography::path_from_rtk_gps().
void CRawlog::insert | ( | CAction & | action | ) |
Add an action to the sequence: a collection of just one element is created.
The object is duplicated, so the original one can be freed if desired.
Definition at line 57 of file CRawlog.cpp.
Referenced by mrpt::detectors::CDetectorDoorCrossing::process().
void CRawlog::insert | ( | CActionCollection & | action | ) |
Add a set of actions to the sequence; the object is duplicated, so the original one can be freed if desired.
Definition at line 40 of file CRawlog.cpp.
References mrpt::rtti::CObject::duplicateGetSmartPtr().
void CRawlog::insert | ( | CSensoryFrame & | observations | ) |
Add a set of observations to the sequence; the object is duplicated, so the original one can be free if desired.
Definition at line 34 of file CRawlog.cpp.
References mrpt::rtti::CObject::duplicateGetSmartPtr().
void CRawlog::insert | ( | const mrpt::serialization::CSerializable::Ptr & | obj | ) |
Generic add for a smart pointer to a CSerializable object:
Definition at line 45 of file CRawlog.cpp.
References IS_CLASS.
bool CRawlog::loadFromRawLogFile | ( | const std::string & | fileName, |
bool | non_obs_objects_are_legal = false |
||
) |
Load the contents from a file containing one of these possibilities:
CSensoryFrame
/CActionCollection
or CObservation*
objects). In this case the method stops reading on EOF of an unrecogniced class name.non_obs_objects_are_legal
is true, any CSerializable
object is allowed in the log file. Otherwise, the read stops on classes different from the ones listed in the item above. Definition at line 166 of file CRawlog.cpp.
References mrpt::serialization::archiveFrom(), CLASS_ID, mrpt::containers::clear(), mrpt::exception_to_str(), IS_CLASS, and mrpt::io::CFileGZInputStream::open().
Referenced by run_test_pf_localization(), and TEST().
|
static |
Reads a consecutive pair action / observation from the rawlog opened at some input stream.
Previous contents of action and observations are discarded (using stlplus::smart_ptr::reset), and at exit they contain the new objects read from the rawlog file. The input/output variable "rawlogEntry" is just a counter of the last rawlog entry read, for logging or monitoring purposes.
Definition at line 290 of file CRawlog.cpp.
References CLASS_ID, and mrpt::exception_to_str().
void CRawlog::remove | ( | size_t | index | ) |
Delete the action or observation stored in the given index.
std::exception | If index is out of bounds |
Definition at line 246 of file CRawlog.cpp.
References MRPT_END, MRPT_START, and THROW_EXCEPTION.
Referenced by mrpt::detectors::CDetectorDoorCrossing::process().
void CRawlog::remove | ( | size_t | first_index, |
size_t | last_index | ||
) |
Delete the elements stored in the given range of indices (including both the first and last one).
std::exception | If any index is out of bounds |
Definition at line 254 of file CRawlog.cpp.
References MRPT_END, MRPT_START, and THROW_EXCEPTION.
bool CRawlog::saveToRawLogFile | ( | const std::string & | fileName | ) | const |
Saves the contents to a rawlog-file, compatible with RawlogViewer (As the sequence of internal objects).
The file is saved with gz-commpressed if MRPT has gz-streams.
Definition at line 266 of file CRawlog.cpp.
References mrpt::serialization::archiveFrom(), and mrpt::exception_to_str().
|
overrideprotectedvirtual |
Pure virtual method for reading (deserializing) from an abstract archive.
Users don't call this method directly. Instead, use stream >> object;
.
in | The input binary stream where the object data must read from. |
version | The version of the object stored in the stream: use this version number in your code to know how to read the incoming data. |
std::exception | On any I/O error |
Implements mrpt::serialization::CSerializable.
Definition at line 148 of file CRawlog.cpp.
References mrpt::containers::clear(), MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION, mrpt::serialization::CArchive::ReadAs(), and mrpt::serialization::CArchive::ReadObject().
|
inlineprotectedvirtualinherited |
Virtual method for reading (deserializing) from an abstract schema based archive.
Definition at line 74 of file CSerializable.h.
References mrpt::serialization::CSerializable::GetRuntimeClass(), and THROW_EXCEPTION.
|
overrideprotectedvirtual |
Must return the current versioning number of the object.
Start in zero for new classes, and increments each time there is a change in the stored format.
Implements mrpt::serialization::CSerializable.
Definition at line 140 of file CRawlog.cpp.
|
inlineprotectedvirtualinherited |
Virtual method for writing (serializing) to an abstract schema based archive.
Definition at line 64 of file CSerializable.h.
References mrpt::serialization::CSerializable::GetRuntimeClass(), and THROW_EXCEPTION.
|
overrideprotectedvirtual |
Pure virtual method for writing (serializing) to an abstract archive.
Users don't call this method directly. Instead, use stream << object;
.
std::exception | On any I/O error |
Implements mrpt::serialization::CSerializable.
Definition at line 141 of file CRawlog.cpp.
References out.
void CRawlog::setCommentText | ( | const std::string & | t | ) |
Changes the block of comment text for the rawlog.
Definition at line 533 of file CRawlog.cpp.
size_t CRawlog::size | ( | ) | const |
Returns the number of actions / observations object in the sequence.
Definition at line 64 of file CRawlog.cpp.
Referenced by mrpt::topography::path_from_rtk_gps(), mrpt::detectors::CDetectorDoorCrossing::process(), run_test_pf_localization(), and TEST().
void CRawlog::swap | ( | CRawlog & | obj | ) |
Efficiently swap the contents of two existing objects.
Definition at line 283 of file CRawlog.cpp.
References m_commentTexts, and m_seqOfActObs.
|
inlinevirtualinherited |
Introduces a pure virtual method responsible for writing to a mxArray
Matlab object, typically a MATLAB struct
whose contents are documented in each derived class.
mxArray
(caller is responsible of memory freeing) or nullptr is class does not support conversion to MATLAB. Definition at line 90 of file CSerializable.h.
|
static |
|
private |
|
private |
|
staticprotected |
Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020 |