Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
base_pose_updater.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Dense>
4#include <memory>
5#include <utility>
6
11
19protected:
20 struct TimedPose {
21 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
22 Eigen::Vector3d pose;
23 rclcpp::Time timestamp;
24
25 TimedPose() : pose(Eigen::Vector3d::Zero()), timestamp(rclcpp::Time(0)) {}
26 TimedPose(const Eigen::Vector3d& p, const rclcpp::Time& t) : pose(p), timestamp(t) {}
27 };
28
29 Eigen::Vector3d _last_pose_;
30 Eigen::Vector3d _last_graphed_pose_;
31 Eigen::Matrix3d _last_pose_covariance_;
32 rclcpp::Time _last_pose_update_;
33
36
38
39public:
40 explicit PoseUpdater(const SLAMParameters& params);
41 PoseUpdater(const PoseUpdater& other);
42 PoseUpdater& operator=(const PoseUpdater& other);
43 virtual ~PoseUpdater();
44
51 virtual std::shared_ptr<PoseUpdater> clone() const;
52
59 virtual void predict_pose(const MotionData& motion_data,
60 std::shared_ptr<V2PMotionModel> motion_model);
61
69 virtual void update_pose(const Eigen::Vector3d& last_pose);
70
75 virtual bool pose_ready_for_graph_update() const;
76
77 Eigen::Matrix3d get_adjoint_operator_matrix(double x_translation, double y_translation,
78 double rotation_angle) const;
79
80 Eigen::Vector3d get_last_pose() const { return _last_pose_; }
81
82 Eigen::Vector3d get_last_graphed_pose() const { return _last_graphed_pose_; }
83
84 Eigen::Vector3d get_pose_difference_noise() const {
85 // Return the square root of the diagonal as standard deviation
86 return _last_pose_covariance_.diagonal().array().sqrt();
87 }
88
89 rclcpp::Time get_last_pose_update() const { return _last_pose_update_; }
90
91 inline size_t pose_buffer_size() const { return _pose_buffer_.size(); }
92 inline size_t pose_buffer_capacity() const { return _pose_buffer_.capacity(); }
93
94 Eigen::Vector3d get_pose_at_timestamp(const rclcpp::Time& timestamp) const;
95};
Class to update the pose of the vehicle.
CircularBuffer< TimedPose > _pose_buffer_
rclcpp::Time get_last_pose_update() const
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 &timestamp) const
virtual void update_pose(const Eigen::Vector3d &last_pose)
Updates the last pose with the given pose.
Eigen::Vector3d get_last_graphed_pose() const
Eigen::Vector3d _last_graphed_pose_
Eigen::Matrix3d _last_pose_covariance_
Eigen::Vector3d get_pose_difference_noise() const
PoseUpdater & operator=(const PoseUpdater &other)
bool _received_first_motion_data_
size_t pose_buffer_capacity() const
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.
Eigen::Vector3d get_last_pose() const
virtual std::shared_ptr< PoseUpdater > clone() const
Class to update the pose of the vehicle.
rclcpp::Time _last_pose_update_
size_t pose_buffer_size() const
Eigen::Vector3d _last_pose_
virtual ~PoseUpdater()
Data structure to hold motion data.
TimedPose(const Eigen::Vector3d &p, const rclcpp::Time &t)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector3d pose
Parameters for the SLAM node.