SuppressChildErrors Class
A decorator that filters the log messages produced while ticking its child Behavior. More...
Declaration
Included Headers
Base class
| class | SharedResourcesNode<BehaviorTreeNodeT> |
|
The SharedResourcesNode class provides a BehaviorContext object when constructing a BehaviorTree.Cpp node. More... | |
Public Constructors Index
| SuppressChildErrors (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< moveit_pro::behaviors::BehaviorContext > &shared_resources) | |
Private Member Functions Index
| BT::NodeStatus | tick () override |
|
Installs the log filter on first tick, then ticks the child and passes its status through unchanged. More... | |
| void | halt () override |
|
Pops the filter. A halted Objective is treated as user-cancelled. More... | |
Private Member Attributes Index
| std::shared_ptr< void > | filter_token_ |
|
RAII token for the installed log filter. Null when no filter is installed. More... | |
Public Static Functions Index
| static BT::PortsList | providedPorts () |
|
Required implementation of the static providedPorts function. More... | |
| static BT::KeyValueVector | metadata () |
Description
A decorator that filters the log messages produced while ticking its child Behavior.
Objective authors regularly use recovery patterns such as Fallback where the first branch is expected to fail as part of normal decision logic (for example, "try to detect an object; if that fails, move to a default pose"). The failing Behavior correctly logs an ERROR from its own perspective, which surfaces as an alarming red toast in the UI and an ERROR line in the system logs even though the system is behaving exactly as designed.
SuppressChildErrors wraps such a subtree and drops the messages it produces at the configured severities, without changing the child's BT::NodeStatus. Suppressed messages are not downgraded to a different severity — they are removed entirely, so no UI toast, console line, or error-buffer entry is produced for them. It requires no changes to the wrapped Behaviors — they keep logging normally. Compose it with ForceSuccess when the author also wants to swallow the failure status.
While the child is ticking, the decorator installs a filter on the shared logger (see LoggerBase::pushFilter). A message is dropped when the per-severity flag for its level is true (suppress_error/suppress_warn/ suppress_info); otherwise it passes through unchanged. The filter is removed as soon as the child reaches a terminal status or the decorator is halted.
| Data Port Name | Port Type | Object Type | Default | Description |
|---|---|---|---|---|
| suppress_error | input | bool | true | Drop ERROR messages logged by the child. |
| suppress_warn | input | bool | false | Drop WARN messages logged by the child. |
| suppress_info | input | bool | false | Drop INFO messages logged by the child. |
Direct spdlog::error(...) calls from Behaviors bypass LoggerBase and are not filtered. They never reach the UI toast path regardless, so this is a console-only limitation.
When two SuppressChildErrors decorators are nested, only the innermost (top-of-stack) filter is consulted for messages logged while it is installed (see LoggerBase::pushFilter). An inner decorator's flags therefore fully shadow an outer one's for the duration of the inner child's tick — e.g. an outer suppress_error=true does not drop an ERROR that an inner suppress_error=false forwards.
Definition at line 52 of file suppress_child_errors.hpp.
Public Constructors
SuppressChildErrors()
|
Declaration at line 55 of file suppress_child_errors.hpp, definition at line 51 of file suppress_child_errors.cpp.
Private Member Functions
halt()
|
Pops the filter. A halted Objective is treated as user-cancelled.
Declaration at line 77 of file suppress_child_errors.hpp, definition at line 115 of file suppress_child_errors.cpp.
tick()
|
Installs the log filter on first tick, then ticks the child and passes its status through unchanged.
- Exceptions
-
BT::LogicError if the child returns IDLE.
- Returns
The child's status, unchanged.
Declaration at line 72 of file suppress_child_errors.hpp, definition at line 73 of file suppress_child_errors.cpp.
Private Member Attributes
filter_token_
|
RAII token for the installed log filter. Null when no filter is installed.
Definition at line 80 of file suppress_child_errors.hpp.
Public Static Functions
metadata()
| static |
Declaration at line 64 of file suppress_child_errors.hpp, definition at line 68 of file suppress_child_errors.cpp.
providedPorts()
| static |
Required implementation of the static providedPorts function.
- Returns
The list of input ports used by this Behavior.
Declaration at line 62 of file suppress_child_errors.hpp, definition at line 57 of file suppress_child_errors.cpp.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.