Decides which messages of a stream to pass so that the output rate does not exceed a cap.
More...
#include <rate_throttle.hpp>
|
| | RateThrottle (const double rate) |
| | RateThrottle (const std::chrono::nanoseconds period) |
| bool | accept (const rclcpp::Time &now) |
| | decide whether a message arriving at now should be passed (and register it if so)
|
Decides which messages of a stream to pass so that the output rate does not exceed a cap.
Deadline (GCRA-like) scheduling: the next allowed time advances by one period per passed message, so a faster, jittery input is decimated to the cap on average instead of undershooting it. A message up to period/4 early is passed, a late message keeps at most period/2 of catch-up credit, so there are no bursts after a pause (passed messages are at least period/4 apart). An input slower than the cap is passed as is. Not thread-safe.
◆ RateThrottle() [1/2]
| mrs_lib::internal::RateThrottle::RateThrottle |
( |
const double | rate | ) |
|
|
inlineexplicit |
- Parameters
-
| rate | maximum output rate [Hz], <= 0 disables throttling |
◆ RateThrottle() [2/2]
| mrs_lib::internal::RateThrottle::RateThrottle |
( |
const std::chrono::nanoseconds | period | ) |
|
|
inlineexplicit |
- Parameters
-
| period | minimum output period, <= 0 disables throttling |
◆ accept()
| bool mrs_lib::internal::RateThrottle::accept |
( |
const rclcpp::Time & | now | ) |
|
|
inline |
decide whether a message arriving at now should be passed (and register it if so)
- Parameters
-
| now | current time, all calls have to use the same clock type |
- Returns
- true if the message should be passed
- Exceptions
-
| std::runtime_error | if now has a different clock type than the previous calls |
The documentation for this class was generated from the following file: