MRPT  2.0.2
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-2020, 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  MRPT_LOG_DEBUG_STREAM("Processing rawlog entry #" << m_rawlogEntry);
51 
52  // Ok, accept this new observations:
53  return true;
54  };
55 
56  return false;
57 
58  MRPT_END
59 }
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:349
bool open(const std::string &fileName, mrpt::optional_ref< std::string > error_msg=std::nullopt)
Opens the file for read.
#define MRPT_LOG_DEBUG_STREAM(__CONTENTS)
Use: MRPT_LOG_DEBUG_STREAM("Var=" << value << " foo=" << foo_var);
#define MRPT_END
Definition: exceptions.h:245
CArchive::UniquePtr archiveUniquePtrFrom(STREAM &s)
Like archiveFrom(), returning a unique_ptr<>.
Definition: CArchive.h:606
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 2.0.2 Git: 9efc2a654 Mon Apr 6 11:24:47 2020 +0200 at lun abr 6 11:30:12 CEST 2020