#include <optional_diagnosed_publisher.h>
Public Member Functions | |
OptionalDiagnosedPublisher (const ros::Publisher &pub, diagnostic_updater::Updater &diag, const diagnostic_updater::FrequencyStatusParam &freq, const diagnostic_updater::TimeStampStatusParam &stamp) | |
virtual void | run (diagnostic_updater::DiagnosticStatusWrapper &stat) |
virtual void | setEnabled (bool enabled) |
virtual | ~OptionalDiagnosedPublisher () |
Private Attributes | |
bool | is_diagnostic_enabled_ |
The DiagnosedPublisher class is handy, but it has on problem: it can't be turned off. If you ever stop publishing, it will flag an error because your publish rate is 0. If you are intentionally not publishing because you don't have any subscribers in order to avoid unnecessary processing, that is inconvenient.
This class simply wraps the DiagnosedPublisher and adds a setEnabled method that can be used to enable or disable it. When disabled, it will simply publish a diagnostic with an "OK" status.
In theory it could dynamically determine whether you have subscribers or not and change it status based on that, but that might not be what you want in the event that you don't have subscribers but still have some kind of error to report.
T | The type of message being published. |
Definition at line 54 of file optional_diagnosed_publisher.h.
swri::OptionalDiagnosedPublisher< T >::OptionalDiagnosedPublisher | ( | const ros::Publisher & | pub, |
diagnostic_updater::Updater & | diag, | ||
const diagnostic_updater::FrequencyStatusParam & | freq, | ||
const diagnostic_updater::TimeStampStatusParam & | stamp | ||
) | [inline] |
Definition at line 57 of file optional_diagnosed_publisher.h.
virtual swri::OptionalDiagnosedPublisher< T >::~OptionalDiagnosedPublisher | ( | ) | [inline, virtual] |
Definition at line 65 of file optional_diagnosed_publisher.h.
virtual void swri::OptionalDiagnosedPublisher< T >::run | ( | diagnostic_updater::DiagnosticStatusWrapper & | stat | ) | [inline, virtual] |
Reimplemented from diagnostic_updater::CompositeDiagnosticTask.
Definition at line 68 of file optional_diagnosed_publisher.h.
virtual void swri::OptionalDiagnosedPublisher< T >::setEnabled | ( | bool | enabled | ) | [inline, virtual] |
Controls whether the diagnostic for this publisher is enabled.
enabled | "true" to enable the diagnostic. |
Definition at line 87 of file optional_diagnosed_publisher.h.
bool swri::OptionalDiagnosedPublisher< T >::is_diagnostic_enabled_ [private] |
Definition at line 93 of file optional_diagnosed_publisher.h.