timestamp_status.cpp
Go to the documentation of this file.
2 
3 using namespace diagnostic_updater;
4 
6  boost::mutex::scoped_lock lock(lock_);
7 
8  using diagnostic_msgs::DiagnosticStatus;
9 
10  stat.summary(DiagnosticStatus::OK, "Timestamps are reasonable.");
11  if (!deltas_valid_)
12  {
13  const auto no_data_is_problem = dynamic_cast<SlowTimeStampStatus*>(this) == nullptr;
14  const auto status = no_data_is_problem ? DiagnosticStatus::WARN : DiagnosticStatus::OK;
15  stat.summary(status, "No data since last update.");
16 
17  stat.add("Earliest timestamp delay", "No data");
18  stat.add("Latest timestamp delay", "No data");
19  }
20  else
21  {
23  {
24  stat.summary(DiagnosticStatus::ERROR, "Timestamps too far in future seen.");
25  early_count_++;
26  }
27 
29  {
30  stat.summary(DiagnosticStatus::ERROR, "Timestamps too far in past seen.");
31  late_count_++;
32  }
33 
34  if (zero_seen_)
35  {
36  stat.summary(DiagnosticStatus::ERROR, "Zero timestamp seen.");
37  zero_count_++;
38  }
39 
40  stat.addf("Earliest timestamp delay", "%f", min_delta_);
41  stat.addf("Latest timestamp delay", "%f", max_delta_);
42  }
43 
44  stat.addf("Earliest acceptable timestamp delay", "%f", params_.min_acceptable_);
45  stat.addf("Latest acceptable timestamp delay", "%f", params_.max_acceptable_);
46  stat.add("Late diagnostic update count", late_count_);
47  stat.add("Early diagnostic update count", early_count_);
48  stat.add("Zero seen diagnostic update count", zero_count_);
49 
50  deltas_valid_ = false;
51  min_delta_ = 0;
52  max_delta_ = 0;
53  zero_seen_ = false;
54 }
diagnostic_updater::TimeStampStatus::max_delta_
double max_delta_
Definition: update_functions.h:396
diagnostic_updater._diagnostic_status_wrapper.WARN
WARN
Definition: _diagnostic_status_wrapper.py:43
diagnostic_updater._diagnostic_status_wrapper.ERROR
ERROR
Definition: _diagnostic_status_wrapper.py:44
diagnostic_updater::TimeStampStatus::late_count_
int late_count_
Definition: update_functions.h:393
update_functions.h
diagnostic_updater::DiagnosticStatusWrapper::add
void add(const std::string &key, const T &val)
Add a key-value pair.
Definition: DiagnosticStatusWrapper.h:268
diagnostic_updater::TimeStampStatusParam::min_acceptable_
double min_acceptable_
Minimum acceptable difference between two timestamps.
Definition: update_functions.h:277
diagnostic_updater::TimeStampStatus::zero_seen_
bool zero_seen_
Definition: update_functions.h:395
diagnostic_updater::SlowTimeStampStatus
Definition: update_functions.h:406
diagnostic_updater
Author: Blaise Gassend.
Definition: diagnostic_updater.h:51
diagnostic_updater::TimeStampStatusParam::max_acceptable_
double max_acceptable_
Maximum acceptable difference between two timestamps.
Definition: update_functions.h:271
diagnostic_updater::TimeStampStatus::run
virtual void run(diagnostic_updater::DiagnosticStatusWrapper &stat)
Fills out this Task's DiagnosticStatusWrapper.
Definition: timestamp_status.cpp:5
diagnostic_updater::TimeStampStatus::lock_
boost::mutex lock_
Definition: update_functions.h:399
diagnostic_updater::DiagnosticStatusWrapper::summary
void summary(unsigned char lvl, const std::string s)
Fills out the level and message fields of the DiagnosticStatus.
Definition: DiagnosticStatusWrapper.h:140
diagnostic_updater::TimeStampStatus::deltas_valid_
bool deltas_valid_
Definition: update_functions.h:398
diagnostic_updater::DiagnosticStatusWrapper::addf
void addf(const std::string &key, const char *format,...)
Add a key-value pair using a format string.
Definition: DiagnosticStatusWrapper.h:288
diagnostic_updater._diagnostic_status_wrapper.OK
OK
Definition: _diagnostic_status_wrapper.py:42
diagnostic_updater::DiagnosticStatusWrapper
Wrapper for the diagnostic_msgs::DiagnosticStatus message that makes it easier to update.
Definition: DiagnosticStatusWrapper.h:98
diagnostic_updater::TimeStampStatus::early_count_
int early_count_
Definition: update_functions.h:392
diagnostic_updater::TimeStampStatus::params_
TimeStampStatusParam params_
Definition: update_functions.h:391
diagnostic_updater::TimeStampStatus::min_delta_
double min_delta_
Definition: update_functions.h:397
diagnostic_updater::TimeStampStatus::zero_count_
int zero_count_
Definition: update_functions.h:394


diagnostic_updater
Author(s): Kevin Watts, Brice Rebsamen , Jeremy Leibs, Blaise Gassend
autogenerated on Tue Nov 15 2022 03:17:19