4 const std::vector<int>& point_indices)
5 : _point_cloud_(point_cloud), _point_indices_(point_indices) {}
33 if (new_color ==
"blue" || new_color ==
"yellow") {
70 std::vector<Cluster>& clusters) {
73 for (
auto& point : clusters) {
74 sum_x += point.get_centroid().x();
75 sum_y += point.get_centroid().y();
78 double mean_x = sum_x /
static_cast<double>(clusters.size());
79 double mean_y = sum_y /
static_cast<double>(clusters.size());
81 double sum_squared_diff_x = 0.0;
82 double sum_squared_diff_y = 0.0;
83 for (
auto& point : clusters) {
84 sum_squared_diff_x += std::pow(point.get_centroid().x() - mean_x, 2);
85 sum_squared_diff_y += std::pow(point.get_centroid().y() - mean_y, 2);
88 double stddev_x = std::sqrt(sum_squared_diff_x /
static_cast<double>(clusters.size()));
89 double stddev_y = std::sqrt(sum_squared_diff_y /
static_cast<double>(clusters.size()));
91 return std::make_tuple(mean_x, mean_y, stddev_x, stddev_y);
96 for (
auto& cluster : clusters) {
97 cluster.set_z_score(mean_x, stddev_x, mean_y, stddev_y);
void set_is_large()
Set cluster as a contender for a large cone.
const std::vector< int > & get_point_indices()
Get the Point Cloud data of the cluster.
void set_confidence(double newConfidence)
Set the Confidence of the cluster to be or not to be a cone.
double get_z_score_y() const
Get the z score on y-axis of an object.
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.
std::string _color_
Color associated with the cluster.
double _confidence_
Confidence on the cluster to be (or not) a cone.
const sensor_msgs::msg::PointCloud2::SharedPtr & get_point_cloud()
Get the Point Cloud data of the cluster.
double get_z_score_x() const
Get the z score on x-axis of an object.
bool _center_is_defined_
Flag indicating whether the center is defined or not.
std::vector< int > _point_indices_
Indices of points in the cluster.
Eigen::Vector4f _center_
Center of the cone's cluster.
double get_confidence()
Get the Confidence of the cluster to be (or not to be) a cone.
static void set_z_scores(std::vector< Cluster > &clusters)
Set the z scores object on every cluster of the vector.
Eigen::Vector4f _centroid_
Centroid of the cluster.
std::string get_color()
Get the color associated with the cluster.
Eigen::Vector4f get_center(Plane &plane)
Get the Center of the cone's cluster.
Eigen::Vector4f get_centroid()
Get the centroid of the cluster.
Cluster(const sensor_msgs::msg::PointCloud2::SharedPtr &point_cloud, const std::vector< int > &point_indices)
Constructor for the Cluster class.
bool get_is_large()
Get cluster's corresponding cone size.
const sensor_msgs::msg::PointCloud2::SharedPtr _point_cloud_
Point cloud data for the cluster.
void set_color(const std::string &new_color)
Set the color for the cluster.
bool _is_large_
Flag indicating the size of the cluster :
static constexpr auto center_calculator
Calculates the center of the cone.
bool _centroid_is_defined_
Flag indicating whether the centroid is defined or not.
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.
void set_point_indices(const std::vector< int > &new_point_indices)
Set the Point Cloud data for the cluster.
static constexpr auto centroid_calculator
Calculates the centroid of the cluster.
The Plane class represents a 3D plane defined by its equation ax + by + cz + d = 0.