19 #ifndef LOCALIZATION_COMMON_TIMESTAMPED_INTERPOLATER_H_
20 #define LOCALIZATION_COMMON_TIMESTAMPED_INTERPOLATER_H_
25 #include <gtsam/base/Matrix.h>
27 #include <Eigen/Geometry>
29 #include <boost/optional.hpp>
39 template <
typename T,
class ParamsT = DefaultInterpolationParams>
44 const boost::optional<int> max_size = boost::none);
53 T
Interpolate(
const T& a,
const T& b,
const double alpha)
const;
56 boost::optional<T>
Relative(
const Time timestamp_a,
const Time timestamp_b)
const;
60 T
Relative(
const T& a,
const T& b)
const;
66 const ParamsT&
params()
const;
76 template <
typename T,
class ParamsT>
80 template <
typename T,
class ParamsT>
82 const std::vector<T>& objects,
83 const boost::optional<int> max_size)
86 template <
typename T,
class ParamsT>
90 if (lower_and_upper_bound.second && lower_and_upper_bound.second->timestamp == timestamp)
91 return lower_and_upper_bound.second->value;
92 if (!lower_and_upper_bound.first || !lower_and_upper_bound.second) {
93 LogDebug(
"Interpolate: Failed to get lower and upper bound timestamps for query timestamp " << timestamp <<
".");
97 const Time lower_bound_time = lower_and_upper_bound.first->timestamp;
98 const Time upper_bound_time = lower_and_upper_bound.second->timestamp;
99 const double alpha = (timestamp - lower_bound_time) / (upper_bound_time - lower_bound_time);
100 return Interpolate(lower_and_upper_bound.first->value, lower_and_upper_bound.second->value, alpha);
103 template <
typename T,
class ParamsT>
105 static_assert(
sizeof(T) == std::size_t(-1),
"This needs to be specialized by template class.");
108 template <
typename T,
class ParamsT>
113 LogDebug(
"Relative: Failed to get interpolated objects for query timestamps " << timestamp_a <<
" and "
114 << timestamp_b <<
".");
118 return Relative(*a, *b);
121 template <
typename T,
class ParamsT>
123 static_assert(
sizeof(T) == std::size_t(-1),
"This needs to be specialized by template class.");
126 template <
typename T,
class ParamsT>
131 template <
typename T,
class ParamsT>
137 #endif // LOCALIZATION_COMMON_TIMESTAMPED_INTERPOLATER_H_