Skip to content

Commit

Permalink
modify ring outlier filter node for supporting counter clockwise azimuth
Browse files Browse the repository at this point in the history
Signed-off-by: vividf <[email protected]>
  • Loading branch information
vividf committed Mar 14, 2024
1 parent fb2ab65 commit 55682dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class DistortionCorrectorComponent : public rclcpp::Node
std::string time_stamp_field_name_;
bool use_imu_;
bool update_azimuth_and_distance_;
float azimuth_factor_ = 100.0;
};

} // namespace pointcloud_preprocessor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ bool DistortionCorrectorComponent::undistortPointCloud(
*it_y = static_cast<float>(undistorted_point.getY());
*it_z = static_cast<float>(undistorted_point.getZ());

if (update_azimuth_and_distance_) {
if (update_azimuth_and_distance_ && need_transform) {
*it_distance = sqrt(*it_x * *it_x + *it_y * *it_y + *it_z * *it_z);
*it_azimuth = cv::fastAtan2(*it_y, *it_x) * 100;
*it_azimuth = cv::fastAtan2(*it_y, *it_x) * azimuth_factor_;
}

Check warning on line 321 in sensing/pointcloud_preprocessor/src/distortion_corrector/distortion_corrector.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

DistortionCorrectorComponent::undistortPointCloud increases in cyclomatic complexity from 21 to 23, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
prev_time_stamp_sec = *it_time_stamp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ void RingOutlierFilterComponent::faster_filter(
*reinterpret_cast<const float *>(&input->data[current_data_idx + azimuth_offset]);
const float & next_azimuth =
*reinterpret_cast<const float *>(&input->data[next_data_idx + azimuth_offset]);
float azimuth_diff = next_azimuth - current_azimuth;
azimuth_diff = azimuth_diff < 0.f ? azimuth_diff + 36000.f : azimuth_diff;
float azimuth_diff = std::abs(next_azimuth - current_azimuth);
azimuth_diff = azimuth_diff > 18000.f ? 36000.f - azimuth_diff : azimuth_diff;

const float & current_distance =
*reinterpret_cast<const float *>(&input->data[current_data_idx + distance_offset]);
Expand Down

0 comments on commit 55682dd

Please sign in to comment.