37 #ifndef __DIAGNOSTIC_STATUS__UPDATE_FUNCTIONS_H__ 38 #define __DIAGNOSTIC_STATUS__UPDATE_FUNCTIONS_H__ 41 #include "diagnostic_msgs/DiagnosticStatus.h" 145 boost::mutex::scoped_lock lock(lock_);
152 seq_nums_[i] = count_;
163 boost::mutex::scoped_lock lock(lock_);
170 boost::mutex::scoped_lock lock(lock_);
173 int events = curseq - seq_nums_[hist_indx_];
174 double window = (curtime - times_[hist_indx_]).toSec();
179 freq = events / window;
181 seq_nums_[hist_indx_] = curseq;
182 times_[hist_indx_] = curtime;
197 else if (window != 0)
202 stat.
addf(
"Events in window",
"%d", events);
203 stat.
addf(
"Events since startup",
"%d", count_);
204 stat.
addf(
"Duration of window (s)",
"%f", window);
206 stat.
addf(
"Actual frequency (Hz)",
"%f",freq);
211 stat.
addf(
"Minimum acceptable frequency (Hz)",
"%f",
215 stat.
addf(
"Maximum acceptable frequency (Hz)",
"%f",
232 max_acceptable_(max_acceptable), min_acceptable_(min_acceptable)
277 deltas_valid_ =
false;
324 boost::mutex::scoped_lock lock(lock_);
334 if (!deltas_valid_ || delta > max_delta_)
337 if (!deltas_valid_ || delta < min_delta_)
340 deltas_valid_ =
true;
static TimeStampStatusParam DefaultTimeStampStatusParam
Default TimeStampStatusParam. This is like calling the constructor with no arguments.
virtual void run(diagnostic_updater::DiagnosticStatusWrapper &stat)
Fills out this Task's DiagnosticStatusWrapper.
double * min_freq_
Minimum acceptable frequency.
TimeStampStatus(const TimeStampStatusParam ¶ms, std::string name)
Constructs the TimeStampStatus with the given parameters.
void summary(unsigned char lvl, const std::string s)
Fills out the level and message fields of the DiagnosticStatus.
TimeStampStatus()
Constructs the TimeStampStatus with the default parameters. Uses a default diagnostic task name of "T...
A structure that holds the constructor parameters for the FrequencyStatus class.
void init(const M_string &remappings)
int window_size_
Number of events to consider in the statistics.
std::vector< ros::Time > times_
A structure that holds the constructor parameters for the TimeStampStatus class.
FrequencyStatus(const FrequencyStatusParam ¶ms, std::string name)
Constructs a FrequencyStatus class with the given parameters.
void addf(const std::string &key, const char *format,...)
Add a key-value pair using a format string.
double max_acceptable_
Maximum acceptable difference between two timestamps.
A diagnostic task that monitors the frequency of an event.
double tolerance_
Tolerance with which bounds must be satisfied.
Heartbeat()
Constructs a HeartBeat.
const FrequencyStatusParam params_
SlowTimeStampStatus(const TimeStampStatusParam ¶ms)
void tick()
Signals that an event has occurred.
double min_acceptable_
Minimum acceptable difference between two timestamps.
TimeStampStatus(const TimeStampStatusParam ¶ms)
Constructs the TimeStampStatus with the given parameters. Uses a default diagnostic task name of "Tim...
virtual void run(diagnostic_updater::DiagnosticStatusWrapper &stat)
Fills out this Task's DiagnosticStatusWrapper.
Diagnostic task to monitor the interval between events.
FrequencyStatusParam(double *min_freq, double *max_freq, double tolerance=0.1, int window_size=5)
Creates a filled-out FrequencyStatusParam.
void clear()
Resets the statistics.
TimeStampStatusParam(const double min_acceptable=-1, const double max_acceptable=5)
Creates a filled-out TimeStampStatusParam.
SlowTimeStampStatus(const TimeStampStatusParam ¶ms, const std::string &name)
FrequencyStatus(const FrequencyStatusParam ¶ms)
Constructs a FrequencyStatus class with the given parameters. Uses a default diagnostic task name of ...
TimeStampStatusParam params_
double * max_freq_
Maximum acceptable frequency.
DiagnosticTask is an abstract base class for collecting diagnostic data.
Diagnostic task to monitor whether a node is alive.
void tick(double stamp)
Signals an event. Timestamp stored as a double.
void tick(const ros::Time t)
Signals an event.
std::vector< int > seq_nums_
Wrapper for the diagnostic_msgs::DiagnosticStatus message that makes it easier to update...