MRPT  2.0.4
RawlogGrabberApp.h
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 #pragma once
10 
14 #include <mrpt/obs/CSensoryFrame.h>
15 #include <mrpt/obs/obs_frwds.h>
17 #include <atomic>
18 #include <mutex>
19 
20 namespace mrpt::apps
21 {
22 /** RawlogGrabber application wrapper class.
23  *
24  * \note If the environment variable `MRPT_HWDRIVERS_VERBOSE=1` is defined
25  * before calling initialize(), verbosity level will be changed to LVL_DEBUG.
26  *
27  * \ingroup mrpt_apps_grp
28  */
30 {
31  public:
33 
34  /** @name Main API
35  * @{ */
36 
37  /** Initializes the application from CLI parameters. Refer to the manpage of
38  * rawlog-grabber. Throws on errors.
39  */
40  void initialize(int argc, const char** argv);
41 
42  inline void initialize(int argc, char** argv)
43  {
44  initialize(argc, const_cast<const char**>(argv));
45  }
46 
47  /** Runs with the current parameter set. Throws on errors. */
48  void run();
49 
50  bool isRunning() const
51  {
52  m_isRunningMtx.lock();
53  const auto r = m_isRunning;
54  m_isRunningMtx.unlock();
55  return r;
56  }
57 
58  /** @} */
59 
60  /** @name Parameters and options. See: initialize()
61  * @{ */
62  /** Acquire this mutex if changing parameters *while* the app is running */
63  std::mutex params_mtx;
64 
65  /** If >0, run() will return after this period (in seconds) */
66  double run_for_seconds = 0;
67 
68  /** If enabled (default), exceptions in sensor threads will be reported to
69  * std::cerr */
71 
72  /** Populated in initialize(). Can be replaced or manipulated by the user
73  * after that and before run() to change the parameters loaded from INI
74  * file. */
76 
77  /** @} */
78 
79  /** @name Outputs and result variables
80  * @{ */
81  /** Acquire this mutex if reading these output variables *while* the app is
82  * running */
83  std::mutex results_mtx;
84 
85  std::string rawlog_filename; //!< The generated .rawlog file
86  std::size_t rawlog_saved_objects = 0; //!< Counter of saved objects
87 
88  /** @} */
89 
90  void SensorThread(std::string sensor_label);
91 
92  private:
93  using TListObservations =
95 
96  void dump_verbose_info(
98  void dump_verbose_info(const mrpt::obs::CSensoryFrame& sf) const;
100  void dump_IMU_info(const mrpt::obs::CObservationIMU& o) const;
101 
102  void process_observations_for_sf(const TListObservations& list_obs);
104 
105  void runImpl();
106 
109 
110  std::atomic_bool allThreadsMustExit = false;
111  mutable std::mutex m_isRunningMtx;
112  bool m_isRunning = false;
113 
114  /** Directory where to save externally stored images, only for
115  * CCameraSensor's. */
117 
119 
121  double SF_max_time_span = 0.25; // Seconds
122 };
123 
124 } // namespace mrpt::apps
mrpt::hwdrivers::CGenericSensor::TListObservations
std::multimap< mrpt::system::TTimeStamp, mrpt::serialization::CSerializable::Ptr > TListObservations
Definition: CGenericSensor.h:77
mrpt::apps::RawlogGrabberApp::dump_GPS_mode_info
void dump_GPS_mode_info(const mrpt::obs::CObservationGPS &o) const
Definition: RawlogGrabberApp.cpp:308
mrpt::apps::RawlogGrabberApp::m_isRunning
bool m_isRunning
Definition: RawlogGrabberApp.h:112
mrpt::apps::RawlogGrabberApp::params
mrpt::config::CConfigFileMemory params
Populated in initialize().
Definition: RawlogGrabberApp.h:75
CConfigFileMemory.h
mrpt::serialization::CSerializable::Ptr
std::shared_ptr< CSerializable > Ptr
Definition: CSerializable.h:36
mrpt::apps::RawlogGrabberApp::isRunning
bool isRunning() const
Definition: RawlogGrabberApp.h:50
mrpt::apps::RawlogGrabberApp::show_sensor_thread_exceptions
bool show_sensor_thread_exceptions
If enabled (default), exceptions in sensor threads will be reported to std::cerr.
Definition: RawlogGrabberApp.h:70
mrpt::apps::RawlogGrabberApp::cs_m_global_list_obs
std::mutex cs_m_global_list_obs
Definition: RawlogGrabberApp.h:108
mrpt::apps::RawlogGrabberApp::m_rawlog_ext_imgs_dir
std::string m_rawlog_ext_imgs_dir
Directory where to save externally stored images, only for CCameraSensor's.
Definition: RawlogGrabberApp.h:116
mrpt::apps::RawlogGrabberApp::TListObservations
mrpt::hwdrivers::CGenericSensor::TListObservations TListObservations
Definition: RawlogGrabberApp.h:94
mrpt::apps::RawlogGrabberApp::m_global_list_obs
TListObservations m_global_list_obs
Definition: RawlogGrabberApp.h:107
mrpt::obs::CObservationIMU
This class stores measurements from an Inertial Measurement Unit (IMU) (attitude estimation,...
Definition: CObservationIMU.h:111
mrpt::apps::RawlogGrabberApp::runImpl
void runImpl()
Definition: RawlogGrabberApp.cpp:83
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:54
mrpt::apps::RawlogGrabberApp
RawlogGrabber application wrapper class.
Definition: RawlogGrabberApp.h:29
mrpt::obs::CSensoryFrame
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
Definition: CSensoryFrame.h:51
CConfigFileBase.h
mrpt::apps::RawlogGrabberApp::m_isRunningMtx
std::mutex m_isRunningMtx
Definition: RawlogGrabberApp.h:111
mrpt::apps::RawlogGrabberApp::dump_verbose_info
void dump_verbose_info(const mrpt::serialization::CSerializable::Ptr &o) const
Definition: RawlogGrabberApp.cpp:265
COutputLogger.h
mrpt::apps::RawlogGrabberApp::rawlog_filename
std::string rawlog_filename
The generated .rawlog file.
Definition: RawlogGrabberApp.h:85
mrpt::apps::RawlogGrabberApp::initialize
void initialize(int argc, const char **argv)
Initializes the application from CLI parameters.
Definition: RawlogGrabberApp.cpp:42
mrpt::apps::RawlogGrabberApp::RawlogGrabberApp
RawlogGrabberApp()
Definition: RawlogGrabberApp.cpp:37
mrpt::apps::RawlogGrabberApp::process_observations_for_sf
void process_observations_for_sf(const TListObservations &list_obs)
Definition: RawlogGrabberApp.cpp:417
CGenericSensor.h
mrpt::apps::RawlogGrabberApp::allThreadsMustExit
std::atomic_bool allThreadsMustExit
Definition: RawlogGrabberApp.h:110
mrpt::apps::RawlogGrabberApp::run_for_seconds
double run_for_seconds
If >0, run() will return after this period (in seconds)
Definition: RawlogGrabberApp.h:66
mrpt::apps
Definition: BaseAppDataSource.h:15
obs_frwds.h
argv
const char * argv[]
Definition: RawlogGrabberApp_unittest.cpp:50
mrpt::apps::RawlogGrabberApp::process_observations_for_nonsf
void process_observations_for_nonsf(const TListObservations &list_obs)
Definition: RawlogGrabberApp.cpp:538
mrpt::apps::RawlogGrabberApp::run
void run()
Runs with the current parameter set.
Definition: RawlogGrabberApp.cpp:242
mrpt::system::COutputLogger
Versatile class for consistent logging and management of output messages.
Definition: system/COutputLogger.h:117
CSensoryFrame.h
mrpt::apps::RawlogGrabberApp::SensorThread
void SensorThread(std::string sensor_label)
Definition: RawlogGrabberApp.cpp:341
mrpt::apps::RawlogGrabberApp::params_mtx
std::mutex params_mtx
Acquire this mutex if changing parameters while the app is running.
Definition: RawlogGrabberApp.h:63
mrpt::obs::CObservationGPS
This class stores messages from GNSS or GNSS+IMU devices, from consumer-grade inexpensive GPS receive...
Definition: CObservationGPS.h:67
mrpt::apps::RawlogGrabberApp::rawlog_saved_objects
std::size_t rawlog_saved_objects
Counter of saved objects.
Definition: RawlogGrabberApp.h:86
argc
const int argc
Definition: RawlogGrabberApp_unittest.cpp:51
mrpt::apps::RawlogGrabberApp::SF_max_time_span
double SF_max_time_span
Definition: RawlogGrabberApp.h:121
mrpt::config::CConfigFileMemory
This class implements a config file-like interface over a memory-stored string list.
Definition: config/CConfigFileMemory.h:36
mrpt::apps::RawlogGrabberApp::initialize
void initialize(int argc, char **argv)
Definition: RawlogGrabberApp.h:42
mrpt::apps::RawlogGrabberApp::m_out_arch_ptr
mrpt::serialization::CArchive * m_out_arch_ptr
Definition: RawlogGrabberApp.h:118
mrpt::apps::RawlogGrabberApp::m_curSF
mrpt::obs::CSensoryFrame m_curSF
Definition: RawlogGrabberApp.h:120
mrpt::apps::RawlogGrabberApp::results_mtx
std::mutex results_mtx
Acquire this mutex if reading these output variables while the app is running.
Definition: RawlogGrabberApp.h:83
mrpt::apps::RawlogGrabberApp::dump_IMU_info
void dump_IMU_info(const mrpt::obs::CObservationIMU &o) const
Definition: RawlogGrabberApp.cpp:327



Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Fri Jul 17 08:43:33 UTC 2020