Main MRPT website > C++ reference
MRPT logo
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes

mrpt::slam::CRawlog Class Reference


Detailed Description

This class stores a rawlog (robotic datasets) in one of two possible formats:

There is a sequence of objects, where each one can be of one type:

Format #2: A sequence of actions and observations. There is a sequence of objects, where each one can be of one type:

Refer to the wiki page about 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 commens 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.

Note:
Since MRPT version 0.5.5, this class also provides a STL container-like interface (see CRawlog::begin, CRawlog::iterator, ...).
The format #2 is supported since MRPT version 0.6.0.
There is a static helper method "detectImagesDirectory" for localizing the external images directory of a rawlog.
See also:
CSensoryFrame, CPose2D, RawLog file format.

Definition at line 72 of file CRawlog.h.

#include <mrpt/slam/CRawlog.h>

Inheritance diagram for mrpt::slam::CRawlog:
Inheritance graph
[legend]

List of all members.

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 }
 

The type of each entry in a rawlog.

More...

Public Member Functions

void getCommentText (std::string &t) const
 Returns the block of comment text for the rawlog.
std::string getCommentText () const
 Returns the block of comment text for the rawlog.
void setCommentText (const std::string &t)
 Changes the block of comment text for the rawlog.
void getCommentTextAsConfigFile (mrpt::utils::CConfigFileMemory &memCfg) const
 Saves the block of comment text for the rawlog into the passed config file object.
 CRawlog ()
 Default constructor.
virtual ~CRawlog ()
 Destructor:
void clear ()
 Clear the sequence of actions/observations, freeing the memory of all the objects in the list.
void clearWithoutDelete ()
 Clear the sequence of actions/observations, without deleting the objects themselves (USE ONLY IF YOU KNOW WHAT YOU DO, NORMALLY YOU'LL CALL "clear" INSTEAD).
void addAction (CAction &action)
 Add an action to the sequence: a collection of just one element is created.
void addActions (CActionCollection &action)
 Add a set of actions to the sequence; the object is duplicated, so the original one can be free if desired.
void addObservations (CSensoryFrame &observations)
 Add a set of observations to the sequence; the object is duplicated, so the original one can be free if desired.
void addActionsMemoryReference (const CActionCollectionPtr &action)
 Add a set of actions to the sequence, using a smart pointer to the object to add.
void addObservationsMemoryReference (const CSensoryFramePtr &observations)
 Add a set of observations to the sequence, using a smart pointer to the object to add.
void addObservationMemoryReference (const CObservationPtr &observation)
 Add a single observation to the sequence, using a smart pointer to the object to add.
bool loadFromRawLogFile (const std::string &fileName)
 Load the contents from a file containing one of these possibilities:

  • A "CRawlog" object.

bool saveToRawLogFile (const std::string &fileName) const
 Saves the contents to a rawlog-file, compatible with RawlogViewer (As the sequence of internal objects).
size_t size () const
 Returns the number of actions / observations object in the sequence.
TEntryType getType (size_t index) const
 Returns the type of a given element.
void remove (size_t index)
 Delete the action or observation stored in the given index.
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).
CActionCollectionPtr getAsAction (size_t index) const
 Returns the i'th element in the sequence, as being actions, where index=0 is the first object.
CSensoryFramePtr getAsObservations (size_t index) const
 Returns the i'th element in the sequence, as being an action, where index=0 is the first object.
CSerializablePtr getAsGeneric (size_t index) const
 Returns the i'th element in the sequence, being its class whatever.
CObservationPtr getAsObservation (size_t index) const
 Returns the i'th element in the sequence, as being an observation, where index=0 is the first object.
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::utils::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.
void moveFrom (CRawlog &obj)
 Efficiently copy the contents from other existing object, and remove the data from the origin (after calling this, the original object will have no actions/observations).
void swap (CRawlog &obj)
 Efficiently swap the contents of two existing objects.
bool getActionObservationPair (CActionCollectionPtr &action, CSensoryFramePtr &observations, size_t &rawlogEntry) const
 Gets the next consecutive pair action / observation from the rawlog loaded into this object.

Static Public Member Functions

static bool readActionObservationPair (CStream &inStream, CActionCollectionPtr &action, CSensoryFramePtr &observations, size_t &rawlogEntry)
 Reads a consecutive pair action / observation from the rawlog opened at some input stream.
