41 m_seqOfActObs.clear();
42 m_commentTexts.text.clear();
55 m_seqOfActObs.push_back( action );
59 m_seqOfActObs.push_back( observations );
62 m_seqOfActObs.push_back(
obj );
69 CObservationCommentPtr o = CObservationCommentPtr(observation);
73 m_seqOfActObs.push_back( observation );
79 temp->insert( action );
80 m_seqOfActObs.push_back( temp );
85 return m_seqOfActObs.size();
92 if (
index >=m_seqOfActObs.size())
95 CSerializablePtr
obj = m_seqOfActObs[
index];
98 return CActionCollectionPtr(
obj );
107 if (
index >=m_seqOfActObs.size())
110 CSerializablePtr
obj = m_seqOfActObs[
index];
113 return CObservationPtr(
obj );
121 if (
index >=m_seqOfActObs.size())
124 return m_seqOfActObs[
index];
131 if (
index >=m_seqOfActObs.size())
134 const CSerializablePtr &
obj = m_seqOfActObs[
index];
137 return etObservation;
139 return etActionCollection;
141 return etSensoryFrame;
150 if (
index >=m_seqOfActObs.size())
153 CSerializablePtr
obj = m_seqOfActObs[
index];
156 return CSensoryFramePtr(
obj );
168 n =
static_cast<uint32_t>( m_seqOfActObs.size() );
171 out << m_seqOfActObs[i];
173 out << m_commentTexts;
192 m_seqOfActObs.resize(
n);
194 m_seqOfActObs[i] = CSerializablePtr(
in.ReadObject() );
196 in >> m_commentTexts;
213 bool keepReading =
true;
216 CSerializablePtr newObj;
220 bool add_obj =
false;
225 CRawlogPtr ao = CRawlogPtr( newObj );
232 CObservationCommentPtr o = CObservationCommentPtr(newObj);
248 if (non_obs_objects_are_legal) {
255 m_seqOfActObs.push_back( newObj );
261 catch (std::exception &e)
263 std::cerr << e.what() << std::endl;
277 if (
index >=m_seqOfActObs.size())
279 m_seqOfActObs.erase( m_seqOfActObs.begin()+
index );
286 if (first_index >=m_seqOfActObs.size() || last_index>=m_seqOfActObs.size() )
288 m_seqOfActObs.erase( m_seqOfActObs.begin()+first_index, m_seqOfActObs.begin()+last_index+1 );
297 if (!m_commentTexts.text.empty())
299 for (
size_t i=0;i<m_seqOfActObs.size();i++)
300 f << *m_seqOfActObs[i];
312 if (
this == &
obj)
return;
314 m_commentTexts =
obj.m_commentTexts;
315 m_seqOfActObs =
obj.m_seqOfActObs;
316 obj.m_seqOfActObs.clear();
317 obj.m_commentTexts.text.clear();
323 if (
this == &
obj)
return;
324 m_seqOfActObs.swap(
obj.m_seqOfActObs);
325 std::swap(m_commentTexts,
obj.m_commentTexts);
330 CActionCollectionPtr &action,
331 CSensoryFramePtr &observations,
332 size_t & rawlogEntry )
337 action.clear_unique();
340 CSerializablePtr
obj;
344 action = CActionCollectionPtr(
obj );
354 observations.clear_unique();
355 while (!observations)
357 CSerializablePtr
obj;
361 observations = CSensoryFramePtr(
obj);
375 catch ( std::exception &e)
377 std::cerr <<
"[CRawlog::readActionObservationPair] Found exception:" << std::endl << e.what() << std::endl;
382 std::cerr <<
"Untyped exception reading rawlog file!!" << std::endl;
392 CActionCollectionPtr &action,
393 CSensoryFramePtr &observations,
394 CObservationPtr &observation,
395 size_t & rawlogEntry )
400 observations.clear_unique();
401 observation.clear_unique();
402 action.clear_unique();
405 CSerializablePtr
obj;
409 action = CActionCollectionPtr(
obj );
413 observation = CObservationPtr(
obj);
423 observations.clear_unique();
424 while (!observations)
426 CSerializablePtr
obj;
430 observations = CSensoryFramePtr(
obj);
440 catch ( std::exception &e)
442 std::cerr <<
"[CRawlog::readActionObservationPair] Found exception:" << std::endl << e.what() << std::endl;
447 std::cerr <<
"Untyped exception reading rawlog file!!" << std::endl;
457 size_t guess_start_position
465 if (m_seqOfActObs.empty())
return;
479 std::advance(it,step);
485 CObservationPtr o = CObservationPtr (*it);
486 this_timestamp = o->timestamp;
490 THROW_EXCEPTION(
"Element found which is not derived from CObservation");
492 if (this_timestamp < time_start )
508 CObservationPtr o = CObservationPtr (*
first);
509 this_timestamp = o->timestamp;
512 if (this_timestamp<time_end)
514 if (o->GetRuntimeClass()->derivedFrom(class_type))
523 THROW_EXCEPTION(
"Element found which is not derived from CObservation");
532 CActionCollectionPtr &action,
533 CSensoryFramePtr &observations,
534 size_t &rawlogEntry )
const 542 action = getAsAction(rawlogEntry++);
548 observations = getAsObservations(rawlogEntry++);
552 catch ( std::exception &)
558 std::cerr <<
"Untyped exception getting act-obs pair from rawlog!!" << std::endl;
565 t = m_commentTexts.text;
569 return m_commentTexts.text;
579 m_commentTexts.text =
t;
587 return temptative_img_path;
589 return temptative_img_path;
591 return temptative_img_path;
593 return rawlog_path +
"Images";
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
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...
GLuint GLuint GLsizei count
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
static std::string detectImagesDirectory(const std::string &rawlogFilename)
Tries to auto-detect the external-images directory of the given rawlog file.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
The virtual base class which provides a unified interface for all persistent objects in MRPT...
#define THROW_EXCEPTION(msg)
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
bool BASE_IMPEXP fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
std::multimap< mrpt::system::TTimeStamp, CObservationPtr > TListTimeAndObservations
For usage with CRawlog classes.
void addActions(CActionCollection &action)
Add a set of actions to the sequence; the object is duplicated, so the original one can be freed if d...
const Scalar * const_iterator
IMPLEMENTS_SERIALIZABLE(CLogFileRecord_FullEval, CHolonomicLogFileRecord, mrpt::nav) IMPLEMENTS_SERIALIZABLE(CHolonomicFullEval
void addObservations(CSensoryFrame &observations)
Add a set of observations to the sequence; the object is duplicated, so the original one can be free ...
GLsizei GLsizei GLuint * obj
void clear()
Clear the contents of this container.
Declares a class for storing a collection of robot actions.
void addGenericObject(const mrpt::utils::CSerializablePtr &obj)
Generic add for a smart pointer to a CSerializable object:
bool saveToRawLogFile(const std::string &fileName) const
Saves the contents to a rawlog-file, compatible with RawlogViewer (As the sequence of internal object...
This class implements a config file-like interface over a memory-stored string list.
std::string getCommentText() const
Returns the block of comment text for the rawlog.
#define IS_DERIVED(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::utils::CSerializable) is an i...
bool loadFromRawLogFile(const std::string &fileName, bool non_obs_objects_are_legal=false)
Load the contents from a file containing one of these possibilities:
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
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 < ti...
This class stores a rawlog (robotic datasets) in one of two possible formats:
This namespace contains representation of robot actions and observations.
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
void moveFrom(CRawlog &obj)
Efficiently copy the contents from other existing object, and remove the data from the origin (after ...
mrpt::utils::CSerializablePtr getAsGeneric(size_t index) const
Returns the i'th element in the sequence, being its class whatever.
void setCommentText(const std::string &t)
Changes the block of comment text for the rawlog.
static CActionCollectionPtr Create()
static bool readActionObservationPair(mrpt::utils::CStream &inStream, CActionCollectionPtr &action, CSensoryFramePtr &observations, size_t &rawlogEntry)
Reads a consecutive pair action / observation from the rawlog opened at some input stream...
GLsizei const GLchar ** string
Used in mrpt::utils::CStream.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
mrpt::utils::CObjectPtr duplicateGetSmartPtr() const
Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object w...
void remove(size_t index)
Delete the action or observation stored in the given index.
Declares a class for storing a robot action.
#define CLASS_ID(class_name)
Access to runtime class ID for a defined class name.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::pair< mrpt::system::TTimeStamp, CObservationPtr > TTimeObservationPair
For usage with CRawlog classes.
#define CFileGZOutputStream
Saves data to a file and transparently compress the data using the given compression level...
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...
Declares a class that represents any robot's observation.
void addActionsMemoryReference(const CActionCollectionPtr &action)
Add a set of actions to the sequence, using a smart pointer to the object to add. ...
TEntryType
The type of each entry in a rawlog.
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::utils::CSerializable) is of t...
void swap(CRawlog &obj)
Efficiently swap the contents of two existing objects.
static bool getActionObservationPairOrObservation(mrpt::utils::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...
void clear()
Clear the sequence of actions/observations.
TEntryType getType(size_t index) const
Returns the type of a given element.
void addObservationsMemoryReference(const CSensoryFramePtr &observations)
Add a set of observations to the sequence, using a smart pointer to the object to add...
void addAction(CAction &action)
Add an action to the sequence: a collection of just one element is created.
A structure that holds runtime class type information.
bool getActionObservationPair(CActionCollectionPtr &action, CSensoryFramePtr &observations, size_t &rawlogEntry) const
Gets the next consecutive pair action / observation from the rawlog loaded into this object...
std::string BASE_IMPEXP extractFileName(const std::string &filePath)
Extract just the name (without extension) of a filename from a complete path plus name plus extension...
unsigned __int32 uint32_t
size_t size() const
Returns the number of actions / observations object in the sequence.
CActionCollectionPtr getAsAction(size_t index) const
Returns the i'th element in the sequence, as being actions, where index=0 is the first object...
virtual ~CRawlog()
Destructor:
std::string BASE_IMPEXP extractFileDirectory(const std::string &filePath)
Extract the whole path (the directory) of a filename from a complete path plus name plus extension...
void setContent(const utils::CStringList &stringList)
Changes the contents of the virtual "config file".
double BASE_IMPEXP distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
void addObservationMemoryReference(const CObservationPtr &observation)
Add a single observation to the sequence, using a smart pointer to the object to add.
void getCommentTextAsConfigFile(mrpt::utils::CConfigFileMemory &memCfg) const
Saves the block of comment text for the rawlog into the passed config file object.