Class robot_interfaces::SensorLogger¶
-
template<typename Observation, typename InfoType = None>
class SensorLogger¶ Record sensor observations and store them to a file.
Fetches observations from the given SensorData and buffers them in memory. Buffered observations can be written to a file. For writing to file cereal is used, so the Observation type has to be serializable by cereal.
Usage Example:
auto logger = SensorLogger<int>(sensor_data, BUFFER_LIMIT); logger.start(); // do something logger.stop_and_save("/tmp/sensordata.log");
- Template Parameters:
Observation – Typ of the observation that is recorded.
Public Types
-
typedef std::shared_ptr<SensorData<Observation, InfoType>> DataPtr¶
-
typedef std::tuple<double, Observation> StampedObservation¶
-
typedef std::shared_ptr<SensorData<Observation, InfoType>> DataPtr
-
typedef std::tuple<double, Observation> StampedObservation
Public Functions
-
inline SensorLogger(DataPtr sensor_data, size_t buffer_limit)¶
Initialize the logger.
- Parameters:
sensor_data – Pointer to the SensorData instance from which observations are obtained.
buffer_limit – Maximum number of observations that are logged. When this limit is reached, the logger will stop automatically, that is new observations are not logged anymore.
-
SensorLogger(SensorLogger&&) = default¶
-
inline ~SensorLogger()¶
-
inline void start()¶
Start logging.
If the logger is already running, this is a noop.
-
inline void stop()¶
Stop logging.
If the logger is already stopped, this is a noop.
-
inline bool is_running() const¶
Check if the logger is currently running.
After calling start(), the logger is running until stop() is called or the buffer is full (in which case it will stop automatically).
-
inline void reset()¶
Clear the log buffer.
-
inline void stop_and_save(const std::string &filename)¶
Stop logging and save logged messages to a file.
- Parameters:
filename – Path to the output file. Existing files will be overwritten.
-
inline SensorLogger(DataPtr sensor_data, size_t buffer_limit)
Initialize the logger.
- Parameters:
sensor_data – Pointer to the SensorData instance from which observations are obtained.
buffer_limit – Maximum number of observations that are logged. When this limit is reached, the logger will stop automatically, that is new observations are not logged anymore.
-
SensorLogger(SensorLogger&&) = default
-
inline ~SensorLogger()
-
inline void start()
Start logging.
If the logger is already running, this is a noop.
-
inline void stop()
Stop logging.
If the logger is already stopped, this is a noop.
-
inline bool is_running() const
Check if the logger is currently running.
After calling start(), the logger is running until stop() is called or the buffer is full (in which case it will stop automatically).
-
inline void reset()
Clear the log buffer.
-
inline void stop_and_save(const std::string &filename)
Stop logging and save logged messages to a file.
- Parameters:
filename – Path to the output file. Existing files will be overwritten.