Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(autoware_pointcloud_preprocessor): distortion corrector node update azimuth and distance #8380

Conversation

vividf
Copy link
Contributor

@vividf vividf commented Aug 6, 2024

Description

This PR solves the issue #3896.
Note that this PR is tested with the nebula PR tier4/nebula#180

  • The node updates the per-point azimuth and distance values based on the undistorted XYZ coordinates when the input point cloud is in the sensor frame (not in the base_link) and the update_azimuth_and_distance parameter is set to true. The azimuth values are calculated using the cv::fastAtan2 function.
  • Please note that updating the azimuth and distance fields increases the execution time by approximately 20%. Additionally, due to the cv::fastAtan2 algorithm's accuracy of about 0.3 degrees, there is a possibility of changing beam order for high azimuth resolution LiDAR.
  • LiDARs from different vendors have different azimuth coordinates. Currently, the coordinate systems listed below have been tested, and the node will update the azimuth based on the input coordinate system.
    • velodyne: (x: 0 degrees, y: 270 degrees)
    • hesai: (x: 90 degrees, y: 0 degrees)
    • others: (x: 0 degrees, y: 90 degrees) and (x: 270 degrees, y: 0 degrees)

before distortion correction (Velodyne):
x: -7.27784, y: 1.06172, z: xxxxx, azimuth: 3.28645, distance: 7.356
after distortion correction:
x: -7.2696, y: 0.767085, z: xxxxx, azimuth: 3.24671, distance: 7.311

More information in https://github.com/vividf/autoware.universe/blob/feature/distortion_corrector_node_update_azimuth_and_distance/sensing/autoware_pointcloud_preprocessor/docs/distortion-corrector.md.

Additionally, this PR also removes the separate sin and cos by using the sin_and_cos function which can speed up the processing time (from this #7120)

Related links

Previous closed PR: #5560

Parent Issue:

  • Link

How was this PR tested?

  • Tested with Unit test.
colcon test --packages-select autoware_pointcloud_preprocessor --event-handlers console_cohesion+
  1. change the input/pointcloud to /sensing/lidar/top/pointcloud_raw_ex in the launch file
  2. change the parameter update_azimuth_and_distance to true in distortion_corrector_node.param.yaml
  3. ros2 launch autoware_pointcloud_preprocessor distortion_corrector_node.launch.xml and ros2 topic hz /sensing/lidar/top/rectified/pointcloud_ex
  4. play the provided ros bag

Time comparison
Input topic: /sensing/lidar/top/pointcloud_raw_ex (number of points is larger than the /sensing/lidar/top/mirror_cropped/pointcloud_ex)
bag: sample rosbag
frame: 121

  • Before this PR
Minimum Maximum Average
Time 7.763 15.318 10.82
  • After this PR
  1. with new sin_and_cos optimization
  2. without update azimuth and distance
Minimum Maximum Average
Time 7.038 14.375 10.28
  1. with new sin_and_cos optimization
  2. with update azimuth and distance
Minimum Maximum Average
Time 9.078 19.907 12.33

Notes for reviewers

None.

Interface changes

None.

Effects on system behavior

None.

@vividf vividf self-assigned this Aug 6, 2024
@github-actions github-actions bot added type:documentation Creating or refining documentation. (auto-assigned) component:sensing Data acquisition from sensors, drivers, preprocessing. (auto-assigned) labels Aug 6, 2024
Copy link

github-actions bot commented Aug 6, 2024

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

@vividf vividf added the tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Aug 6, 2024
@vividf vividf marked this pull request as draft August 8, 2024 05:35
@github-actions github-actions bot added the component:common Common packages from the autoware-common repository. (auto-assigned) label Aug 14, 2024
Copy link
Contributor

@knzo25 knzo25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just small change requests

@vividf vividf requested a review from knzo25 October 9, 2024 03:59
@vividf
Copy link
Contributor Author

vividf commented Oct 21, 2024

@knzo25 kindly ping

Copy link
Contributor

@knzo25 knzo25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@vividf
Copy link
Contributor Author

vividf commented Oct 28, 2024

@TakaHoribe @soblin @takayuki5168
Seems that this PR need your approval since it include not only pointcloud preprocessor package :)
Thanks

