MRPT  1.9.9
DataSourceRawlog.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "apps-precomp.h" // Precompiled headers
11 
13 #include <mrpt/obs/CRawlog.h>
14 
15 using namespace mrpt::apps;
16 
19  mrpt::obs::CSensoryFrame::Ptr& observations,
20  mrpt::obs::CObservation::Ptr& observation)
21 {
23 
24  // 1st time? Open rawlog:
25  if (!m_rawlog_arch)
26  {
27  std::string err_msg;
28  if (!m_rawlog_io.open(m_rawlogFileName, err_msg))
29  {
31  "Error opening rawlog file: `%s`", err_msg.c_str());
32  }
34 
35  MRPT_LOG_INFO_FMT("RAWLOG file: `%s`", m_rawlogFileName.c_str());
36  }
37 
38  // Read:
39 
40  for (;;)
41  {
43  *m_rawlog_arch, action, observations, observation,
45  return false;
46 
47  // Optional skip of first N entries
48  if (m_rawlogEntry < m_rawlog_offset) continue;
49 
50  // Ok, accept this new observations:
51  return true;
52  };
53 
54  return false;
55 
56  MRPT_END
57 }
mrpt::serialization::CArchive::UniquePtr m_rawlog_arch
#define MRPT_START
Definition: exceptions.h:241
bool impl_get_next_observations(mrpt::obs::CActionCollection::Ptr &action, mrpt::obs::CSensoryFrame::Ptr &observations, mrpt::obs::CObservation::Ptr &observation) override
Get next sensory data.
static bool getActionObservationPairOrObservation(mrpt::serialization::CArchive &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...
Definition: CRawlog.cpp:370
bool open(const std::string &fileName, mrpt::optional_ref< std::string > error_msg=std::nullopt)
Opens the file for read.
GLsizei const GLchar ** string
Definition: glext.h:4116
#define MRPT_END
Definition: exceptions.h:245
CArchive::UniquePtr archiveUniquePtrFrom(STREAM &s)
Like archiveFrom(), returning a unique_ptr<>.
Definition: CArchive.h:605
mrpt::io::CFileGZInputStream m_rawlog_io
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
Definition: exceptions.h:69
#define MRPT_LOG_INFO_FMT(_FMT_STRING,...)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: cb8dd5fc8 Sat Dec 7 21:55:39 2019 +0100 at sáb dic 7 22:00:13 CET 2019