18 #ifndef STATE_ESTIMATION_NODES__KALMAN_FILTER_WRAPPER_HPP_
19 #define STATE_ESTIMATION_NODES__KALMAN_FILTER_WRAPPER_HPP_
24 #include <nav_msgs/msg/odometry.hpp>
30 #include <Eigen/Geometry>
50 template<
typename MotionModelT, std::
int32_t kNumOfStates, std::
int32_t kProcessNoiseDim>
55 template<std::
int32_t kRows, std::
int32_t kCols>
56 using RectangularMatrixT = Eigen::Matrix<common::types::float32_t, kRows, kCols>;
58 template<std::
int32_t kNum>
59 using SquareMatrixT = Eigen::Matrix<common::types::float32_t, kNum, kNum>;
61 template<std::
int32_t kLength>
62 using VectorT = Eigen::Matrix<common::types::float32_t, kLength, 1>;
84 const SquareMatrixT<kNumOfStates> & initial_covariance_factor,
85 const RectangularMatrixT<kNumOfStates, kProcessNoiseDim> & process_noise,
86 const std::chrono::nanoseconds & expected_dt,
87 const std::string & frame_id,
89 std::numeric_limits<common::types::float32_t>::max(),
90 const MotionModelT & motion_model = MotionModelT{})
91 : m_motion_model{motion_model},
92 m_initial_covariance_factor{initial_covariance_factor},
94 m_mahalanobis_threshold{mahalanobis_threshold}
97 motion_model.get_num_states() == kNumOfStates,
98 "Wrong number of states in the motion model.");
100 SquareMatrixT<kNumOfStates> F;
101 m_motion_model.compute_jacobian(F, expected_dt);
102 m_GQ_left_factor = F * process_noise;
103 m_ekf = std::make_unique<FilterT>(m_motion_model, m_GQ_left_factor);
114 template<
typename MeasurementT>
115 void reset(
const MeasurementT & measurement,
const GlobalTime & time_of_event_occurance);
130 const VectorT<kNumOfStates> & state,
131 const SquareMatrixT<kNumOfStates> & initial_covariance_chol,
146 template<TimeReferenceFrame kTimeReferenceFrame>
148 const Time<kTimeReferenceFrame> & time_of_update);
164 template<
typename MeasurementT>
167 const MeasurementT & measurement);
172 return m_ekf_initialized && m_time_keeper.is_initialized();
181 const VectorT<kNumOfStates> &
sample,
182 const VectorT<kNumOfStates> & mean,
183 const SquareMatrixT<kNumOfStates> & covariance_factor)
const;
188 MeasurementBasedTimeKeeper m_time_keeper{};
190 MotionModelT m_motion_model;
192 RectangularMatrixT<kNumOfStates, kProcessNoiseDim> m_GQ_left_factor;
197 SquareMatrixT<kNumOfStates> m_initial_covariance_factor;
199 std::unique_ptr<FilterT> m_ekf{};
201 std::string m_frame_id{};
212 #endif // STATE_ESTIMATION_NODES__KALMAN_FILTER_WRAPPER_HPP_