6 : _pose_buffer_(params.max_pose_history_updater) {
24 if (
this == &other)
return *
this;
40 return std::make_shared<PoseUpdater>(*
this);
44 if (
_pose_buffer_.size() == 0)
throw std::out_of_range(
"Pose buffer is empty");
48 if (curr.timestamp.seconds() <= timestamp.seconds()) {
49 if (i == 0)
return curr.pose;
51 auto diff_curr = timestamp.seconds() - curr.timestamp.seconds();
52 auto diff_prev = prev.timestamp.seconds() - timestamp.seconds();
53 return (diff_curr < diff_prev) ? curr.pose : prev.pose;
72 std::shared_ptr<V2PMotionModel> motion_model) {
82 RCLCPP_DEBUG(rclcpp::get_logger(
"slam"),
"Delta time: %f", delta);
83 Eigen::Vector3d new_pose =
85 Eigen::MatrixXd jacobian_motion_data =
87 Eigen::MatrixXd motion_noise = jacobian_motion_data *
89 jacobian_motion_data.transpose();
91 Eigen::Matrix3d adjoint_matrix =
122 const double y_translation,
123 const double rotation_angle)
const {
124 Eigen::Matrix3d adjoint_matrix = Eigen::Matrix3d::Zero();
125 adjoint_matrix(0, 0) = cos(rotation_angle);
126 adjoint_matrix(0, 1) = -sin(rotation_angle);
127 adjoint_matrix(0, 2) = y_translation;
128 adjoint_matrix(1, 0) = sin(rotation_angle);
129 adjoint_matrix(1, 1) = cos(rotation_angle);
130 adjoint_matrix(1, 2) = -x_translation;
131 adjoint_matrix(2, 2) = 1.0;
132 return adjoint_matrix;
Class to update the pose of the vehicle.
CircularBuffer< TimedPose > _pose_buffer_
Eigen::Matrix3d get_adjoint_operator_matrix(double x_translation, double y_translation, double rotation_angle) const
Eigen::Vector3d get_pose_at_timestamp(const rclcpp::Time ×tamp) const
virtual void update_pose(const Eigen::Vector3d &last_pose)
Updates the last pose with the given pose.
Eigen::Vector3d _last_graphed_pose_
Eigen::Matrix3d _last_pose_covariance_
PoseUpdater(const SLAMParameters ¶ms)
PoseUpdater & operator=(const PoseUpdater &other)
bool _received_first_motion_data_
virtual void predict_pose(const MotionData &motion_data, std::shared_ptr< V2PMotionModel > motion_model)
Updates the last pose and returns the pose difference.
virtual bool pose_ready_for_graph_update() const
Check if the pose is ready for graph update.
virtual std::shared_ptr< PoseUpdater > clone() const
Class to update the pose of the vehicle.
rclcpp::Time _last_pose_update_
bool _new_pose_from_graph_
Eigen::Vector3d _last_pose_
Eigen::Vector3d pose_difference_eigen(const Eigen::Vector3d &pose1, const Eigen::Vector3d &pose2)
Data structure to hold motion data.
std::shared_ptr< Eigen::VectorXd > motion_data_
std::shared_ptr< Eigen::VectorXd > motion_data_noise_
Parameters for the SLAM node.