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> 32 #include <Eigen/Geometry> 53 template<
typename MotionModelT, std::
int32_t kNumOfStates, std::
int32_t kProcessNoiseDim>
58 template<std::
int32_t kRows, std::
int32_t kCols>
59 using RectangularMatrixT = Eigen::Matrix<common::types::float32_t, kRows, kCols>;
61 template<std::
int32_t kNum>
62 using SquareMatrixT = Eigen::Matrix<common::types::float32_t, kNum, kNum>;
64 template<std::
int32_t kLength>
65 using VectorT = Eigen::Matrix<common::types::float32_t, kLength, 1>;
97 const SquareMatrixT<kNumOfStates> & initial_covariance_factor,
98 const RectangularMatrixT<kNumOfStates, kProcessNoiseDim> & process_noise,
99 const std::chrono::nanoseconds & expected_dt,
100 const std::string & frame_id,
101 const std::chrono::nanoseconds & history_duration = std::chrono::milliseconds{5000},
103 std::numeric_limits<common::types::float32_t>::max(),
104 const MotionModelT & motion_model = MotionModelT{})
105 : m_motion_model{motion_model},
106 m_initial_covariance_factor{initial_covariance_factor},
107 m_frame_id{frame_id},
108 m_mahalanobis_threshold{mahalanobis_threshold},
109 m_expected_prediction_period{expected_dt}
112 motion_model.get_num_states() == kNumOfStates,
113 "Wrong number of states in the motion model.");
115 SquareMatrixT<kNumOfStates> F;
116 m_motion_model.compute_jacobian(F, expected_dt);
117 m_GQ_left_factor = F * process_noise;
118 m_filter = std::make_unique<FilterT>(m_motion_model, m_GQ_left_factor);
119 m_history = std::make_unique<HistoryT>(
121 static_cast<std::size_t
>(history_duration / expected_dt),
122 m_mahalanobis_threshold);
132 template<
typename MeasurementT>
133 void add_reset_event_to_history(
const MeasurementT & measurement);
146 void add_reset_event_to_history(
147 const VectorT<kNumOfStates> & state,
148 const SquareMatrixT<kNumOfStates> & initial_covariance_chol,
149 const std::chrono::system_clock::time_point & event_timestamp);
171 template<
typename MeasurementT>
177 return (m_history) && (!m_history->empty()) && m_time_grid.is_initialized();
185 std::unique_ptr<FilterT> m_filter{};
189 MotionModelT m_motion_model;
191 RectangularMatrixT<kNumOfStates, kProcessNoiseDim> m_GQ_left_factor;
196 SquareMatrixT<kNumOfStates> m_initial_covariance_factor;
198 std::string m_frame_id{};
202 std::unique_ptr<HistoryT> m_history{};
204 std::chrono::nanoseconds m_expected_prediction_period{};
213 #endif // STATE_ESTIMATION_NODES__KALMAN_FILTER_WRAPPER_HPP_
common::types::bool8_t is_initialized() const noexcept
Check if the filter is is_initialized with a state.
Definition: kalman_filter_wrapper.hpp:175
This file defines a class for extended square root covariance filter.
Measurement< common::types::float32_t, motion::motion_model::ConstantAcceleration::States::VELOCITY_X, motion::motion_model::ConstantAcceleration::States::VELOCITY_Y > MeasurementSpeed
Definition: measurement_conversion.hpp:47
float float32_t
Definition: types.hpp:36
An event to indicate a prediction step.
Definition: history.hpp:64
Measurement< common::types::float32_t, motion::motion_model::ConstantAcceleration::States::POSE_X, motion::motion_model::ConstantAcceleration::States::POSE_Y > MeasurementPose
Definition: measurement_conversion.hpp:37
bool bool8_t
Definition: types.hpp:33
This file includes common type definition.
An event to reset the state of the filter.
Definition: history.hpp:72
This file defines the constant velocity motion model.
KalmanFilterWrapper(const SquareMatrixT< kNumOfStates > &initial_covariance_factor, const RectangularMatrixT< kNumOfStates, kProcessNoiseDim > &process_noise, const std::chrono::nanoseconds &expected_dt, const std::string &frame_id, const std::chrono::nanoseconds &history_duration=std::chrono::milliseconds{5000}, common::types::float32_t mahalanobis_threshold=std::numeric_limits< common::types::float32_t >::max(), const MotionModelT &motion_model=MotionModelT{})
Create an EKF wrapper.
Definition: kalman_filter_wrapper.hpp:96
This class encapsulates a history of events used with EKF.
Definition: history.hpp:95
This is a utility class that allows querying timestamps on a 1D grid.
Definition: steady_time_grid.hpp:39
This class provides a high level interface to the Kalman Filter allowing to predict the state of the ...
Definition: kalman_filter_wrapper.hpp:54
Definition: measurement.hpp:46
autoware_auto_msgs::msg::VehicleOdometry Odometry
Definition: safety_state_machine.hpp:43
This class wraps the carlson-schmidt square root covariance filter with some vector-valued motion mod...
Definition: esrcf.hpp:48
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24