Skip to content

Commit

Permalink
ci(pre-commit): autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Apr 14, 2022
1 parent 4dcabb8 commit 02370b0
Show file tree
Hide file tree
Showing 224 changed files with 3,672 additions and 4,520 deletions.
14 changes: 6 additions & 8 deletions common/autoware_auto_cmake/design/autoware_auto_cmake-design.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
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

Provide common CMake variables and functions to Autoware packages.
Expand All @@ -13,8 +11,8 @@ 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

Expand All @@ -24,6 +22,6 @@ Add `autoware_auto_cmake` as a "build_depend" in the dependent packages.

### 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` |
4 changes: 2 additions & 2 deletions common/autoware_auto_cmake/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

<build_depend>ros_environment</build_depend>

<buildtool_export_depend>ament_cmake_core</buildtool_export_depend>
<buildtool_export_depend>ament_cmake_lint_cmake</buildtool_export_depend>
<buildtool_export_depend>ament_cmake_copyright</buildtool_export_depend>
<buildtool_export_depend>ament_cmake_core</buildtool_export_depend>
<buildtool_export_depend>ament_cmake_cppcheck</buildtool_export_depend>
<buildtool_export_depend>ament_cmake_cpplint</buildtool_export_depend>
<buildtool_export_depend>ament_cmake_lint_cmake</buildtool_export_depend>
<buildtool_export_depend>ament_cmake_uncrustify</buildtool_export_depend>

