Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
circunference_center_calculation_test.cpp
Go to the documentation of this file.
1#include <gtest/gtest.h>
2
5#include <sensor_msgs/msg/point_cloud2.hpp>
6#include <sensor_msgs/msg/point_field.hpp>
8#include <utils/cluster.hpp>
9#include <utils/plane.hpp>
10
16class CircunferenceCenterCalculationTest : public ::testing::Test {
17public:
20
21protected:
22 void SetUp() override {
24 plane_ = Plane(0, 0, 1, 0);
25 }
26};
27
33 std::vector<std::array<float, 5>> pts = {{0.0, 0.0, 1.0, 0.5, 39},
34 {2.0, 2.0, 1.0, 1.0, 39},
35 {4.0, 0.0, 1.0, 1.5, 39},
36 {2.0, -2.0, 1.0, 1.5, 39}};
37 auto input_cloud = test_utils::make_lidar_pointcloud2(pts);
38 std::vector<int> indices = {0, 1, 2, 3};
39 auto output_cloud = test_utils::make_lidar_pointcloud2({});
40 auto center = center_calculator_.calculate_center(input_cloud, indices, plane_);
41 ASSERT_EQ(center.x(), 2);
42 ASSERT_EQ(center.y(), 0);
43}
44
50 std::vector<std::array<float, 5>> pts = {{0.0, 0.0, 2.0, 0.5, 39},
51 {3.0, 3.0, 2.0, 1.0, 39},
52 {-3.0, 3.0, 2.0, 1.5, 39},
53 {0.0, 6.0, 2.0, 1.5, 39}};
54 auto input_cloud = test_utils::make_lidar_pointcloud2(pts);
55 std::vector<int> indices = {0, 1, 2, 3};
56 auto output_cloud = test_utils::make_lidar_pointcloud2({});
57 auto center = center_calculator_.calculate_center(input_cloud, indices, plane_);
58 ASSERT_EQ(center.x(), 0);
59 ASSERT_EQ(center.y(), 3);
60}
TEST_F(CircunferenceCenterCalculationTest, NormalUseCase)
Test case for finding the circunference of center (2, 0)
Test class for setting up data and testing CircinferenceCenterCalculation algorithm.
Concrete class representing a circumference-based method for estimating the center position of a cone...
The Plane class represents a 3D plane defined by its equation ax + by + cz + d = 0.
Definition plane.hpp:12
sensor_msgs::msg::PointCloud2::SharedPtr make_lidar_pointcloud2(const std::vector< std::array< float, 5 > > &pts)