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 }
void summary(unsigned char lvl, const std::string s)
Fills out the level and message fields of the DiagnosticStatus.
Author: Blaise Gassend.
virtual void run(diagnostic_updater::DiagnosticStatusWrapper &stat)
Fills out this Task&#39;s DiagnosticStatusWrapper.
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.
double min_acceptable_
Minimum acceptable difference between two timestamps.
void add(const std::string &key, const T &val)
Add a key-value pair.
Wrapper for the diagnostic_msgs::DiagnosticStatus message that makes it easier to update...


diagnostic_updater
Author(s): Kevin Watts, Brice Rebsamen , Jeremy Leibs, Blaise Gassend
autogenerated on Thu Oct 8 2020 03:19:34