Class GenericAnalyzer

Inheritance Relationships

Base Type

  • public GenericAnalyzerBase

Derived Type

Class Documentation

class GenericAnalyzer : public GenericAnalyzerBase

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:
  • type This is the class name of the analyzer, used to load the correct plugin type.

  • path All diagnostic items analyzed by the GenericAnalyzer will be under “Base Path/My Path”.

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/msg/DiagnosticStatus messages to determine item matches.

Optional Parameters for Matching:

  • contains Any item that contains these values

  • startswith Item name must start with this value

  • name Exact name match

  • expected Exact name match, will warn if not present

  • regex Regular expression (regex) match against name The above parameters can be given as a single string (“tilt_hokuyo_node”) or a list of strings ([‘Battery’, ‘Smart Battery’]).

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

  • remove_prefix If these prefix is found in a status name, it will be removed in the output. Can be given as a string or list of strings.

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
*

Subclassed by diagnostic_aggregator::DiscardAnalyzer

Public Functions

DIAGNOSTIC_AGGREGATOR_PUBLIC GenericAnalyzer()

Default constructor loaded by pluginlib.

virtual DIAGNOSTIC_AGGREGATOR_PUBLIC ~GenericAnalyzer()
DIAGNOSTIC_AGGREGATOR_PUBLIC bool init (const std::string &base_path, const std::string &breadcrumb, const rclcpp::Node::SharedPtr node)

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

virtual DIAGNOSTIC_AGGREGATOR_PUBLIC std::vector< std::shared_ptr< diagnostic_msgs::msg::DiagnosticStatus > > report ()

Reports current state, returns vector of formatted status messages.

Returns:

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

virtual DIAGNOSTIC_AGGREGATOR_PUBLIC bool match (const std::string &name)

Returns true if item matches any of the given criteria.