diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..b41fae9 --- /dev/null +++ b/.clang-format @@ -0,0 +1,47 @@ +# Modified from https://github.com/ament/ament_lint/blob/master/ament_clang_format/ament_clang_format/configuration/.clang-format +Language: Cpp +BasedOnStyle: Google + +AccessModifierOffset: -2 +AlignAfterOpenBracket: AlwaysBreak +AllowShortFunctionsOnASingleLine: InlineOnly +BraceWrapping: + AfterClass: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true +BreakBeforeBraces: Custom +ColumnLimit: 100 +ConstructorInitializerIndentWidth: 0 +ContinuationIndentWidth: 2 +DerivePointerAlignment: false +PointerAlignment: Middle +ReflowComments: true +IncludeCategories: + # C++ system headers + - Regex: <[a-z_]*> + Priority: 6 + CaseSensitive: true + # C system headers + - Regex: <.*\.h> + Priority: 5 + CaseSensitive: true + # Boost headers + - Regex: boost/.* + Priority: 4 + CaseSensitive: true + # Message headers + - Regex: .*_msgs/.* + Priority: 3 + CaseSensitive: true + - Regex: .*_srvs/.* + Priority: 3 + CaseSensitive: true + # Other Package headers + - Regex: <.*> + Priority: 2 + CaseSensitive: true + # Local package headers + - Regex: '".*"' + Priority: 1 + CaseSensitive: true diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..c4533f5 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,461 @@ +Checks: " + -*, + boost-use-to-string, + bugprone-argument-comment, + bugprone-assert-side-effect, + bugprone-bad-signal-to-kill-thread, + bugprone-bool-pointer-implicit-conversion, + bugprone-branch-clone, + bugprone-copy-constructor-init, + bugprone-dangling-handle, + bugprone-dynamic-static-initializers, + bugprone-exception-escape, + bugprone-fold-init-type, + bugprone-forward-declaration-namespace, + bugprone-forwarding-reference-overload, + bugprone-inaccurate-erase, + bugprone-incorrect-roundings, + bugprone-integer-division, + bugprone-lambda-function-name, + bugprone-macro-parentheses, + bugprone-macro-repeated-side-effects, + bugprone-misplaced-operator-in-strlen-in-alloc, + bugprone-misplaced-widening-cast, + bugprone-move-forwarding-reference, + bugprone-multiple-statement-macro, + bugprone-not-null-terminated-result, + bugprone-parent-virtual-call, + bugprone-posix-return, + bugprone-signed-char-misuse, + bugprone-sizeof-container, + bugprone-sizeof-expression, + bugprone-string-constructor, + bugprone-string-integer-assignment, + bugprone-string-literal-with-embedded-nul, + bugprone-suspicious-enum-usage, + bugprone-suspicious-memset-usage, + bugprone-suspicious-missing-comma, + bugprone-suspicious-semicolon, + bugprone-suspicious-string-compare, + bugprone-swapped-arguments, + bugprone-terminating-continue, + bugprone-throw-keyword-missing, + bugprone-too-small-loop-variable, + bugprone-unchecked-optional-access, + bugprone-undefined-memory-manipulation, + bugprone-undelegated-constructor, + bugprone-unhandled-self-assignment, + bugprone-unused-raii, + bugprone-unused-return-value, + bugprone-use-after-move, + bugprone-virtual-near-miss, + cppcoreguidelines-avoid-goto, + cppcoreguidelines-init-variables, + cppcoreguidelines-interfaces-global-init, + cppcoreguidelines-macro-usage, + cppcoreguidelines-narrowing-conversions, + cppcoreguidelines-no-malloc, + cppcoreguidelines-pro-bounds-pointer-arithmetic, + cppcoreguidelines-pro-type-const-cast, + cppcoreguidelines-pro-type-cstyle-cast, + cppcoreguidelines-pro-type-member-init, + cppcoreguidelines-pro-type-reinterpret-cast, + cppcoreguidelines-pro-type-static-cast-downcast, + cppcoreguidelines-pro-type-union-access, + cppcoreguidelines-slicing, + cppcoreguidelines-special-member-functions, + google-build-explicit-make-pair, + google-build-namespaces, + google-build-using-namespace, + google-explicit-constructor, + google-global-names-in-headers, + google-upgrade-googletest-case, + hicpp-exception-baseclass, + hicpp-multiway-paths-covered, + hicpp-no-assembler, + hicpp-signed-bitwise, + llvm-namespace-comment, + misc-definitions-in-headers, + misc-misplaced-const, + misc-new-delete-overloads, + misc-non-copyable-objects, + misc-redundant-expression, + misc-static-assert, + misc-throw-by-value-catch-by-reference, + misc-unconventional-assign-operator, + misc-uniqueptr-reset-release, + misc-unused-alias-decls, + misc-unused-parameters, + misc-unused-using-decls, + modernize-concat-nested-namespaces, + modernize-deprecated-headers, + modernize-deprecated-ios-base-aliases, + modernize-loop-convert, + modernize-make-shared, + modernize-make-unique, + modernize-pass-by-value, + modernize-raw-string-literal, + modernize-redundant-void-arg, + modernize-replace-auto-ptr, + modernize-replace-disallow-copy-and-assign-macro, + modernize-replace-random-shuffle, + modernize-return-braced-init-list, + modernize-shrink-to-fit, + modernize-unary-static-assert, + modernize-use-auto, + modernize-use-bool-literals, + modernize-use-default-member-init, + modernize-use-emplace, + modernize-use-equals-default, + modernize-use-equals-delete, + modernize-use-nodiscard, + modernize-use-noexcept, + modernize-use-nullptr, + modernize-use-override, + modernize-use-transparent-functors, + modernize-use-uncaught-exceptions, + modernize-use-using, + openmp-use-default-none, + performance-faster-string-find, + performance-for-range-copy, + performance-implicit-conversion-in-loop, + performance-inefficient-algorithm, + performance-inefficient-string-concatenation, + performance-inefficient-vector-operation, + performance-move-const-arg, + performance-move-constructor-init, + performance-no-automatic-move, + performance-no-int-to-ptr, + performance-noexcept-move-constructor, + performance-trivially-destructible, + performance-type-promotion-in-math-fn, + performance-unnecessary-copy-initialization, + performance-unnecessary-value-param, + portability-simd-intrinsics, + readability-const-return-type, + readability-container-size-empty, + readability-convert-member-functions-to-static, + readability-delete-null-pointer, + readability-else-after-return, + readability-function-cognitive-complexity, + readability-identifier-naming, + readability-inconsistent-declaration-parameter-name, + readability-isolate-declaration, + readability-make-member-function-const, + readability-misleading-indentation, + readability-misplaced-array-index, + readability-non-const-parameter, + readability-redundant-access-specifiers, + readability-redundant-control-flow, + readability-redundant-declaration, + readability-redundant-function-ptr-dereference, + readability-redundant-member-init, + readability-redundant-smartptr-get, + readability-redundant-string-cstr, + readability-redundant-string-init, + readability-simplify-boolean-expr, + readability-simplify-subscript-expr, + readability-static-accessed-through-instance, + readability-static-definition-in-anonymous-namespace, + readability-string-compare, + readability-uniqueptr-delete-release" + +WarningsAsErrors: " + boost-use-to-string, + bugprone-dangling-handle, + bugprone-fold-init-type, + bugprone-inaccurate-erase, + bugprone-incorrect-roundings, + bugprone-misplaced-widening-cast, + bugprone-sizeof-container, + bugprone-sizeof-expression, + bugprone-string-constructor, + bugprone-suspicious-enum-usage, + bugprone-suspicious-memset-usage, + bugprone-suspicious-missing-comma, + bugprone-suspicious-semicolon, + bugprone-swapped-arguments, + bugprone-unused-raii, + bugprone-use-after-move, + llvm-namespace-comment, + misc-non-copyable-objects, + misc-redundant-expression, + misc-throw-by-value-catch-by-reference, + misc-unused-alias-decls, + misc-unused-parameters, + misc-unused-using-decls, + modernize-deprecated-headers, + modernize-redundant-void-arg, + modernize-use-bool-literals, + modernize-use-emplace, + modernize-use-equals-default, + modernize-use-equals-delete, + modernize-use-nullptr, + modernize-use-override, + modernize-use-using, + performance-faster-string-find, + performance-inefficient-algorithm, + readability-make-member-function-const, + readability-misleading-indentation, + readability-misplaced-array-index, + readability-string-compare" + +HeaderFilterRegex: ^(?!\/usr)(?!\/opt) + +AnalyzeTemporaryDtors: false + +FormatStyle: none + +CheckOptions: + - key: bugprone-argument-comment.CommentBoolLiterals + value: "0" + - key: bugprone-argument-comment.CommentCharacterLiterals + value: "0" + - key: bugprone-argument-comment.CommentFloatLiterals + value: "0" + - key: bugprone-argument-comment.CommentIntegerLiterals + value: "0" + - key: bugprone-argument-comment.CommentNullPtrs + value: "0" + - key: bugprone-argument-comment.CommentStringLiterals + value: "0" + - key: bugprone-argument-comment.CommentUserDefinedLiterals + value: "0" + - key: bugprone-argument-comment.IgnoreSingleArgument + value: "0" + - key: bugprone-argument-comment.StrictMode + value: "0" + - key: bugprone-assert-side-effect.AssertMacros + value: assert + - key: bugprone-assert-side-effect.CheckFunctionCalls + value: "0" + - key: bugprone-dangling-handle.HandleClasses + value: std::basic_string_view;std::experimental::basic_string_view + - key: bugprone-dynamic-static-initializers.HeaderFileExtensions + value: ",h,hh,hpp,hxx" + - key: bugprone-exception-escape.FunctionsThatShouldNotThrow + value: "" + - key: bugprone-exception-escape.IgnoredExceptions + value: "" + - key: bugprone-misplaced-widening-cast.CheckImplicitCasts + value: "0" + - key: bugprone-not-null-terminated-result.WantToUseSafeFunctions + value: "1" + - key: bugprone-signed-char-misuse.CharTypdefsToIgnore + value: "" + - key: bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant + value: "1" + - key: bugprone-sizeof-expression.WarnOnSizeOfConstant + value: "1" + - key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression + value: "0" + - key: bugprone-sizeof-expression.WarnOnSizeOfThis + value: "1" + - key: bugprone-string-constructor.LargeLengthThreshold + value: "8388608" + - key: bugprone-string-constructor.WarnOnLargeLength + value: "1" + - key: bugprone-suspicious-enum-usage.StrictMode + value: "0" + - key: bugprone-suspicious-missing-comma.MaxConcatenatedTokens + value: "5" + - key: bugprone-suspicious-missing-comma.RatioThreshold + value: "0.200000" + - key: bugprone-suspicious-missing-comma.SizeThreshold + value: "5" + - key: bugprone-suspicious-string-compare.StringCompareLikeFunctions + value: "" + - key: bugprone-suspicious-string-compare.WarnOnImplicitComparison + value: "1" + - key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison + value: "0" + - key: bugprone-too-small-loop-variable.MagnitudeBitsUpperLimit + value: "16" + - key: bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField + value: "1" + - key: bugprone-unused-return-value.CheckedFunctions + value: ::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty + - key: cert-dcl16-c.NewSuffixes + value: L;LL;LU;LLU + - key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField + value: "0" + - key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors + value: "1" + - key: cppcoreguidelines-macro-usage.AllowedRegexp + value: ^DEBUG_* + - key: cppcoreguidelines-macro-usage.CheckCapsOnly + value: "0" + - key: cppcoreguidelines-macro-usage.IgnoreCommandLineMacros + value: "1" + - key: cppcoreguidelines-no-malloc.Allocations + value: ::malloc;::calloc + - key: cppcoreguidelines-no-malloc.Deallocations + value: ::free + - key: cppcoreguidelines-no-malloc.Reallocations + value: ::realloc + - key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic + value: "1" + - key: cppcoreguidelines-pro-type-member-init.IgnoreArrays + value: "0" + - key: cppcoreguidelines-pro-type-member-init.UseAssignment + value: "0" + - key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions + value: "0" + - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor + value: "0" + - key: google-readability-braces-around-statements.ShortStatementLines + value: "1" + - key: google-readability-function-size.StatementThreshold + value: "800" + - key: google-readability-namespace-comments.ShortNamespaceLines + value: "10" + - key: google-readability-namespace-comments.SpacesBeforeComments + value: "2" + - key: hicpp-multiway-paths-covered.WarnOnMissingElse + value: "0" + - key: hicpp-signed-bitwise.IgnorePositiveIntegerLiterals + value: "0" + - key: misc-definitions-in-headers.HeaderFileExtensions + value: ",h,hh,hpp,hxx" + - key: misc-definitions-in-headers.UseHeaderFileExtension + value: "1" + - key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries + value: "1" + - key: misc-unused-parameters.StrictMode + value: "0" + - key: modernize-loop-convert.MaxCopySize + value: "16" + - key: modernize-loop-convert.MinConfidence + value: reasonable + - key: modernize-loop-convert.NamingStyle + value: CamelCase + - key: modernize-make-shared.IgnoreMacros + value: "1" + - key: modernize-make-shared.IncludeStyle + value: google + - key: modernize-make-shared.MakeSmartPtrFunction + value: std::make_shared + - key: modernize-make-shared.MakeSmartPtrFunctionHeader + value: memory + - key: modernize-make-unique.IgnoreMacros + value: "1" + - key: modernize-make-unique.IncludeStyle + value: google + - key: modernize-make-unique.MakeSmartPtrFunction + value: std::make_unique + - key: modernize-make-unique.MakeSmartPtrFunctionHeader + value: memory + - key: modernize-pass-by-value.IncludeStyle + value: google + - key: modernize-pass-by-value.ValuesOnly + value: "0" + - key: modernize-raw-string-literal.ReplaceShorterLiterals + value: "0" + - key: modernize-replace-auto-ptr.IncludeStyle + value: google + - key: modernize-replace-random-shuffle.IncludeStyle + value: google + - key: modernize-use-auto.MinTypeNameLength + value: "5" + - key: modernize-use-auto.RemoveStars + value: "0" + - key: modernize-use-default-member-init.IgnoreMacros + value: "1" + - key: modernize-use-default-member-init.UseAssignment + value: "0" + - key: modernize-use-emplace.ContainersWithPushBack + value: ::std::vector;::std::list;::std::deque + - key: modernize-use-emplace.SmartPointers + value: ::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr + - key: modernize-use-emplace.TupleMakeFunctions + value: ::std::make_pair;::std::make_tuple + - key: modernize-use-emplace.TupleTypes + value: ::std::pair;::std::tuple + - key: modernize-use-equals-default.IgnoreMacros + value: "1" + - key: modernize-use-equals-delete.IgnoreMacros + value: "1" + - key: modernize-use-nodiscard.ReplacementString + value: "[[nodiscard]]" + - key: modernize-use-noexcept.ReplacementString + value: "" + - key: modernize-use-noexcept.UseNoexceptFalse + value: "1" + - key: modernize-use-nullptr.NullMacros + value: "NULL" + - key: modernize-use-override.AllowOverrideAndFinal + value: "0" + - key: modernize-use-override.FinalSpelling + value: final + - key: modernize-use-override.IgnoreDestructors + value: "0" + - key: modernize-use-override.OverrideSpelling + value: override + - key: modernize-use-transparent-functors.SafeMode + value: "0" + - key: modernize-use-using.IgnoreMacros + value: "1" + - key: performance-faster-string-find.StringLikeClasses + value: std::basic_string + - key: performance-for-range-copy.AllowedTypes + value: "" + - key: performance-for-range-copy.WarnOnAllAutoCopies + value: "0" + - key: performance-inefficient-string-concatenation.StrictMode + value: "0" + - key: performance-inefficient-vector-operation.EnableProto + value: "0" + - key: performance-inefficient-vector-operation.VectorLikeClasses + value: ::std::vector + - key: performance-move-const-arg.CheckTriviallyCopyableMove + value: "1" + - key: performance-move-constructor-init.IncludeStyle + value: google + - key: performance-no-automatic-move.AllowedTypes + value: "" + - key: performance-type-promotion-in-math-fn.IncludeStyle + value: google + - key: performance-unnecessary-copy-initialization.AllowedTypes + value: "" + - key: performance-unnecessary-value-param.AllowedTypes + value: .*Ptr;.*SharedFuture + - key: performance-unnecessary-value-param.IncludeStyle + value: google + - key: portability-simd-intrinsics.Std + value: "" + - key: portability-simd-intrinsics.Suggest + value: "0" + - key: readability-function-cognitive-complexity.IgnoreMacros + value: "1" + - key: readability-else-after-return.WarnOnUnfixable + value: "1" + - key: readability-identifier-naming.NamespaceCase + value: lower_case + - key: readability-identifier-naming.ClassCase + value: CamelCase + - key: readability-identifier-naming.PrivateMemberSuffix + value: _ + - key: readability-identifier-naming.StructCase + value: CamelCase + - key: readability-identifier-naming.FunctionCase + value: lower_case + - key: readability-identifier-naming.VariableCase + value: lower_case + - key: readability-identifier-naming.GlobalConstantCase + value: lower_case + - key: readability-identifier-naming.GlobalConstantPrefix + value: g_ + - key: readability-identifier-naming.ConstexprVariableCase + value: lower_case + - key: readability-inconsistent-declaration-parameter-name.IgnoreMacros + value: "1" + - key: readability-inconsistent-declaration-parameter-name.Strict + value: "0" + - key: readability-redundant-smartptr-get.IgnoreMacros + value: "1" + - key: readability-redundant-string-init.StringNames + value: ::std::basic_string + - key: readability-simplify-subscript-expr.Types + value: ::std::basic_string;::std::basic_string_view;::std::vector;::std::array + - key: readability-static-accessed-through-instance.NameSpecifierNestingThreshold + value: "3" diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..4e50b0d --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,4 @@ +### Copied from .github/CODEOWNERS-manual ### + +### Automatically generated from package.xml ### +autoware_utils/** esteve.fernandez@tier4.jp ryohsuke.mitsudome@tier4.jp yutaka.kondo@tier4.jp diff --git a/.github/CODEOWNERS-manual b/.github/CODEOWNERS-manual new file mode 100644 index 0000000..e69de29 diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml new file mode 100644 index 0000000..12a8579 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -0,0 +1,71 @@ +name: Bug +description: Report a bug +body: + - type: checkboxes + attributes: + label: Checklist + description: Confirm the following items before proceeding. If one cannot be satisfied, create a discussion thread instead. + options: + - label: I've read the [contribution guidelines](https://github.com/autowarefoundation/autoware/blob/main/CONTRIBUTING.md). + required: true + - label: I've searched other issues and no duplicate issues were found. + required: true + - label: I'm convinced that this is not my fault but a bug. + required: true + + - type: textarea + attributes: + label: Description + description: Write a brief description of the bug. + validations: + required: true + + - type: textarea + attributes: + label: Expected behavior + description: Describe the expected behavior. + validations: + required: true + + - type: textarea + attributes: + label: Actual behavior + description: Describe the actual behavior. + validations: + required: true + + - type: textarea + attributes: + label: Steps to reproduce + description: Write the steps to reproduce the bug. + placeholder: |- + 1. + 2. + 3. + validations: + required: true + + - type: textarea + attributes: + label: Versions + description: Provide the version information. You can omit this if you believe it's irrelevant. + placeholder: |- + - OS: + - ROS 2: + - Autoware: + validations: + required: false + + - type: textarea + attributes: + label: Possible causes + description: Write the possible causes if you have any ideas. + validations: + required: false + + - type: textarea + attributes: + label: Additional context + description: Add any other additional context if it exists. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..48765c2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,13 @@ +blank_issues_enabled: false +contact_links: + - name: Question + url: https://github.com/autowarefoundation/autoware/discussions/new?category=q-a + about: Ask a question + + - name: Feature request + url: https://github.com/autowarefoundation/autoware/discussions/new?category=feature-requests + about: Send a feature request + + - name: Idea + url: https://github.com/autowarefoundation/autoware/discussions/new?category=ideas + about: Post an idea diff --git a/.github/ISSUE_TEMPLATE/task.yaml b/.github/ISSUE_TEMPLATE/task.yaml new file mode 100644 index 0000000..cd8322f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/task.yaml @@ -0,0 +1,42 @@ +name: Task +description: Plan a task +body: + - type: checkboxes + attributes: + label: Checklist + description: Confirm the following items before proceeding. If one cannot be satisfied, create a discussion thread instead. + options: + - label: I've read the [contribution guidelines](https://github.com/autowarefoundation/autoware/blob/main/CONTRIBUTING.md). + required: true + - label: I've searched other issues and no duplicate issues were found. + required: true + - label: I've agreed with the maintainers that I can plan this task. + required: true + + - type: textarea + attributes: + label: Description + description: Write a brief description of the task. + validations: + required: true + + - type: textarea + attributes: + label: Purpose + description: Describe the purpose of the task. + validations: + required: true + + - type: textarea + attributes: + label: Possible approaches + description: Describe possible approaches for the task. + validations: + required: true + + - type: textarea + attributes: + label: Definition of done + description: Write the definition of done for the task. + validations: + required: true diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..97b0e95 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,8 @@ +**Note**: Confirm the [contribution guidelines](https://autowarefoundation.github.io/autoware-documentation/main/contributing/) before submitting a pull request. + +Click the `Preview` tab and select a PR template: + +- [Standard change](?expand=1&template=standard-change.md) +- [Small change](?expand=1&template=small-change.md) + +**Do NOT send a PR with this description.** diff --git a/.github/PULL_REQUEST_TEMPLATE/small-change.md b/.github/PULL_REQUEST_TEMPLATE/small-change.md new file mode 100644 index 0000000..2ff933c --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/small-change.md @@ -0,0 +1,40 @@ +## Description + + + +## Tests performed + + + + +Not applicable. + +## Effects on system behavior + + + +Not applicable. + +## Pre-review checklist for the PR author + +The PR author **must** check the checkboxes below when creating the PR. + +- [ ] I've confirmed the [contribution guidelines]. +- [ ] The PR follows the [pull request guidelines]. + +## In-review checklist for the PR reviewers + +The PR reviewers **must** check the checkboxes below before approval. + +- [ ] The PR follows the [pull request guidelines]. + +## Post-review checklist for the PR author + +The PR author **must** check the checkboxes below before merging. + +- [ ] There are no open discussions or they are tracked via tickets. + +After all checkboxes are checked, anyone who has write access can merge the PR. + +[contribution guidelines]: https://autowarefoundation.github.io/autoware-documentation/main/contributing/ +[pull request guidelines]: https://autowarefoundation.github.io/autoware-documentation/main/contributing/pull-request-guidelines/ diff --git a/.github/PULL_REQUEST_TEMPLATE/standard-change.md b/.github/PULL_REQUEST_TEMPLATE/standard-change.md new file mode 100644 index 0000000..7aedefd --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/standard-change.md @@ -0,0 +1,50 @@ +## Description + + + +## Related links + + + +## Tests performed + + + +## Notes for reviewers + + + +## Interface changes + + + +## Effects on system behavior + + + +## Pre-review checklist for the PR author + +The PR author **must** check the checkboxes below when creating the PR. + +- [ ] I've confirmed the [contribution guidelines]. +- [ ] The PR follows the [pull request guidelines]. + +## In-review checklist for the PR reviewers + +The PR reviewers **must** check the checkboxes below before approval. + +- [ ] The PR follows the [pull request guidelines]. +- [ ] The PR has been properly tested. +- [ ] The PR has been reviewed by the code owners. + +## Post-review checklist for the PR author + +The PR author **must** check the checkboxes below before merging. + +- [ ] There are no open discussions or they are tracked via tickets. +- [ ] The PR is ready for merge. + +After all checkboxes are checked, anyone who has write access can merge the PR. + +[contribution guidelines]: https://autowarefoundation.github.io/autoware-documentation/main/contributing/ +[pull request guidelines]: https://autowarefoundation.github.io/autoware-documentation/main/contributing/pull-request-guidelines/ diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..0264c03 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily + open-pull-requests-limit: 1 + labels: + - tag:bot + - type:github-actions diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..bc99e43 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,12 @@ +# Modified from https://github.com/probot/stale#usage + +# Number of days of inactivity before an Issue or Pull Request with the stale label is closed +daysUntilClose: false + +# Label to use when marking as stale +staleLabel: status:stale + +# Comment to post when marking as stale +markComment: > + This pull request has been automatically marked as stale because it has not had + recent activity. diff --git a/.github/sync-files-reverse-reference.yaml b/.github/sync-files-reverse-reference.yaml new file mode 100644 index 0000000..f5d016c --- /dev/null +++ b/.github/sync-files-reverse-reference.yaml @@ -0,0 +1,39 @@ +- repository: autowarefoundation/autoware.universe + files: + - source: .github/workflows/build-and-test.yaml + pre-commands: | + sd -s '${{ matrix.container-suffix }}' '' {source} + sd -f ms 'container-suffix:.*include:' 'include:' {source} + + sd "container: ghcr.io/autowarefoundation/autoware-universe:(\w+)-latest.*" "container: ros:\$1" {source} + sd "build_depends.humble.repos" "build_depends.repos" {source} + - source: .github/workflows/build-and-test-differential.yaml + pre-commands: | + sd -s '${{ matrix.container-suffix }}' '' {source} + sd -f ms 'container-suffix:.*include:' 'include:' {source} + + sd "container: ghcr.io/autowarefoundation/autoware-universe:(\w+)-latest.*" "container: ros:\$1" {source} + sd "build_depends.humble.repos" "build_depends.repos" {source} + - source: .github/workflows/build-and-test-differential-self-hosted.yaml + pre-commands: | + sd -s '${{ matrix.container-suffix }}' '' {source} + sd -f ms 'container-suffix:.*include:' 'include:' {source} + + sd "container: ghcr.io/autowarefoundation/autoware-universe:(\w+)-latest.*" "container: ros:\$1" {source} + sd "build_depends.humble.repos" "build_depends.repos" {source} + - source: .github/workflows/build-and-test-self-hosted.yaml + pre-commands: | + sd -s '${{ matrix.container-suffix }}' '' {source} + sd -f ms 'container-suffix:.*include:' 'include:' {source} + + sd "container: ghcr.io/autowarefoundation/autoware-universe:(\w+)-latest.*" "container: ros:\$1" {source} + sd "build_depends.humble.repos" "build_depends.repos" {source} + - source: .github/workflows/check-build-depends.yaml + pre-commands: | + sd "container: ghcr.io/autowarefoundation/autoware-universe:(\w+)-latest.*" "container: ros:\$1" {source} + sd "build_depends.humble.repos" "build_depends.repos" {source} + - source: .github/workflows/clang-tidy-pr-comments.yaml + - source: .github/workflows/clang-tidy-pr-comments-manually.yaml + - source: .github/workflows/update-codeowners-from-packages.yaml + - source: .pre-commit-config.yaml + - source: codecov.yaml diff --git a/.github/sync-files.yaml b/.github/sync-files.yaml new file mode 100644 index 0000000..39bcd3f --- /dev/null +++ b/.github/sync-files.yaml @@ -0,0 +1,32 @@ +- repository: autowarefoundation/autoware + files: + - source: CODE_OF_CONDUCT.md + - source: CONTRIBUTING.md + - source: DISCLAIMER.md + - source: LICENSE + - source: .github/ISSUE_TEMPLATE/bug.yaml + - source: .github/ISSUE_TEMPLATE/config.yml + - source: .github/ISSUE_TEMPLATE/task.yaml + - source: .github/PULL_REQUEST_TEMPLATE.md + - source: .github/PULL_REQUEST_TEMPLATE/small-change.md + - source: .github/PULL_REQUEST_TEMPLATE/standard-change.md + - source: .github/dependabot.yaml + - source: .github/stale.yml + - source: .github/workflows/cancel-previous-workflows.yaml + - source: .github/workflows/github-release.yaml + - source: .github/workflows/pre-commit.yaml + - source: .github/workflows/pre-commit-autoupdate.yaml + - source: .github/workflows/pre-commit-optional.yaml + - source: .github/workflows/semantic-pull-request.yaml + - source: .github/workflows/spell-check-differential.yaml + - source: .github/workflows/sync-files.yaml + - source: .clang-format + - source: .clang-tidy + - source: .markdown-link-check.json + - source: .markdownlint.yaml + - source: .pre-commit-config-optional.yaml + - source: .prettierignore + - source: .prettierrc.yaml + - source: .yamllint.yaml + - source: CPPLINT.cfg + - source: setup.cfg diff --git a/.github/workflows/build-and-test-differential-self-hosted.yaml b/.github/workflows/build-and-test-differential-self-hosted.yaml new file mode 100644 index 0000000..b684019 --- /dev/null +++ b/.github/workflows/build-and-test-differential-self-hosted.yaml @@ -0,0 +1,58 @@ +name: build-and-test-differential-self-hosted + +on: + pull_request: + types: + - opened + - synchronize + - labeled + workflow_dispatch: + +jobs: + prevent-no-label-execution: + uses: autowarefoundation/autoware-github-actions/.github/workflows/prevent-no-label-execution.yaml@v1 + with: + label: ARM64 + + build-and-test-differential-self-hosted: + needs: prevent-no-label-execution + if: ${{ needs.prevent-no-label-execution.outputs.run == 'true' }} + runs-on: [self-hosted, linux, ARM64] + container: ${{ matrix.container }} + strategy: + fail-fast: false + matrix: + rosdistro: + - humble + include: + - rosdistro: humble + container: ros:humble + build-depends-repos: build_depends.repos + steps: + - name: Check out repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Remove exec_depend + uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1 + + - name: Get modified packages + id: get-modified-packages + uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1 + + - name: Build + if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }} + uses: autowarefoundation/autoware-github-actions/colcon-build@v1 + with: + rosdistro: ${{ matrix.rosdistro }} + target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }} + build-depends-repos: ${{ matrix.build-depends-repos }} + + - name: Test + if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }} + uses: autowarefoundation/autoware-github-actions/colcon-test@v1 + with: + rosdistro: ${{ matrix.rosdistro }} + target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }} + build-depends-repos: ${{ matrix.build-depends-repos }} diff --git a/.github/workflows/build-and-test-differential.yaml b/.github/workflows/build-and-test-differential.yaml new file mode 100644 index 0000000..ad9fc66 --- /dev/null +++ b/.github/workflows/build-and-test-differential.yaml @@ -0,0 +1,91 @@ +name: build-and-test-differential + +on: + pull_request: + +jobs: + build-and-test-differential: + runs-on: ubuntu-latest + container: ${{ matrix.container }} + strategy: + fail-fast: false + matrix: + rosdistro: + - humble + include: + - rosdistro: humble + container: ros:humble + build-depends-repos: build_depends.repos + steps: + - name: Check out repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Remove exec_depend + uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1 + + - name: Get modified packages + id: get-modified-packages + uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1 + + - name: Build + if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }} + uses: autowarefoundation/autoware-github-actions/colcon-build@v1 + with: + rosdistro: ${{ matrix.rosdistro }} + target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }} + build-depends-repos: ${{ matrix.build-depends-repos }} + + - name: Test + id: test + if: ${{ steps.get-modified-packages.outputs.modified-packages != '' }} + uses: autowarefoundation/autoware-github-actions/colcon-test@v1 + with: + rosdistro: ${{ matrix.rosdistro }} + target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }} + build-depends-repos: ${{ matrix.build-depends-repos }} + + - name: Upload coverage to CodeCov + if: ${{ steps.test.outputs.coverage-report-files != '' }} + uses: codecov/codecov-action@v3 + with: + files: ${{ steps.test.outputs.coverage-report-files }} + fail_ci_if_error: false + verbose: true + flags: differential + + clang-tidy-differential: + runs-on: ubuntu-latest + container: ros:humble + needs: build-and-test-differential + steps: + - name: Check out repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Remove exec_depend + uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1 + + - name: Get modified packages + id: get-modified-packages + uses: autowarefoundation/autoware-github-actions/get-modified-packages@v1 + + - name: Get modified files + id: get-modified-files + uses: tj-actions/changed-files@v42 + with: + files: | + **/*.cpp + **/*.hpp + + - name: Run clang-tidy + if: ${{ steps.get-modified-files.outputs.all_changed_files != '' }} + uses: autowarefoundation/autoware-github-actions/clang-tidy@v1 + with: + rosdistro: humble + target-packages: ${{ steps.get-modified-packages.outputs.modified-packages }} + target-files: ${{ steps.get-modified-files.outputs.all_changed_files }} + clang-tidy-config-url: https://raw.githubusercontent.com/autowarefoundation/autoware/main/.clang-tidy + build-depends-repos: build_depends.repos diff --git a/.github/workflows/build-and-test-self-hosted.yaml b/.github/workflows/build-and-test-self-hosted.yaml new file mode 100644 index 0000000..e1a4c0b --- /dev/null +++ b/.github/workflows/build-and-test-self-hosted.yaml @@ -0,0 +1,46 @@ +name: build-and-test-self-hosted + +on: + schedule: + - cron: 0 0 * * * + workflow_dispatch: + +jobs: + build-and-test-self-hosted: + runs-on: [self-hosted, linux, ARM64] + container: ${{ matrix.container }} + strategy: + fail-fast: false + matrix: + rosdistro: + - humble + include: + - rosdistro: humble + container: ros:humble + build-depends-repos: build_depends.repos + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Remove exec_depend + uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1 + + - name: Get self packages + id: get-self-packages + uses: autowarefoundation/autoware-github-actions/get-self-packages@v1 + + - name: Build + if: ${{ steps.get-self-packages.outputs.self-packages != '' }} + uses: autowarefoundation/autoware-github-actions/colcon-build@v1 + with: + rosdistro: ${{ matrix.rosdistro }} + target-packages: ${{ steps.get-self-packages.outputs.self-packages }} + build-depends-repos: ${{ matrix.build-depends-repos }} + + - name: Test + if: ${{ steps.get-self-packages.outputs.self-packages != '' }} + uses: autowarefoundation/autoware-github-actions/colcon-test@v1 + with: + rosdistro: ${{ matrix.rosdistro }} + target-packages: ${{ steps.get-self-packages.outputs.self-packages }} + build-depends-repos: ${{ matrix.build-depends-repos }} diff --git a/.github/workflows/build-and-test-with-reverse-depends.yaml b/.github/workflows/build-and-test-with-reverse-depends.yaml new file mode 100644 index 0000000..fd54629 --- /dev/null +++ b/.github/workflows/build-and-test-with-reverse-depends.yaml @@ -0,0 +1,52 @@ +name: build-and-test-with-reverse-depends + +on: + workflow_dispatch: + +jobs: + build-and-test-with-reverse-depends: + runs-on: ubuntu-latest + container: ros:humble + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Set up yq + uses: chrisdickinson/setup-yq@v1.0.1 + with: + yq-version: v4.25.1 + + - name: Clone reverse depends + run: | + git clone https://github.com/autowarefoundation/autoware.universe.git reverse_depends + + - name: Remove exec_depend + uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1 + + - name: Get self packages + id: get-self-packages + uses: autowarefoundation/autoware-github-actions/get-self-packages@v1 + + - name: Import depends of reverse depends + run: | + yq -i 'del(.repositories.* | select(.url == "https://github.com/autowarefoundation/autoware_common.git"))' reverse_depends/build_depends.repos + yq -i 'del(.repositories.* | select(.url == "https://github.com/tier4/autoware_auto_msgs.git"))' reverse_depends/build_depends.repos + vcs import reverse_depends < reverse_depends/build_depends.repos + rm -rf reverse_depends/map/lanelet2_extension + + - name: Build + if: ${{ steps.get-self-packages.outputs.self-packages != '' }} + uses: autowarefoundation/autoware-github-actions/colcon-build@v1 + with: + rosdistro: humble + target-packages: ${{ steps.get-self-packages.outputs.self-packages }} + build-depends-repos: build_depends.repos + + - name: Test + if: ${{ steps.get-self-packages.outputs.self-packages != '' }} + id: test + uses: autowarefoundation/autoware-github-actions/colcon-test@v1 + with: + rosdistro: humble + target-packages: ${{ steps.get-self-packages.outputs.self-packages }} + build-depends-repos: build_depends.repos diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml new file mode 100644 index 0000000..c34102c --- /dev/null +++ b/.github/workflows/build-and-test.yaml @@ -0,0 +1,66 @@ +name: build-and-test + +on: + push: + schedule: + - cron: 0 0 * * * + workflow_dispatch: + +jobs: + build-and-test: + if: ${{ github.event_name != 'push' || github.ref_name == github.event.repository.default_branch }} + runs-on: ubuntu-latest + container: ${{ matrix.container }} + strategy: + fail-fast: false + matrix: + rosdistro: + - humble + include: + - rosdistro: humble + container: ros:humble + build-depends-repos: build_depends.repos + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Free disk space (Ubuntu) + uses: jlumbroso/free-disk-space@v1.3.1 + with: + tool-cache: false + dotnet: false + swap-storage: false + large-packages: false + + - name: Remove exec_depend + uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1 + + - name: Get self packages + id: get-self-packages + uses: autowarefoundation/autoware-github-actions/get-self-packages@v1 + + - name: Build + if: ${{ steps.get-self-packages.outputs.self-packages != '' }} + uses: autowarefoundation/autoware-github-actions/colcon-build@v1 + with: + rosdistro: ${{ matrix.rosdistro }} + target-packages: ${{ steps.get-self-packages.outputs.self-packages }} + build-depends-repos: ${{ matrix.build-depends-repos }} + + - name: Test + if: ${{ steps.get-self-packages.outputs.self-packages != '' }} + id: test + uses: autowarefoundation/autoware-github-actions/colcon-test@v1 + with: + rosdistro: ${{ matrix.rosdistro }} + target-packages: ${{ steps.get-self-packages.outputs.self-packages }} + build-depends-repos: ${{ matrix.build-depends-repos }} + + - name: Upload coverage to CodeCov + if: ${{ steps.test.outputs.coverage-report-files != '' }} + uses: codecov/codecov-action@v3 + with: + files: ${{ steps.test.outputs.coverage-report-files }} + fail_ci_if_error: false + verbose: true + flags: total diff --git a/.github/workflows/cancel-previous-workflows.yaml b/.github/workflows/cancel-previous-workflows.yaml new file mode 100644 index 0000000..1da4d24 --- /dev/null +++ b/.github/workflows/cancel-previous-workflows.yaml @@ -0,0 +1,14 @@ +name: cancel-previous-workflows + +on: + pull_request_target: + +jobs: + cancel-previous-workflows: + runs-on: ubuntu-latest + steps: + - name: Cancel previous runs + uses: styfle/cancel-workflow-action@0.12.0 + with: + workflow_id: all + all_but_latest: true diff --git a/.github/workflows/check-build-depends.yaml b/.github/workflows/check-build-depends.yaml new file mode 100644 index 0000000..81618a1 --- /dev/null +++ b/.github/workflows/check-build-depends.yaml @@ -0,0 +1,37 @@ +name: check-build-depends + +on: + pull_request: + paths: + - build_depends*.repos + +jobs: + check-build-depends: + runs-on: ubuntu-latest + container: ${{ matrix.container }} + strategy: + fail-fast: false + matrix: + rosdistro: + - humble + include: + - rosdistro: humble + container: ros:humble + build-depends-repos: build_depends.repos + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Remove exec_depend + uses: autowarefoundation/autoware-github-actions/remove-exec-depend@v1 + + - name: Get self packages + id: get-self-packages + uses: autowarefoundation/autoware-github-actions/get-self-packages@v1 + + - name: Build + uses: autowarefoundation/autoware-github-actions/colcon-build@v1 + with: + rosdistro: ${{ matrix.rosdistro }} + target-packages: ${{ steps.get-self-packages.outputs.self-packages }} + build-depends-repos: ${{ matrix.build-depends-repos }} diff --git a/.github/workflows/clang-tidy-pr-comments-manually.yaml b/.github/workflows/clang-tidy-pr-comments-manually.yaml new file mode 100644 index 0000000..9bccd97 --- /dev/null +++ b/.github/workflows/clang-tidy-pr-comments-manually.yaml @@ -0,0 +1,62 @@ +name: clang-tidy-pr-comments-manually + +on: + workflow_dispatch: + inputs: + workflow_run_id_or_url: + description: The target workflow run ID or URL of the build-and-test-differential workflow + required: true +jobs: + clang-tidy-pr-comments-manually: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Download analysis results + run: | + workflow_run_id=$(echo "${{ inputs.workflow_run_id_or_url }}" | sed -e "s|.*runs/||" -e "s|/jobs.*||") + gh run download "$workflow_run_id" -D /tmp || true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Check if the fixes.yaml file exists + id: check-fixes-yaml-existence + uses: autowarefoundation/autoware-github-actions/check-file-existence@v1 + with: + files: /tmp/clang-tidy-result/fixes.yaml + + - name: Set variables + if: ${{ steps.check-fixes-yaml-existence.outputs.exists == 'true' }} + id: set-variables + run: | + echo "pr-id=$(cat /tmp/clang-tidy-result/pr-id.txt)" >> $GITHUB_OUTPUT + echo "pr-head-repo=$(cat /tmp/clang-tidy-result/pr-head-repo.txt)" >> $GITHUB_OUTPUT + echo "pr-head-ref=$(cat /tmp/clang-tidy-result/pr-head-ref.txt)" >> $GITHUB_OUTPUT + + - name: Check out PR head + if: ${{ steps.check-fixes-yaml-existence.outputs.exists == 'true' }} + uses: actions/checkout@v3 + with: + repository: ${{ steps.set-variables.outputs.pr-head-repo }} + ref: ${{ steps.set-variables.outputs.pr-head-ref }} + persist-credentials: false + + - name: Replace paths in fixes.yaml + if: ${{ steps.check-fixes-yaml-existence.outputs.exists == 'true' }} + run: | + sed -i -e "s|/__w/|/home/runner/work/|g" /tmp/clang-tidy-result/fixes.yaml + cat /tmp/clang-tidy-result/fixes.yaml + + - name: Copy fixes.yaml to access from Docker Container Action + if: ${{ steps.check-fixes-yaml-existence.outputs.exists == 'true' }} + run: | + cp /tmp/clang-tidy-result/fixes.yaml fixes.yaml + + - name: Run clang-tidy-pr-comments action + if: ${{ steps.check-fixes-yaml-existence.outputs.exists == 'true' }} + uses: platisd/clang-tidy-pr-comments@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + clang_tidy_fixes: fixes.yaml + pull_request_id: ${{ steps.set-variables.outputs.pr-id }} diff --git a/.github/workflows/clang-tidy-pr-comments.yaml b/.github/workflows/clang-tidy-pr-comments.yaml new file mode 100644 index 0000000..baaa0fb --- /dev/null +++ b/.github/workflows/clang-tidy-pr-comments.yaml @@ -0,0 +1,63 @@ +name: clang-tidy-pr-comments + +on: + workflow_run: + workflows: + - build-and-test-differential + types: + - completed + +jobs: + clang-tidy-pr-comments: + if: ${{ github.event.workflow_run.event == 'pull_request' && contains(fromJson('["success", "failure"]'), github.event.workflow_run.conclusion) }} + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Download analysis results + run: | + gh run download ${{ github.event.workflow_run.id }} -D /tmp || true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Check if the fixes.yaml file exists + id: check-fixes-yaml-existence + uses: autowarefoundation/autoware-github-actions/check-file-existence@v1 + with: + files: /tmp/clang-tidy-result/fixes.yaml + + - name: Set variables + if: ${{ steps.check-fixes-yaml-existence.outputs.exists == 'true' }} + id: set-variables + run: | + echo "pr-id=$(cat /tmp/clang-tidy-result/pr-id.txt)" >> $GITHUB_OUTPUT + echo "pr-head-repo=$(cat /tmp/clang-tidy-result/pr-head-repo.txt)" >> $GITHUB_OUTPUT + echo "pr-head-ref=$(cat /tmp/clang-tidy-result/pr-head-ref.txt)" >> $GITHUB_OUTPUT + + - name: Check out PR head + if: ${{ steps.check-fixes-yaml-existence.outputs.exists == 'true' }} + uses: actions/checkout@v3 + with: + repository: ${{ steps.set-variables.outputs.pr-head-repo }} + ref: ${{ steps.set-variables.outputs.pr-head-ref }} + persist-credentials: false + + - name: Replace paths in fixes.yaml + if: ${{ steps.check-fixes-yaml-existence.outputs.exists == 'true' }} + run: | + sed -i -e "s|/__w/|/home/runner/work/|g" /tmp/clang-tidy-result/fixes.yaml + cat /tmp/clang-tidy-result/fixes.yaml + + - name: Copy fixes.yaml to access from Docker Container Action + if: ${{ steps.check-fixes-yaml-existence.outputs.exists == 'true' }} + run: | + cp /tmp/clang-tidy-result/fixes.yaml fixes.yaml + + - name: Run clang-tidy-pr-comments action + if: ${{ steps.check-fixes-yaml-existence.outputs.exists == 'true' }} + uses: platisd/clang-tidy-pr-comments@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + clang_tidy_fixes: fixes.yaml + pull_request_id: ${{ steps.set-variables.outputs.pr-id }} diff --git a/.github/workflows/github-release.yaml b/.github/workflows/github-release.yaml new file mode 100644 index 0000000..b426d0c --- /dev/null +++ b/.github/workflows/github-release.yaml @@ -0,0 +1,78 @@ +name: github-release + +on: + push: + branches: + - beta/v* + tags: + - v* + workflow_dispatch: + inputs: + beta-branch-or-tag-name: + description: The name of the beta branch or tag to release + type: string + required: true + +jobs: + github-release: + runs-on: ubuntu-latest + steps: + - name: Set tag name + id: set-tag-name + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + REF_NAME="${{ github.event.inputs.beta-branch-or-tag-name }}" + else + REF_NAME="${{ github.ref_name }}" + fi + + echo "ref-name=$REF_NAME" >> $GITHUB_OUTPUT + echo "tag-name=${REF_NAME#beta/}" >> $GITHUB_OUTPUT + + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ steps.set-tag-name.outputs.ref-name }} + + - name: Set target name for beta branches + id: set-target-name + run: | + if [[ "${{ steps.set-tag-name.outputs.ref-name }}" =~ "beta/" ]]; then + echo "target-name=${{ steps.set-tag-name.outputs.ref-name }}" >> $GITHUB_OUTPUT + fi + + - name: Create a local tag for beta branches + run: | + if [ "${{ steps.set-target-name.outputs.target-name }}" != "" ]; then + git tag "${{ steps.set-tag-name.outputs.tag-name }}" + fi + + - name: Run generate-changelog + id: generate-changelog + uses: autowarefoundation/autoware-github-actions/generate-changelog@v1 + + - name: Select verb + id: select-verb + run: | + has_previous_draft=$(gh release view --json isDraft -q ".isDraft" "${{ steps.set-tag-name.outputs.tag-name }}") || true + + verb=create + if [ "$has_previous_draft" = "true" ]; then + verb=edit + fi + + echo "verb=$verb" >> $GITHUB_OUTPUT + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Release to GitHub + run: | + gh release ${{ steps.select-verb.outputs.verb }} "${{ steps.set-tag-name.outputs.tag-name }}" \ + --draft \ + --target "${{ steps.set-target-name.outputs.target-name }}" \ + --title "Release ${{ steps.set-tag-name.outputs.tag-name }}" \ + --notes "$NOTES" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NOTES: ${{ steps.generate-changelog.outputs.changelog }} diff --git a/.github/workflows/pre-commit-autoupdate.yaml b/.github/workflows/pre-commit-autoupdate.yaml new file mode 100644 index 0000000..23b403f --- /dev/null +++ b/.github/workflows/pre-commit-autoupdate.yaml @@ -0,0 +1,37 @@ +name: pre-commit-autoupdate + +on: + schedule: + - cron: 0 0 * * * + workflow_dispatch: + +jobs: + check-secret: + uses: autowarefoundation/autoware-github-actions/.github/workflows/check-secret.yaml@v1 + secrets: + secret: ${{ secrets.APP_ID }} + + pre-commit-autoupdate: + needs: check-secret + if: ${{ needs.check-secret.outputs.set == 'true' }} + runs-on: ubuntu-latest + steps: + - name: Generate token + id: generate-token + uses: tibdex/github-app-token@v2 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.PRIVATE_KEY }} + + - name: Run pre-commit-autoupdate + uses: autowarefoundation/autoware-github-actions/pre-commit-autoupdate@v1 + with: + token: ${{ steps.generate-token.outputs.token }} + pre-commit-config: .pre-commit-config.yaml + pr-labels: | + tag:bot + tag:pre-commit-autoupdate + pr-branch: pre-commit-autoupdate + pr-title: "ci(pre-commit): autoupdate" + pr-commit-message: "ci(pre-commit): autoupdate" + auto-merge-method: squash diff --git a/.github/workflows/pre-commit-optional.yaml b/.github/workflows/pre-commit-optional.yaml new file mode 100644 index 0000000..3873819 --- /dev/null +++ b/.github/workflows/pre-commit-optional.yaml @@ -0,0 +1,19 @@ +name: pre-commit-optional + +on: + pull_request: + +jobs: + pre-commit-optional: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run pre-commit + uses: autowarefoundation/autoware-github-actions/pre-commit@v1 + with: + pre-commit-config: .pre-commit-config-optional.yaml + base-branch: origin/${{ github.base_ref }} diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml new file mode 100644 index 0000000..c724885 --- /dev/null +++ b/.github/workflows/pre-commit.yaml @@ -0,0 +1,27 @@ +name: pre-commit + +on: + pull_request: + +jobs: + pre-commit: + if: ${{ github.event.repository.private }} # Use pre-commit.ci for public repositories + runs-on: ubuntu-latest + steps: + - name: Generate token + id: generate-token + uses: tibdex/github-app-token@v2 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.PRIVATE_KEY }} + + - name: Check out repository + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Run pre-commit + uses: autowarefoundation/autoware-github-actions/pre-commit@v1 + with: + pre-commit-config: .pre-commit-config.yaml + token: ${{ steps.generate-token.outputs.token }} diff --git a/.github/workflows/semantic-pull-request.yaml b/.github/workflows/semantic-pull-request.yaml new file mode 100644 index 0000000..71224c2 --- /dev/null +++ b/.github/workflows/semantic-pull-request.yaml @@ -0,0 +1,12 @@ +name: semantic-pull-request + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + semantic-pull-request: + uses: autowarefoundation/autoware-github-actions/.github/workflows/semantic-pull-request.yaml@v1 diff --git a/.github/workflows/spell-check-differential.yaml b/.github/workflows/spell-check-differential.yaml new file mode 100644 index 0000000..1fbf2ff --- /dev/null +++ b/.github/workflows/spell-check-differential.yaml @@ -0,0 +1,16 @@ +name: spell-check-differential + +on: + pull_request: + +jobs: + spell-check-differential: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Run spell-check + uses: autowarefoundation/autoware-github-actions/spell-check@v1 + with: + cspell-json-url: https://raw.githubusercontent.com/tier4/autoware-spell-check-dict/main/.cspell.json diff --git a/.github/workflows/sync-files-reverse-reference.yaml b/.github/workflows/sync-files-reverse-reference.yaml new file mode 100644 index 0000000..8219686 --- /dev/null +++ b/.github/workflows/sync-files-reverse-reference.yaml @@ -0,0 +1,24 @@ +name: sync-files-reverse-reference + +on: + workflow_dispatch: + +jobs: + sync-files-reverse-reference: + runs-on: ubuntu-latest + steps: + - name: Generate token + id: generate-token + uses: tibdex/github-app-token@v2 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.PRIVATE_KEY }} + + - name: Run sync-files + uses: autowarefoundation/autoware-github-actions/sync-files@v1 + with: + token: ${{ steps.generate-token.outputs.token }} + config: .github/sync-files-reverse-reference.yaml + pr-branch: sync-files-reverse-reference + pr-title: "chore: sync files of reverse references" + pr-commit-message: "chore: sync files of reverse references" diff --git a/.github/workflows/sync-files.yaml b/.github/workflows/sync-files.yaml new file mode 100644 index 0000000..51e523b --- /dev/null +++ b/.github/workflows/sync-files.yaml @@ -0,0 +1,33 @@ +name: sync-files + +on: + schedule: + - cron: 0 0 * * * + workflow_dispatch: + +jobs: + check-secret: + uses: autowarefoundation/autoware-github-actions/.github/workflows/check-secret.yaml@v1 + secrets: + secret: ${{ secrets.APP_ID }} + + sync-files: + needs: check-secret + if: ${{ needs.check-secret.outputs.set == 'true' }} + runs-on: ubuntu-latest + steps: + - name: Generate token + id: generate-token + uses: tibdex/github-app-token@v2 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.PRIVATE_KEY }} + + - name: Run sync-files + uses: autowarefoundation/autoware-github-actions/sync-files@v1 + with: + token: ${{ steps.generate-token.outputs.token }} + pr-labels: | + tag:bot + tag:sync-files + auto-merge-method: squash diff --git a/.github/workflows/update-codeowners-from-packages.yaml b/.github/workflows/update-codeowners-from-packages.yaml new file mode 100644 index 0000000..8b3d240 --- /dev/null +++ b/.github/workflows/update-codeowners-from-packages.yaml @@ -0,0 +1,33 @@ +name: update-codeowners-from-packages + +on: + schedule: + - cron: 0 0 * * * + workflow_dispatch: + +jobs: + check-secret: + uses: autowarefoundation/autoware-github-actions/.github/workflows/check-secret.yaml@v1 + secrets: + secret: ${{ secrets.APP_ID }} + + update-codeowners-from-packages: + needs: check-secret + if: ${{ needs.check-secret.outputs.set == 'true' }} + runs-on: ubuntu-latest + steps: + - name: Generate token + id: generate-token + uses: tibdex/github-app-token@v2 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.PRIVATE_KEY }} + + - name: Run update-codeowners-from-packages + uses: autowarefoundation/autoware-github-actions/update-codeowners-from-packages@v1 + with: + token: ${{ steps.generate-token.outputs.token }} + pr-labels: | + tag:bot + tag:update-codeowners-from-packages + auto-merge-method: squash diff --git a/.markdown-link-check.json b/.markdown-link-check.json new file mode 100644 index 0000000..c71a3e4 --- /dev/null +++ b/.markdown-link-check.json @@ -0,0 +1,16 @@ +{ + "aliveStatusCodes": [200, 206, 403], + "ignorePatterns": [ + { + "pattern": "^http://localhost" + }, + { + "pattern": "^http://127\\.0\\.0\\.1" + }, + { + "pattern": "^https://github.com/.*/discussions/new" + } + ], + "retryOn429": true, + "retryCount": 10 +} diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..babaaa1 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,11 @@ +# See https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md for all rules. +default: true +MD013: false +MD024: + siblings_only: true +MD029: + style: ordered +MD033: false +MD041: false +MD046: false +MD049: false diff --git a/.pre-commit-config-optional.yaml b/.pre-commit-config-optional.yaml new file mode 100644 index 0000000..3b43f9a --- /dev/null +++ b/.pre-commit-config-optional.yaml @@ -0,0 +1,6 @@ +repos: + - repo: https://github.com/tcort/markdown-link-check + rev: v3.11.2 + hooks: + - id: markdown-link-check + args: [--quiet, --config=.markdown-link-check.json] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a5ca7b6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,95 @@ +ci: + autofix_commit_msg: "style(pre-commit): autofix" + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-json + - id: check-merge-conflict + - id: check-toml + - id: check-xml + - id: check-yaml + args: [--unsafe] + - id: detect-private-key + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.33.0 + hooks: + - id: markdownlint + args: [-c, .markdownlint.yaml, --fix] + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.0.0-alpha.6 + hooks: + - id: prettier + + - repo: https://github.com/adrienverge/yamllint + rev: v1.30.0 + hooks: + - id: yamllint + + - repo: https://github.com/tier4/pre-commit-hooks-ros + rev: v0.8.0 + hooks: + - id: flake8-ros + - id: prettier-xacro + - id: prettier-launch-xml + - id: prettier-package-xml + - id: ros-include-guard + - id: sort-package-xml + + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.9.0.2 + hooks: + - id: shellcheck + + - repo: https://github.com/scop/pre-commit-shfmt + rev: v3.6.0-2 + hooks: + - id: shfmt + args: [-w, -s, -i=4] + + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + + - repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black + args: [--line-length=100] + + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v16.0.0 + hooks: + - id: clang-format + types_or: [c++, c, cuda] + + - repo: https://github.com/cpplint/cpplint + rev: 1.6.1 + hooks: + - id: cpplint + args: [--quiet] + exclude: .cu + + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.23.2 + hooks: + - id: check-metaschema + files: ^.+/schema/.*schema\.json$ + + - repo: local + hooks: + - id: prettier-svg + name: prettier svg + description: Apply Prettier with plugin-xml to svg. + entry: prettier --write --list-different --ignore-unknown --print-width 200 --xml-self-closing-space false --xml-whitespace-sensitivity ignore + language: node + files: .svg$ + additional_dependencies: [prettier@2.7.1, "@prettier/plugin-xml@2.2.0"] diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..a3c34d0 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +*.param.yaml +*.rviz diff --git a/.prettierrc.yaml b/.prettierrc.yaml new file mode 100644 index 0000000..e29bf32 --- /dev/null +++ b/.prettierrc.yaml @@ -0,0 +1,20 @@ +printWidth: 100 +tabWidth: 2 +overrides: + - files: package.xml + options: + printWidth: 1000 + xmlSelfClosingSpace: false + xmlWhitespaceSensitivity: ignore + + - files: "*.launch.xml" + options: + printWidth: 200 + xmlSelfClosingSpace: false + xmlWhitespaceSensitivity: ignore + + - files: "*.xacro" + options: + printWidth: 200 + xmlSelfClosingSpace: false + xmlWhitespaceSensitivity: ignore diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..8dbcfb8 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,132 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +- Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery, and sexual attention or advances of + any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, + without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][mozilla coc]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][faq]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[mozilla coc]: https://github.com/mozilla/diversity +[faq]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..22c7ee2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,3 @@ +# Contributing + +See . diff --git a/CPPLINT.cfg b/CPPLINT.cfg new file mode 100644 index 0000000..ba6bdf0 --- /dev/null +++ b/CPPLINT.cfg @@ -0,0 +1,14 @@ +# Modified from https://github.com/ament/ament_lint/blob/ebd524bb9973d5ec1dc48a670ce54f958a5a0243/ament_cpplint/ament_cpplint/main.py#L64-L120 +set noparent +linelength=100 +includeorder=standardcfirst +filter=-build/c++11 # we do allow C++11 +filter=-build/namespaces_literals # we allow using namespace for literals +filter=-runtime/references # we consider passing non-const references to be ok +filter=-whitespace/braces # we wrap open curly braces for namespaces, classes and functions +filter=-whitespace/indent # we don't indent keywords like public, protected and private with one space +filter=-whitespace/parens # we allow closing parenthesis to be on the next line +filter=-whitespace/semicolon # we allow the developer to decide about whitespace after a semicolon +filter=-build/header_guard # we automatically fix the names of header guards using pre-commit +filter=-build/include_order # we use the custom include order +filter=-build/include_subdir # we allow the style of "foo.hpp" diff --git a/DISCLAIMER.md b/DISCLAIMER.md new file mode 100644 index 0000000..1b5a9bb --- /dev/null +++ b/DISCLAIMER.md @@ -0,0 +1,46 @@ +DISCLAIMER + +“Autoware” will be provided by The Autoware Foundation under the Apache License 2.0. +This “DISCLAIMER” will be applied to all users of Autoware (a “User” or “Users”) with +the Apache License 2.0 and Users shall hereby approve and acknowledge all the contents +specified in this disclaimer below and will be deemed to consent to this +disclaimer without any objection upon utilizing or downloading Autoware. + +Disclaimer and Waiver of Warranties + +1. AUTOWARE FOUNDATION MAKES NO REPRESENTATION OR WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, WITH RESPECT TO PROVIDING AUTOWARE (the “Service”) + including but not limited to any representation or warranty (i) of fitness or + suitability for a particular purpose contemplated by the Users, (ii) of the + expected functions, commercial value, accuracy, or usefulness of the Service, + (iii) that the use by the Users of the Service complies with the laws and + regulations applicable to the Users or any internal rules established by + industrial organizations, (iv) that the Service will be free of interruption or + defects, (v) of the non-infringement of any third party's right and (vi) the + accuracy of the content of the Services and the software itself. + +2. The Autoware Foundation shall not be liable for any damage incurred by the + User that are attributable to the Autoware Foundation for any reasons + whatsoever. UNDER NO CIRCUMSTANCES SHALL THE AUTOWARE FOUNDATION BE LIABLE FOR + INCIDENTAL, INDIRECT, SPECIAL OR FUTURE DAMAGES OR LOSS OF PROFITS. + +3. A User shall be entirely responsible for the content posted by the User and + its use of any content of the Service or the Website. If the User is held + responsible in a civil action such as a claim for damages or even in a criminal + case, the Autoware Foundation and member companies, governments and academic & + non-profit organizations and their directors, officers, employees and agents + (collectively, the “Indemnified Parties”) shall be completely discharged from + any rights or assertions the User may have against the Indemnified Parties, or + from any legal action, litigation or similar procedures. + +Indemnity + +A User shall indemnify and hold the Indemnified Parties harmless from any of +their damages, losses, liabilities, costs or expenses (including attorneys' +fees or criminal compensation), or any claims or demands made against the +Indemnified Parties by any third party, due to or arising out of, or in +connection with utilizing Autoware (including the representations and +warranties), the violation of applicable Product Liability Law of each country +(including criminal case) or violation of any applicable laws by the Users, or +the content posted by the User or its use of any content of the Service or the +Website. diff --git a/autoware_utils/CMakeLists.txt b/autoware_utils/CMakeLists.txt new file mode 100644 index 0000000..21eb4ad --- /dev/null +++ b/autoware_utils/CMakeLists.txt @@ -0,0 +1,19 @@ +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 new file mode 100644 index 0000000..35493ac --- /dev/null +++ b/autoware_utils/README.md @@ -0,0 +1,25 @@ +# 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 new file mode 100644 index 0000000..77d2fec --- /dev/null +++ b/autoware_utils/include/autoware_utils/autoware_utils.hpp @@ -0,0 +1,24 @@ +// 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 new file mode 100644 index 0000000..e86392a --- /dev/null +++ b/autoware_utils/include/autoware_utils/math/constants.hpp @@ -0,0 +1,24 @@ +// 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 new file mode 100644 index 0000000..bb913aa --- /dev/null +++ b/autoware_utils/include/autoware_utils/math/normalization.hpp @@ -0,0 +1,50 @@ +// 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 new file mode 100644 index 0000000..da899a3 --- /dev/null +++ b/autoware_utils/include/autoware_utils/math/range.hpp @@ -0,0 +1,78 @@ +// 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 new file mode 100644 index 0000000..97db93f --- /dev/null +++ b/autoware_utils/include/autoware_utils/math/unit_conversion.hpp @@ -0,0 +1,43 @@ +// 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 new file mode 100644 index 0000000..8e27b4c --- /dev/null +++ b/autoware_utils/include/autoware_utils/ros/uuid_helper.hpp @@ -0,0 +1,72 @@ +// 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 new file mode 100644 index 0000000..5c6327a --- /dev/null +++ b/autoware_utils/package.xml @@ -0,0 +1,25 @@ + + + + autoware_utils + 0.1.0 + The autoware_utils package + Ryohsuke Mitsudome + Esteve Fernandez + Yutaka Kondo + 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 new file mode 100644 index 0000000..25b20e5 --- /dev/null +++ b/autoware_utils/src/autoware_utils.cpp @@ -0,0 +1,15 @@ +// 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 new file mode 100644 index 0000000..dd2e3f0 --- /dev/null +++ b/autoware_utils/test/src/math/test_constants.cpp @@ -0,0 +1,31 @@ +// 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 new file mode 100644 index 0000000..fbdedd4 --- /dev/null +++ b/autoware_utils/test/src/math/test_normalization.cpp @@ -0,0 +1,83 @@ +// 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 new file mode 100644 index 0000000..ff47512 --- /dev/null +++ b/autoware_utils/test/src/math/test_range.cpp @@ -0,0 +1,235 @@ +// 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 new file mode 100644 index 0000000..c355252 --- /dev/null +++ b/autoware_utils/test/src/math/test_unit_conversion.cpp @@ -0,0 +1,65 @@ +// 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 new file mode 100644 index 0000000..05434fb --- /dev/null +++ b/autoware_utils/test/src/ros/test_uuid_helper.cpp @@ -0,0 +1,76 @@ +// 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 new file mode 100644 index 0000000..391fdc5 --- /dev/null +++ b/autoware_utils/test/src/test_autoware_utils.cpp @@ -0,0 +1,28 @@ +// 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; +} diff --git a/codecov.yaml b/codecov.yaml new file mode 100644 index 0000000..8ca2196 --- /dev/null +++ b/codecov.yaml @@ -0,0 +1,22 @@ +coverage: + status: + project: + default: + target: auto + patch: + default: + target: auto + +comment: + show_carryforward_flags: true + +flag_management: + default_rules: + carryforward: true + statuses: + - name_prefix: project- + type: project + target: auto + - name_prefix: patch- + type: patch + target: auto