<test_depend>ament_cmake_lint_cmake</test_depend>
Expand Down
11 changes: 5 additions & 6 deletions common/autoware_auto_common/design/comparisons.md
Original file line number Diff line number Diff line change
@@ -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_`.
Expand All @@ -15,10 +14,10 @@ The `exclusive_or` function will test whether two values cast to different boole

# 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

Expand Down
98 changes: 57 additions & 41 deletions common/autoware_auto_common/include/common/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,32 @@ namespace type_traits
///
/// @return A boolean that should be false for any type passed into this function.
///
template<typename T>
template <typename T>
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<class QueryT, class TupleT>
template <class QueryT, class TupleT>
struct COMMON_PUBLIC index
{
static_assert(!std::is_same<TupleT, std::tuple<>>::value, "Could not find QueryT in given tuple");
};

/// Specialization for a tuple that starts with the HeadT type. End of recursion.
template<class HeadT, class ... Tail>
template <class HeadT, class... Tail>
struct COMMON_PUBLIC index<HeadT, std::tuple<HeadT, Tail...>>
: std::integral_constant<std::int32_t, 0> {};
: std::integral_constant<std::int32_t, 0>
{
};

/// Specialization for a tuple with a type different to QueryT that calls the recursive step.
template<class QueryT, class HeadT, class ... Tail>
template <class QueryT, class HeadT, class... Tail>
struct COMMON_PUBLIC index<QueryT, std::tuple<HeadT, Tail...>>
: std::integral_constant<std::int32_t, 1 + index<QueryT, std::tuple<Tail...>>::value> {};
: std::integral_constant<std::int32_t, 1 + index<QueryT, std::tuple<Tail...>>::value>
{
};

///
/// @brief Visit every element in a tuple.
Expand All @@ -75,13 +79,17 @@ struct COMMON_PUBLIC index<QueryT, std::tuple<HeadT, Tail...>>
///
/// @return Does not return anything. Capture variables in a lambda to return any values.
///
template<std::size_t I = 0UL, typename Callable, typename ... TypesT>
COMMON_PUBLIC inline constexpr typename std::enable_if_t<I == sizeof...(TypesT)>
visit(std::tuple<TypesT...> &, Callable) noexcept {}
template <std::size_t I = 0UL, typename Callable, typename... TypesT>
COMMON_PUBLIC inline constexpr typename std::enable_if_t<I == sizeof...(TypesT)> visit(
std::tuple<TypesT...> &, Callable) noexcept
{
}
/// @brief Same as the previous specialization but for const tuple.
template<std::size_t I = 0UL, typename Callable, typename ... TypesT>
COMMON_PUBLIC inline constexpr typename std::enable_if_t<I == sizeof...(TypesT)>
visit(const std::tuple<TypesT...> &, Callable) noexcept {}
template <std::size_t I = 0UL, typename Callable, typename... TypesT>
COMMON_PUBLIC inline constexpr typename std::enable_if_t<I == sizeof...(TypesT)> visit(
const std::tuple<TypesT...> &, Callable) noexcept
{
}

///
/// @brief Visit every element in a tuple.
Expand All @@ -98,32 +106,37 @@ visit(const std::tuple<TypesT...> &, Callable) noexcept {}
///
/// @return Does not return anything. Capture variables in a lambda to return any values.
///
template<std::size_t I = 0UL, typename Callable, typename ... TypesT>
COMMON_PUBLIC inline constexpr typename std::enable_if_t<I != sizeof...(TypesT)>
visit(std::tuple<TypesT...> & tuple, Callable callable) noexcept
template <std::size_t I = 0UL, typename Callable, typename... TypesT>
COMMON_PUBLIC inline constexpr typename std::enable_if_t<I != sizeof...(TypesT)> visit(
std::tuple<TypesT...> & tuple, Callable callable) noexcept
{
callable(std::get<I>(tuple));
visit<I + 1UL, Callable, TypesT...>(tuple, callable);
}
/// @brief Same as the previous specialization but for const tuple.
template<std::size_t I = 0UL, typename Callable, typename ... TypesT>
COMMON_PUBLIC inline constexpr typename std::enable_if_t<I != sizeof...(TypesT)>
visit(const std::tuple<TypesT...> & tuple, Callable callable) noexcept
template <std::size_t I = 0UL, typename Callable, typename... TypesT>
COMMON_PUBLIC inline constexpr typename std::enable_if_t<I != sizeof...(TypesT)> visit(
const std::tuple<TypesT...> & tuple, Callable callable) noexcept
{
callable(std::get<I>(tuple));
visit<I + 1UL, Callable, TypesT...>(tuple, callable);
}

/// @brief A class to compute a conjunction over given traits.
template<class ...>
struct COMMON_PUBLIC conjunction : std::true_type {};
template <class...>
struct COMMON_PUBLIC conjunction : std::true_type
{
};
/// @brief A conjunction of another type shall derive from that type.
template<class TraitT>
struct COMMON_PUBLIC conjunction<TraitT>: TraitT {};
template<class TraitT, class ... TraitsTs>
template <class TraitT>
struct COMMON_PUBLIC conjunction<TraitT> : TraitT
{
};
template <class TraitT, class... TraitsTs>
struct COMMON_PUBLIC conjunction<TraitT, TraitsTs...>
: std::conditional_t<static_cast<bool>(TraitT::value), conjunction<TraitsTs...>, TraitT> {};

: std::conditional_t<static_cast<bool>(TraitT::value), conjunction<TraitsTs...>, TraitT>
{
};

///
/// @brief A trait to check if a tuple has a type.
Expand All @@ -133,7 +146,7 @@ struct COMMON_PUBLIC conjunction<TraitT, TraitsTs...>
/// @tparam QueryT A query type.
/// @tparam TupleT A tuple to search the type in.
///
template<typename QueryT, typename TupleT>
template <typename QueryT, typename TupleT>
struct has_type;

///
Expand All @@ -142,8 +155,10 @@ struct has_type;
///
/// @tparam QueryT Any type.
///
template<typename QueryT>
struct has_type<QueryT, std::tuple<>>: std::false_type {};
template <typename QueryT>
struct has_type<QueryT, std::tuple<>> : std::false_type
{
};

///
/// @brief Recursive override of the main trait.
Expand All @@ -152,8 +167,10 @@ struct has_type<QueryT, std::tuple<>>: std::false_type {};
/// @tparam HeadT Head type in the tuple.
/// @tparam TailTs Rest of the tuple types.
///
template<typename QueryT, typename HeadT, typename ... TailTs>
struct has_type<QueryT, std::tuple<HeadT, TailTs...>>: has_type<QueryT, std::tuple<TailTs...>> {};
template <typename QueryT, typename HeadT, typename... TailTs>
struct has_type<QueryT, std::tuple<HeadT, TailTs...>> : has_type<QueryT, std::tuple<TailTs...>>
{
};

///
/// @brief End of recursion for the main `has_type` trait. Becomes a `true_type` when the first
Expand All @@ -162,9 +179,10 @@ struct has_type<QueryT, std::tuple<HeadT, TailTs...>>: has_type<QueryT, std::tup
/// @tparam QueryT Query type.
/// @tparam TailTs Other types in the tuple.
///
template<typename QueryT, typename ... TailTs>
struct has_type<QueryT, std::tuple<QueryT, TailTs...>>: std::true_type {};

template <typename QueryT, typename... TailTs>
struct has_type<QueryT, std::tuple<QueryT, TailTs...>> : std::true_type
{
};

///
/// @brief A trait used to intersect types stored in tuples at compile time. The resulting
Expand All @@ -176,7 +194,7 @@ struct has_type<QueryT, std::tuple<QueryT, TailTs...>>: std::true_type {};
/// @tparam TupleT1 Tuple 1
/// @tparam TupleT2 Tuple 2
///
template<typename TupleT1, typename TupleT2>
template <typename TupleT1, typename TupleT2>
struct intersect
{
///
Expand All @@ -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<std::size_t... Indices>
template <std::size_t... Indices>
static constexpr auto make_intersection(std::index_sequence<Indices...>)
{
return std::tuple_cat(
std::conditional_t<
has_type<std::tuple_element_t<Indices, TupleT1>, TupleT2>::value,
std::tuple<std::tuple_element_t<Indices, TupleT1>>,
std::tuple<>>{} ...);
return std::tuple_cat(std::conditional_t<
has_type<std::tuple_element_t<Indices, TupleT1>, TupleT2>::value,
std::tuple<std::tuple_element_t<Indices, TupleT1>>, std::tuple<>>{}...);
}
/// The resulting tuple type.
using type =
decltype(make_intersection(std::make_index_sequence<std::tuple_size<TupleT1>::value> {}));
decltype(make_intersection(std::make_index_sequence<std::tuple_size<TupleT1>::value>{}));
};

} // namespace type_traits
Expand Down
51 changes: 20 additions & 31 deletions common/autoware_auto_common/include/common/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
#ifndef COMMON__TYPES_HPP_
#define COMMON__TYPES_HPP_

#include "common/visibility_control.hpp"
#include "helper_functions/float_comparisons.hpp"

#include <cstdint>
#include <vector>
#include <limits>

#include "helper_functions/float_comparisons.hpp"
#include "common/visibility_control.hpp"
#include <vector>

namespace autoware
{
Expand Down Expand Up @@ -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<float32_t>::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);
}
};
Expand All @@ -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<float32_t>::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);
}
};

Expand All @@ -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<float32_t>::epsilon()) &&
return helper_functions::comparisons::rel_eq(
p1.x, p2.x, std::numeric_limits<float32_t>::epsilon()) &&

helper_functions::comparisons::rel_eq(
p1.y, p2.y, std::numeric_limits<float32_t>::epsilon()) &&
helper_functions::comparisons::rel_eq(
p1.y, p2.y, std::numeric_limits<float32_t>::epsilon()) &&

helper_functions::comparisons::rel_eq(
p1.z, p2.z, std::numeric_limits<float32_t>::epsilon()) &&
helper_functions::comparisons::rel_eq(
p1.z, p2.z, std::numeric_limits<float32_t>::epsilon()) &&

helper_functions::comparisons::rel_eq(
p1.intensity, p2.intensity, std::numeric_limits<float32_t>::epsilon());
helper_functions::comparisons::rel_eq(
p1.intensity, p2.intensity, std::numeric_limits<float32_t>::epsilon());
}
};

Expand All @@ -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<typename ... Ts>
template <typename... Ts>
using void_t = void;
} // namespace types
} // namespace common
Expand Down
24 changes: 12 additions & 12 deletions common/autoware_auto_common/include/common/visibility_control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Loading

0 comments on commit 02370b0

Please sign in to comment.