10 float min_z = std::numeric_limits<float>::max();
11 float max_z = std::numeric_limits<float>::lowest();
13 for (
const auto &idx : indices) {
15 min_z = std::min(z, min_z);
16 max_z = std::max(z, max_z);
21 if (std::isnan(ground_height)) {
25 double max_distance_above = max_z - ground_height;
26 double min_distance_above = min_z - ground_height;
30 result &= min_distance_above <
params_->max_distance_from_ground_min;
32 result &= max_distance_above <
params_->max_distance_from_ground_max;
45 for (
size_t idx : indices) {
50 double dx = x - centroid.x();
51 double dy = y - centroid.y();
52 double dz = std::abs(z - centroid.z());
54 double distanceXY = std::sqrt(dx * dx + dy * dy);
58 double half_height = 0;
60 radius =
params_->large_cone_width / 2.0;
61 half_height =
params_->large_cone_height / 2.0;
63 radius =
params_->small_cone_width / 2.0;
64 half_height =
params_->small_cone_height / 2.0;
67 if (distanceXY > radius || dz > half_height) {
73 double out_ratio =
static_cast<double>(n_out_points) / indices.size();
76 return out_ratio <
params_->n_out_points_ratio;
81 double distance = std::sqrt(center.x() * center.x() + center.y() * center.y());
85 double max_points = std::max(
86 params_->n_points_intial_max - (distance *
params_->n_points_max_distance_reduction), 4.0);
87 double min_points = std::max(
88 params_->n_points_intial_min - (distance *
params_->n_points_min_distance_reduction), 1.0);
90 return n_points <= max_points && n_points >= min_points;
Represents a cluster of 3D points using PCL (Point Cloud Library).
const std::vector< int > & get_point_indices()
Get the Point Cloud data of the cluster.
const sensor_msgs::msg::PointCloud2::SharedPtr & get_point_cloud()
Get the Point Cloud data of the cluster.
Eigen::Vector4f get_centroid()
Get the centroid of the cluster.
bool get_is_large()
Get cluster's corresponding cone size.
ConeEvaluator(std::shared_ptr< EvaluatorParameters > params)
Constructs a new DeviationValidator object with specified intervals on the deviation.
bool evaluateCluster(Cluster &cluster, const GroundGrid &ground_grid)
Perform the cluster evaluation, guaranteeing they pass all validators.
std::shared_ptr< EvaluatorParameters > params_
bool npoints_valid(Cluster &cluster) const
Check if the number of points in the cluster is valid, according to the distance.
bool close_to_ground(Cluster &cluster, const GroundGrid &ground_grid) const
Check if the cluster is close to the ground.
bool cylinder_fits_cone(Cluster &cluster) const
Check if a cylinder fits the cone dimensions.
Class to represent a ground height grid for ground proximity checks.
float get_ground_height(const float x, const float y) const
Get the ground height at a specific (x, y) location.
constexpr size_t PointZ(size_t idx)
constexpr size_t PointX(size_t idx)
constexpr size_t PointY(size_t idx)