duration_status.h
Go to the documentation of this file.
1 #pragma once
2 
11 #include <memory>
12 #include <mutex>
13 #include <string>
14 #include <vector>
15 
18 #include <ros/duration.h>
19 #include <ros/time.h>
20 
25 
26 namespace cras
27 {
28 
35 {
36 public:
43  DurationStatus(const ::std::string& name, const ::cras::DurationStatusParam& params);
44 
55  explicit DurationStatus(const ::std::string& name,
56  const ::ros::Duration& minDuration = {0, 0}, const ::ros::Duration& maxDuration = ::ros::DURATION_MAX,
57  double tolerance = 0.1, size_t windowSize = 5u, bool noEventsIsOk = true);
58 
64  DurationStatus(const ::std::string& name, const ::cras::SimpleDurationStatusParam& params);
65 
66  DurationStatus(const ::std::string& name, const ::cras::BoundParamHelperPtr& params,
67  const ::cras::DurationStatusParam& defaultParams);
68 
69  DurationStatus(const ::std::string& name, const ::cras::BoundParamHelperPtr& params,
70  const ::cras::SimpleDurationStatusParam& defaultParams);
71 
72  ~DurationStatus() override;
73 
78  void start(const ::ros::Time& time = ::ros::Time::now());
79 
84  void start(const ::ros::WallTime& time);
85 
90  void stop(const ::ros::Time& time = ::ros::Time::now());
91 
96  void stop(const ::ros::WallTime& time);
97 
98  void run(::diagnostic_updater::DiagnosticStatusWrapper& stat) override;
99 
104  const ::ros::Duration& getMinDuration() const;
105 
110  const ::ros::Duration& getMaxDuration() const;
111 
116  double getTolerance() const;
117 
122  size_t getWindowSize() const;
123 
124 protected:
127 
128  bool wallTimeMode {false};
129  size_t count {0u};
131  ::cras::optional<::ros::Time> lastStartTime;
132  ::std::vector<::ros::Duration> minDurations;
133  ::std::vector<::ros::Duration> maxDurations;
134  ::std::vector<::ros::Time> historyTimes;
135  ::std::vector<::cras::RunningStats<::ros::Duration>> historyStats;
136  size_t historyIndex {0u};
137  ::std::mutex lock;
138 };
139 
140 using DurationStatusPtr = ::std::shared_ptr<::cras::DurationStatus>;
141 
142 }
cras::DurationStatus::wallTimeMode
bool wallTimeMode
Definition: duration_status.h:128
cras::DurationStatus::historyStats
::std::vector<::cras::RunningStats<::ros::Duration > > historyStats
Definition: duration_status.h:135
cras
Definition: any.hpp:15
cras::RunningStats
Computation of running average and variance using Welford's algorithm.
Definition: running_stats.hpp:28
cras::DurationStatus::start
void start(const ::ros::Time &time=::ros::Time::now())
Start a single duration measurement.
cras::BoundParamHelperPtr
::std::shared_ptr<::cras::BoundParamHelper > BoundParamHelperPtr
Definition: bound_param_helper.hpp:24
cras::DurationStatus::getWindowSize
size_t getWindowSize() const
Number of updates during which the duration is computed.
time.h
cras::DurationStatus::stop
void stop(const ::ros::Time &time=::ros::Time::now())
Stop a single duration measurement.
cras::DurationStatus::getMaxDuration
const ::ros::Duration & getMaxDuration() const
Maximum allowed duration.
cras::DurationStatus::DurationStatus
DurationStatus(const ::std::string &name, const ::cras::DurationStatusParam &params)
Create the diagnostic task for a header-less message (checking frequency only).
cras::DurationStatus::lastStartTime
::cras::optional<::ros::Time > lastStartTime
Definition: duration_status.h:131
cras::DurationStatusPtr
::std::shared_ptr<::cras::DurationStatus > DurationStatusPtr
Definition: duration_status.h:140
cras::DurationStatus::maxDurations
::std::vector<::ros::Duration > maxDurations
Definition: duration_status.h:133
bound_param_helper.hpp
Bound param helper (allows omitting the param adapter in each getParam call).
duration_status_param.h
Definitions of parameters for a DurationStatus diagnostic task.
cras::DurationStatus::stats
::cras::RunningStats<::ros::Duration > stats
Definition: duration_status.h:130
running_stats_duration.hpp
Template specializations of RunningStats for ros::Duration and ros::WallDuration.
diagnostic_updater.h
diagnostic_updater::DiagnosticTask
duration.h
cras::DurationStatus::historyTimes
::std::vector<::ros::Time > historyTimes
Definition: duration_status.h:134
DiagnosticStatusWrapper.h
cras::DurationStatus::params
::cras::DurationStatusParam params
The parameters via which this task has been configured.
Definition: duration_status.h:126
cras::DurationStatus::~DurationStatus
~DurationStatus() override
cras::DurationStatus::lock
::std::mutex lock
Definition: duration_status.h:137
cras::DurationStatus::historyIndex
size_t historyIndex
Definition: duration_status.h:136
cras::DurationStatusParam
Parameters of DurationStatus diagnostic task.
Definition: duration_status_param.h:21
cras::DurationStatus::getTolerance
double getTolerance() const
Tolerance of duration.
cras::DurationStatus::getMinDuration
const ::ros::Duration & getMinDuration() const
Minimum allowed duration.
cras::DurationStatus::run
void run(::diagnostic_updater::DiagnosticStatusWrapper &stat) override
cras::DurationStatus::count
size_t count
Definition: duration_status.h:129
cras::DurationStatus
Diagnostic task for topic frequency and timestamp delay (combining FrequencyStatus and TimeStampStatu...
Definition: duration_status.h:34
cras::DurationStatus::minDurations
::std::vector<::ros::Duration > minDurations
Definition: duration_status.h:132
diagnostic_updater::DiagnosticStatusWrapper
ros::Time::now
static Time now()
optional.hpp
A C++11 shim for std::optional. Uses std::optional when used in C++17 mode.


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Tue Nov 26 2024 03:49:04