Class AnalyzerGroup
Defined in File analyzer_group.hpp
Inheritance Relationships
Base Type
public diagnostic_aggregator::Analyzer
(Class Analyzer)
Class Documentation
-
class AnalyzerGroup : public diagnostic_aggregator::Analyzer
Allows analyzers to be grouped together, or used as sub-analyzers.
The AnalyzerGroup is used by the diagnostic aggregator internally to load and handle analyzers. It can be used as a normal analyzer plugin to allow analyzers to become “sub-analyzers”, or move as a group.
The “sub-analyzers” are initialized using parameters in the “~analyzers” namespace of the AnalyzerGroup. The “type” parameters determines the analyzer type.
Example initialization:
* sensors: * type: AnalyzerGroup * path: Sensors * analyzers: * base_hk: * type: GenericAnalyzer * path: Base Hokuyo * timeout: 5.0 * find_and_remove_prefix: base_hokuyo_node * num_items: 3 * tilt_hk: * type: GenericAnalyzer * path: Tilt Hokuyo * timeout: 5.0 * find_and_remove_prefix: tilt_hokuyo_node * num_items: 3 * imu: * type: GenericAnalyzer * path: IMU * timeout: 5.0 * find_and_remove_prefix: imu_node * num_items: 3 *
Each namespace below “analyzers” describes a new Analyzer that will be loaded as a sub-analyzer. Any analyzer that fails to initialize or loads incorrectly will generate an error in the console output, and a special diagnostic item in the output of the AnalyzerGroup that describes the error.
In the above example, the AnalyzerGroup will have three sub-analyzers. The AnalyzerGroup will report a DiagnosticStatus message in the processed output with the name “Sensors” (the top-level state). The “Sensors” message will have the level of the highest of the sub-analyzers, or the highest of “Sensors/Base Hokuyo”, “Sensors/Tilt Hokuyo” and “Sensors/IMU”. The state of any other items, like “Sensors/IMU/Connection” won’t matter to the AnalyzerGroup.
The Aggregator uses the AnalyzerGroup internally to load and update analyzers.
Public Functions
-
DIAGNOSTIC_AGGREGATOR_PUBLIC AnalyzerGroup()
-
virtual DIAGNOSTIC_AGGREGATOR_PUBLIC ~AnalyzerGroup()
- virtual DIAGNOSTIC_AGGREGATOR_PUBLIC bool init (const std::string &base_path, const std::string &breadcrumb, const rclcpp::Node::SharedPtr node)
Initialized with base path and namespace.
The parameters in its namespace determine the sub-analyzers.
- virtual DIAGNOSTIC_AGGREGATOR_PUBLIC bool addAnalyzer (std::shared_ptr< Analyzer > &analyzer)
Add an analyzer to this analyzerGroup.
!
- virtual DIAGNOSTIC_AGGREGATOR_PUBLIC bool removeAnalyzer (std::shared_ptr< Analyzer > &analyzer)
Remove an analyzer from this analyzerGroup.
!
- virtual DIAGNOSTIC_AGGREGATOR_PUBLIC bool match (const std::string &name)
Match returns true if any sub-analyzers match an item.
- DIAGNOSTIC_AGGREGATOR_PUBLIC void resetMatches ()
Clear match arrays. Used when analyzers are added or removed.
- virtual DIAGNOSTIC_AGGREGATOR_PUBLIC bool analyze (const std::shared_ptr< StatusItem > item)
Analyze returns true if any sub-analyzers will analyze an item.
- virtual DIAGNOSTIC_AGGREGATOR_PUBLIC std::vector< std::shared_ptr< diagnostic_msgs::msg::DiagnosticStatus > > report ()
The processed output is the combined output of the sub-analyzers, and the top level status.
-
inline virtual std::string getPath() const
Returns full prefix of analyzer. (ex: ‘/Robot/Sensors’)
-
inline virtual std::string getName() const
Returns nice name for display. (ex: ‘Sensors’)
-
DIAGNOSTIC_AGGREGATOR_PUBLIC AnalyzerGroup()