Skip to content

Commit a9293b8

Browse files
committed
Add method is_running() to loggers
To check if the logger is still running. Can be used to automatically take some action (e.g. save and exit) when the buffer is full.
1 parent 512a827 commit a9293b8

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
coefficients, frame rate, etc.). For this, a method `get_sensor_info()` is added to
1414
`SensorFrontend`. It defaults to an empty struct for backward compatibility. To use
1515
it, implement the method with the same name in `SensorDriver`.
16+
- Add `is_running()` to `RobotLogger` and `SensorLogger`. Can, for example, be used to
17+
detect if the buffer is full (in which case the logger stops automatically).
1618

1719
### Changed
1820
- The return type of `RobotDriver::get_error()` is changed to

include/robot_interfaces/pybind_helper.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ void create_robot_logger_python_bindings(pybind11::module &m)
177177
.def("stop_and_save",
178178
&Types::Logger::stop_and_save,
179179
pybind11::call_guard<pybind11::gil_scoped_release>())
180+
.def("is_running",
181+
&Types::Logger::is_running,
182+
pybind11::call_guard<pybind11::gil_scoped_release>())
180183
.def("reset",
181184
&Types::Logger::reset,
182185
pybind11::call_guard<pybind11::gil_scoped_release>())

include/robot_interfaces/robot_logger.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ class RobotLogger
141141
}
142142
}
143143

144+
/**
145+
* @brief Check if the logger is currently running.
146+
*
147+
* After calling @ref start(), the logger is running until @ref stop() is
148+
* called or the buffer is full (in which case it will stop automatically).
149+
*/
150+
bool is_running() const
151+
{
152+
return enabled_;
153+
}
154+
144155
//! @brief Clear the log buffer.
145156
void reset()
146157
{

include/robot_interfaces/sensors/sensor_logger.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ class SensorLogger
107107
}
108108
}
109109

110+
/**
111+
* @brief Check if the logger is currently running.
112+
*
113+
* After calling @ref start(), the logger is running until @ref stop() is
114+
* called or the buffer is full (in which case it will stop automatically).
115+
*/
116+
bool is_running() const
117+
{
118+
return enabled_;
119+
}
120+
110121
//! @brief Clear the log buffer.
111122
void reset()
112123
{

0 commit comments

Comments
 (0)