20 #ifndef STATE_ESTIMATION_NODES__KALMAN_FILTER_WRAPPER_HPP_
21 #define STATE_ESTIMATION_NODES__KALMAN_FILTER_WRAPPER_HPP_
25 #include <nav_msgs/msg/odometry.hpp>
34 #include <Eigen/Geometry>
47 namespace state_estimation
56 template<
typename FilterT>
67 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
85 const typename FilterT::MotionModel motion_model,
86 const typename FilterT::NoiseModel noise_model,
87 const typename FilterT::State::Matrix initial_state_covariance,
88 const std::chrono::nanoseconds & expected_dt,
89 const std::string & frame_id,
90 const std::chrono::nanoseconds & history_duration = std::chrono::milliseconds{5000},
92 std::numeric_limits<common::types::float32_t>::max())
93 : m_initial_covariance{initial_state_covariance},
95 m_mahalanobis_threshold{mahalanobis_threshold},
96 m_expected_prediction_period{expected_dt},
101 initial_state_covariance,
105 static_cast<std::size_t
>(history_duration / expected_dt),
106 m_mahalanobis_threshold} {}
115 template<
typename MeasurementT>
118 add_reset_event_to_history(
119 measurement.measurement.map_into(
State{}),
120 m_initial_covariance,
121 measurement.timestamp);
134 const typename State::Matrix & initial_covariance,
135 const std::chrono::system_clock::time_point & event_timestamp)
138 m_time_grid =
SteadyTimeGrid{event_timestamp, m_expected_prediction_period};
149 if (!is_initialized()) {
return false;}
150 const auto next_prediction_timestamp =
151 m_time_grid.get_next_timestamp_after(m_history.get_last_timestamp());
168 template<
typename MeasurementT>
171 if (!is_initialized()) {
return false;}
172 m_history.emplace_event(measurement.timestamp, measurement.measurement);
179 return (!m_history.empty()) && m_time_grid.is_initialized();
187 typename State::Matrix m_initial_covariance{};
189 SteadyTimeGrid m_time_grid{};
191 std::string m_frame_id{};
195 std::chrono::nanoseconds m_expected_prediction_period{};
199 HistoryT m_history{};
212 #endif // STATE_ESTIMATION_NODES__KALMAN_FILTER_WRAPPER_HPP_