30 using TimePosList = std::deque<TimePosPair>;
46 void add(
const T& pos,
double time)
58 std::vector<T> points()
const 60 std::vector<T> points;
61 for (
auto&& p : _list) {
62 points.push_back(p.where);
67 bool empty()
const {
return _list.empty(); }
68 size_t size()
const {
return _list.size(); }
70 double start_time()
const 82 double latest_time()
const 85 return _list.back().when;
91 return _list.back().where;
97 CHECK_GE_F(size(), 2);
98 return _list[_list.size()-1].where - _list[_list.size()-2].where;
101 double duration()
const 104 return latest_time() - start_time();
116 double dt = _list.back().when - _list[begin].when;
122 T dx = _list.back().where - _list[begin].where;
124 return dx / (float)dt;
129 return velocity(latest_time());
137 const double now = latest_time();
139 for (
size_t i=0; i<_list.size(); ++i) {
140 if (now - _list[i].when < duration) {
141 if (distance(_list[i].where, _list.back().where) > max_dist) {
155 while (!_list.empty() && _list.front().when < now - _max_history_time) {
164 if (_list.size() < 2) {
168 auto duration = now - start_time();
176 for (
size_t i=0; i<_list.size()-1; ++i) {
177 if (now - _list[i].when < vel_time) {
210 bool _has_start =
false;
213 double _max_history_time = 10;
223 virtual float velocity(
double now)
const override;
Definition: movement_tracker.hpp:22
static constexpr double velocity_time()
The time over which we calculate velocity.
Definition: movement_tracker.hpp:203
Definition: movement_tracker.hpp:25
static constexpr size_t min_velocity_samples()
The minimum number of samples for there to be any velocity calculated.
Definition: movement_tracker.hpp:191
void flush(double now)
Flush out oldes entries.
Definition: movement_tracker.hpp:153
T rel() const
Last movement delta.
Definition: movement_tracker.hpp:95
bool is_still(F max_dist, double duration) const
Has all movement been within "max_dist" radius, during the last "duration" seconds?
Definition: movement_tracker.hpp:134
Made to take into account the cyclic nature of angles (in radians, btw)
Definition: movement_tracker.hpp:219
virtual T velocity(double now) const
Definition: movement_tracker.hpp:109
static constexpr double min_velocity_time()
Minimum time before we have a good velocity.
Definition: movement_tracker.hpp:197
Definition: coroutine.hpp:18
bool velocity_calc_begin(size_t &out_index, double now) const
From where shall we calculate velocity? Return false on "not at all".
Definition: movement_tracker.hpp:162