Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
least_squares_test.cpp
Go to the documentation of this file.
1#include <gtest/gtest.h>
2
3#include <utils/cluster.hpp>
4
6
10class LeastSquaresDifferentiationTest : public ::testing::Test {
11protected:
15 void SetUp() override {
16 blue_cone = std::make_shared<pcl::PointCloud<pcl::PointXYZI>>();
17 yellow_cone = std::make_shared<pcl::PointCloud<pcl::PointXYZI>>();
18 pcl_cloud_2_points = std::make_shared<pcl::PointCloud<pcl::PointXYZI>>();
19 real_blue_cone = std::make_shared<pcl::PointCloud<pcl::PointXYZI>>();
20
21 blue_cone->points.push_back(pcl::PointXYZI{1.0, 0.0, 0.0, 20});
22 blue_cone->points.push_back(pcl::PointXYZI{0.0, 1.0, 1, 20});
23 blue_cone->points.push_back(pcl::PointXYZI{0.0, 0.0, 2.0, 21});
24 blue_cone->points.push_back(pcl::PointXYZI{0.0060, 0.0060, 4.0, 60.0});
25 blue_cone->points.push_back(pcl::PointXYZI{10, 10, 5, 70});
26 blue_cone->points.push_back(pcl::PointXYZI{10, 10, 4.5, 65});
27 blue_cone->points.push_back(pcl::PointXYZI{10, 10, 7, 49});
28 blue_cone->points.push_back(pcl::PointXYZI{10, 10, 9, 30});
29 blue_cone->points.push_back(pcl::PointXYZI{10, 10, 10, 20});
30
31 yellow_cone->points.push_back(pcl::PointXYZI{1.0, 0.0, 0.0, 60});
32 yellow_cone->points.push_back(pcl::PointXYZI{0.0, 1.0, 0, 70});
33 yellow_cone->points.push_back(pcl::PointXYZI{0.0, 0.0, 2.0, 50});
34 yellow_cone->points.push_back(pcl::PointXYZI{0.0060, 0.0060, 3.0, 50.0});
35 yellow_cone->points.push_back(pcl::PointXYZI{10, 10, 4, 40});
36 yellow_cone->points.push_back(pcl::PointXYZI{10, 10, 5, 20});
37 yellow_cone->points.push_back(pcl::PointXYZI{10, 10, 6, 15});
38 yellow_cone->points.push_back(pcl::PointXYZI{10, 10, 7, 30});
39 yellow_cone->points.push_back(pcl::PointXYZI{10, 10, 8, 45});
40 yellow_cone->points.push_back(pcl::PointXYZI{10, 10, 9, 60});
41 yellow_cone->points.push_back(pcl::PointXYZI{10, 10, 10, 80});
42
43 pcl_cloud_2_points->points.push_back(pcl::PointXYZI{1.0, 0.0, 0.0, 0.5});
44 pcl_cloud_2_points->points.push_back(pcl::PointXYZI{0.0, 1.0, 0.0, 1.0});
45
46 real_blue_cone->points.push_back(pcl::PointXYZI{1.0, 0.0, 0.3, 5});
47 real_blue_cone->points.push_back(pcl::PointXYZI{1.0, 0.0, 0.3, 1});
48 real_blue_cone->points.push_back(pcl::PointXYZI{1.0, 0.0, 0.3, 72});
49 real_blue_cone->points.push_back(pcl::PointXYZI{1.0, 0.0, 0.27, 6});
50 }
51
52 pcl::PointCloud<pcl::PointXYZI>::Ptr blue_cone;
53 pcl::PointCloud<pcl::PointXYZI>::Ptr yellow_cone;
54 pcl::PointCloud<pcl::PointXYZI>::Ptr pcl_cloud_2_points;
55 pcl::PointCloud<pcl::PointXYZI>::Ptr real_blue_cone;
57};
58
60 Cluster cluster(yellow_cone);
61
62 cone_differentiator.coneDifferentiation(&cluster);
63
64 ASSERT_EQ(cluster.get_color(), "yellow");
65}
66
68 Cluster cluster(blue_cone);
69
70 cone_differentiator.coneDifferentiation(&cluster);
71
72 ASSERT_EQ(cluster.get_color(), "blue");
73}
74
76 Cluster cluster(pcl_cloud_2_points);
77
78 cone_differentiator.coneDifferentiation(&cluster);
79
80 ASSERT_EQ(cluster.get_color(), "undefined");
81}
Represents a cluster of 3D points using PCL (Point Cloud Library).
Definition cluster.hpp:14
std::string get_color()
Get the color associated with the cluster.
Definition cluster.cpp:30
Class for Cone Differentiation using the Least Squares Method.
Fixture for testing the LeastSquaresDifferentiation class.
pcl::PointCloud< pcl::PointXYZI >::Ptr real_blue_cone
pcl::PointCloud< pcl::PointXYZI >::Ptr yellow_cone
pcl::PointCloud< pcl::PointXYZI >::Ptr blue_cone
const LeastSquaresDifferentiation cone_differentiator
pcl::PointCloud< pcl::PointXYZI >::Ptr pcl_cloud_2_points
void SetUp() override
Set up the test fixtures.
TEST_F(LeastSquaresDifferentiationTest, TestYellowCone)