Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
ekf_slam_solver_test.cpp
Go to the documentation of this file.
2
3#include <gtest/gtest.h>
4
8
9class EKFSLAMSolverTest : public ::testing::Test {
10protected:
24
25 std::shared_ptr<DataAssociationModel> data_association;
26 std::shared_ptr<V2PMotionModel> motion_model;
27 std::shared_ptr<LandmarkFilter> landmark_filter;
28 std::shared_ptr<EKFSLAMSolver> ekf_slam_solver;
29 std::shared_ptr<std::vector<double>> execution_time;
30 std::weak_ptr<rclcpp::Node> node;
31};
32
37TEST_F(EKFSLAMSolverTest, stateAugmentation) {
38 Eigen::VectorXd state = Eigen::VectorXd::Zero(3);
39 Eigen::MatrixXd covariance = Eigen::MatrixXd::Identity(3, 3);
40 Eigen::VectorXd new_landmarks_coordinates(10);
41 new_landmarks_coordinates << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
42 ekf_slam_solver->state_augmentation(state, covariance, new_landmarks_coordinates);
43 std::vector<double> expected_state = {0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
44 EXPECT_EQ(state.size(), expected_state.size());
45 for (int i = 0; i < state.size(); i++) {
46 EXPECT_NEAR(state(i), expected_state[i], 0.0001);
47 }
48}
49
54TEST_F(EKFSLAMSolverTest, stateAugmentation2) {
55 Eigen::VectorXd state = Eigen::VectorXd::Zero(3);
56 state << 0, 0, M_PI / 2;
57 Eigen::MatrixXd covariance = Eigen::MatrixXd::Identity(3, 3);
58 Eigen::VectorXd new_landmarks_coordinates(10);
59 Eigen::VectorXd new_landmarks_confidences(5);
60 new_landmarks_coordinates << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
61 ekf_slam_solver->state_augmentation(state, covariance, new_landmarks_coordinates);
62 std::vector<double> expected_state = {0, 0, M_PI / 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
63 EXPECT_EQ(state.size(), expected_state.size());
64 for (int i = 0; i < state.size(); i++) {
65 EXPECT_NEAR(state(i), expected_state[i], 0.0001);
66 }
67}
std::weak_ptr< rclcpp::Node > node
std::shared_ptr< std::vector< double > > execution_time
std::shared_ptr< V2PMotionModel > motion_model
std::shared_ptr< LandmarkFilter > landmark_filter
std::shared_ptr< EKFSLAMSolver > ekf_slam_solver
std::shared_ptr< DataAssociationModel > data_association
TEST_F(EKFSLAMSolverTest, stateAugmentation)
Test the state augmentation function of the EKF SLAM solver with trivial state.
const std::map< std::string, std::function< std::shared_ptr< V2PMotionModel >()>, std::less<> > v2p_models_map
Definition map.hpp:17
const std::map< std::string, std::function< std::shared_ptr< DataAssociationModel >(const DataAssociationParameters &)>, std::less<> > data_association_models_map
Map of data association models, with the key being the name of the data association model and the val...
Definition map.hpp:21
Parameters for the SLAM node.
double data_association_gate_
float data_association_limit_distance_
std::string motion_model_name_
double new_landmark_confidence_gate_
std::string data_association_model_name_
std::string load_config()
Load the configuration for the SLAM node from YAML file.