Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
cluster.hpp
Go to the documentation of this file.
1#pragma once
2#include <sensor_msgs/msg/point_cloud2.hpp>
3#include <string>
4#include <tuple>
5#include <vector>
6
10
14class Cluster {
15public:
19 explicit Cluster(const sensor_msgs::msg::PointCloud2::SharedPtr& point_cloud,
20 const std::vector<int>& point_indices);
21
26 Eigen::Vector4f get_centroid();
27
33 Eigen::Vector4f get_center(Plane& plane);
34
39 std::string get_color();
40
45 void set_color(const std::string& new_color);
46
51 void set_point_indices(const std::vector<int>& new_point_indices);
52
57 const std::vector<int>& get_point_indices();
58
63 const sensor_msgs::msg::PointCloud2::SharedPtr& get_point_cloud();
64
70 void set_confidence(double newConfidence);
71
77 double get_confidence();
78
87 void set_z_score(double mean_x, double std_dev_x, double mean_y, double std_dev_y);
88
94 double get_z_score_x() const;
95
101 double get_z_score_y() const;
102
110 static std::tuple<double, double, double, double> calculate_mean_and_std_dev(
111 std::vector<Cluster>& clusters);
112
118 static void set_z_scores(std::vector<Cluster>& clusters);
119
124 bool get_is_large();
125
129 void set_is_large();
130
131private:
132 const sensor_msgs::msg::PointCloud2::SharedPtr
134 std::vector<int> _point_indices_;
135 std::string _color_ = "undefined";
136 Eigen::Vector4f _centroid_;
137 Eigen::Vector4f _center_;
139 bool _center_is_defined_ = false;
140 double _confidence_ = 0;
141 double _z_score_x_ = 0;
142 double _z_score_y_ = 0;
143 bool _is_large_ = false;
146
147 static constexpr auto center_calculator =
149 static constexpr auto centroid_calculator =
151};
Concrete Class representing a centroid-based method for estimating the center position of a cone.
Concrete class representing a circumference-based method for estimating the center position of a cone...
Represents a cluster of 3D points using PCL (Point Cloud Library).
Definition cluster.hpp:14
void set_is_large()
Set cluster as a contender for a large cone.
Definition cluster.cpp:103
const std::vector< int > & get_point_indices()
Get the Point Cloud data of the cluster.
Definition cluster.cpp:44
void set_confidence(double newConfidence)
Set the Confidence of the cluster to be or not to be a cone.
Definition cluster.cpp:50
double get_z_score_y() const
Get the z score on y-axis of an object.
Definition cluster.cpp:67
void set_z_score(double mean_x, double std_dev_x, double mean_y, double std_dev_y)
Set the z score object on the x and y axis.
Definition cluster.cpp:54
std::string _color_
Color associated with the cluster.
Definition cluster.hpp:135
double _confidence_
Confidence on the cluster to be (or not) a cone.
Definition cluster.hpp:140
const sensor_msgs::msg::PointCloud2::SharedPtr & get_point_cloud()
Get the Point Cloud data of the cluster.
Definition cluster.cpp:46
double get_z_score_x() const
Get the z score on x-axis of an object.
Definition cluster.cpp:65
bool _center_is_defined_
Flag indicating whether the center is defined or not.
Definition cluster.hpp:139
double _z_score_y_
Definition cluster.hpp:142
std::vector< int > _point_indices_
Indices of points in the cluster.
Definition cluster.hpp:134
Eigen::Vector4f _center_
Center of the cone's cluster.
Definition cluster.hpp:137
double get_confidence()
Get the Confidence of the cluster to be (or not to be) a cone.
Definition cluster.cpp:52
static void set_z_scores(std::vector< Cluster > &clusters)
Set the z scores object on every cluster of the vector.
Definition cluster.cpp:94
Eigen::Vector4f _centroid_
Centroid of the cluster.
Definition cluster.hpp:136
std::string get_color()
Get the color associated with the cluster.
Definition cluster.cpp:30
Eigen::Vector4f get_center(Plane &plane)
Get the Center of the cone's cluster.
Definition cluster.cpp:18
Eigen::Vector4f get_centroid()
Get the centroid of the cluster.
Definition cluster.cpp:7
double _z_score_x_
Definition cluster.hpp:141
bool get_is_large()
Get cluster's corresponding cone size.
Definition cluster.cpp:101
const sensor_msgs::msg::PointCloud2::SharedPtr _point_cloud_
Point cloud data for the cluster.
Definition cluster.hpp:133
void set_color(const std::string &new_color)
Set the color for the cluster.
Definition cluster.cpp:32
bool _is_large_
Flag indicating the size of the cluster :
Definition cluster.hpp:143
static constexpr auto center_calculator
Calculates the center of the cone.
Definition cluster.hpp:147
bool _centroid_is_defined_
Flag indicating whether the centroid is defined or not.
Definition cluster.hpp:138
static std::tuple< double, double, double, double > calculate_mean_and_std_dev(std::vector< Cluster > &clusters)
Calculates the mean and standard deviation on x and y axis.
Definition cluster.cpp:69
void set_point_indices(const std::vector< int > &new_point_indices)
Set the Point Cloud data for the cluster.
Definition cluster.cpp:38
static constexpr auto centroid_calculator
Calculates the centroid of the cluster.
Definition cluster.hpp:149
The Plane class represents a 3D plane defined by its equation ax + by + cz + d = 0.
Definition plane.hpp:12