EasyFleet
A simple-by-default framework for multi-robot, multi-capability fleets built on ROS 2
Toggle main menu visibility
Loading...
Searching...
No Matches
throttle.hpp
1
// Copyright 2026 Intelligent Robotics Lab
2
//
3
// This file is part of the project EasyFleet
4
// Licensed under the Apache License, Version 2.0 (the "License");
5
// you may not use this file except in compliance with the License.
6
// You may obtain a copy of the License at
7
//
8
// http://www.apache.org/licenses/LICENSE-2.0
9
//
10
// Unless required by applicable law or agreed to in writing, software
11
// distributed under the License is distributed on an "AS IS" BASIS,
12
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
// See the License for the specific language governing permissions and
14
// limitations under the License.
15
16
#ifndef EASYFLEET_MISSION_MANAGER__THROTTLE_HPP_
17
#define EASYFLEET_MISSION_MANAGER__THROTTLE_HPP_
18
19
#include <chrono>
20
#include <memory>
21
22
namespace
easyfleet_mission_manager
23
{
24
29
class
Throttle
30
{
31
public
:
34
explicit
Throttle
(std::chrono::milliseconds interval)
35
: interval_(interval), last_(std::make_shared<std::chrono::steady_clock::time_point>())
36
{
37
}
38
42
bool
ready
()
const
43
{
44
const
auto
now = std::chrono::steady_clock::now();
45
if
(now - *last_ >= interval_) {
46
*last_ = now;
47
return
true
;
48
}
49
return
false
;
50
}
51
52
private
:
53
std::chrono::milliseconds interval_;
54
std::shared_ptr<std::chrono::steady_clock::time_point> last_;
55
};
56
57
}
// namespace easyfleet_mission_manager
58
59
#endif
// EASYFLEET_MISSION_MANAGER__THROTTLE_HPP_
easyfleet_mission_manager::Throttle::Throttle
Throttle(std::chrono::milliseconds interval)
Constructs a throttle with the given minimum interval.
Definition
throttle.hpp:34
easyfleet_mission_manager::Throttle::ready
bool ready() const
Whether at least interval has elapsed since the last call that returned true.
Definition
throttle.hpp:42
easyfleet_mission_manager
include
easyfleet_mission_manager
throttle.hpp
Generated by
1.17.0