34 m_seqOfActObs.clear();
35 m_commentTexts.text.clear();
40 m_seqOfActObs.push_back(
41 std::dynamic_pointer_cast<CSerializable>(
47 m_seqOfActObs.push_back(
48 std::dynamic_pointer_cast<CSerializable>(
54 m_seqOfActObs.push_back(action);
60 m_seqOfActObs.push_back(observations);
64 m_seqOfActObs.push_back(
obj);
77 m_seqOfActObs.push_back(observation);
83 mrpt::make_aligned_shared<CActionCollection>();
85 m_seqOfActObs.push_back(temp);
98 return std::dynamic_pointer_cast<CActionCollection>(
obj);
101 "Element at index %i is not a CActionCollection", (
int)
index);
114 return std::dynamic_pointer_cast<CObservation>(
obj);
117 "Element at index %i is not a CObservation", (
int)
index);
126 return m_seqOfActObs[
index];
138 return etObservation;
140 return etActionCollection;
142 return etSensoryFrame;
157 return std::dynamic_pointer_cast<CSensoryFrame>(
obj);
160 "Element at index %i is not a CSensoryFrame", (
int)
index);
171 n =
static_cast<uint32_t>(m_seqOfActObs.size());
173 for (i = 0; i <
n; i++) out << m_seqOfActObs[i];
175 out << m_commentTexts;
194 m_seqOfActObs.resize(
n);
195 for (i = 0; i <
n; i++)
198 in >> m_commentTexts;
207 const std::string& fileName,
bool non_obs_objects_are_legal)
216 bool keepReading =
true;
223 bool add_obj =
false;
257 if (non_obs_objects_are_legal)
266 if (add_obj) m_seqOfActObs.push_back(newObj);
272 catch (std::exception& e)
274 std::cerr << e.what() << std::endl;
289 m_seqOfActObs.erase(m_seqOfActObs.begin() +
index);
296 if (first_index >= m_seqOfActObs.size() ||
297 last_index >= m_seqOfActObs.size())
300 m_seqOfActObs.begin() + first_index,
301 m_seqOfActObs.begin() + last_index + 1);
310 if (!m_commentTexts.text.empty()) f << m_commentTexts;
311 for (
size_t i = 0; i < m_seqOfActObs.size(); i++)
312 f << *m_seqOfActObs[i];
324 if (
this == &
obj)
return;
326 m_commentTexts =
obj.m_commentTexts;
327 m_seqOfActObs =
obj.m_seqOfActObs;
328 obj.m_seqOfActObs.clear();
329 obj.m_commentTexts.text.clear();
335 if (
this == &
obj)
return;
336 m_seqOfActObs.swap(
obj.m_seqOfActObs);
337 std::swap(m_commentTexts,
obj.m_commentTexts);
364 observations.reset();
365 while (!observations)
385 catch (std::exception& e)
387 std::cerr <<
"[CRawlog::readActionObservationPair] Found exception:" 389 << e.what() << std::endl;
394 std::cerr <<
"Untyped exception reading rawlog file!!" << std::endl;
410 observations.reset();
433 observations.reset();
434 while (!observations)
450 catch (std::exception& e)
452 std::cerr <<
"[CRawlog::readActionObservationPair] Found exception:" 454 << e.what() << std::endl;
459 std::cerr <<
"Untyped exception reading rawlog file!!" << std::endl;
474 if (m_seqOfActObs.empty())
return;
488 std::advance(it, step);
501 "Element found which is not derived from CObservation");
503 if (this_timestamp < time_start)
515 while (
first != last)
525 if (this_timestamp < time_end)
527 if (o->GetRuntimeClass()->derivedFrom(class_type))
537 "Element found which is not derived from CObservation");
547 size_t& rawlogEntry)
const 555 action = getAsAction(rawlogEntry++);
561 observations = getAsObservations(rawlogEntry++);
565 catch (std::exception&)
571 std::cerr <<
"Untyped exception getting act-obs pair from rawlog!!" 592 return temptative_img_path;
595 temptative_img_path =
597 return temptative_img_path;
600 temptative_img_path =
602 return temptative_img_path;
604 return rawlog_path +
"Images";
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
GLuint GLuint GLsizei count
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
std::shared_ptr< CRawlog > Ptr
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...
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 IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
#define THROW_EXCEPTION(msg)
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
void addObservationsMemoryReference(const CSensoryFrame::Ptr &observations)
Add a set of observations to the sequence, using a smart pointer to the object to add...
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
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::CSerializable::Ptr &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...
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...
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...
mrpt::utils::CSerializable::Ptr getAsGeneric(size_t index) const
Returns the i'th element in the sequence, being its class whatever.
#define CLASS_ID(T)
Access to runtime class ID for a defined class name.
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
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...
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
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...
static bool getActionObservationPairOrObservation(mrpt::utils::CStream &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...
This class stores a rawlog (robotic datasets) in one of two possible formats:
This namespace contains representation of robot actions and observations.
std::multimap< mrpt::system::TTimeStamp, CObservation::Ptr > TListTimeAndObservations
For usage with CRawlog classes.
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
std::shared_ptr< CSensoryFrame > Ptr
void moveFrom(CRawlog &obj)
Efficiently copy the contents from other existing object, and remove the data from the origin (after ...
mrpt::utils::CObject::Ptr duplicateGetSmartPtr() const
Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object w...
void setCommentText(const std::string &t)
Changes the block of comment text for the rawlog.
std::shared_ptr< CObservation > Ptr
GLsizei const GLchar ** string
Used in mrpt::utils::CStream.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
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...
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
std::shared_ptr< CSerializable > Ptr
void remove(size_t index)
Delete the action or observation stored in the given index.
Declares a class for storing a robot action.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
void addActionsMemoryReference(const CActionCollection::Ptr &action)
Add a set of actions to the sequence, using a smart pointer to the object to add. ...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
std::shared_ptr< CActionCollection > Ptr
#define CFileGZOutputStream
Saves data to a file and transparently compress the data using the given compression level...
Declares a class that represents any robot's observation.
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.
void clear()
Clear the sequence of actions/observations.
TEntryType getType(size_t index) const
Returns the type of a given element.
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.
std::string 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.
virtual ~CRawlog()
Destructor:
std::string 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 distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
static bool readActionObservationPair(mrpt::utils::CStream &inStream, CActionCollection::Ptr &action, CSensoryFrame::Ptr &observations, size_t &rawlogEntry)
Reads a consecutive pair action / observation from the rawlog opened at some input stream...
std::pair< mrpt::system::TTimeStamp, CObservation::Ptr > TTimeObservationPair
For usage with CRawlog classes.
void getCommentTextAsConfigFile(mrpt::utils::CConfigFileMemory &memCfg) const
Saves the block of comment text for the rawlog into the passed config file object.
void addObservationMemoryReference(const CObservation::Ptr &observation)
Add a single observation to the sequence, using a smart pointer to the object to add.