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 
31  RateType minRate {0};
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 
54  RateType minRate {0};
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 }
An extension of diagnostic_updater::FrequencyStatusParam that allows passing non-pointer min/max freq...
::std::conditional_t<::ros::message_traits::HasHeader< Message >::value, ::cras::SimpleTopicStatusParamWithHeader, ::cras::SimpleTopicStatusParamNoHeader > SimpleTopicStatusParam
Helper struct for easy brace-initialization of TopicStatusParam objects.
::cras::SimpleTopicStatusParamWithHeader HeaderParam
The type of parameters for topics with header.
RateType minRate
Minimum allowed frequency.
::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...
A combined parameter defining both rate diagnostics and delay diagnostics (for messages with a header...
RateType maxRate
Maximum allowed frequency.
decltype(::diagnostic_updater::FrequencyStatusParam::window_size_) rateWindowSize
Number of updates during which the frequency is computed.
::cras::SimpleTopicStatusParamNoHeader NoHeaderParam
The type of parameters for topics without a header.
::std::remove_pointer_t< decltype(::diagnostic_updater::FrequencyStatusParam::max_freq_)> RateType
decltype(::diagnostic_updater::FrequencyStatusParam::tolerance_) rateTolerance
Tolerance of the rate.
Helper struct for easy brace-initialization of TopicStatusParam objects. On supported compilers...
Definition: any.hpp:15
::std::remove_pointer_t< decltype(::diagnostic_updater::FrequencyStatusParam::max_freq_)> RateType
Helper struct for easy brace-initialization of TopicStatusParam objects. On supported compilers...
Utility class with various predefined topic diagnostic parameters.


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Sat Jun 17 2023 02:32:53