diff --git a/nebula_tests/velodyne/velodyne_ros_decoder_test_vlp16.cpp b/nebula_tests/velodyne/velodyne_ros_decoder_test_vlp16.cpp index 179770038..743721734 100644 --- a/nebula_tests/velodyne/velodyne_ros_decoder_test_vlp16.cpp +++ b/nebula_tests/velodyne/velodyne_ros_decoder_test_vlp16.cpp @@ -11,6 +11,7 @@ #include +#include #include #include #include @@ -180,8 +181,10 @@ Status VelodyneRosDecoderTest::get_parameters( } else { double min_angle = fmod(fmod(view_direction + view_width / 2, 2 * M_PI) + 2 * M_PI, 2 * M_PI); double max_angle = fmod(fmod(view_direction - view_width / 2, 2 * M_PI) + 2 * M_PI, 2 * M_PI); - sensor_configuration.cloud_min_angle = 100 * (2 * M_PI - min_angle) * 180 / M_PI + 0.5; - sensor_configuration.cloud_max_angle = 100 * (2 * M_PI - max_angle) * 180 / M_PI + 0.5; + sensor_configuration.cloud_min_angle = + static_cast(std::lround(100 * (2 * M_PI - min_angle) * 180 / M_PI)); + sensor_configuration.cloud_max_angle = + static_cast(std::lround(100 * (2 * M_PI - max_angle) * 180 / M_PI)); if (sensor_configuration.cloud_min_angle == sensor_configuration.cloud_max_angle) { // avoid returning empty cloud if min_angle = max_angle sensor_configuration.cloud_min_angle = 0; diff --git a/nebula_tests/velodyne/velodyne_ros_decoder_test_vlp32.cpp b/nebula_tests/velodyne/velodyne_ros_decoder_test_vlp32.cpp index 39f7aecca..c354af54b 100644 --- a/nebula_tests/velodyne/velodyne_ros_decoder_test_vlp32.cpp +++ b/nebula_tests/velodyne/velodyne_ros_decoder_test_vlp32.cpp @@ -11,6 +11,7 @@ #include +#include #include #include #include @@ -178,8 +179,10 @@ Status VelodyneRosDecoderTest::get_parameters( } else { double min_angle = fmod(fmod(view_direction + view_width / 2, 2 * M_PI) + 2 * M_PI, 2 * M_PI); double max_angle = fmod(fmod(view_direction - view_width / 2, 2 * M_PI) + 2 * M_PI, 2 * M_PI); - sensor_configuration.cloud_min_angle = 100 * (2 * M_PI - min_angle) * 180 / M_PI + 0.5; - sensor_configuration.cloud_max_angle = 100 * (2 * M_PI - max_angle) * 180 / M_PI + 0.5; + sensor_configuration.cloud_min_angle = + static_cast(std::lround(100 * (2 * M_PI - min_angle) * 180 / M_PI)); + sensor_configuration.cloud_max_angle = + static_cast(std::lround(100 * (2 * M_PI - max_angle) * 180 / M_PI)); if (sensor_configuration.cloud_min_angle == sensor_configuration.cloud_max_angle) { // avoid returning empty cloud if min_angle = max_angle sensor_configuration.cloud_min_angle = 0; diff --git a/nebula_tests/velodyne/velodyne_ros_decoder_test_vls128.cpp b/nebula_tests/velodyne/velodyne_ros_decoder_test_vls128.cpp index 71817ecee..4102757c8 100644 --- a/nebula_tests/velodyne/velodyne_ros_decoder_test_vls128.cpp +++ b/nebula_tests/velodyne/velodyne_ros_decoder_test_vls128.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -183,8 +184,10 @@ Status VelodyneRosDecoderTest::get_parameters( } else { double min_angle = fmod(fmod(view_direction + view_width / 2, 2 * M_PI) + 2 * M_PI, 2 * M_PI); double max_angle = fmod(fmod(view_direction - view_width / 2, 2 * M_PI) + 2 * M_PI, 2 * M_PI); - sensor_configuration.cloud_min_angle = 100 * (2 * M_PI - min_angle) * 180 / M_PI + 0.5; - sensor_configuration.cloud_max_angle = 100 * (2 * M_PI - max_angle) * 180 / M_PI + 0.5; + sensor_configuration.cloud_min_angle = + static_cast(std::lround(100 * (2 * M_PI - min_angle) * 180 / M_PI)); + sensor_configuration.cloud_max_angle = + static_cast(std::lround(100 * (2 * M_PI - max_angle) * 180 / M_PI)); if (sensor_configuration.cloud_min_angle == sensor_configuration.cloud_max_angle) { // avoid returning empty cloud if min_angle = max_angle sensor_configuration.cloud_min_angle = 0;