roo_control
API Documentation for roo_control
Loading...
Searching...
No Matches
inert_switch.cpp
Go to the documentation of this file.
2
3#include <cmath>
4
5namespace roo_control {
6
7roo_time::Duration DefaultBackoff(int retry_count) {
8 float min_delay_us = 1000.0f; // 1 ms
9 float max_delay_us = 5000000.0f; // 5 s
10 float delay = pow(1.33, retry_count) * min_delay_us;
11 if (delay > max_delay_us) {
12 delay = max_delay_us;
13 }
14 // Randomize by +=20%, to make unrelated retries spread more evenly in time.
15 delay += (float)delay * ((float)rand() / RAND_MAX - 0.5f) * 0.4f;
16 return roo_time::Micros((uint64_t)delay);
17}
18
19} // namespace roo_control
roo_time::Duration DefaultBackoff(int retry_count)
Default backoff policy for InertSwitch retries.