Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
icp_test.cpp
Go to the documentation of this file.
1
6#include "icp/icp.hpp"
7
8#include <gtest/gtest.h>
9
10#include <memory>
11
16class ICPSuite : public ::testing::Test {
17public:
18 pcl::PointCloud<pcl::PointXYZI>::Ptr source_cloud;
19
20protected:
24 void SetUp() override {
25 source_cloud = std::make_shared<pcl::PointCloud<pcl::PointXYZI>>();
26 source_cloud->points.push_back(pcl::PointXYZI{3, -3, 0, 0});
27 source_cloud->points.push_back(pcl::PointXYZI{2, -4, 0, 0});
28 source_cloud->points.push_back(pcl::PointXYZI{4, -4, 0, 0});
29 source_cloud->width = 1;
30 source_cloud->height = 3;
31 }
32};
33
37TEST_F(ICPSuite, Initialization) {
38 ICP icp("../../src/perception/test/icp/icp_tests/basic_cloud.pcd", 0.1, 50, 1e-8, 1);
39 const pcl::PointCloud<pcl::PointXYZI>::Ptr target_cloud =
40 std::make_shared<pcl::PointCloud<pcl::PointXYZI>>();
41 ASSERT_NO_THROW(icp.executeICP(source_cloud, target_cloud));
42}
43
47TEST_F(ICPSuite, Alignment) {
48 ICP icp("../../src/perception/test/icp/icp_tests/basic_cloud.pcd", 100.0, 300, 5, 5);
49
50 const pcl::PointCloud<pcl::PointXYZI>::Ptr aligned_cloud =
51 std::make_shared<pcl::PointCloud<pcl::PointXYZI>>();
52 const double fitness_score = icp.executeICP(source_cloud, aligned_cloud);
53
54 // Ensure that the fitness score is not negative, indicating successful alignment
55 ASSERT_GE(fitness_score, 0);
56}
57
61TEST_F(ICPSuite, AlignmentFailed) {
62 ICP icp("../../src/perception/test/icp/icp_tests/basic_cloud.pcd", 1.0, 50, 1e-8, 5);
63
64 const pcl::PointCloud<pcl::PointXYZI>::Ptr aligned_cloud =
65 std::make_shared<pcl::PointCloud<pcl::PointXYZI>>();
66 const double fitness_score = icp.executeICP(source_cloud, aligned_cloud);
67
68 ASSERT_EQ(fitness_score, -1);
69}
Class for performing Iterative Closest Point (ICP) registration.
Definition icp.hpp:12
double executeICP(pcl::PointCloud< pcl::PointXYZI >::Ptr source, pcl::PointCloud< pcl::PointXYZI >::Ptr final_cloud)
Execute the ICP registration.
Definition icp.cpp:24
Test suite for the ICP class.
Definition icp_test.cpp:16
pcl::PointCloud< pcl::PointXYZI >::Ptr source_cloud
Definition icp_test.cpp:18
void SetUp() override
Set up the test fixture.
Definition icp_test.cpp:24
TEST_F(ICPSuite, Initialization)
Test case to check if ICP initializes properly.
Definition icp_test.cpp:37