static bool getActionObservationPairOrObservation (CStream &inStream, CActionCollectionPtr &action, CSensoryFramePtr &observations, CObservationPtr &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.
static std::string detectImagesDirectory (const std::string &rawlogFilename)
 Tries to auto-detect the external-images directory of the given rawlog file.

Private Types

typedef std::vector
< CSerializablePtr
TListObjects

Private Attributes

TListObjects m_seqOfActObs
 The list where the objects really are in.
CObservationComment m_commentTexts
 Comments of the rawlog.

RTTI stuff



typedef CRawlogPtr SmartPtr
static mrpt::utils::CLASSINIT _init_CRawlog
static mrpt::utils::TRuntimeClassId classCRawlog
static const
mrpt::utils::TRuntimeClassId
classinfo
static const
mrpt::utils::TRuntimeClassId
_GetBaseClass ()
virtual const
mrpt::utils::TRuntimeClassId
GetRuntimeClass () const
 Returns information about the class of an object in runtime.
virtual mrpt::utils::CObjectduplicate () const
 Returns a copy of the object, indepently of its class.
static mrpt::utils::CObjectCreateObject ()
static CRawlogPtr Create ()

Member Typedef Documentation

A typedef for the associated smart pointer

Definition at line 75 of file CRawlog.h.

typedef std::vector<CSerializablePtr> mrpt::slam::CRawlog::TListObjects [private]

Definition at line 78 of file CRawlog.h.


Member Enumeration Documentation

The type of each entry in a rawlog.

See also:
CRawlog::getType
Enumerator:
etSensoryFrame 
etActionCollection 
etObservation 

Definition at line 92 of file CRawlog.h.


Constructor & Destructor Documentation

mrpt::slam::CRawlog::CRawlog (  ) 

Default constructor.

virtual mrpt::slam::CRawlog::~CRawlog (  )  [virtual]

Destructor:


Member Function Documentation

static const mrpt::utils::TRuntimeClassId* mrpt::slam::CRawlog::_GetBaseClass (  )  [static, protected]

Reimplemented from mrpt::utils::CSerializable.

void mrpt::slam::CRawlog::addAction ( 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 free if desired.

void mrpt::slam::CRawlog::addActions ( CActionCollection action  ) 

Add a set of actions to the sequence; the object is duplicated, so the original one can be free if desired.

See also:
addObservations, addActionsMemoryReference
void mrpt::slam::CRawlog::addActionsMemoryReference ( const CActionCollectionPtr action  ) 

Add a set of actions to the sequence, using a smart pointer to the object to add.

See also:
addActions, addObservationsMemoryReference, addObservationMemoryReference
void mrpt::slam::CRawlog::addObservationMemoryReference ( const CObservationPtr observation  ) 

Add a single observation to the sequence, using a smart pointer to the object to add.

See also:
addObservations, addActionsMemoryReference
void mrpt::slam::CRawlog::addObservations ( CSensoryFrame observations  ) 

Add a set of observations to the sequence; the object is duplicated, so the original one can be free if desired.

See also:
addActions, addObservationsMemoryReference
void mrpt::slam::CRawlog::addObservationsMemoryReference ( const CSensoryFramePtr observations  ) 

Add a set of observations to the sequence, using a smart pointer to the object to add.

See also:
addObservations, addActionsMemoryReference, addObservationMemoryReference
const_iterator mrpt::slam::CRawlog::begin (  )  const [inline]

Definition at line 272 of file CRawlog.h.

iterator mrpt::slam::CRawlog::begin (  )  [inline]

Definition at line 273 of file CRawlog.h.

void mrpt::slam::CRawlog::clear (  ) 

Clear the sequence of actions/observations, freeing the memory of all the objects in the list.

void mrpt::slam::CRawlog::clearWithoutDelete (  ) 

Clear the sequence of actions/observations, without deleting the objects themselves (USE ONLY IF YOU KNOW WHAT YOU DO, NORMALLY YOU'LL CALL "clear" INSTEAD).

static CRawlogPtr mrpt::slam::CRawlog::Create (  )  [static]
static mrpt::utils::CObject* mrpt::slam::CRawlog::CreateObject (  )  [static]
static std::string mrpt::slam::CRawlog::detectImagesDirectory ( const std::string &  rawlogFilename  )  [static]

Tries to auto-detect the external-images directory of the given rawlog file.

This searches for the existence of the directories:

  • "<rawlog_file_path>/<rawlog_filename>_Images"
  • "<rawlog_file_path>/<rawlog_filename>_images"
  • "<rawlog_file_path>/<rawlog_filename>_IMAGES"
  • "<rawlog_file_path>/Images" (This one is returned if none of the choices actually exists).

The results from this function should be written into mrpt::utils::CImage::IMAGES_PATH_BASE to enable automatic loading of extenrnally-stored images in rawlogs.

virtual mrpt::utils::CObject* mrpt::slam::CRawlog::duplicate (  )  const [virtual]

Returns a copy of the object, indepently of its class.

Implements mrpt::utils::CObject.

const_iterator mrpt::slam::CRawlog::end (  )  const [inline]

Definition at line 274 of file CRawlog.h.

iterator mrpt::slam::CRawlog::end (  )  [inline]

Definition at line 275 of file CRawlog.h.

iterator mrpt::slam::CRawlog::erase ( const iterator it  )  [inline]

Definition at line 277 of file CRawlog.h.

void mrpt::slam::CRawlog::findObservationsByClassInRange ( mrpt::system::TTimeStamp  time_start,
mrpt::system::TTimeStamp  time_end,
const mrpt::utils::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.

See also:
findClosestObservationsByClass
bool mrpt::slam::CRawlog::getActionObservationPair ( CActionCollectionPtr action,
CSensoryFramePtr 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::clear_unique), 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.

Returns:
false if there was some error, true otherwise.
See also:
readActionObservationPair
static bool mrpt::slam::CRawlog::getActionObservationPairOrObservation ( CStream inStream,
CActionCollectionPtr action,
CSensoryFramePtr observations,
CObservationPtr observation,
size_t &  rawlogEntry 
) [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::clear_unique), and at exit they contain the new objects read from the rawlog file.

At return, one of this will happen:

  • action/observations contain objects (i.e. action.present() evaluates as true).
  • observation contains an object (i.e. observation.present() evaluates as true).

The input/output variable "rawlogEntry" is just a counter of the last rawlog entry read, for logging or monitoring purposes.

Returns:
false if there was some error, true otherwise.
See also:
getActionObservationPair
CActionCollectionPtr mrpt::slam::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.

See also:
size, isAction, getAsObservations, getAsObservation
Exceptions:
std::exception If index is out of bounds
CSerializablePtr mrpt::slam::CRawlog::getAsGeneric ( size_t  index  )  const

Returns the i'th element in the sequence, being its class whatever.

See also:
size, isAction, getAsAction, getAsObservations
Exceptions:
std::exception If index is out of bounds
CObservationPtr mrpt::slam::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.

See also:
size, isAction, getAsAction
Exceptions:
std::exception If index is out of bounds
CSensoryFramePtr mrpt::slam::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.

See also:
size, isAction, getAsAction, getAsObservation
Exceptions:
std::exception If index is out of bounds
void mrpt::slam::CRawlog::getCommentText ( std::string &  t  )  const

Returns the block of comment text for the rawlog.

std::string mrpt::slam::CRawlog::getCommentText (  )  const

Returns the block of comment text for the rawlog.

void mrpt::slam::CRawlog::getCommentTextAsConfigFile ( mrpt::utils::CConfigFileMemory memCfg  )  const

Saves the block of comment text for the rawlog into the passed config file object.

virtual const mrpt::utils::TRuntimeClassId* mrpt::slam::CRawlog::GetRuntimeClass (  )  const [virtual]

Returns information about the class of an object in runtime.

Reimplemented from mrpt::utils::CSerializable.

TEntryType mrpt::slam::CRawlog::getType ( size_t  index  )  const

Returns the type of a given element.

See also:
isAction, isObservation
bool mrpt::slam::CRawlog::loadFromRawLogFile ( const std::string &  fileName  ) 

Load the contents from a file containing one of these possibilities:

  • A "CRawlog" object.

  • Directly the sequence of objects (pairs CSensoryFrame/CActionCollection or CObservation* objects). In this case the method stops reading on EOF of an unrecogniced class name.
    Returns:
    It returns false if the file does not exists.
void mrpt::slam::CRawlog::moveFrom ( CRawlog obj  ) 

Efficiently copy the contents from other existing object, and remove the data from the origin (after calling this, the original object will have no actions/observations).

static bool mrpt::slam::CRawlog::readActionObservationPair ( CStream inStream,
CActionCollectionPtr action,
CSensoryFramePtr observations,
size_t &  rawlogEntry 
) [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::clear_unique), 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.

Returns:
false if there was some error, true otherwise.
See also:
getActionObservationPair, getActionObservationPairOrObservation
void mrpt::slam::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).

Exceptions:
std::exception If any index is out of bounds
void mrpt::slam::CRawlog::remove ( size_t  index  ) 

Delete the action or observation stored in the given index.

Exceptions:
std::exception If index is out of bounds
bool mrpt::slam::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.

Returns:
It returns false if the file does not exists.
void mrpt::slam::CRawlog::setCommentText ( const std::string &  t  ) 

Changes the block of comment text for the rawlog.

size_t mrpt::slam::CRawlog::size (  )  const

Returns the number of actions / observations object in the sequence.

void mrpt::slam::CRawlog::swap ( CRawlog obj  ) 

Efficiently swap the contents of two existing objects.


Member Data Documentation

Definition at line 75 of file CRawlog.h.

Definition at line 75 of file CRawlog.h.

Definition at line 75 of file CRawlog.h.

Comments of the rawlog.

Definition at line 81 of file CRawlog.h.

The list where the objects really are in.

Definition at line 79 of file CRawlog.h.




Page generated by Doxygen 1.7.1 for MRPT 0.9.4 SVN: at Mon Jan 10 23:33:19 UTC 2011