Open dllu opened 4 years ago
Nice.
I like the template solution, as it allows for a default template argument that we can set to double for backwards compatibility. Note there is the reverse map TimestampKeyMap
that needs to be supported, too.
I'd love it if you'd put in a PR for this :-) if so please use TimeStamp as the keyword argument, and we should switch to using
instead of typedef.
Feature
FixedLagSmoother
should usestd::chrono
types, or be templated to accept any type, for managing timestamps instead ofdouble
.Motivation
Currently
FixedLagSmoother
has hardcoded the type for timestamps asdouble
. However, this is not strictly correct, as it leads to:The STL
#include <chrono>
provides templated types using either integer or floating point backend as zero-cost abstractions over using primitive integer or floating point types. It provides the notions oftime_point
andduration
. In addition it becomes easy to use it with real system time, e.g.std::chrono::steady_clock::now()
.Paying close attention to timestamp types may also bugs, as it disincentivises people from writing code that looks like
which may iterate an unexpected number of types for some choices of
deltaT
.Pitch
I skimmed through the code of
FixedLagSmoother
and its derived classes and it seems straightforward to replacedouble
with another type.For example, instead of
double
, we can have:Alternatives
Instead of using
std::chrono
we could also just template to let the user supply any type, so that users are free to decide whether they want to usestd::chrono
or not, e.g.Additional context
The ISO C++ Core Guidelines provides an example of an interface
blink_led
that takes a timestamp as an input.