@vividf vividf enabled auto-merge (squash) October 28, 2024 12:46
@vividf vividf merged commit 4061041 into autowarefoundation:main Oct 28, 2024
28 of 32 checks passed
esteve pushed a commit to esteve/autoware.universe that referenced this pull request Oct 29, 2024
…ate azimuth and distance (autowarefoundation#8380)

* feat: add option for updating distance and azimuth value

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

* chore: clean code

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

* chore: remove space

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

* chore: add documentation

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

* chore: fix docs

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

* feat: conversion formula implementation for degree, still need to change to rad

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

* chore: fix tests for AzimuthConversionExists function

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

* feat: add fastatan to utils

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

* feat: remove seperate sin, cos and use sin_and_cos function

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

* chore: fix readme

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

* chore: fix some grammar errors

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

* chore: fix spell error

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

* chore: set debug mode to false

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

* chore: set update_azimuth_and_distance default value to false

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

* chore: update readme

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

* chore: remove cout

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

* chore: add opencv license

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

* chore: fix grammar error

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

* style(pre-commit): autofix

* chore: add runtime error when azimuth conversion failed

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

* chore: change default pointcloud

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

* chore: change function name

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

* chore: move variables to structure

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

* chore: add random seed

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

* chore: rewrite get conversion function

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

* chore: fix opencv fast atan2 function

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

* chore: fix schema description

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

* Update sensing/autoware_pointcloud_preprocessor/test/test_distortion_corrector_node.cpp

Co-authored-by: Max Schmeller <[email protected]>

* Update sensing/autoware_pointcloud_preprocessor/test/test_distortion_corrector_node.cpp

Co-authored-by: Max Schmeller <[email protected]>

* chore: move code to function for readability

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

* chore: simplify code

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

* chore: fix sentence, angle conversion

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

* chore: add more invalid condition

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

* chore: fix the string name to enum

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

* chore: remove runtime error

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

* chore: use optional for AngleConversion structure

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

* chore: fix bug and clean code

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

* chore: refactor the logic of calculating conversion

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

* chore: refactor function in unit test

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

* chore: RCLCPP_WARN_STREAM logging when failed to get angle conversion

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

* chore: improve normalize angle algorithm

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

* chore: improve multiple_of_90_degrees logic

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

* chore: add opencv license

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

* style(pre-commit): autofix

* chore: clean code

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

* chore: fix sentence

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

* style(pre-commit): autofix

* chore: add 0 0 0 points in test case

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

* chore: fix spell error

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

* Update common/autoware_universe_utils/NOTICE

Co-authored-by: Max Schmeller <[email protected]>

* Update sensing/autoware_pointcloud_preprocessor/src/distortion_corrector/distortion_corrector_node.cpp

Co-authored-by: Max Schmeller <[email protected]>

* Update sensing/autoware_pointcloud_preprocessor/src/distortion_corrector/distortion_corrector.cpp

Co-authored-by: Max Schmeller <[email protected]>

* chore: use constexpr for threshold

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

* chore: fix the path of license

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

* chore: explanation for failures

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

* chore: use throttle

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

* chore: fix empty pointcloud function

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

* refactor: change camel to snake case

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

* Update sensing/autoware_pointcloud_preprocessor/include/autoware/pointcloud_preprocessor/distortion_corrector/distortion_corrector_node.hpp

Co-authored-by: Max Schmeller <[email protected]>

* Update sensing/autoware_pointcloud_preprocessor/include/autoware/pointcloud_preprocessor/distortion_corrector/distortion_corrector_node.hpp

Co-authored-by: Max Schmeller <[email protected]>

* style(pre-commit): autofix

* Update sensing/autoware_pointcloud_preprocessor/test/test_distortion_corrector_node.cpp

Co-authored-by: Max Schmeller <[email protected]>

* refactor: refactor virtual function in base class

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

* chore: fix test naming error

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

* chore: fix clang error

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

* chore: fix error

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

* chore: fix clangd

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

* chore: add runtime error if the setting is wrong

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

* chore: clean code

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

* Update sensing/autoware_pointcloud_preprocessor/src/distortion_corrector/distortion_corrector.cpp

Co-authored-by: Max Schmeller <[email protected]>

* style(pre-commit): autofix

* chore: fix unit test for runtime error

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

* Update sensing/autoware_pointcloud_preprocessor/docs/distortion-corrector.md

Co-authored-by: Kenzo Lobos Tsunekawa <[email protected]>

* chore: fix offset_rad_threshold

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

* chore: change pointer to reference

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

* chore: snake_case for unit test

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

* chore: fix refactor process twist and imu

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

* chore: fix abs and return type of matrix to tf2

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

* chore: fix grammar error

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

* chore: fix readme description

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

* chore: remove runtime error

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

---------

Signed-off-by: vividf <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Max Schmeller <[email protected]>
Co-authored-by: Kenzo Lobos Tsunekawa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:common Common packages from the autoware-common repository. (auto-assigned) component:sensing Data acquisition from sensors, drivers, preprocessing. (auto-assigned) tag:require-cuda-build-and-test tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) type:documentation Creating or refining documentation. (auto-assigned)
Projects
Development

Successfully merging this pull request may close these issues.

distortion_corrector should update "azimuth" and "distance" field
6 participants