topic_status_param.hpp
Go to the documentation of this file.
1 #pragma once
2 
11 #include <limits>
12 #include <type_traits>
13 
15 #include <ros/message_traits.h>
16 
17 namespace cras
18 {
19 
27 {
28  typedef ::std::remove_pointer_t<decltype(::diagnostic_updater::FrequencyStatusParam::max_freq_)> RateType;
29 
32 
34  RateType maxRate {::std::numeric_limits<RateType>::infinity()};
35 
38 
41 };
42 
50 {
51  typedef ::std::remove_pointer_t<decltype(::diagnostic_updater::FrequencyStatusParam::max_freq_)> RateType;
52 
55 
57  RateType maxRate {::std::numeric_limits<RateType>::infinity()};
58 
61 
64 
67 
70 };
71 
78 template <typename Message>
79 using SimpleTopicStatusParam = ::std::conditional_t<::ros::message_traits::HasHeader<Message>::value,
81 
86 {
88  typedef ::cras::SimpleTopicStatusParamNoHeader NoHeaderParam;
90  typedef ::cras::SimpleTopicStatusParamWithHeader HeaderParam;
91 
93  static constexpr NoHeaderParam _1Hz {1, 1};
95  static constexpr HeaderParam delayed1Hz {1, 1};
97  static constexpr HeaderParam fast1Hz {1, 1, 0.1, 5, -1, 0.1};
98 
100  static constexpr NoHeaderParam _10Hz {10, 10};
102  static constexpr HeaderParam delayed10Hz {10, 10};
104  static constexpr HeaderParam fast10Hz {10, 10, 0.1, 5, -1, 0.1};
105 
107  static constexpr NoHeaderParam _100Hz {100, 100};
109  static constexpr HeaderParam delayed100Hz {100, 100};
111  static constexpr HeaderParam fast100Hz {100, 100, 0.1, 5, -1, 0.1};
112 };
113 
120 {
121 public:
129  FrequencyStatusParam(double *min_freq, double *max_freq, double tolerance = 0.1, int window_size = 5);
130 
139  explicit FrequencyStatusParam(
140  double min_freq = 0.0, double max_freq = ::std::numeric_limits<double>::infinity(),
141  double tolerance = 0.1, int window_size = 5);
142 
149  FrequencyStatusParam(const ::cras::FrequencyStatusParam& other); // NOLINT
150 
156  FrequencyStatusParam(const ::diagnostic_updater::FrequencyStatusParam& other); // NOLINT
157 
163  FrequencyStatusParam(const ::cras::SimpleTopicStatusParamNoHeader& params); // NOLINT
164 
171  ::cras::FrequencyStatusParam& operator=(const ::cras::FrequencyStatusParam& other);
172 
178  ::cras::FrequencyStatusParam& operator=(const ::diagnostic_updater::FrequencyStatusParam& other);
179 
186  double getExpectedRate() const;
187 
188 private:
193  void copyAdditionalData(const ::cras::FrequencyStatusParam& other);
194 
196  double minFreq {0.0};
197 
199  double maxFreq {::std::numeric_limits<double>::infinity()};
200 
203  bool usesInternalPointers {false};
204 };
205 
212 {
213 public:
224  double* min_freq, double* max_freq, double tolerance = 0.1, int window_size = 5,
225  double min_acceptable = -1.0, double max_acceptable = 5.0);
226 
237  TopicStatusParamWithHeader( // NOLINT(google-explicit-constructor)
238  double min_freq = 0.0, double max_freq = ::std::numeric_limits<double>::infinity(),
239  double tolerance = 0.1, int window_size = 5, double min_acceptable = -1.0, double max_acceptable = 5.0);
240 
245  explicit TopicStatusParamWithHeader(const ::diagnostic_updater::FrequencyStatusParam& freqParam);
246 
251  explicit TopicStatusParamWithHeader(const ::diagnostic_updater::TimeStampStatusParam& stampParam);
252 
259  const ::diagnostic_updater::FrequencyStatusParam& freqParam,
260  const ::diagnostic_updater::TimeStampStatusParam& stampParam);
261 
267  TopicStatusParamWithHeader( // NOLINT(google-explicit-constructor)
268  const ::cras::SimpleTopicStatusParamWithHeader& params);
269 };
270 
278 template <typename Message>
279 using TopicStatusParam = ::std::conditional_t<::ros::message_traits::HasHeader<Message>::value,
281 
282 }
cras::SimpleTopicStatusParamNoHeader::minRate
RateType minRate
Minimum allowed frequency.
Definition: topic_status_param.hpp:31
cras::SimpleTopicStatusParam
::std::conditional_t<::ros::message_traits::HasHeader< Message >::value, ::cras::SimpleTopicStatusParamWithHeader, ::cras::SimpleTopicStatusParamNoHeader > SimpleTopicStatusParam
Helper struct for easy brace-initialization of TopicStatusParam objects.
Definition: topic_status_param.hpp:80
cras::SimpleTopicStatusParamNoHeader::maxRate
RateType maxRate
Maximum allowed frequency.
Definition: topic_status_param.hpp:34
cras::TopicStatusParams::NoHeaderParam
::cras::SimpleTopicStatusParamNoHeader NoHeaderParam
The type of parameters for topics without a header.
Definition: topic_status_param.hpp:88
cras::FrequencyStatusParam::maxFreq
double maxFreq
Maximum frequency. This field is used by the internal pointers if they are used, otherwise it is igno...
Definition: topic_status_param.hpp:199
cras
Definition: any.hpp:15
diagnostic_updater::TimeStampStatusParam
cras::TopicStatusParams::_100Hz
static constexpr NoHeaderParam _100Hz
100 Hz headerless topic, rate tolerance 10%, window size 5 updates
Definition: topic_status_param.hpp:107
cras::FrequencyStatusParam::FrequencyStatusParam
FrequencyStatusParam(double *min_freq, double *max_freq, double tolerance=0.1, int window_size=5)
The original constructor from diagnostic_updater::FrequencyStatusParam.
cras::SimpleTopicStatusParamWithHeader::maxDelay
decltype(::diagnostic_updater::TimeStampStatusParam::max_acceptable_) maxDelay
Max acceptable delay (in s). It can be negative if timestamps in future are expected.
Definition: topic_status_param.hpp:69
cras::TopicStatusParamWithHeader::TopicStatusParamWithHeader
TopicStatusParamWithHeader(double *min_freq, double *max_freq, double tolerance=0.1, int window_size=5, double min_acceptable=-1.0, double max_acceptable=5.0)
Construct the param object.
cras::TopicStatusParams::_1Hz
static constexpr NoHeaderParam _1Hz
1 Hz headerless topic, rate tolerance 10%, window size 5 updates
Definition: topic_status_param.hpp:93
cras::SimpleTopicStatusParamWithHeader::minDelay
decltype(::diagnostic_updater::TimeStampStatusParam::min_acceptable_) minDelay
Min acceptable delay (in s). It can be negative if timestamps in future are expected.
Definition: topic_status_param.hpp:66
diagnostic_updater::FrequencyStatusParam::max_freq_
double * max_freq_
cras::TopicStatusParams::fast100Hz
static constexpr HeaderParam fast100Hz
100 Hz topic with header, rate tolerance 10%, window size 5 updates, delay -1 to 0....
Definition: topic_status_param.hpp:111
diagnostic_updater::TimeStampStatusParam::min_acceptable_
double min_acceptable_
cras::FrequencyStatusParam::operator=
::cras::FrequencyStatusParam & operator=(const ::cras::FrequencyStatusParam &other)
Copy values from another object of this type. If it uses the internal pointers, their values are copi...
cras::TopicStatusParams::delayed10Hz
static constexpr HeaderParam delayed10Hz
10 Hz topic with header, rate tolerance 10%, window size 5 updates, delay -1 to 5 secs
Definition: topic_status_param.hpp:102
cras::FrequencyStatusParam::minFreq
double minFreq
Minimum frequency. This field is used by the internal pointers if they are used, otherwise it is igno...
Definition: topic_status_param.hpp:196
cras::SimpleTopicStatusParamWithHeader
Helper struct for easy brace-initialization of TopicStatusParam objects. On supported compilers,...
Definition: topic_status_param.hpp:49
cras::TopicStatusParams::fast1Hz
static constexpr HeaderParam fast1Hz
1 Hz topic with header, rate tolerance 10%, window size 5 updates, delay -1 to 0.1 secs
Definition: topic_status_param.hpp:97
message_traits.h
cras::SimpleTopicStatusParamWithHeader::minRate
RateType minRate
Minimum allowed frequency.
Definition: topic_status_param.hpp:54
cras::FrequencyStatusParam::getExpectedRate
double getExpectedRate() const
Get the expected/average rate. If min and max are the same, their value will be returned....
cras::SimpleTopicStatusParamWithHeader::maxRate
RateType maxRate
Maximum allowed frequency.
Definition: topic_status_param.hpp:57
cras::FrequencyStatusParam::copyAdditionalData
void copyAdditionalData(const ::cras::FrequencyStatusParam &other)
This method handles copying of the internal pointers if they are used.
diagnostic_updater::TimeStampStatusParam::max_acceptable_
double max_acceptable_
cras::TopicStatusParams::delayed1Hz
static constexpr HeaderParam delayed1Hz
1 Hz topic with header, rate tolerance 10%, window size 5 updates, delay -1 to 5 secs
Definition: topic_status_param.hpp:95
cras::SimpleTopicStatusParamWithHeader::rateWindowSize
decltype(::diagnostic_updater::FrequencyStatusParam::window_size_) rateWindowSize
Number of updates during which the frequency is computed.
Definition: topic_status_param.hpp:63
cras::FrequencyStatusParam
An extension of diagnostic_updater::FrequencyStatusParam that allows passing non-pointer min/max freq...
Definition: topic_status_param.hpp:119
cras::TopicStatusParams::_10Hz
static constexpr NoHeaderParam _10Hz
10 Hz headerless topic, rate tolerance 10%, window size 5 updates
Definition: topic_status_param.hpp:100
cras::SimpleTopicStatusParamWithHeader::RateType
::std::remove_pointer_t< decltype(::diagnostic_updater::FrequencyStatusParam::max_freq_)> RateType
Definition: topic_status_param.hpp:51
cras::FrequencyStatusParam::usesInternalPointers
bool usesInternalPointers
Whether internal pointers are used or not (depends on whether this object was constructed with explic...
Definition: topic_status_param.hpp:203
update_functions.h
cras::TopicStatusParams::fast10Hz
static constexpr HeaderParam fast10Hz
10 Hz topic with header, rate tolerance 10%, window size 5 updates, delay -1 to 0....
Definition: topic_status_param.hpp:104
cras::TopicStatusParam
::std::conditional_t<::ros::message_traits::HasHeader< Message >::value, ::cras::TopicStatusParamWithHeader, ::cras::FrequencyStatusParam > TopicStatusParam
Helper struct for automatic choosing of the correct topic status parameter object based on whether th...
Definition: topic_status_param.hpp:280
cras::SimpleTopicStatusParamNoHeader::rateWindowSize
decltype(::diagnostic_updater::FrequencyStatusParam::window_size_) rateWindowSize
Number of updates during which the frequency is computed.
Definition: topic_status_param.hpp:40
cras::SimpleTopicStatusParamNoHeader
Helper struct for easy brace-initialization of TopicStatusParam objects. On supported compilers,...
Definition: topic_status_param.hpp:26
cras::SimpleTopicStatusParamNoHeader::rateTolerance
decltype(::diagnostic_updater::FrequencyStatusParam::tolerance_) rateTolerance
Tolerance of the rate.
Definition: topic_status_param.hpp:37
diagnostic_updater::FrequencyStatusParam::tolerance_
double tolerance_
cras::SimpleTopicStatusParamWithHeader::rateTolerance
decltype(::diagnostic_updater::FrequencyStatusParam::tolerance_) rateTolerance
Tolerance of the rate.
Definition: topic_status_param.hpp:60
cras::TopicStatusParams::delayed100Hz
static constexpr HeaderParam delayed100Hz
100 Hz topic with header, rate tolerance 10%, window size 5 updates, delay -1 to 5 secs
Definition: topic_status_param.hpp:109
cras::TopicStatusParamWithHeader
A combined parameter defining both rate diagnostics and delay diagnostics (for messages with a header...
Definition: topic_status_param.hpp:210
cras::SimpleTopicStatusParamNoHeader::RateType
::std::remove_pointer_t< decltype(::diagnostic_updater::FrequencyStatusParam::max_freq_)> RateType
Definition: topic_status_param.hpp:28
diagnostic_updater::FrequencyStatusParam::window_size_
int window_size_
cras::TopicStatusParams::HeaderParam
::cras::SimpleTopicStatusParamWithHeader HeaderParam
The type of parameters for topics with header.
Definition: topic_status_param.hpp:90
cras::TopicStatusParams
Utility class with various predefined topic diagnostic parameters.
Definition: topic_status_param.hpp:85
diagnostic_updater::FrequencyStatusParam


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Tue Nov 5 2024 03:50:30