Skip to content

Commit

Permalink
refactor(ground_segmentation): refactor based on cppcheck (#7060)
Browse files Browse the repository at this point in the history
* remove unread variabls

Signed-off-by: Ryuta Kambe <[email protected]>

* remove unread variabls

Signed-off-by: Ryuta Kambe <[email protected]>

* remove duplicateBranch

Signed-off-by: Ryuta Kambe <[email protected]>

* style(pre-commit): autofix

* fix

Signed-off-by: veqcc <[email protected]>

---------

Signed-off-by: Ryuta Kambe <[email protected]>
Signed-off-by: veqcc <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
veqcc and pre-commit-ci[bot] authored May 21, 2024
1 parent 2f2925d commit 1f6a6c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ RANSACGroundFilterComponent::RANSACGroundFilterComponent(const rclcpp::NodeOptio
unit_vec_ = Eigen::Vector3d::UnitX();
} else if (unit_axis_ == "y") {
unit_vec_ = Eigen::Vector3d::UnitY();
} else if (unit_axis_ == "z") {
unit_vec_ = Eigen::Vector3d::UnitZ();
} else {
} else { // including (unit_axis_ == "z")
unit_vec_ = Eigen::Vector3d::UnitZ();
}

Expand Down Expand Up @@ -384,9 +382,7 @@ rcl_interfaces::msg::SetParametersResult RANSACGroundFilterComponent::paramCallb
unit_vec_ = Eigen::Vector3d::UnitX();
} else if (unit_axis_ == "y") {
unit_vec_ = Eigen::Vector3d::UnitY();
} else if (unit_axis_ == "z") {
unit_vec_ = Eigen::Vector3d::UnitZ();
} else {
} else { // including (unit_axis_ == "z")
unit_vec_ = Eigen::Vector3d::UnitZ();
}
RCLCPP_DEBUG(get_logger(), "Setting unit_axis to: %s.", unit_axis_.c_str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,12 @@ void ScanGroundFilterComponent::classifyPointCloudGridScan(

// check the first point in ray
auto * p = &in_radial_ordered_clouds[i][0];
auto * prev_p = &in_radial_ordered_clouds[i][0]; // for checking the distance to prev point

bool initialized_first_gnd_grid = false;
bool prev_list_init = false;
pcl::PointXYZ p_orig_point, prev_p_orig_point;
for (auto & point : in_radial_ordered_clouds[i]) {
prev_p = p;
auto * prev_p = p; // for checking the distance to prev point
prev_p_orig_point = p_orig_point;
p = &point;
get_point_from_global_offset(in_cloud, p_orig_point, in_cloud->point_step * p->orig_index);
Expand Down Expand Up @@ -469,7 +468,6 @@ void ScanGroundFilterComponent::classifyPointCloud(
float prev_gnd_slope = 0.0f;
float points_distance = 0.0f;
PointsCentroid ground_cluster, non_ground_cluster;
float local_slope = 0.0f;
PointLabel prev_point_label = PointLabel::INIT;
pcl::PointXYZ prev_gnd_point(0, 0, 0), p_orig_point, prev_p_orig_point;
// loop through each point in the radial div
Expand Down Expand Up @@ -524,7 +522,7 @@ void ScanGroundFilterComponent::classifyPointCloud(
}
if (calculate_slope) {
// far from the previous point
local_slope = std::atan2(height_from_gnd, radius_distance_from_gnd);
auto local_slope = std::atan2(height_from_gnd, radius_distance_from_gnd);
if (local_slope - prev_gnd_slope > local_slope_max_angle) {
// the point is outside of the local slope threshold
p->point_state = PointLabel::NON_GROUND;
Expand Down

0 comments on commit 1f6a6c5

Please sign in to comment.