tier4 / nebula

A universal LiDAR and radar driver for ROS 2, supporting Hesai, Velodyne, Robosense and Continental sensors.
https://tier4.github.io/nebula/
Apache License 2.0
55 stars 53 forks source link

fix(nebula_tests): fix bugprone-incorrect-roundings #219

Closed kobayu858 closed 2 weeks ago

kobayu858 commented 2 weeks ago

PR Type

Related Links

Description

This is a fix based on clang-tidy bugprone-incorrect-roundings error.

/home/emb4/autoware/autoware/src/sensor_component/external/nebula/nebula_tests/velodyne/velodyne_ros_decoder_test_vlp16.cpp:185:44: error: casting (double + 0.5) to integer leads to incorrect rounding; consider using lround (#include <cmath>) instead [bugprone-incorrect-roundings,-warnings-as-errors]
    sensor_configuration.cloud_min_angle = 100 * (2 * M_PI - min_angle) * 180 / M_PI + 0.5;
                                           ^
/home/emb4/autoware/autoware/src/sensor_component/external/nebula/nebula_tests/velodyne/velodyne_ros_decoder_test_vlp16.cpp:186:44: error: casting (double + 0.5) to integer leads to incorrect rounding; consider using lround (#include <cmath>) instead [bugprone-incorrect-roundings,-warnings-as-errors]
    sensor_configuration.cloud_max_angle = 100 * (2 * M_PI - max_angle) * 180 / M_PI + 0.5;
                                           ^
/home/emb4/autoware/autoware/src/sensor_component/external/nebula/nebula_tests/velodyne/velodyne_ros_decoder_test_vlp32.cpp:183:44: error: casting (double + 0.5) to integer leads to incorrect rounding; consider using lround (#include <cmath>) instead [bugprone-incorrect-roundings,-warnings-as-errors]
    sensor_configuration.cloud_min_angle = 100 * (2 * M_PI - min_angle) * 180 / M_PI + 0.5;
                                           ^
/home/emb4/autoware/autoware/src/sensor_component/external/nebula/nebula_tests/velodyne/velodyne_ros_decoder_test_vlp32.cpp:184:44: error: casting (double + 0.5) to integer leads to incorrect rounding; consider using lround (#include <cmath>) instead [bugprone-incorrect-roundings,-warnings-as-errors]
    sensor_configuration.cloud_max_angle = 100 * (2 * M_PI - max_angle) * 180 / M_PI + 0.5;
                                           ^
/home/emb4/autoware/autoware/src/sensor_component/external/nebula/nebula_tests/velodyne/velodyne_ros_decoder_test_vls128.cpp:188:44: error: casting (double + 0.5) to integer leads to incorrect rounding; consider using lround (#include <cmath>) instead [bugprone-incorrect-roundings,-warnings-as-errors]
    sensor_configuration.cloud_min_angle = 100 * (2 * M_PI - min_angle) * 180 / M_PI + 0.5;
                                           ^
/home/emb4/autoware/autoware/src/sensor_component/external/nebula/nebula_tests/velodyne/velodyne_ros_decoder_test_vls128.cpp:189:44: error: casting (double + 0.5) to integer leads to incorrect rounding; consider using lround (#include <cmath>) instead [bugprone-incorrect-roundings,-warnings-as-errors]
    sensor_configuration.cloud_max_angle = 100 * (2 * M_PI - max_angle) * 180 / M_PI + 0.5;
                                           ^

Review Procedure

Remarks

Pre-Review Checklist for the PR Author

PR Author should check the checkboxes below when creating the PR.

Checklist for the PR Reviewer

Reviewers should check the checkboxes below before approval.

Post-Review Checklist for the PR Author

PR Author should check the checkboxes below before merging.

CI Checks

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.

Project coverage is 55.44%. Comparing base (c7456f9) to head (8f1fc03). Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...tests/velodyne/velodyne_ros_decoder_test_vlp16.cpp 0.00% 4 Missing :warning:
...tests/velodyne/velodyne_ros_decoder_test_vlp32.cpp 0.00% 4 Missing :warning:
...ests/velodyne/velodyne_ros_decoder_test_vls128.cpp 0.00% 4 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #219 +/- ## =========================================== + Coverage 26.16% 55.44% +29.27% =========================================== Files 99 65 -34 Lines 9199 4280 -4919 Branches 2215 1140 -1075 =========================================== - Hits 2407 2373 -34 + Misses 6402 1545 -4857 + Partials 390 362 -28 ``` | [Flag](https://app.codecov.io/gh/tier4/nebula/pull/219/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tier4) | Coverage Δ | | |---|---|---| | [differential](https://app.codecov.io/gh/tier4/nebula/pull/219/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tier4) | `55.44% <0.00%> (?)` | | | [total](https://app.codecov.io/gh/tier4/nebula/pull/219/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tier4) | `?` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tier4#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

veqcc commented 2 weeks ago

@mojomex Hi, this is a minor fix baed on clang-tidy. Please assign another reviewer if there is someone suitable for it, thanks 👍