31 CRawlog::~CRawlog() {
clear(); }
34 m_seqOfActObs.clear();
35 m_commentTexts.text.clear();
40 m_seqOfActObs.push_back(std::dynamic_pointer_cast<CSerializable>(
46 m_seqOfActObs.push_back(std::dynamic_pointer_cast<CSerializable>(
52 m_seqOfActObs.push_back(action);
55 void CRawlog::addObservationsMemoryReference(
58 m_seqOfActObs.push_back(observations);
62 m_seqOfActObs.push_back(
obj);
65 void CRawlog::addObservationMemoryReference(
75 m_seqOfActObs.push_back(observation);
82 m_seqOfActObs.push_back(temp);
95 return std::dynamic_pointer_cast<CActionCollection>(
obj);
98 "Element at index %i is not a CActionCollection", (
int)
index);
111 return std::dynamic_pointer_cast<CObservation>(
obj);
114 "Element at index %i is not a CObservation", (
int)
index);
123 return m_seqOfActObs[
index];
135 return etObservation;
137 return etActionCollection;
139 return etSensoryFrame;
154 return std::dynamic_pointer_cast<CSensoryFrame>(
obj);
157 "Element at index %i is not a CSensoryFrame", (
int)
index);
161 uint8_t CRawlog::serializeGetVersion()
const {
return 1; }
165 for (
const auto&
a : m_seqOfActObs) out <<
a;
166 out << m_commentTexts;
178 for (
auto&
a : m_seqOfActObs)
a =
in.ReadObject();
179 in >> m_commentTexts;
187 bool CRawlog::loadFromRawLogFile(
188 const std::string& fileName,
bool non_obs_objects_are_legal)
198 bool keepReading =
true;
205 bool add_obj =
false;
214 else if (newObj->GetRuntimeClass()->derivedFrom(
239 if (non_obs_objects_are_legal)
248 if (add_obj) m_seqOfActObs.push_back(newObj);
254 catch (
const std::exception& e)
271 m_seqOfActObs.erase(m_seqOfActObs.begin() +
index);
275 void CRawlog::remove(
size_t first_index,
size_t last_index)
278 if (first_index >= m_seqOfActObs.size() ||
279 last_index >= m_seqOfActObs.size())
282 m_seqOfActObs.begin() + first_index,
283 m_seqOfActObs.begin() + last_index + 1);
293 if (!m_commentTexts.text.empty()) f << m_commentTexts;
294 for (
const auto& m_seqOfActOb : m_seqOfActObs) f << *m_seqOfActOb;
297 catch (
const std::exception& e)
306 if (
this == &
obj)
return;
307 m_seqOfActObs.swap(
obj.m_seqOfActObs);
308 std::swap(m_commentTexts,
obj.m_commentTexts);
311 bool CRawlog::readActionObservationPair(
335 observations.reset();
336 while (!observations)
356 catch (
const std::exception& e)
358 std::cerr <<
"[CRawlog::readActionObservationPair] Found exception:" 365 std::cerr <<
"Untyped exception reading rawlog file!!" << std::endl;
370 bool CRawlog::getActionObservationPairOrObservation(
378 observations.reset();
401 observations.reset();
402 while (!observations)
418 catch (
const std::exception& e)
420 std::cerr <<
"[CRawlog::readActionObservationPair] Found exception:" 427 std::cerr <<
"Untyped exception reading rawlog file!!" << std::endl;
432 void CRawlog::findObservationsByClassInRange(
442 if (m_seqOfActObs.empty())
return;
446 auto first = m_seqOfActObs.begin();
447 const auto last = m_seqOfActObs.end();
456 std::advance(it, step);
464 this_timestamp = o->timestamp;
469 "Element found which is not derived from CObservation");
471 if (this_timestamp < time_start)
483 while (
first != last)
490 this_timestamp = o->timestamp;
493 if (this_timestamp < time_end)
495 if (o->GetRuntimeClass()->derivedFrom(class_type))
505 "Element found which is not derived from CObservation");
513 bool CRawlog::getActionObservationPair(
515 size_t& rawlogEntry)
const 519 while (getType(rawlogEntry) != CRawlog::etActionCollection)
523 action = getAsAction(rawlogEntry++);
525 while (getType(rawlogEntry) != CRawlog::etSensoryFrame)
529 observations = getAsObservations(rawlogEntry++);
533 catch (
const std::exception& e)
540 std::cerr <<
"Untyped exception getting act-obs pair from rawlog!!" 546 void CRawlog::getCommentText(
std::string&
t)
const {
t = m_commentTexts.text; }
547 std::string CRawlog::getCommentText()
const {
return m_commentTexts.text; }
548 void CRawlog::getCommentTextAsConfigFile(
554 void CRawlog::setCommentText(
const std::string&
t) { m_commentTexts.text =
t; }
561 return temptative_img_path;
563 temptative_img_path =
566 return temptative_img_path;
568 temptative_img_path =
571 return temptative_img_path;
573 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)
To be added to 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 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.
#define IS_DERIVED(obj, class_name)
True if the given reference to object (derived from mrpt::rtti::CObject) is an instance of the given ...
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...
#define IS_CLASS(obj, class_name)
True if the given reference to object (derived from mrpt::rtti::CObject) is of the given class...
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.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
std::string exception_to_str(const std::exception &e)
Builds a nice textual representation of a nested exception, which if generated using MRPT macros (THR...
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.
#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
Makes a deep copy of the object and returns a smart pointer to it.
Used in mrpt::serialization::CArchive.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.