Allows analyzers to be grouped together, or used as sub-analyzers. More...
#include <analyzer_group.h>
Public Member Functions | |
virtual bool | addAnalyzer (boost::shared_ptr< Analyzer > &analyzer) |
Add an analyzer to this analyzerGroup. More... | |
virtual bool | analyze (const boost::shared_ptr< StatusItem > item) |
Analyze returns true if any sub-analyzers will analyze an item. More... | |
AnalyzerGroup () | |
virtual std::string | getName () const |
Returns nice name for display. (ex: 'Sensors') More... | |
virtual std::string | getPath () const |
Returns full prefix of analyzer. (ex: '/Robot/Sensors') More... | |
virtual bool | init (const std::string base_path, const ros::NodeHandle &n) |
Initialized with base path and namespace. More... | |
virtual bool | match (const std::string name) |
Match returns true if any sub-analyzers match an item. More... | |
virtual bool | removeAnalyzer (boost::shared_ptr< Analyzer > &analyzer) |
Remove an analyzer from this analyzerGroup. More... | |
virtual std::vector< boost::shared_ptr< diagnostic_msgs::DiagnosticStatus > > | report () |
The processed output is the combined output of the sub-analyzers, and the top level status. More... | |
void | resetMatches () |
Clear match arrays. Used when analyzers are added or removed. More... | |
virtual | ~AnalyzerGroup () |
Public Member Functions inherited from diagnostic_aggregator::Analyzer | |
Analyzer () | |
Default constructor, called by pluginlib. More... | |
virtual | ~Analyzer () |
Private Attributes | |
pluginlib::ClassLoader< Analyzer > | analyzer_loader_ |
Loads Analyzer plugins in "analyzers" namespace. More... | |
std::vector< boost::shared_ptr< Analyzer > > | analyzers_ |
std::vector< boost::shared_ptr< StatusItem > > | aux_items_ |
These items store errors, if any, for analyzers that failed to initialize or load. More... | |
std::map< const std::string, std::vector< bool > > | matched_ |
std::string | nice_name_ |
std::string | path_ |
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.
Definition at line 110 of file analyzer_group.h.
diagnostic_aggregator::AnalyzerGroup::AnalyzerGroup | ( | ) |
|
virtual |
Definition at line 164 of file analyzer_group.cpp.
|
virtual |
|
virtual |
Analyze returns true if any sub-analyzers will analyze an item.
Implements diagnostic_aggregator::Analyzer.
Definition at line 220 of file analyzer_group.cpp.
|
inlinevirtual |
Returns nice name for display. (ex: 'Sensors')
Implements diagnostic_aggregator::Analyzer.
Definition at line 156 of file analyzer_group.h.
|
inlinevirtual |
Returns full prefix of analyzer. (ex: '/Robot/Sensors')
Implements diagnostic_aggregator::Analyzer.
Definition at line 154 of file analyzer_group.h.
|
virtual |
Initialized with base path and namespace.
The parameters in its namespace determine the sub-analyzers.
Implements diagnostic_aggregator::Analyzer.
Definition at line 51 of file analyzer_group.cpp.
|
virtual |
Match returns true if any sub-analyzers match an item.
Implements diagnostic_aggregator::Analyzer.
Definition at line 186 of file analyzer_group.cpp.
|
virtual |
|
virtual |
The processed output is the combined output of the sub-analyzers, and the top level status.
Implements diagnostic_aggregator::Analyzer.
Definition at line 235 of file analyzer_group.cpp.
void AnalyzerGroup::resetMatches | ( | ) |
Clear match arrays. Used when analyzers are added or removed.
Definition at line 214 of file analyzer_group.cpp.
|
private |
Loads Analyzer plugins in "analyzers" namespace.
Definition at line 164 of file analyzer_group.h.
|
private |
Definition at line 171 of file analyzer_group.h.
|
private |
These items store errors, if any, for analyzers that failed to initialize or load.
Definition at line 169 of file analyzer_group.h.
|
private |
Definition at line 176 of file analyzer_group.h.
|
private |
Definition at line 159 of file analyzer_group.h.
|
private |
Definition at line 159 of file analyzer_group.h.