Public Member Functions | Private Attributes | List of all members
diagnostic_aggregator::GenericAnalyzer Class Reference

GenericAnalyzer is most basic diagnostic Analyzer. More...

#include <generic_analyzer.h>

Inheritance diagram for diagnostic_aggregator::GenericAnalyzer:
Inheritance graph

Public Member Functions

 GenericAnalyzer ()
 Default constructor loaded by pluginlib. More...
bool init (const std::string base_path, const ros::NodeHandle &n)
 Initializes GenericAnalyzer from namespace. Returns true if s. More...
virtual bool match (const std::string name)
 Returns true if item matches any of the given criteria. More...
virtual std::vector< boost::shared_ptr< diagnostic_msgs::DiagnosticStatus > > report ()
 Reports current state, returns vector of formatted status messages. More...
virtual ~GenericAnalyzer ()
- Public Member Functions inherited from diagnostic_aggregator::GenericAnalyzerBase
virtual bool analyze (const boost::shared_ptr< StatusItem > item)
 Update state with new StatusItem. More...
 GenericAnalyzerBase ()
virtual std::string getName () const
 Returns nice name (ex: "Power System") More...
virtual std::string getPath () const
 Returns full prefix (ex: "/Robot/Power System") More...
bool init (const std::string path, const std::string nice_name, double timeout=-1.0, int num_items_expected=-1, bool discard_stale=false)
virtual ~GenericAnalyzerBase ()
- Public Member Functions inherited from diagnostic_aggregator::Analyzer
 Analyzer ()
 Default constructor, called by pluginlib. More...
virtual ~Analyzer ()

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_

Additional Inherited Members

- Protected Member Functions inherited from diagnostic_aggregator::GenericAnalyzerBase
void addItem (std::string name, boost::shared_ptr< StatusItem > item)
 Subclasses can add items to analyze. More...
- Protected Attributes inherited from diagnostic_aggregator::GenericAnalyzerBase
std::string nice_name_
int num_items_expected_
std::string path_
double timeout_

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

◆ GenericAnalyzer()

diagnostic_aggregator::GenericAnalyzer::GenericAnalyzer ( )

Default constructor loaded by pluginlib.

◆ ~GenericAnalyzer()

GenericAnalyzer::~GenericAnalyzer ( )

Definition at line 147 of file generic_analyzer.cpp.

Member Function Documentation

◆ init()

bool GenericAnalyzer::init ( const std::string  base_path,
const ros::NodeHandle n 

Initializes GenericAnalyzer from namespace. Returns true if s.

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

Implements diagnostic_aggregator::GenericAnalyzerBase.

Definition at line 48 of file generic_analyzer.cpp.

◆ match()

bool GenericAnalyzer::match ( const std::string  name)

Returns true if item matches any of the given criteria.

Implements diagnostic_aggregator::GenericAnalyzerBase.

Definition at line 150 of file generic_analyzer.cpp.

◆ report()

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

Reports current state, returns vector of formatted status messages.

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

Reimplemented from diagnostic_aggregator::GenericAnalyzerBase.

Reimplemented in diagnostic_aggregator::DiscardAnalyzer.

Definition at line 186 of file generic_analyzer.cpp.

Member Data Documentation

◆ chaff_

std::vector<std::string> diagnostic_aggregator::GenericAnalyzer::chaff_

Removed from the start of node names.

Definition at line 232 of file generic_analyzer.h.

◆ contains_

std::vector<std::string> diagnostic_aggregator::GenericAnalyzer::contains_

Definition at line 235 of file generic_analyzer.h.

◆ expected_

std::vector<std::string> diagnostic_aggregator::GenericAnalyzer::expected_

Definition at line 233 of file generic_analyzer.h.

◆ name_

std::vector<std::string> diagnostic_aggregator::GenericAnalyzer::name_

Definition at line 236 of file generic_analyzer.h.

◆ regex_

std::vector<boost::regex> diagnostic_aggregator::GenericAnalyzer::regex_

Regular expressions to check against diagnostics names.

Definition at line 237 of file generic_analyzer.h.

◆ startswith_

std::vector<std::string> diagnostic_aggregator::GenericAnalyzer::startswith_

Definition at line 234 of file generic_analyzer.h.

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

Author(s): Kevin Watts, Brice Rebsamen
autogenerated on Mon Feb 28 2022 22:18:07