Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
ekf_slam_solver.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Dense>
4#include <chrono>
5
11
14 std::shared_ptr<SLAMObservationModel> observation_model_;
15 Eigen::VectorXd state_ = Eigen::VectorXd::Zero(3);
16 Eigen::MatrixXd covariance_;
17 Eigen::MatrixXd process_noise_matrix_;
18 std::shared_mutex mutex_;
19 Eigen::Vector3d pose_difference_ = Eigen::Vector3d::Zero();
21
22 rclcpp::Time last_update_;
23
25 bool cones_receieved_ = false;
26
34 Eigen::MatrixXd get_observation_noise_matrix(int num_landmarks) const;
35
47 void predict(Eigen::VectorXd& state, Eigen::MatrixXd& covariance,
48 const Eigen::MatrixXd& process_noise_matrix, const rclcpp::Time last_update,
49 const common_lib::structures::Velocities& velocities);
50
62 void correct(Eigen::VectorXd& state, Eigen::MatrixXd& covariance,
63 const std::vector<int>& observed_landmarks_indices,
64 const Eigen::VectorXd& matched_observations);
65
89 void state_augmentation(Eigen::VectorXd& state, Eigen::MatrixXd& covariance,
90 const Eigen::VectorXd& new_landmarks);
91
92 std::vector<common_lib::structures::Cone> get_map_estimate() override;
94
97
98public:
99 EKFSLAMSolver(const SLAMParameters& params,
100 std::shared_ptr<DataAssociationModel> data_association,
101 std::shared_ptr<V2PMotionModel> motion_model,
102 std::shared_ptr<LandmarkFilter> landmark_filter,
103 std::shared_ptr<std::vector<double>> execution_times,
104 std::shared_ptr<LoopClosure> loop_closure);
105
111 void add_velocities(const common_lib::structures::Velocities& velocities) override;
112
118 void add_observations(const std::vector<common_lib::structures::Cone>& positions,
119 rclcpp::Time cones_timestamp) override;
120
127 void load_initial_state(const Eigen::VectorXd& map, const Eigen::Vector3d& pose) override;
128
134 Eigen::MatrixXd get_covariance() override { return covariance_; }
135
141 int get_lap_counter() override { return lap_counter_; }
142
143 Eigen::VectorXi get_associations() const override { return Eigen::VectorXi::Zero(0); }
144 Eigen::VectorXd get_observations_global() const override { return Eigen::VectorXd::Zero(0); }
145 Eigen::VectorXd get_map_coordinates() const override { return Eigen::VectorXd::Zero(0); }
146};
std::shared_mutex mutex_
Eigen::MatrixXd get_observation_noise_matrix(int num_landmarks) const
Get the observation noise matrix object used in the correction step of the EKF with the right dimensi...
Eigen::VectorXi get_associations() const override
void add_velocities(const common_lib::structures::Velocities &velocities) override
Executed to deal with new velocity data.
int get_lap_counter() override
Get the lap counter.
void load_initial_state(const Eigen::VectorXd &map, const Eigen::Vector3d &pose) override
Initialize the EKF SLAM solver with a previously saved map and pose.
Eigen::MatrixXd covariance_
Eigen::VectorXd get_observations_global() const override
void correct(Eigen::VectorXd &state, Eigen::MatrixXd &covariance, const std::vector< int > &observed_landmarks_indices, const Eigen::VectorXd &matched_observations)
correction step of the EKF that updates the state and covariance based on the observed landmarks
common_lib::structures::Pose get_pose_estimate() override
Get the pose estimate object.
Eigen::Vector3d pose_difference_
std::shared_ptr< SLAMObservationModel > observation_model_
SLAMParameters slam_parameters_
friend class EKFSLAMSolverTest_stateAugmentation2_Test
friend class EKFSLAMSolverTest_stateAugmentation_Test
Eigen::MatrixXd get_covariance() override
Get the covariance matrix of the EKF.
rclcpp::Time last_update_
Eigen::VectorXd get_map_coordinates() const override
Eigen::VectorXd state_
void predict(Eigen::VectorXd &state, Eigen::MatrixXd &covariance, const Eigen::MatrixXd &process_noise_matrix, const rclcpp::Time last_update, const common_lib::structures::Velocities &velocities)
executed when velocity data is received.
void state_augmentation(Eigen::VectorXd &state, Eigen::MatrixXd &covariance, const Eigen::VectorXd &new_landmarks)
add new landmarks to the state vector and covariance matrix
std::vector< common_lib::structures::Cone > get_map_estimate() override
Get the map estimate object.
void add_observations(const std::vector< common_lib::structures::Cone > &positions, rclcpp::Time cones_timestamp) override
process obervations of landmarks
Eigen::MatrixXd process_noise_matrix_
Interface for SLAM solvers.
Trait class for velocities integration in SLAM solvers.
Parameters for the SLAM node.
Struct for pose representation.
Definition pose.hpp:13