31 CRawlog::~CRawlog() {
clear(); }
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);
57 void CRawlog::addObservationsMemoryReference(
60 m_seqOfActObs.push_back(observations);
64 m_seqOfActObs.push_back(
obj);
67 void CRawlog::addObservationMemoryReference(
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);
164 uint8_t CRawlog::serializeGetVersion()
const {
return 1; }
168 for (
const auto&
a : m_seqOfActObs) out <<
a;
169 out << m_commentTexts;
181 for (
auto&
a : m_seqOfActObs)
a =
in.ReadObject();
182 in >> m_commentTexts;
190 bool CRawlog::loadFromRawLogFile(
191 const std::string& fileName,
bool non_obs_objects_are_legal)
201 bool keepReading =
true;
208 bool add_obj =
false;
242 if (non_obs_objects_are_legal)
251 if (add_obj) m_seqOfActObs.push_back(newObj);
257 catch (std::exception& e)
259 std::cerr << e.what() << std::endl;
274 m_seqOfActObs.erase(m_seqOfActObs.begin() +
index);
278 void CRawlog::remove(
size_t first_index,
size_t last_index)
281 if (first_index >= m_seqOfActObs.size() ||
282 last_index >= m_seqOfActObs.size())
285 m_seqOfActObs.begin() + first_index,
286 m_seqOfActObs.begin() + last_index + 1);
296 if (!m_commentTexts.text.empty()) f << m_commentTexts;
297 for (
size_t i = 0; i < m_seqOfActObs.size(); i++)
298 f << *m_seqOfActObs[i];
309 if (
this == &
obj)
return;
310 m_seqOfActObs.swap(
obj.m_seqOfActObs);
311 std::swap(m_commentTexts,
obj.m_commentTexts);
314 bool CRawlog::readActionObservationPair(
338 observations.reset();
339 while (!observations)
359 catch (std::exception& e)
361 std::cerr <<
"[CRawlog::readActionObservationPair] Found exception:" 363 << e.what() << std::endl;
368 std::cerr <<
"Untyped exception reading rawlog file!!" << std::endl;
373 bool CRawlog::getActionObservationPairOrObservation(
381 observations.reset();
404 observations.reset();
405 while (!observations)
421 catch (std::exception& e)
423 std::cerr <<
"[CRawlog::readActionObservationPair] Found exception:" 425 << e.what() << std::endl;
430 std::cerr <<
"Untyped exception reading rawlog file!!" << std::endl;
435 void CRawlog::findObservationsByClassInRange(
445 if (m_seqOfActObs.empty())
return;
459 std::advance(it, step);
467 this_timestamp = o->timestamp;
472 "Element found which is not derived from CObservation");
474 if (this_timestamp < time_start)
486 while (
first != last)
493 this_timestamp = o->timestamp;
496 if (this_timestamp < time_end)
498 if (o->GetRuntimeClass()->derivedFrom(class_type))
508 "Element found which is not derived from CObservation");
516 bool CRawlog::getActionObservationPair(
518 size_t& rawlogEntry)
const 522 while (getType(rawlogEntry) != CRawlog::etActionCollection)
526 action = getAsAction(rawlogEntry++);
528 while (getType(rawlogEntry) != CRawlog::etSensoryFrame)
532 observations = getAsObservations(rawlogEntry++);
536 catch (std::exception&)
542 std::cerr <<
"Untyped exception getting act-obs pair from rawlog!!" 548 void CRawlog::getCommentText(
std::string&
t)
const {
t = m_commentTexts.text; }
549 std::string CRawlog::getCommentText()
const {
return m_commentTexts.text; }
550 void CRawlog::getCommentTextAsConfigFile(
556 void CRawlog::setCommentText(
const std::string&
t) { m_commentTexts.text =
t; }
563 return temptative_img_path;
566 temptative_img_path =
568 return temptative_img_path;
571 temptative_img_path =
573 return temptative_img_path;
575 return rawlog_path +
"Images";
This class implements a config file-like interface over a memory-stored string list.
GLuint GLuint GLsizei count
#define THROW_EXCEPTION(msg)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
A structure that holds runtime class type information.
void WriteAs(const TYPE_FROM_ACTUAL &value)
GLsizei GLsizei GLuint * obj
Declares a class for storing a collection of robot actions.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream, std::istream, std::ostream, std::stringstream
std::pair< mrpt::system::TTimeStamp, CObservation::Ptr > TTimeObservationPair
For usage with CRawlog classes.
#define ASSERT_(f)
Defines an assertion mechanism.
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
#define IS_DERIVED(ptrObj, class_name)
Evaluates to true if a pointer to an object (derived from mrpt::rtti::CObject) is an instance of the ...
#define CLASS_ID(T)
Access to runtime class ID for a defined class name.
std::multimap< mrpt::system::TTimeStamp, CObservation::Ptr > TListTimeAndObservations
For usage with CRawlog classes.
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...
GLsizei const GLchar ** string
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Declares a class for storing a robot action.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
Declares a class that represents any robot's observation.
void setContent(const std::vector< std::string > &stringList)
Changes the contents of the virtual "config file".
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::rtti::CObject) is of the give...
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Saves data to a file and transparently compress the data using the given compression level...
std::string extractFileName(const std::string &filePath)
Extract just the name (without extension) of a filename from a complete path plus name plus extension...
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
unsigned __int32 uint32_t
GLubyte GLubyte GLubyte a
void clear()
Clear the contents of this container.
const Scalar * const_iterator
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
std::string extractFileDirectory(const std::string &filePath)
Extract the whole path (the directory) of a filename from a complete path plus name plus extension...
double distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
mrpt::rtti::CObject::Ptr duplicateGetSmartPtr() const
Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object w...
Used in mrpt::serialization::CArchive.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.