Public Member Functions | Private Attributes
diagnostic_aggregator::GenericAnalyzer Class Reference

GenericAnalyzer is most basic diagnostic Analyzer. More...

#include <generic_analyzer.h>

Inheritance diagram for diagnostic_aggregator::GenericAnalyzer:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 GenericAnalyzer ()
 Default constructor loaded by pluginlib.
bool init (const std::string base_path, const ros::NodeHandle &n)
 Initializes GenericAnalyzer from namespace. Returns true if s.
virtual bool match (const std::string name)
 Returns true if item matches any of the given criteria.
virtual std::vector
< boost::shared_ptr
< diagnostic_msgs::DiagnosticStatus > > 
report ()
 Reports current state, returns vector of formatted status messages.
virtual ~GenericAnalyzer ()

Private Attributes

std::vector< std::string > chaff_
std::vector< std::string > contains_
std::vector< std::string > expected_
std::vector< std::string > name_
std::vector< boost::regex > regex_
std::vector< std::string > startswith_

Detailed Description

GenericAnalyzer is most basic diagnostic Analyzer.

GenericAnalyzer analyzes a segment of diagnostics data and reports processed diagnostics data. All analyzed status messages are prepended with "Base Path/My Path", where "Base Path" is from the parent of this Analyzer, (ex: 'PR2') and "My Path" is from this analyzer (ex: 'Power System').

The GenericAnalyzer is initialized as a plugin by the diagnostic Aggregator. Following is an example of the necessary parameters of the GenericAnalyzer. See the Aggregator class for more information on loading Analyzer plugins.

 * my_namespace:
 *   type: GenericAnalyzer
 *   path: My Path
 *

Required Parameters:

In the above example, the GenericAnalyzer wouldn't analyze anything. The GenericAnalyzer must be configured to listen to diagnostic status names. To do this, optional parameters, like "contains", will tell the analyzer to analyze an item that contains that value. The GenericAnalyzer looks at the name of the income diagnostic_msgs/DiagnosticStatus messages to determine item matches.

Optional Parameters for Matching:

In some cases, it's possible to clean up the processed diagnostic status names.

The special parameter '''find_and_remove_prefix''' combines "startswith" and "remove_prefix". It can be given as a string or list of strings.

If the number of incoming items under a GenericAnalyzer is known, use '''num_items''' to set an exact value. If the number of items that matches the above parameters is incorrect, the GenericAnalyzer will report an error in the top-level status. This is "-1" by default. Negative values will not cause a check on the number of items.

For tracking stale items, use the "timeout" parameter. Any item that doesn't update within the timeout will be marked as "Stale", and will cause an error in the top-level status. Default is 5.0 seconds. Any value <0 will cause stale items to be ignored.

The GenericAnalyzer can discard stale items. Use the "discard_stale" parameter to remove any items that haven't updated within the timeout. This is "false" by default.

Example configurations:

 * hokuyo:
 *   type: GenericAnalyzer
 *   path: Hokuyo
 *   find_and_remove_prefix: hokuyo_node
 *   num_items: 3
 *
 * power_system:
 *   type: GenericAnalyzer
 *   path: Power System
 *   startswith: [
 *     'Battery',
 *     'IBPS']
 *   expected: Power board 1000
 *   dicard_stale: true
 *

The GenericAnalyzer will report the latest status of any item that is should analyze. It will report a separate diagnostic_msgs/DiagnosticStatus with the name "Base Path/My Path". This "top-level" status will have the error state of the highest of its children.

Stale items are handled differently. A stale child will cause an error in the top-level status, but if all children are stale, the top-level status will be stale.

Example analyzer behavior, using the "Hokuyo" configuration above:

 * Input - (DiagnosticStatus Name, Error State)
 * hokuyo_node: Connection Status, OK
 * hokuyo_node: Frequency Status, Warning
 * hokuyo_node: Driver Status, OK
 *
 * Output - (DiagnosticStatus Name, Error State)
 * Hokuyo, Warning
 * Hokuyo/Connection Status, OK
 * Hokuyo/Frequency Status, Warning
 * Hokuyo/Driver Status, OK
 *

Definition at line 198 of file generic_analyzer.h.


Constructor & Destructor Documentation

Default constructor loaded by pluginlib.

Definition at line 144 of file generic_analyzer.cpp.


Member Function Documentation

bool GenericAnalyzer::init ( const std::string  base_path,
const ros::NodeHandle n 
) [virtual]

Initializes GenericAnalyzer from namespace. Returns true if s.

Parameters:
base_path: Prefix for all analyzers (ex: 'Robot')
n: NodeHandle in full namespace
Returns:
True if initialization succeed, false if no errors of

Implements diagnostic_aggregator::GenericAnalyzerBase.

Definition at line 50 of file generic_analyzer.cpp.

bool GenericAnalyzer::match ( const std::string  name) [virtual]

Returns true if item matches any of the given criteria.

Implements diagnostic_aggregator::GenericAnalyzerBase.

Definition at line 147 of file generic_analyzer.cpp.

vector< boost::shared_ptr< diagnostic_msgs::DiagnosticStatus > > GenericAnalyzer::report ( ) [virtual]

Reports current state, returns vector of formatted status messages.

Returns:
Vector of DiagnosticStatus messages, with correct prefix for all names.

Reimplemented from diagnostic_aggregator::GenericAnalyzerBase.

Reimplemented in diagnostic_aggregator::DiscardAnalyzer.

Definition at line 183 of file generic_analyzer.cpp.


Member Data Documentation

std::vector<std::string> diagnostic_aggregator::GenericAnalyzer::chaff_ [private]

Removed from the start of node names.

Definition at line 232 of file generic_analyzer.h.

std::vector<std::string> diagnostic_aggregator::GenericAnalyzer::contains_ [private]

Definition at line 235 of file generic_analyzer.h.

std::vector<std::string> diagnostic_aggregator::GenericAnalyzer::expected_ [private]

Definition at line 233 of file generic_analyzer.h.

std::vector<std::string> diagnostic_aggregator::GenericAnalyzer::name_ [private]

Definition at line 236 of file generic_analyzer.h.

std::vector<boost::regex> diagnostic_aggregator::GenericAnalyzer::regex_ [private]

Regular expressions to check against diagnostics names.

Definition at line 237 of file generic_analyzer.h.

std::vector<std::string> diagnostic_aggregator::GenericAnalyzer::startswith_ [private]

Definition at line 234 of file generic_analyzer.h.


The documentation for this class was generated from the following files:


diagnostic_aggregator
Author(s): Kevin Watts
autogenerated on Fri Jan 3 2014 11:19:06