Skip to content

Commit

Permalink
ci(pre-commit): clear the exclude option (tier4#426)
Browse files Browse the repository at this point in the history
* ci(pre-commit): remove unnecessary excludes

Signed-off-by: Kenji Miyake <[email protected]>

* ci(pre-commit): autofix

* ci(pre-commit): autofix

* address pre-commit for Markdown files

Signed-off-by: Kenji Miyake <[email protected]>

* fix Python imports

Signed-off-by: Kenji Miyake <[email protected]>

* address cpplint errors

Signed-off-by: Kenji Miyake <[email protected]>

* fix broken package.xml

Signed-off-by: Kenji Miyake <[email protected]>

* rename ROS parameter files

Signed-off-by: Kenji Miyake <[email protected]>

* fix build

Signed-off-by: Kenji Miyake <[email protected]>

* use autoware_lint_common

Signed-off-by: Kenji Miyake <[email protected]>

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and boyali committed Oct 19, 2022
1 parent 63bd3db commit a5a2e8c
Show file tree
Hide file tree
Showing 232 changed files with 3,824 additions and 4,685 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 10 additions & 12 deletions common/autoware_auto_cmake/design/autoware_auto_cmake-design.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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` |
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
5 changes: 0 additions & 5 deletions common/autoware_auto_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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}
Expand Down
17 changes: 8 additions & 9 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 @@ -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"
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
Loading

0 comments on commit a5a2e8c

Please sign in to comment.