diff --git a/autoware_cmake/CMakeLists.txt b/autoware_cmake/CMakeLists.txt deleted file mode 100644 index f44b2482..00000000 --- a/autoware_cmake/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -cmake_minimum_required(VERSION 3.14) - -project(autoware_cmake NONE) - -find_package(ament_cmake_auto REQUIRED) -ament_auto_find_build_dependencies() - -list(APPEND ${PROJECT_NAME}_CONFIG_EXTRAS - "autoware_cmake-extras.cmake" -) - -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - ament_lint_auto_find_test_dependencies() -endif() - -ament_auto_package( - INSTALL_TO_SHARE - cmake -) diff --git a/autoware_cmake/README.md b/autoware_cmake/README.md deleted file mode 100644 index 8c6e2a39..00000000 --- a/autoware_cmake/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# autoware_cmake - -This package provides CMake scripts for Autoware. - -## Usage - -### autoware_package.cmake - -Call `autoware_package()` before defining build targets, which will set common options for Autoware. - -```cmake -cmake_minimum_required(VERSION 3.5) -project(package_name) - -find_package(autoware_cmake REQUIRED) -autoware_package() - -ament_auto_add_library(...) -``` diff --git a/autoware_cmake/autoware_cmake-extras.cmake b/autoware_cmake/autoware_cmake-extras.cmake deleted file mode 100644 index 08caf9fa..00000000 --- a/autoware_cmake/autoware_cmake-extras.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2022 The Autoware Contributors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -include("${autoware_cmake_DIR}/autoware_package.cmake") diff --git a/autoware_cmake/cmake/autoware_package.cmake b/autoware_cmake/cmake/autoware_package.cmake deleted file mode 100644 index 85233eab..00000000 --- a/autoware_cmake/cmake/autoware_package.cmake +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright 2022 The Autoware Contributors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -macro(autoware_package) - # Set compile options - if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - set(CMAKE_CXX_EXTENSIONS OFF) - endif() - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic -Werror) - endif() - - # Ignore PCL errors in Clang - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wno-gnu-anonymous-struct -Wno-nested-anon-types) - endif() - - # Ignore Boost deprecated messages - add_compile_definitions(BOOST_ALLOW_DEPRECATED_HEADERS) - - # Ignore unnecessary CMake warnings - set(__dummy__ ${CMAKE_EXPORT_COMPILE_COMMANDS}) - - # Set ROS_DISTRO macros - set(ROS_DISTRO $ENV{ROS_DISTRO}) - if(${ROS_DISTRO} STREQUAL "rolling") - add_compile_definitions(ROS_DISTRO_ROLLING) - elseif(${ROS_DISTRO} STREQUAL "galactic") - add_compile_definitions(ROS_DISTRO_GALACTIC) - elseif(${ROS_DISTRO} STREQUAL "humble") - add_compile_definitions(ROS_DISTRO_HUMBLE) - endif() - - # Find dependencies - find_package(ament_cmake_auto REQUIRED) - ament_auto_find_build_dependencies() - - # Set common system includes - include_directories(SYSTEM - ${EIGEN3_INCLUDE_DIR} - ) - - # Workaround for lanelet2-core@1.2.1 - if(TARGET lanelet2_core::lanelet2_core) - get_target_property(lanelet2_core_INCLUDE_DIRECTORIES lanelet2_core::lanelet2_core INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM - ${lanelet2_core_INCLUDE_DIRECTORIES} - ) - endif() - - # Find test dependencies - if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - ament_lint_auto_find_test_dependencies() - endif() -endmacro() diff --git a/autoware_cmake/package.xml b/autoware_cmake/package.xml deleted file mode 100644 index 93416988..00000000 --- a/autoware_cmake/package.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - autoware_cmake - 0.1.0 - CMake scripts for Autoware - Ryohsuke Mitsudome - Esteve Fernandez - Apache License 2.0 - - ament_cmake_auto - - ament_cmake_auto - ament_lint_auto - ros_environment - - ament_lint_auto - autoware_lint_common - - - ament_cmake - - diff --git a/autoware_lint_common/CMakeLists.txt b/autoware_lint_common/CMakeLists.txt deleted file mode 100644 index 473e4d14..00000000 --- a/autoware_lint_common/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 3.14) - -project(autoware_lint_common NONE) - -find_package(ament_cmake_core REQUIRED) -find_package(ament_cmake_export_dependencies REQUIRED) -find_package(ament_cmake_test REQUIRED) - -ament_package_xml() -ament_export_dependencies(${${PROJECT_NAME}_EXEC_DEPENDS}) -ament_package() diff --git a/autoware_lint_common/README.md b/autoware_lint_common/README.md deleted file mode 100644 index 89314c94..00000000 --- a/autoware_lint_common/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# autoware_lint_common - -A custom version of [ament_lint_common](https://github.com/ament/ament_lint/tree/master/ament_lint_common) for [Autoware](https://www.autoware.org/). - -## Usage - -Add dependencies of `ament_lint_auto` and `autoware_lint_common` to your package as below. - -`package.xml`: - -```xml -ament_lint_auto -autoware_lint_common -``` - -`CMakeLists.txt`: - -```cmake -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - ament_lint_auto_find_test_dependencies() -endif() -``` - -For ROS 2 messages and services, you need to remove the `ADD_LINTER_TESTS` argument in the `rosidl_generate_interfaces()` function in the `CMakelists.txt` file. - -Then, the following linters will run during `colcon test`. - -- [ament_cmake_copyright](https://github.com/ament/ament_lint/blob/master/ament_cmake_copyright/doc/index.rst) -- [ament_cmake_cppcheck](https://github.com/ament/ament_lint/blob/master/ament_cmake_cppcheck/doc/index.rst) -- [ament_cmake_lint_cmake](https://github.com/ament/ament_lint/blob/master/ament_cmake_lint_cmake/doc/index.rst) -- [ament_cmake_xmllint](https://github.com/ament/ament_lint/blob/master/ament_cmake_xmllint/doc/index.rst) - -## Design - -The original `ament_lint_common` contains other formatters/linters like `ament_cmake_uncrustify`, `ament_cmake_cpplint` and `ament_cmake_flake8`. -However, we don't include them because it's more useful to run them with `pre-commit` as [MoveIt](https://github.com/ros-planning/moveit2) does. - -For example, the benefits are: - -- We can use any version of tools independent of ament's version. -- We can easily integrate into IDE. -- We can easily check all the files in the repository without writing `test_depend` in each package. -- We can run formatters/linters without building, which makes error detection faster. - -Ideally, we think other linters should be moved to `pre-commit` as well, so we'll try to support them in the future. diff --git a/autoware_lint_common/package.xml b/autoware_lint_common/package.xml deleted file mode 100644 index 01bee8b5..00000000 --- a/autoware_lint_common/package.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - autoware_lint_common - 0.1.0 - The list of commonly used linters in Autoware - Ryohsuke Mitsudome - Esteve Fernandez - Apache License 2.0 - - ament_cmake_core - ament_cmake_export_dependencies - ament_cmake_test - - ament_cmake_core - ament_cmake_test - - ament_cmake_copyright - ament_cmake_cppcheck - ament_cmake_lint_cmake - ament_cmake_xmllint - - - ament_cmake - - diff --git a/autoware_utils/CMakeLists.txt b/autoware_utils/CMakeLists.txt deleted file mode 100644 index 21eb4ad2..00000000 --- a/autoware_utils/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -project(autoware_utils) - -find_package(autoware_cmake REQUIRED) -autoware_package() - -ament_auto_add_library(autoware_utils SHARED - src/autoware_utils.cpp -) - -if(BUILD_TESTING) - file(GLOB_RECURSE test_files test/**/*.cpp) - ament_add_ros_isolated_gtest(test_autoware_utils ${test_files}) - target_link_libraries(test_autoware_utils - autoware_utils - ) -endif() - -ament_auto_package() diff --git a/autoware_utils/README.md b/autoware_utils/README.md deleted file mode 100644 index 35493ac0..00000000 --- a/autoware_utils/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# autoware_utils - -Common utilities for Autoware. - -## Usage - -To use all features, include `autoware_utils/autoware_utils.hpp`: - -```cpp -#include - -using autoware_utils::deg2rad; -using autoware_utils::normalize_degree; -using autoware_utils::pi; -``` - -To select features, include necessary header files: - -```cpp -#include -#include - -using autoware_utils::normalize_degree; -using autoware_utils::pi; -``` diff --git a/autoware_utils/include/autoware_utils/autoware_utils.hpp b/autoware_utils/include/autoware_utils/autoware_utils.hpp deleted file mode 100644 index 77d2fecc..00000000 --- a/autoware_utils/include/autoware_utils/autoware_utils.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2020 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef AUTOWARE_UTILS__AUTOWARE_UTILS_HPP_ -#define AUTOWARE_UTILS__AUTOWARE_UTILS_HPP_ - -#include "autoware_utils/math/constants.hpp" -#include "autoware_utils/math/normalization.hpp" -#include "autoware_utils/math/range.hpp" -#include "autoware_utils/math/unit_conversion.hpp" -#include "autoware_utils/ros/uuid_helper.hpp" - -#endif // AUTOWARE_UTILS__AUTOWARE_UTILS_HPP_ diff --git a/autoware_utils/include/autoware_utils/math/constants.hpp b/autoware_utils/include/autoware_utils/math/constants.hpp deleted file mode 100644 index e86392a3..00000000 --- a/autoware_utils/include/autoware_utils/math/constants.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2020 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef AUTOWARE_UTILS__MATH__CONSTANTS_HPP_ -#define AUTOWARE_UTILS__MATH__CONSTANTS_HPP_ - -namespace autoware_utils -{ -constexpr double pi = 3.14159265358979323846; // To be replaced by std::numbers::pi in C++20 -constexpr double gravity = 9.80665; -} // namespace autoware_utils - -#endif // AUTOWARE_UTILS__MATH__CONSTANTS_HPP_ diff --git a/autoware_utils/include/autoware_utils/math/normalization.hpp b/autoware_utils/include/autoware_utils/math/normalization.hpp deleted file mode 100644 index bb913aa6..00000000 --- a/autoware_utils/include/autoware_utils/math/normalization.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef AUTOWARE_UTILS__MATH__NORMALIZATION_HPP_ -#define AUTOWARE_UTILS__MATH__NORMALIZATION_HPP_ - -#include "autoware_utils/math/constants.hpp" - -#include - -namespace autoware_utils -{ -inline double normalize_degree(const double deg, const double min_deg = -180) -{ - const auto max_deg = min_deg + 360.0; - - const auto value = std::fmod(deg, 360.0); - if (min_deg <= value && value < max_deg) { - return value; - } - - return value - std::copysign(360.0, value); -} - -inline double normalize_radian(const double rad, const double min_rad = -pi) -{ - const auto max_rad = min_rad + 2 * pi; - - const auto value = std::fmod(rad, 2 * pi); - if (min_rad <= value && value < max_rad) { - return value; - } - - return value - std::copysign(2 * pi, value); -} - -} // namespace autoware_utils - -#endif // AUTOWARE_UTILS__MATH__NORMALIZATION_HPP_ diff --git a/autoware_utils/include/autoware_utils/math/range.hpp b/autoware_utils/include/autoware_utils/math/range.hpp deleted file mode 100644 index da899a37..00000000 --- a/autoware_utils/include/autoware_utils/math/range.hpp +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2021 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef AUTOWARE_UTILS__MATH__RANGE_HPP_ -#define AUTOWARE_UTILS__MATH__RANGE_HPP_ - -#include -#include -#include -#include - -namespace autoware_utils -{ -template -std::vector arange(const T start, const T stop, const T step = 1) -{ - if (step == 0) { - throw std::invalid_argument("step must be non-zero value."); - } - - if (step > 0 && stop < start) { - throw std::invalid_argument("must be stop >= start for positive step."); - } - - if (step < 0 && stop > start) { - throw std::invalid_argument("must be stop <= start for negative step."); - } - - const double max_i_double = std::ceil(static_cast(stop - start) / step); - const auto max_i = static_cast(max_i_double); - - std::vector out; - out.reserve(max_i); - for (size_t i = 0; i < max_i; ++i) { - out.push_back(start + i * step); - } - - return out; -} - -template -std::vector linspace(const T start, const T stop, const size_t num) -{ - const auto start_double = static_cast(start); - const auto stop_double = static_cast(stop); - - if (num == 0) { - return {}; - } - - if (num == 1) { - return {start_double}; - } - - std::vector out; - out.reserve(num); - const double step = (stop_double - start_double) / static_cast(num - 1); - for (size_t i = 0; i < num; i++) { - out.push_back(start_double + static_cast(i) * step); - } - - return out; -} - -} // namespace autoware_utils - -#endif // AUTOWARE_UTILS__MATH__RANGE_HPP_ diff --git a/autoware_utils/include/autoware_utils/math/unit_conversion.hpp b/autoware_utils/include/autoware_utils/math/unit_conversion.hpp deleted file mode 100644 index 97db93fe..00000000 --- a/autoware_utils/include/autoware_utils/math/unit_conversion.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2020 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef AUTOWARE_UTILS__MATH__UNIT_CONVERSION_HPP_ -#define AUTOWARE_UTILS__MATH__UNIT_CONVERSION_HPP_ - -#include "autoware_utils/math/constants.hpp" - -namespace autoware_utils -{ -constexpr double deg2rad(const double deg) -{ - return deg * pi / 180.0; -} - -constexpr double rad2deg(const double rad) -{ - return rad * 180.0 / pi; -} - -constexpr double kmph2mps(const double kmph) -{ - return kmph * 1000.0 / 3600.0; -} - -constexpr double mps2kmph(const double mps) -{ - return mps * 3600.0 / 1000.0; -} -} // namespace autoware_utils - -#endif // AUTOWARE_UTILS__MATH__UNIT_CONVERSION_HPP_ diff --git a/autoware_utils/include/autoware_utils/ros/uuid_helper.hpp b/autoware_utils/include/autoware_utils/ros/uuid_helper.hpp deleted file mode 100644 index 8e27b4cf..00000000 --- a/autoware_utils/include/autoware_utils/ros/uuid_helper.hpp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2022 Tier IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef AUTOWARE_UTILS__ROS__UUID_HELPER_HPP_ -#define AUTOWARE_UTILS__ROS__UUID_HELPER_HPP_ - -#include - -#include - -#include -#include -#include - -namespace autoware_utils -{ -inline unique_identifier_msgs::msg::UUID generate_uuid() -{ - // Generate random number - unique_identifier_msgs::msg::UUID uuid; - std::mt19937 gen(std::random_device{}()); - std::independent_bits_engine bit_eng(gen); - std::generate(uuid.uuid.begin(), uuid.uuid.end(), bit_eng); - - return uuid; -} -inline unique_identifier_msgs::msg::UUID generate_default_uuid() -{ - // Generate UUID with all zeros - unique_identifier_msgs::msg::UUID default_uuid; - // Use std::generate to fill the UUID with zeros - std::generate(default_uuid.uuid.begin(), default_uuid.uuid.end(), []() { return 0; }); - - return default_uuid; -} -inline std::string to_hex_string(const unique_identifier_msgs::msg::UUID & id) -{ - std::stringstream ss; - for (auto i = 0; i < 16; ++i) { - ss << std::hex << std::setfill('0') << std::setw(2) << +id.uuid[i]; - } - return ss.str(); -} - -inline boost::uuids::uuid to_boost_uuid(const unique_identifier_msgs::msg::UUID & id) -{ - boost::uuids::uuid boost_uuid{}; - std::copy(id.uuid.begin(), id.uuid.end(), boost_uuid.begin()); - return boost_uuid; -} - -inline unique_identifier_msgs::msg::UUID to_uuid_msg(const boost::uuids::uuid & id) -{ - unique_identifier_msgs::msg::UUID ros_uuid{}; - std::copy(id.begin(), id.end(), ros_uuid.uuid.begin()); - return ros_uuid; -} - -} // namespace autoware_utils - -#endif // AUTOWARE_UTILS__ROS__UUID_HELPER_HPP_ diff --git a/autoware_utils/package.xml b/autoware_utils/package.xml deleted file mode 100644 index e22b6769..00000000 --- a/autoware_utils/package.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - autoware_utils - 0.1.0 - The autoware_utils package - Ryohsuke Mitsudome - Esteve Fernandez - Apache License 2.0 - - ament_cmake_auto - autoware_cmake - - builtin_interfaces - libboost-system-dev - rclcpp - unique_identifier_msgs - - ament_cmake_ros - - - ament_cmake - - diff --git a/autoware_utils/src/autoware_utils.cpp b/autoware_utils/src/autoware_utils.cpp deleted file mode 100644 index 25b20e5f..00000000 --- a/autoware_utils/src/autoware_utils.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2020 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "autoware_utils/autoware_utils.hpp" diff --git a/autoware_utils/test/src/math/test_constants.cpp b/autoware_utils/test/src/math/test_constants.cpp deleted file mode 100644 index dd2e3f0d..00000000 --- a/autoware_utils/test/src/math/test_constants.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2020 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "autoware_utils/math/constants.hpp" - -#include - -TEST(constants, pi) // NOLINT for gtest -{ - using autoware_utils::pi; - - EXPECT_DOUBLE_EQ(pi, 3.14159265358979323846); -} - -TEST(constants, gravity) // NOLINT for gtest -{ - using autoware_utils::gravity; - - EXPECT_DOUBLE_EQ(gravity, 9.80665); -} diff --git a/autoware_utils/test/src/math/test_normalization.cpp b/autoware_utils/test/src/math/test_normalization.cpp deleted file mode 100644 index fbdedd49..00000000 --- a/autoware_utils/test/src/math/test_normalization.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2020 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "autoware_utils/math/normalization.hpp" - -#include - -TEST(normalization, normalize_degree) // NOLINT for gtest -{ - using autoware_utils::normalize_degree; - - // -180 <= deg < 180 - { - constexpr double eps = 0.1; - constexpr double v_min = -180; - constexpr double v_mid = 0; - constexpr double v_max = 180; - - EXPECT_DOUBLE_EQ(normalize_degree(v_min - eps), v_max - eps); - EXPECT_DOUBLE_EQ(normalize_degree(v_min), v_min); - EXPECT_DOUBLE_EQ(normalize_degree(v_mid), v_mid); - EXPECT_DOUBLE_EQ(normalize_degree(v_max - eps), v_max - eps); - EXPECT_DOUBLE_EQ(normalize_degree(v_max), v_min); - } - - // 0 <= deg < 360 - { - constexpr double eps = 0.1; - constexpr double v_min = 0; - constexpr double v_mid = 180; - constexpr double v_max = 360; - - EXPECT_DOUBLE_EQ(normalize_degree(v_min - eps, 0), v_max - eps); - EXPECT_DOUBLE_EQ(normalize_degree(v_min, 0), v_min); - EXPECT_DOUBLE_EQ(normalize_degree(v_mid, 0), v_mid); - EXPECT_DOUBLE_EQ(normalize_degree(v_max - eps, 0), v_max - eps); - EXPECT_DOUBLE_EQ(normalize_degree(v_max, 0), v_min); - } -} - -TEST(normalization, normalize_radian) // NOLINT for gtest -{ - using autoware_utils::normalize_radian; - - // -M_PI <= deg < M_PI - { - constexpr double eps = 0.1; - constexpr double v_min = -M_PI; - constexpr double v_mid = 0; - constexpr double v_max = M_PI; - - EXPECT_DOUBLE_EQ(normalize_radian(v_min - eps), v_max - eps); - EXPECT_DOUBLE_EQ(normalize_radian(v_min), v_min); - EXPECT_DOUBLE_EQ(normalize_radian(v_mid), v_mid); - EXPECT_DOUBLE_EQ(normalize_radian(v_max - eps), v_max - eps); - EXPECT_DOUBLE_EQ(normalize_radian(v_max), v_min); - } - - // 0 <= deg < 2 * M_PI - { - constexpr double eps = 0.1; - constexpr double v_min = 0; - constexpr double v_mid = M_PI; - constexpr double v_max = 2 * M_PI; - - EXPECT_DOUBLE_EQ(normalize_radian(v_min - eps, 0), v_max - eps); - EXPECT_DOUBLE_EQ(normalize_radian(v_min, 0), v_min); - EXPECT_DOUBLE_EQ(normalize_radian(v_mid, 0), v_mid); - EXPECT_DOUBLE_EQ(normalize_radian(v_max - eps, 0), v_max - eps); - EXPECT_DOUBLE_EQ(normalize_radian(v_max, 0), v_min); - } -} diff --git a/autoware_utils/test/src/math/test_range.cpp b/autoware_utils/test/src/math/test_range.cpp deleted file mode 100644 index ff47512f..00000000 --- a/autoware_utils/test/src/math/test_range.cpp +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright 2021 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "autoware_utils/math/range.hpp" - -#include - -#include - -template -void expect_near_vector( - const std::vector & input, const std::vector & expect, const T abs_error = 1e-6) -{ - ASSERT_EQ(input.size(), expect.size()) << "unequal length"; - - for (size_t i = 0; i < input.size(); i++) { - const auto x = input.at(i); - const auto y = expect.at(i); - EXPECT_NEAR(x, y, abs_error) << "differ at index " << i << ":" << x << ", " << y; - } -} - -void expect_eq_vector(const std::vector & input, const std::vector & expect) -{ - ASSERT_EQ(input.size(), expect.size()) << "unequal length"; - - for (size_t i = 0; i < input.size(); ++i) { - const auto x = input.at(i); - const auto y = expect.at(i); - EXPECT_EQ(x, y) << "differ at index " << i << ": " << x << ", " << y; - } -} - -TEST(range, arange_double) // NOLINT for gtest -{ - using autoware_utils::arange; - - // general cases - { - expect_near_vector(arange(0.0, 5.0, 1.0), std::vector{0.0, 1.0, 2.0, 3.0, 4.0}); - expect_near_vector(arange(0.0, 5.1, 1.0), std::vector{0.0, 1.0, 2.0, 3.0, 4.0, 5.0}); - expect_near_vector(arange(2.0, 5.0, 0.5), std::vector{2.0, 2.5, 3.0, 3.5, 4.0, 4.5}); - expect_near_vector( - arange(0.1, 2.0, 0.2), std::vector{0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9}); - - // argument step is omitted. - expect_near_vector(arange(0.0, 5.0), std::vector{0.0, 1.0, 2.0, 3.0, 4.0}); - } - // corner cases - { - // stop == start - expect_near_vector(arange(3.0, 3.0, 1.0), std::vector{}); - // step > stop - start - expect_near_vector(arange(2.0, 4.0, 10.0), std::vector{2.0}); - // step is negative value and stop < start - expect_near_vector( - arange(3.0, -3.0, -1.0), std::vector{3.0, 2.0, 1.0, 0.0, -1.0, -2.0}); - } - // invalid cases - { - // step == 0 - EXPECT_THROW(arange(0.0, 5.0, 0.0), std::invalid_argument); // NOLINT for gtest - EXPECT_THROW(arange(0.0, -5.0, 0.0), std::invalid_argument); // NOLINT for gtest - - // positive step but start > stop. - EXPECT_THROW(arange(0.0, -1.0, 0.1), std::invalid_argument); // NOLINT for gtest - // negative step but start < stop. - EXPECT_THROW(arange(0.0, 1.0, -0.1), std::invalid_argument); // NOLINT for gtest - } -} - -TEST(range, arange_float) // NOLINT for gtest -{ - using autoware_utils::arange; - - // general cases - { - expect_near_vector(arange(0.0f, 5.0f, 1.0f), std::vector{0.0, 1.0, 2.0, 3.0, 4.0}); - expect_near_vector(arange(0.0f, 5.1f, 1.0f), std::vector{0.0, 1.0, 2.0, 3.0, 4.0, 5.0}); - expect_near_vector(arange(2.0f, 5.0f, 0.5f), std::vector{2.0, 2.5, 3.0, 3.5, 4.0, 4.5}); - expect_near_vector( - arange(0.1f, 2.0f, 0.2f), - std::vector{0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9}); - - // argument step is omitted. - expect_near_vector(arange(0.0f, 5.0f), std::vector{0.0, 1.0, 2.0, 3.0, 4.0}); - } - // corner cases - { - // stop == start - expect_near_vector(arange(3.0f, 3.0f, 1.0f), std::vector{}); - // step > stop - start - expect_near_vector(arange(2.0f, 4.0f, 10.0f), std::vector{2.0}); - // step is negative value and stop < start - expect_near_vector( - arange(3.0f, -3.0f, -1.0f), std::vector{3.0, 2.0, 1.0, 0.0, -1.0, -2.0}); - } - // invalid cases - { - // step == 0 - EXPECT_THROW(arange(0.0f, 5.0f, 0.0f), std::invalid_argument); // NOLINT for gtest - EXPECT_THROW(arange(0.0f, -5.0f, 0.0f), std::invalid_argument); // NOLINT for gtest - - // positive step but start > stop. - EXPECT_THROW(arange(0.0f, -1.0f, 0.1f), std::invalid_argument); // NOLINT for gtest - // negative step but start < stop. - EXPECT_THROW(arange(0.0f, 1.0f, -0.1f), std::invalid_argument); // NOLINT for gtest - } -} - -TEST(range, arange_int) // NOLINT for gtest -{ - using autoware_utils::arange; - - // general cases - { - expect_eq_vector(arange(0, 5, 2), std::vector{0, 2, 4}); - - // argument step is omitted. - expect_eq_vector(arange(0, 5), std::vector{0, 1, 2, 3, 4}); - } - // corner cases - { - // stop == start - expect_eq_vector(arange(3, 3, 1), std::vector{}); - // step > stop - start - expect_eq_vector(arange(2, 4, 10), std::vector{2}); - // step is negative value and stop < start - expect_eq_vector(arange(3, -3, -1), std::vector{3, 2, 1, 0, -1, -2}); - } - // invalid cases - { - // step == 0 - EXPECT_THROW(arange(0, 5, 0), std::invalid_argument); // NOLINT for gtest - EXPECT_THROW(arange(0, -5, 0), std::invalid_argument); // NOLINT for gtest - - // positive step but start > stop. - EXPECT_THROW(arange(0, -3, 1), std::invalid_argument); // NOLINT for gtest - // negative step but start < stop. - EXPECT_THROW(arange(0, 3, -1), std::invalid_argument); // NOLINT for gtest - } -} - -TEST(range, linspace_double) // NOLINT for gtest -{ - using autoware_utils::linspace; - - // general cases - { - expect_near_vector(linspace(3.0, 7.0, 5), std::vector{3.0, 4.0, 5.0, 6.0, 7.0}); - expect_near_vector(linspace(1.0, 2.0, 3), std::vector{1.0, 1.5, 2.0}); - expect_near_vector(linspace(-1.0, 3.0, 5), std::vector{-1.0, 0.0, 1.0, 2.0, 3.0}); - expect_near_vector( - linspace(0.1, 1.0, 10), - std::vector{0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0}); - } - // corner cases - { - // num == 2 - expect_near_vector(linspace(0.0, 10.0, 2), std::vector{0.0, 10.0}); - // num == 1 - expect_near_vector(linspace(11.0, 20.0, 1), std::vector{11.0}); - // num == 0 - expect_near_vector(linspace(30.0, 40.0, 0), std::vector{}); - // start == stop - expect_near_vector(linspace(2.3, 2.3, 3), std::vector{2.3, 2.3, 2.3}); - // start > stop - expect_near_vector(linspace(10.0, 5.0, 6), std::vector{10.0, 9.0, 8.0, 7.0, 6.0, 5.0}); - } -} - -TEST(range, linspace_float) // NOLINT for gtest -{ - using autoware_utils::linspace; - - // general cases - { - expect_near_vector(linspace(3.0f, 7.0f, 5), std::vector{3.0, 4.0, 5.0, 6.0, 7.0}); - expect_near_vector(linspace(1.0f, 2.0f, 3), std::vector{1.0, 1.5, 2.0}); - expect_near_vector(linspace(-1.0f, 3.0f, 5), std::vector{-1.0, 0.0, 1.0, 2.0, 3.0}); - expect_near_vector( - linspace(0.1f, 1.0f, 10), - std::vector{0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0}); - } - // corner cases - { - // num == 2 - expect_near_vector(linspace(0.0f, 10.0f, 2), std::vector{0.0, 10.0}); - // num == 1 - expect_near_vector(linspace(11.0f, 20.0f, 1), std::vector{11.0}); - // num == 0 - expect_near_vector(linspace(30.0f, 40.0f, 0), std::vector{}); - // start == stop - expect_near_vector(linspace(2.3f, 2.3f, 3), std::vector{2.3, 2.3, 2.3}); - // start > stop - expect_near_vector( - linspace(10.0f, 5.0f, 6), std::vector{10.0, 9.0, 8.0, 7.0, 6.0, 5.0}); - } -} - -TEST(range, linspace_int) // NOLINT for gtest -{ - using autoware_utils::linspace; - - // general cases - { - expect_near_vector(linspace(3, 7, 5), std::vector{3.0, 4.0, 5.0, 6.0, 7.0}); - expect_near_vector(linspace(1, 2, 3), std::vector{1.0, 1.5, 2.0}); - expect_near_vector(linspace(-1, 3, 5), std::vector{-1.0, 0.0, 1.0, 2.0, 3.0}); - } - // corner cases - { - // num == 2 - expect_near_vector(linspace(0, 10, 2), std::vector{0.0, 10.0}); - // num == 1 - expect_near_vector(linspace(11, 20, 1), std::vector{11.0}); - // num == 0 - expect_near_vector(linspace(30, 40, 0), std::vector{}); - // start == stop - expect_near_vector(linspace(3, 3, 3), std::vector{3.0, 3.0, 3.0}); - // start > stop - expect_near_vector(linspace(10, 5, 6), std::vector{10.0, 9.0, 8.0, 7.0, 6.0, 5.0}); - } -} diff --git a/autoware_utils/test/src/math/test_unit_conversion.cpp b/autoware_utils/test/src/math/test_unit_conversion.cpp deleted file mode 100644 index c3552526..00000000 --- a/autoware_utils/test/src/math/test_unit_conversion.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2020 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "autoware_utils/math/unit_conversion.hpp" - -#include - -using autoware_utils::pi; - -TEST(unit_conversion, deg2rad) // NOLINT for gtest -{ - using autoware_utils::deg2rad; - - EXPECT_DOUBLE_EQ(deg2rad(-720), -4 * pi); - EXPECT_DOUBLE_EQ(deg2rad(0), 0); - EXPECT_DOUBLE_EQ(deg2rad(30), pi / 6); - EXPECT_DOUBLE_EQ(deg2rad(60), pi / 3); - EXPECT_DOUBLE_EQ(deg2rad(90), pi / 2); - EXPECT_DOUBLE_EQ(deg2rad(180), pi); - EXPECT_DOUBLE_EQ(deg2rad(360), 2 * pi); -} - -TEST(unit_conversion, rad2deg) // NOLINT for gtest -{ - using autoware_utils::rad2deg; - - EXPECT_DOUBLE_EQ(rad2deg(-4 * pi), -720); - EXPECT_DOUBLE_EQ(rad2deg(0), 0); - EXPECT_DOUBLE_EQ(rad2deg(pi / 6), 30); - EXPECT_DOUBLE_EQ(rad2deg(pi / 3), 60); - EXPECT_DOUBLE_EQ(rad2deg(pi / 2), 90); - EXPECT_DOUBLE_EQ(rad2deg(pi), 180); - EXPECT_DOUBLE_EQ(rad2deg(2 * pi), 360); -} - -TEST(unit_conversion, kmph2mps) // NOLINT for gtest -{ - using autoware_utils::kmph2mps; - - EXPECT_DOUBLE_EQ(kmph2mps(0), 0); - EXPECT_DOUBLE_EQ(kmph2mps(36), 10); - EXPECT_DOUBLE_EQ(kmph2mps(72), 20); - EXPECT_DOUBLE_EQ(kmph2mps(180), 50); -} - -TEST(unit_conversion, mps2kmph) // NOLINT for gtest -{ - using autoware_utils::mps2kmph; - - EXPECT_DOUBLE_EQ(mps2kmph(0), 0); - EXPECT_DOUBLE_EQ(mps2kmph(10), 36); - EXPECT_DOUBLE_EQ(mps2kmph(20), 72); - EXPECT_DOUBLE_EQ(mps2kmph(50), 180); -} diff --git a/autoware_utils/test/src/ros/test_uuid_helper.cpp b/autoware_utils/test/src/ros/test_uuid_helper.cpp deleted file mode 100644 index 05434fbb..00000000 --- a/autoware_utils/test/src/ros/test_uuid_helper.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2024 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "autoware_utils/ros/uuid_helper.hpp" - -#include - -#include - -TEST(UUIDHelperTest, generate_uuid) -{ - // Generate two UUIDs and ensure they are all different - - unique_identifier_msgs::msg::UUID uuid1 = autoware_utils::generate_uuid(); - unique_identifier_msgs::msg::UUID uuid2 = autoware_utils::generate_uuid(); - - EXPECT_FALSE(uuid1 == uuid2) << "Duplicate UUID generated: " - << autoware_utils::to_hex_string(uuid2); -} - -TEST(UUIDHelperTest, generate_default_uuid) -{ - // Generate two UUIDs and ensure they are all different - - unique_identifier_msgs::msg::UUID default_uuid = autoware_utils::generate_default_uuid(); - unique_identifier_msgs::msg::UUID zero_uuid; - std::fill(zero_uuid.uuid.begin(), zero_uuid.uuid.end(), 0x00); - - EXPECT_EQ(default_uuid, zero_uuid); -} - -TEST(UUIDHelperTest, to_hex_string) -{ - unique_identifier_msgs::msg::UUID uuid; - // Populate the UUID with some values - std::fill(uuid.uuid.begin(), uuid.uuid.end(), 0x42); - - std::string hex_string = autoware_utils::to_hex_string(uuid); - - // Check if the generated hex string is correct - EXPECT_EQ(hex_string, "42424242424242424242424242424242"); -} - -TEST(UUIDHelperTest, to_boost_uuid) -{ - unique_identifier_msgs::msg::UUID uuid; - // Populate the UUID with some values - std::fill(uuid.uuid.begin(), uuid.uuid.end(), 0x42); - - boost::uuids::uuid boost_uuid{}; - std::fill(boost_uuid.begin(), boost_uuid.end(), 0x42); - - // Check if the conversion from ROS UUID to Boost UUID is correct - EXPECT_TRUE(boost_uuid == autoware_utils::to_boost_uuid(uuid)); -} - -TEST(UUIDHelperTest, to_uuid_msg) -{ - boost::uuids::random_generator generator; - boost::uuids::uuid boost_uuid = generator(); - unique_identifier_msgs::msg::UUID ros_uuid = autoware_utils::to_uuid_msg(boost_uuid); - - // Check if the conversion from Boost UUID to ROS UUID is correct - EXPECT_TRUE(std::equal(boost_uuid.begin(), boost_uuid.end(), ros_uuid.uuid.begin())); -} diff --git a/autoware_utils/test/src/test_autoware_utils.cpp b/autoware_utils/test/src/test_autoware_utils.cpp deleted file mode 100644 index 391fdc5f..00000000 --- a/autoware_utils/test/src/test_autoware_utils.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2020 TIER IV, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "autoware_utils/autoware_utils.hpp" - -#include - -#include - -int main(int argc, char * argv[]) -{ - testing::InitGoogleTest(&argc, argv); - rclcpp::init(argc, argv); - bool result = RUN_ALL_TESTS(); - rclcpp::shutdown(); - return result; -}