-
Notifications
You must be signed in to change notification settings - Fork 107
Open
Labels
help wantedExtra attention is neededExtra attention is needed
Description
A common pattern of logging I have come across in hardware integration is a flipflop kind of pattern:
e.g. Hardware callback reports at 10Hz "BAD" for X seconds, and then reports "GOOD" when hardware state good:
void hardware_callback(const std::string state) {
if (state == "BAD") {
RCLCPP_INFO(get_logger(), "hardware not ready yet");
}
if (state == "GOOD") {
RCLCPP_INFO(get_logger(), "System in good state, ready.");
}
}
Would spam debug msgs:
hardware not ready yet
hardware not ready yet
hardware not ready yet
hardware not ready yet
// and finally system swaps over
System in good state, ready.
System in good state, ready.
System in good state, ready.
System in good state, ready.
System in good state, ready.
// and then back again
hardware not ready yet
hardware not ready yet
hardware not ready yet
hardware not ready yet
hardware not ready yet
Ideally it would be something like:
void hardware_callback(const std::string state) {
if (state == "BAD") {
RCLCPP_INFO_LATCH(get_logger(), hw_state_latch, true, "hardware not ready yet");
}
if (state == "GOOD") {
RCLCPP_INFO_LATCH(get_logger(), hw_state_latch, false, "System in good state, ready.");
}
}
Yielding:
hardware not ready yet
// and finally system swaps over
System in good state, ready.
// and then back again
hardware not ready yet
I'd be willing to write this feature if someone could give me instructions on how it would be implemented in the rcutils framework, and if it would actually be merged.
I am not too sure on how to define the static/global that can be referenced in other functions.
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed