diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 733a842865802..f8273cebdd578 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -94,4 +94,4 @@ repos: args: [--quiet] exclude: .cu -exclude: .svg|control/trajectory_follower|control/trajectory_follower_nodes|common/autoware_auto_cmake|common/autoware_auto_common|common/autoware_auto_geometry|common/autoware_auto_tf2|common/autoware_testing|common/fake_test_node|common/had_map_utils|common/motion_common|common/motion_testing|common/time_utils|common/vehicle_constants_manager|common/autoware_auto_perception_rviz_plugin|common/osqp_interface|simulator/simple_planning_simulator|planning/freespace_planner|planning/astar_search|planning/costmap_generator +exclude: .svg diff --git a/common/autoware_auto_cmake/design/autoware_auto_cmake-design.md b/common/autoware_auto_cmake/design/autoware_auto_cmake-design.md index 62c82d6dd7db2..8946a02f8d951 100644 --- a/common/autoware_auto_cmake/design/autoware_auto_cmake-design.md +++ b/common/autoware_auto_cmake/design/autoware_auto_cmake-design.md @@ -1,10 +1,8 @@ -autoware_auto_cmake {#autoware-auto-cmake-design} -=========== +# autoware_auto_cmake {#autoware-auto-cmake-design} This is the design document for the `autoware_auto_cmake` package. - -# Purpose +## Purpose Provide common CMake variables and functions to Autoware packages. @@ -13,17 +11,17 @@ Those include: - Setting the language standard - Getting user-provided variables - Providing functions to: - + set compiler flags - + turn off optimizations + - set compiler flags + - turn off optimizations -# Design +## Design -## Usage +### Usage Add `autoware_auto_cmake` as a "build_depend" in the dependent packages. -### CMake variables {#cmake-config-variables} +#### CMake variables {#cmake-config-variables} -|Name|Type|Descritpion|Default| -|----|----|-----------|-------| -|`DOWNLOAD_ARTIFACTS`|*BOOL*|Allow downloading artifacts at build time.|`OFF`| +| Name | Type | Descritpion | Default | +| -------------------- | ------ | ------------------------------------------ | ------- | +| `DOWNLOAD_ARTIFACTS` | _BOOL_ | Allow downloading artifacts at build time. | `OFF` | diff --git a/common/autoware_auto_cmake/package.xml b/common/autoware_auto_cmake/package.xml index 6d8163eae6018..6c3df541c4095 100644 --- a/common/autoware_auto_cmake/package.xml +++ b/common/autoware_auto_cmake/package.xml @@ -12,11 +12,11 @@ ros_environment - ament_cmake_core - ament_cmake_lint_cmake ament_cmake_copyright + ament_cmake_core ament_cmake_cppcheck ament_cmake_cpplint + ament_cmake_lint_cmake ament_cmake_uncrustify ament_cmake_lint_cmake diff --git a/common/autoware_auto_common/CMakeLists.txt b/common/autoware_auto_common/CMakeLists.txt index 45284843f5644..54407c7a0facf 100644 --- a/common/autoware_auto_common/CMakeLists.txt +++ b/common/autoware_auto_common/CMakeLists.txt @@ -32,7 +32,6 @@ if(BUILD_TESTING) # Temporarily disable cpplint and uncrustify list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_cpplint - ament_cmake_uncrustify ) ament_lint_auto_find_test_dependencies() @@ -46,10 +45,6 @@ if(BUILD_TESTING) find_package(ament_cmake_cpplint) ament_cpplint(${FILES_MINUS_SOME}) - # Re-enable uncrustify - find_package(ament_cmake_uncrustify) - ament_uncrustify(${FILES_MINUS_SOME}) - # Unit tests set(TEST_COMMON test_common_gtest) ament_add_gtest(${TEST_COMMON} diff --git a/common/autoware_auto_common/design/comparisons.md b/common/autoware_auto_common/design/comparisons.md index 6e1d2eb9db35e..d8c1ef6de17e8 100644 --- a/common/autoware_auto_common/design/comparisons.md +++ b/common/autoware_auto_common/design/comparisons.md @@ -1,5 +1,4 @@ -Comparisons {#helper-comparisons} -=========== +# Comparisons {#helper-comparisons} The `float_comparisons.hpp` library is a simple set of functions for performing approximate numerical comparisons. There are separate functions for performing comparisons using absolute bounds and relative bounds. Absolute comparison checks are prefixed with `abs_` and relative checks are prefixed with `rel_`. @@ -8,19 +7,19 @@ The `bool_comparisons.hpp` library additionally contains an XOR operator. The intent of the library is to improve readability of code and reduce likelihood of typographical errors when using numerical and boolean comparisons. -# Target use cases +## Target use cases The approximate comparisons are intended to be used to check whether two numbers lie within some absolute or relative interval. The `exclusive_or` function will test whether two values cast to different boolean values. -# Assumptions +## Assumptions -* The approximate comparisons all take an `epsilon` parameter. -The value of this parameter must be >= 0. -* The library is only intended to be used with floating point types. -A static assertion will be thrown if the library is used with a non-floating point type. +- The approximate comparisons all take an `epsilon` parameter. + The value of this parameter must be >= 0. +- The library is only intended to be used with floating point types. + A static assertion will be thrown if the library is used with a non-floating point type. -# Example Usage +## Example Usage ```c++ #include "common/bool_comparisons.hpp" diff --git a/common/autoware_auto_common/include/common/type_traits.hpp b/common/autoware_auto_common/include/common/type_traits.hpp index ed0ab1709d92c..44dfe92681017 100644 --- a/common/autoware_auto_common/include/common/type_traits.hpp +++ b/common/autoware_auto_common/include/common/type_traits.hpp @@ -41,28 +41,32 @@ namespace type_traits /// /// @return A boolean that should be false for any type passed into this function. /// -template +template constexpr inline autoware::common::types::bool8_t COMMON_PUBLIC impossible_branch() noexcept { return sizeof(T) == 0; } /// Find an index of a type in a tuple -template +template struct COMMON_PUBLIC index { static_assert(!std::is_same>::value, "Could not find QueryT in given tuple"); }; /// Specialization for a tuple that starts with the HeadT type. End of recursion. -template +template struct COMMON_PUBLIC index> - : std::integral_constant {}; +: std::integral_constant +{ +}; /// Specialization for a tuple with a type different to QueryT that calls the recursive step. -template +template struct COMMON_PUBLIC index> - : std::integral_constant>::value> {}; +: std::integral_constant>::value> +{ +}; /// /// @brief Visit every element in a tuple. @@ -75,13 +79,17 @@ struct COMMON_PUBLIC index> /// /// @return Does not return anything. Capture variables in a lambda to return any values. /// -template -COMMON_PUBLIC inline constexpr typename std::enable_if_t -visit(std::tuple &, Callable) noexcept {} +template +COMMON_PUBLIC inline constexpr typename std::enable_if_t visit( + std::tuple &, Callable) noexcept +{ +} /// @brief Same as the previous specialization but for const tuple. -template -COMMON_PUBLIC inline constexpr typename std::enable_if_t -visit(const std::tuple &, Callable) noexcept {} +template +COMMON_PUBLIC inline constexpr typename std::enable_if_t visit( + const std::tuple &, Callable) noexcept +{ +} /// /// @brief Visit every element in a tuple. @@ -98,32 +106,37 @@ visit(const std::tuple &, Callable) noexcept {} /// /// @return Does not return anything. Capture variables in a lambda to return any values. /// -template -COMMON_PUBLIC inline constexpr typename std::enable_if_t -visit(std::tuple & tuple, Callable callable) noexcept +template +COMMON_PUBLIC inline constexpr typename std::enable_if_t visit( + std::tuple & tuple, Callable callable) noexcept { callable(std::get(tuple)); visit(tuple, callable); } /// @brief Same as the previous specialization but for const tuple. -template -COMMON_PUBLIC inline constexpr typename std::enable_if_t -visit(const std::tuple & tuple, Callable callable) noexcept +template +COMMON_PUBLIC inline constexpr typename std::enable_if_t visit( + const std::tuple & tuple, Callable callable) noexcept { callable(std::get(tuple)); visit(tuple, callable); } /// @brief A class to compute a conjunction over given traits. -template -struct COMMON_PUBLIC conjunction : std::true_type {}; +template +struct COMMON_PUBLIC conjunction : std::true_type +{ +}; /// @brief A conjunction of another type shall derive from that type. -template -struct COMMON_PUBLIC conjunction: TraitT {}; -template +template +struct COMMON_PUBLIC conjunction : TraitT +{ +}; +template struct COMMON_PUBLIC conjunction - : std::conditional_t(TraitT::value), conjunction, TraitT> {}; - +: std::conditional_t(TraitT::value), conjunction, TraitT> +{ +}; /// /// @brief A trait to check if a tuple has a type. @@ -133,7 +146,7 @@ struct COMMON_PUBLIC conjunction /// @tparam QueryT A query type. /// @tparam TupleT A tuple to search the type in. /// -template +template struct has_type; /// @@ -142,8 +155,10 @@ struct has_type; /// /// @tparam QueryT Any type. /// -template -struct has_type>: std::false_type {}; +template +struct has_type> : std::false_type +{ +}; /// /// @brief Recursive override of the main trait. @@ -152,8 +167,10 @@ struct has_type>: std::false_type {}; /// @tparam HeadT Head type in the tuple. /// @tparam TailTs Rest of the tuple types. /// -template -struct has_type>: has_type> {}; +template +struct has_type> : has_type> +{ +}; /// /// @brief End of recursion for the main `has_type` trait. Becomes a `true_type` when the first @@ -162,9 +179,10 @@ struct has_type>: has_type -struct has_type>: std::true_type {}; - +template +struct has_type> : std::true_type +{ +}; /// /// @brief A trait used to intersect types stored in tuples at compile time. The resulting @@ -176,7 +194,7 @@ struct has_type>: std::true_type {}; /// @tparam TupleT1 Tuple 1 /// @tparam TupleT2 Tuple 2 /// -template +template struct intersect { /// @@ -185,18 +203,16 @@ struct intersect /// @details This function "iterates" over the types in TupleT1 and checks if those are in /// TupleT2. If this is true, these types are concatenated into a new tuple. /// - template + template static constexpr auto make_intersection(std::index_sequence) { - return std::tuple_cat( - std::conditional_t< - has_type, TupleT2>::value, - std::tuple>, - std::tuple<>>{} ...); + return std::tuple_cat(std::conditional_t< + has_type, TupleT2>::value, + std::tuple>, std::tuple<>>{}...); } /// The resulting tuple type. using type = - decltype(make_intersection(std::make_index_sequence::value> {})); + decltype(make_intersection(std::make_index_sequence::value>{})); }; } // namespace type_traits diff --git a/common/autoware_auto_common/include/common/types.hpp b/common/autoware_auto_common/include/common/types.hpp index f3d49fcea04ff..5c77449e30ff5 100644 --- a/common/autoware_auto_common/include/common/types.hpp +++ b/common/autoware_auto_common/include/common/types.hpp @@ -19,12 +19,12 @@ #ifndef COMMON__TYPES_HPP_ #define COMMON__TYPES_HPP_ +#include "common/visibility_control.hpp" +#include "helper_functions/float_comparisons.hpp" + #include -#include #include - -#include "helper_functions/float_comparisons.hpp" -#include "common/visibility_control.hpp" +#include namespace autoware { @@ -61,16 +61,12 @@ struct COMMON_PUBLIC PointXYZIF float32_t intensity{0}; uint16_t id{0}; static constexpr uint16_t END_OF_SCAN_ID = 65535u; - friend bool operator==( - const PointXYZIF & p1, - const PointXYZIF & p2) noexcept + friend bool operator==(const PointXYZIF & p1, const PointXYZIF & p2) noexcept { using autoware::common::helper_functions::comparisons::rel_eq; const auto epsilon = std::numeric_limits::epsilon(); - return rel_eq(p1.x, p2.x, epsilon) && - rel_eq(p1.y, p2.y, epsilon) && - rel_eq(p1.z, p2.z, epsilon) && - rel_eq(p1.intensity, p2.intensity, epsilon) && + return rel_eq(p1.x, p2.x, epsilon) && rel_eq(p1.y, p2.y, epsilon) && + rel_eq(p1.z, p2.z, epsilon) && rel_eq(p1.intensity, p2.intensity, epsilon) && (p1.id == p2.id); } }; @@ -82,16 +78,12 @@ struct COMMON_PUBLIC PointXYZF float32_t z{0}; uint16_t id{0}; static constexpr uint16_t END_OF_SCAN_ID = 65535u; - friend bool operator==( - const PointXYZF & p1, - const PointXYZF & p2) noexcept + friend bool operator==(const PointXYZF & p1, const PointXYZF & p2) noexcept { using autoware::common::helper_functions::comparisons::rel_eq; const auto epsilon = std::numeric_limits::epsilon(); - return rel_eq(p1.x, p2.x, epsilon) && - rel_eq(p1.y, p2.y, epsilon) && - rel_eq(p1.z, p2.z, epsilon) && - (p1.id == p2.id); + return rel_eq(p1.x, p2.x, epsilon) && rel_eq(p1.y, p2.y, epsilon) && + rel_eq(p1.z, p2.z, epsilon) && (p1.id == p2.id); } }; @@ -101,22 +93,19 @@ struct COMMON_PUBLIC PointXYZI float32_t y{0.0F}; float32_t z{0.0F}; float32_t intensity{0.0F}; - friend bool operator==( - const PointXYZI & p1, - const PointXYZI & p2) noexcept + friend bool operator==(const PointXYZI & p1, const PointXYZI & p2) noexcept { - return - helper_functions::comparisons::rel_eq( - p1.x, p2.x, std::numeric_limits::epsilon()) && + return helper_functions::comparisons::rel_eq( + p1.x, p2.x, std::numeric_limits::epsilon()) && - helper_functions::comparisons::rel_eq( - p1.y, p2.y, std::numeric_limits::epsilon()) && + helper_functions::comparisons::rel_eq( + p1.y, p2.y, std::numeric_limits::epsilon()) && - helper_functions::comparisons::rel_eq( - p1.z, p2.z, std::numeric_limits::epsilon()) && + helper_functions::comparisons::rel_eq( + p1.z, p2.z, std::numeric_limits::epsilon()) && - helper_functions::comparisons::rel_eq( - p1.intensity, p2.intensity, std::numeric_limits::epsilon()); + helper_functions::comparisons::rel_eq( + p1.intensity, p2.intensity, std::numeric_limits::epsilon()); } }; @@ -127,7 +116,7 @@ static constexpr uint16_t POINT_BLOCK_CAPACITY = 512U; // TODO(yunus.caliskan): switch to std::void_t when C++17 is available /// \brief `std::void_t<> implementation -template +template using void_t = void; } // namespace types } // namespace common diff --git a/common/autoware_auto_common/include/common/visibility_control.hpp b/common/autoware_auto_common/include/common/visibility_control.hpp index d2d3d89148d03..0a988d6407dfa 100644 --- a/common/autoware_auto_common/include/common/visibility_control.hpp +++ b/common/autoware_auto_common/include/common/visibility_control.hpp @@ -18,21 +18,21 @@ #define COMMON__VISIBILITY_CONTROL_HPP_ #if defined(_MSC_VER) && defined(_WIN64) - #if defined(COMMON_BUILDING_DLL) || defined(COMMON_EXPORTS) - #define COMMON_PUBLIC __declspec(dllexport) - #define COMMON_LOCAL - #else // defined(COMMON_BUILDING_DLL) || defined(COMMON_EXPORTS) - #define COMMON_PUBLIC __declspec(dllimport) - #define COMMON_LOCAL - #endif // defined(COMMON_BUILDING_DLL) || defined(COMMON_EXPORTS) +#if defined(COMMON_BUILDING_DLL) || defined(COMMON_EXPORTS) +#define COMMON_PUBLIC __declspec(dllexport) +#define COMMON_LOCAL +#else // defined(COMMON_BUILDING_DLL) || defined(COMMON_EXPORTS) +#define COMMON_PUBLIC __declspec(dllimport) +#define COMMON_LOCAL +#endif // defined(COMMON_BUILDING_DLL) || defined(COMMON_EXPORTS) #elif defined(__GNUC__) && defined(__linux__) - #define COMMON_PUBLIC __attribute__((visibility("default"))) - #define COMMON_LOCAL __attribute__((visibility("hidden"))) +#define COMMON_PUBLIC __attribute__((visibility("default"))) +#define COMMON_LOCAL __attribute__((visibility("hidden"))) #elif defined(__GNUC__) && defined(__APPLE__) - #define COMMON_PUBLIC __attribute__((visibility("default"))) - #define COMMON_LOCAL __attribute__((visibility("hidden"))) +#define COMMON_PUBLIC __attribute__((visibility("default"))) +#define COMMON_LOCAL __attribute__((visibility("hidden"))) #else // !(defined(__GNUC__) && defined(__APPLE__)) - #error "Unsupported Build Configuration" +#error "Unsupported Build Configuration" #endif // _MSC_VER #endif // COMMON__VISIBILITY_CONTROL_HPP_ diff --git a/common/autoware_auto_common/include/helper_functions/angle_utils.hpp b/common/autoware_auto_common/include/helper_functions/angle_utils.hpp index 39ee0bf657748..31a33ef2dab47 100644 --- a/common/autoware_auto_common/include/helper_functions/angle_utils.hpp +++ b/common/autoware_auto_common/include/helper_functions/angle_utils.hpp @@ -46,12 +46,16 @@ constexpr auto kDoublePi = 2.0 * M_PI; /// /// @return Angle wrapped to the chosen range. /// -template +template constexpr T wrap_angle(T angle) noexcept { auto help_angle = angle + T(M_PI); - while (help_angle < T{}) {help_angle += T(detail::kDoublePi);} - while (help_angle >= T(detail::kDoublePi)) {help_angle -= T(detail::kDoublePi);} + while (help_angle < T{}) { + help_angle += T(detail::kDoublePi); + } + while (help_angle >= T(detail::kDoublePi)) { + help_angle -= T(detail::kDoublePi); + } return help_angle - T(M_PI); } diff --git a/common/autoware_auto_common/include/helper_functions/bool_comparisons.hpp b/common/autoware_auto_common/include/helper_functions/bool_comparisons.hpp index dda752bf2f2b5..c6bf09365af4f 100644 --- a/common/autoware_auto_common/include/helper_functions/bool_comparisons.hpp +++ b/common/autoware_auto_common/include/helper_functions/bool_comparisons.hpp @@ -36,7 +36,7 @@ namespace comparisons * @brief Convenience method for performing logical exclusive or ops. * @return True iff exactly one of 'a' and 'b' is true. */ -template +template types::bool8_t exclusive_or(const T & a, const T & b) { return static_cast(a) != static_cast(b); diff --git a/common/autoware_auto_common/include/helper_functions/byte_reader.hpp b/common/autoware_auto_common/include/helper_functions/byte_reader.hpp index aa05e5c6a7be4..bef27ea310e26 100644 --- a/common/autoware_auto_common/include/helper_functions/byte_reader.hpp +++ b/common/autoware_auto_common/include/helper_functions/byte_reader.hpp @@ -40,14 +40,13 @@ class ByteReader /// \brief Default constructor, byte reader class /// \param[in] byte_vector A vector to read bytes from explicit ByteReader(const std::vector & byte_vector) - : byte_vector_(byte_vector), - index_(0U) + : byte_vector_(byte_vector), index_(0U) { } // brief Read bytes and store it in the argument passed in big-endian order /// \param[inout] value Read and store the bytes from the vector matching the size of the argument - template + template void read(T & value) { constexpr std::size_t kTypeSize = sizeof(T); @@ -65,10 +64,7 @@ class ByteReader index_ += kTypeSize; } - void skip(std::size_t count) - { - index_ += count; - } + void skip(std::size_t count) { index_ += count; } }; } // namespace helper_functions } // namespace common diff --git a/common/autoware_auto_common/include/helper_functions/crtp.hpp b/common/autoware_auto_common/include/helper_functions/crtp.hpp index 7cba8d0350829..707d522251dc2 100644 --- a/common/autoware_auto_common/include/helper_functions/crtp.hpp +++ b/common/autoware_auto_common/include/helper_functions/crtp.hpp @@ -25,7 +25,7 @@ namespace common { namespace helper_functions { -template +template class crtp { protected: @@ -33,7 +33,7 @@ class crtp { // This is the CRTP pattern for static polymorphism: this is related, static_cast is the only // way to do this - //lint -e{9005, 9176, 1939} NOLINT + // lint -e{9005, 9176, 1939} NOLINT return *static_cast(this); } @@ -41,7 +41,7 @@ class crtp { // This is the CRTP pattern for static polymorphism: this is related, static_cast is the only // way to do this - //lint -e{9005, 9176, 1939} NOLINT + // lint -e{9005, 9176, 1939} NOLINT return *static_cast(this); } }; diff --git a/common/autoware_auto_common/include/helper_functions/float_comparisons.hpp b/common/autoware_auto_common/include/helper_functions/float_comparisons.hpp index fcf1b90c59cf2..de1f459f21d0a 100644 --- a/common/autoware_auto_common/include/helper_functions/float_comparisons.hpp +++ b/common/autoware_auto_common/include/helper_functions/float_comparisons.hpp @@ -39,12 +39,11 @@ namespace comparisons * @pre eps >= 0 * @return True iff 'a' and 'b' are within 'eps' of each other. */ -template +template bool abs_eq(const T & a, const T & b, const T & eps) { static_assert( - std::is_floating_point::value, - "Float comparisons only support floating point types."); + std::is_floating_point::value, "Float comparisons only support floating point types."); return std::abs(a - b) <= eps; } @@ -54,7 +53,7 @@ bool abs_eq(const T & a, const T & b, const T & eps) * @pre eps >= 0 * @return True iff 'a' is less than 'b' minus 'eps'. */ -template +template bool abs_lt(const T & a, const T & b, const T & eps) { return !abs_eq(a, b, eps) && (a < b); @@ -65,7 +64,7 @@ bool abs_lt(const T & a, const T & b, const T & eps) * @pre eps >= 0 * @return True iff 'a' is less than or equal to 'b' plus 'eps'. */ -template +template bool abs_lte(const T & a, const T & b, const T & eps) { return abs_eq(a, b, eps) || (a < b); @@ -76,7 +75,7 @@ bool abs_lte(const T & a, const T & b, const T & eps) * @pre eps >= 0 * @return True iff 'a' is greater than or equal to 'b' minus 'eps'. */ -template +template bool abs_gte(const T & a, const T & b, const T & eps) { return !abs_lt(a, b, eps); @@ -87,7 +86,7 @@ bool abs_gte(const T & a, const T & b, const T & eps) * @pre eps >= 0 * @return True iff 'a' is greater than 'b' minus 'eps'. */ -template +template bool abs_gt(const T & a, const T & b, const T & eps) { return !abs_lte(a, b, eps); @@ -98,7 +97,7 @@ bool abs_gt(const T & a, const T & b, const T & eps) * @pre eps >= 0 * @return True iff 'a' is within 'eps' of zero. */ -template +template bool abs_eq_zero(const T & a, const T & eps) { return abs_eq(a, static_cast(0), eps); @@ -110,12 +109,11 @@ bool abs_eq_zero(const T & a, const T & eps) * @pre rel_eps >= 0 * @return True iff 'a' and 'b' are within relative 'rel_eps' of each other. */ -template +template bool rel_eq(const T & a, const T & b, const T & rel_eps) { static_assert( - std::is_floating_point::value, - "Float comparisons only support floating point types."); + std::is_floating_point::value, "Float comparisons only support floating point types."); const auto delta = std::abs(a - b); const auto larger = std::max(std::abs(a), std::abs(b)); @@ -135,7 +133,7 @@ bool rel_eq(const T & a, const T & b, const T & rel_eps) * @pre rel_eps >= 0 * @return True iff 'a' and 'b' are within 'eps' or 'rel_eps' of each other */ -template +template bool approx_eq(const T & a, const T & b, const T & abs_eps, const T & rel_eps) { const auto are_absolute_eq = abs_eq(a, b, abs_eps); diff --git a/common/autoware_auto_common/include/helper_functions/mahalanobis_distance.hpp b/common/autoware_auto_common/include/helper_functions/mahalanobis_distance.hpp index fde5efca90a23..dcfa65880fdd7 100644 --- a/common/autoware_auto_common/include/helper_functions/mahalanobis_distance.hpp +++ b/common/autoware_auto_common/include/helper_functions/mahalanobis_distance.hpp @@ -32,10 +32,9 @@ namespace helper_functions /// \param mean Single column matrix containing mean of samples received so far /// \param covariance_factor Covariance matrix /// \return Square of mahalanobis distance -template +template types::float32_t calculate_squared_mahalanobis_distance( - const Eigen::Matrix & sample, - const Eigen::Matrix & mean, + const Eigen::Matrix & sample, const Eigen::Matrix & mean, const Eigen::Matrix & covariance_factor) { using Vector = Eigen::Matrix; @@ -59,12 +58,10 @@ types::float32_t calculate_squared_mahalanobis_distance( /// \param mean Single column matrix containing mean of samples received so far /// \param covariance_factor Covariance matrix /// \return Mahalanobis distance -template +template types::float32_t calculate_mahalanobis_distance( - const Eigen::Matrix & sample, - const Eigen::Matrix & mean, - const Eigen::Matrix & covariance_factor -) + const Eigen::Matrix & sample, const Eigen::Matrix & mean, + const Eigen::Matrix & covariance_factor) { return sqrtf(calculate_squared_mahalanobis_distance(sample, mean, covariance_factor)); } diff --git a/common/autoware_auto_common/include/helper_functions/message_adapters.hpp b/common/autoware_auto_common/include/helper_functions/message_adapters.hpp index 90156b152fdd1..fc813f7d5107b 100644 --- a/common/autoware_auto_common/include/helper_functions/message_adapters.hpp +++ b/common/autoware_auto_common/include/helper_functions/message_adapters.hpp @@ -20,6 +20,7 @@ #define HELPER_FUNCTIONS__MESSAGE_ADAPTERS_HPP_ #include + #include namespace autoware @@ -35,11 +36,15 @@ using TimeStamp = builtin_interfaces::msg::Time; /// \brief Helper class to check existance of header file in compile time: /// https://stackoverflow.com/a/16000226/2325407 -template -struct HasHeader : std::false_type {}; +template +struct HasHeader : std::false_type +{ +}; -template -struct HasHeader: std::true_type {}; +template +struct HasHeader : std::true_type +{ +}; /////////// Template declarations @@ -48,7 +53,7 @@ struct HasHeader: std::true_type {}; /// \tparam T Message type. /// \param msg Message. /// \return Frame id of the message. -template +template const std::string & get_frame_id(const T & msg) noexcept; /// Get a reference to the frame id from message. nullptr_t is used to prevent @@ -57,7 +62,7 @@ const std::string & get_frame_id(const T & msg) noexcept; /// \tparam T Message type. /// \param msg Message. /// \return Frame id of the message. -template +template std::string & get_frame_id(T & msg) noexcept; /// Get stamp from message. nullptr_t is used to prevent template ambiguity on @@ -65,7 +70,7 @@ std::string & get_frame_id(T & msg) noexcept; /// \tparam T Message type. /// \param msg Message. /// \return Frame id of the message. -template +template const TimeStamp & get_stamp(const T & msg) noexcept; /// Get a reference to the stamp from message. nullptr_t is used to prevent @@ -74,30 +79,29 @@ const TimeStamp & get_stamp(const T & msg) noexcept; /// \tparam T Message type. /// \param msg Message. /// \return Frame id of the message. -template +template TimeStamp & get_stamp(T & msg) noexcept; - /////////////// Default specializations for message types that contain a header. -template::value, nullptr_t>::type = nullptr> +template ::value, nullptr_t>::type = nullptr> const std::string & get_frame_id(const T & msg) noexcept { return msg.header.frame_id; } -template::value, nullptr_t>::type = nullptr> +template ::value, nullptr_t>::type = nullptr> std::string & get_frame_id(T & msg) noexcept { return msg.header.frame_id; } -template::value, nullptr_t>::type = nullptr> +template ::value, nullptr_t>::type = nullptr> TimeStamp & get_stamp(T & msg) noexcept { return msg.header.stamp; } -template::value, nullptr_t>::type = nullptr> +template ::value, nullptr_t>::type = nullptr> TimeStamp get_stamp(const T & msg) noexcept { return msg.header.stamp; diff --git a/common/autoware_auto_common/include/helper_functions/template_utils.hpp b/common/autoware_auto_common/include/helper_functions/template_utils.hpp index b52be9eae0c59..25a1da4134660 100644 --- a/common/autoware_auto_common/include/helper_functions/template_utils.hpp +++ b/common/autoware_auto_common/include/helper_functions/template_utils.hpp @@ -18,6 +18,7 @@ #define HELPER_FUNCTIONS__TEMPLATE_UTILS_HPP_ #include + #include namespace autoware @@ -30,36 +31,43 @@ namespace helper_functions /// `std::false_type` otherwise. /// \tparam ExpressionTemplate Expression to be checked in compile time /// \tparam T Template parameter to instantiate the expression. -template class ExpressionTemplate, typename T, typename = void> -struct expression_valid : std::false_type {}; +template