From 02acbb47d11e60073a5a05c48a2e44473f55fbb4 Mon Sep 17 00:00:00 2001 From: Eddy Zhou <71026430+Edwardius@users.noreply.github.com> Date: Wed, 7 Feb 2024 00:22:44 +0900 Subject: [PATCH] Add C++/Python Linters (#67) * adding linters * stuff * Fix code style issues with clang_format * remove linting tests * purge all ament linters * PURGE THE AMENT LINTER FUCK YOUUUU --------- Co-authored-by: WATonomousAdmin --- .clang-format | 270 ++++++++++++++++++ .github/workflows/linting_auto.yml | 38 +++ .github/workflows/linting_check.yml | 34 +++ src/action/behaviour_planning/CMakeLists.txt | 12 - src/action/behaviour_planning/package.xml | 2 - src/action/global_planning/CMakeLists.txt | 12 - src/action/global_planning/package.xml | 2 - src/action/local_planning/CMakeLists.txt | 12 - src/action/local_planning/package.xml | 2 - .../model_predictive_control/CMakeLists.txt | 12 - .../model_predictive_control/package.xml | 2 - .../can_interfacing/CMakeLists.txt | 12 - src/interfacing/can_interfacing/package.xml | 2 - .../sensor_interfacing/CMakeLists.txt | 12 - .../sensor_interfacing/package.xml | 2 - .../test/test_copyright.py | 25 -- .../test/test_flake8.py | 25 -- src/perception/lane_detection/CMakeLists.txt | 12 - src/perception/lane_detection/package.xml | 2 - .../lidar_object_detection/CMakeLists.txt | 12 - .../lidar_object_detection/package.xml | 2 - .../CMakeLists.txt | 6 - .../radar_object_detection_launch/package.xml | 2 - .../radar_vis/CMakeLists.txt | 10 - .../radar_vis/include/radar_vis.hpp | 12 +- .../radar_vis/include/radar_vis_node.hpp | 30 +- .../radar_vis/package.xml | 2 - .../radar_vis/src/radar_vis.cpp | 13 +- .../radar_vis/src/radar_vis_node.cpp | 19 +- .../radar_vis/test/radar_vis_test.cpp | 4 +- .../semantic_segmentation/CMakeLists.txt | 12 - .../semantic_segmentation/package.xml | 2 - src/perception/tracking/CMakeLists.txt | 12 - src/perception/tracking/package.xml | 2 - .../traffic_light_detection/CMakeLists.txt | 12 - .../traffic_light_detection/package.xml | 2 - .../traffic_sign_detection/CMakeLists.txt | 12 - .../traffic_sign_detection/package.xml | 2 - src/samples/cpp/aggregator/CMakeLists.txt | 12 - .../aggregator/include/aggregator_core.hpp | 18 +- .../aggregator/include/aggregator_node.hpp | 15 +- src/samples/cpp/aggregator/package.xml | 2 - .../cpp/aggregator/src/aggregator_core.cpp | 32 +-- .../cpp/aggregator/src/aggregator_node.cpp | 42 +-- .../cpp/aggregator/test/aggregator_test.cpp | 15 +- src/samples/cpp/producer/CMakeLists.txt | 12 - .../cpp/producer/include/producer_core.hpp | 12 +- .../cpp/producer/include/producer_node.hpp | 11 +- src/samples/cpp/producer/package.xml | 2 - .../cpp/producer/src/producer_core.cpp | 23 +- .../cpp/producer/src/producer_node.cpp | 30 +- .../cpp/producer/test/producer_test.cpp | 9 +- src/samples/cpp/transformer/CMakeLists.txt | 12 - .../transformer/include/transformer_core.hpp | 24 +- .../transformer/include/transformer_node.hpp | 10 +- src/samples/cpp/transformer/package.xml | 2 - .../cpp/transformer/src/transformer_core.cpp | 40 +-- .../cpp/transformer/src/transformer_node.cpp | 23 +- .../cpp/transformer/test/transformer_test.cpp | 43 ++- .../python/aggregator/test/test_copyright.py | 23 -- .../python/aggregator/test/test_flake8.py | 25 -- .../python/aggregator/test/test_pep257.py | 23 -- .../python/producer/test/test_copyright.py | 23 -- .../python/producer/test/test_flake8.py | 25 -- .../python/producer/test/test_pep257.py | 23 -- .../python/transformer/test/test_copyright.py | 23 -- .../python/transformer/test/test_flake8.py | 25 -- .../python/transformer/test/test_pep257.py | 23 -- src/world_modeling/hd_map/CMakeLists.txt | 12 - src/world_modeling/hd_map/package.xml | 2 - .../localization/CMakeLists.txt | 12 - src/world_modeling/localization/package.xml | 2 - .../motion_forecasting/CMakeLists.txt | 12 - .../motion_forecasting/package.xml | 2 - src/world_modeling/occupancy/CMakeLists.txt | 12 - src/world_modeling/occupancy/package.xml | 2 - .../occupancy_segmentation/CMakeLists.txt | 12 - .../occupancy_segmentation/package.xml | 2 - watod-config.sh | 2 +- 79 files changed, 501 insertions(+), 831 deletions(-) create mode 100644 .clang-format create mode 100644 .github/workflows/linting_auto.yml create mode 100644 .github/workflows/linting_check.yml delete mode 100755 src/perception/camera_object_detection/test/test_copyright.py delete mode 100755 src/perception/camera_object_detection/test/test_flake8.py delete mode 100755 src/samples/python/aggregator/test/test_copyright.py delete mode 100755 src/samples/python/aggregator/test/test_flake8.py delete mode 100755 src/samples/python/aggregator/test/test_pep257.py delete mode 100755 src/samples/python/producer/test/test_copyright.py delete mode 100755 src/samples/python/producer/test/test_flake8.py delete mode 100755 src/samples/python/producer/test/test_pep257.py delete mode 100755 src/samples/python/transformer/test/test_copyright.py delete mode 100755 src/samples/python/transformer/test/test_flake8.py delete mode 100755 src/samples/python/transformer/test/test_pep257.py diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..1eec1fe8 --- /dev/null +++ b/.clang-format @@ -0,0 +1,270 @@ +--- +Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseColons: false +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +AttributeMacros: + - __capability +BinPackArguments: true +BinPackParameters: true +BitFieldColonSpacing: Both +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterExternBlock: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAfterAttributes: Never +BreakAfterJavaFieldAnnotations: false +BreakArrays: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Attach +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +ColumnLimit: 100 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: true +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^<.*\.h>' + Priority: 1 + SortPriority: 0 + CaseSensitive: false + - Regex: '^<.*' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 3 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '([-_](test|unittest))?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: true +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: None +IndentRequiresClause: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +KeepEmptyLinesAtEOF: false +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PackConstructorInitializers: NextLine +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +PPIndentWidth: -1 +QualifierAlignment: Leave +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + - ParseTestProto + - ParsePartialTestProto + CanonicalDelimiter: pb + BasedOnStyle: google +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SortIncludes: CaseSensitive +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: Auto +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE +... + diff --git a/.github/workflows/linting_auto.yml b/.github/workflows/linting_auto.yml new file mode 100644 index 00000000..4948e14b --- /dev/null +++ b/.github/workflows/linting_auto.yml @@ -0,0 +1,38 @@ +name: Monorepo Code Linting - Auto Linter + +on: + push: + branches: + - main + pull_request: + types: + - labeled + +jobs: + run-linters: + name: Run C++/Python linters + runs-on: ubuntu-latest + + steps: + - name: Check out Git repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + + - name: Install Python dependencies + run: pip install autopep8 clang-format + + - name: Run linters, make changes + uses: WATonomous/wato-lint-action@v1 + with: + git_name: WATonomousAdmin + git_email: admin@watonomous.ca + auto_fix: ${{ contains(github.event.pull_request.labels.*.name, 'auto-lint') }} + Autopep8: true + Autopep8_args: "--max-line-length 100" + clang_format: true + clang_format_auto_fix: ${{ contains(github.event.pull_request.labels.*.name, 'auto-lint') }} + clang_format_args: "-style=file" diff --git a/.github/workflows/linting_check.yml b/.github/workflows/linting_check.yml new file mode 100644 index 00000000..aef1335f --- /dev/null +++ b/.github/workflows/linting_check.yml @@ -0,0 +1,34 @@ +name: Monorepo Code Linting - Checker + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + run-linters: + name: Run C++/Python linters + runs-on: ubuntu-latest + + steps: + - name: Check out Git repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + + - name: Install Python dependencies + run: pip install autopep8 clang-format + + - name: Run linters + uses: WATonomous/wato-lint-action@v1 + with: + Autopep8: true + Autopep8_args: "--max-line-length 100" + clang_format: true + clang_format_args: "-style=file" diff --git a/src/action/behaviour_planning/CMakeLists.txt b/src/action/behaviour_planning/CMakeLists.txt index 1c2ea316..f1492fcf 100644 --- a/src/action/behaviour_planning/CMakeLists.txt +++ b/src/action/behaviour_planning/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/action/behaviour_planning/package.xml b/src/action/behaviour_planning/package.xml index f5a64c22..e0245197 100644 --- a/src/action/behaviour_planning/package.xml +++ b/src/action/behaviour_planning/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/action/global_planning/CMakeLists.txt b/src/action/global_planning/CMakeLists.txt index 63902385..f4ac54b8 100644 --- a/src/action/global_planning/CMakeLists.txt +++ b/src/action/global_planning/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/action/global_planning/package.xml b/src/action/global_planning/package.xml index 05117ffe..375d711a 100644 --- a/src/action/global_planning/package.xml +++ b/src/action/global_planning/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/action/local_planning/CMakeLists.txt b/src/action/local_planning/CMakeLists.txt index 2674291e..52c97525 100644 --- a/src/action/local_planning/CMakeLists.txt +++ b/src/action/local_planning/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/action/local_planning/package.xml b/src/action/local_planning/package.xml index 15869970..de31dd70 100644 --- a/src/action/local_planning/package.xml +++ b/src/action/local_planning/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/action/model_predictive_control/CMakeLists.txt b/src/action/model_predictive_control/CMakeLists.txt index 19cf3a5c..de05ad62 100644 --- a/src/action/model_predictive_control/CMakeLists.txt +++ b/src/action/model_predictive_control/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/action/model_predictive_control/package.xml b/src/action/model_predictive_control/package.xml index 200ee3c9..a855111e 100644 --- a/src/action/model_predictive_control/package.xml +++ b/src/action/model_predictive_control/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/interfacing/can_interfacing/CMakeLists.txt b/src/interfacing/can_interfacing/CMakeLists.txt index 1b600061..7b07ded4 100644 --- a/src/interfacing/can_interfacing/CMakeLists.txt +++ b/src/interfacing/can_interfacing/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/interfacing/can_interfacing/package.xml b/src/interfacing/can_interfacing/package.xml index be74ad1c..9abb194e 100644 --- a/src/interfacing/can_interfacing/package.xml +++ b/src/interfacing/can_interfacing/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/interfacing/sensor_interfacing/CMakeLists.txt b/src/interfacing/sensor_interfacing/CMakeLists.txt index 7b970c2d..d5acd83d 100644 --- a/src/interfacing/sensor_interfacing/CMakeLists.txt +++ b/src/interfacing/sensor_interfacing/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/interfacing/sensor_interfacing/package.xml b/src/interfacing/sensor_interfacing/package.xml index 1134df16..4fecd9f5 100644 --- a/src/interfacing/sensor_interfacing/package.xml +++ b/src/interfacing/sensor_interfacing/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/perception/camera_object_detection/test/test_copyright.py b/src/perception/camera_object_detection/test/test_copyright.py deleted file mode 100755 index 97a39196..00000000 --- a/src/perception/camera_object_detection/test/test_copyright.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, 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. - -from ament_copyright.main import main -import pytest - - -# Remove the `skip` decorator once the source file(s) have a copyright header -@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.') -@pytest.mark.copyright -@pytest.mark.linter -def test_copyright(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found errors' diff --git a/src/perception/camera_object_detection/test/test_flake8.py b/src/perception/camera_object_detection/test/test_flake8.py deleted file mode 100755 index 27ee1078..00000000 --- a/src/perception/camera_object_detection/test/test_flake8.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2017 Open Source Robotics Foundation, 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. - -from ament_flake8.main import main_with_errors -import pytest - - -@pytest.mark.flake8 -@pytest.mark.linter -def test_flake8(): - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ - '\n'.join(errors) diff --git a/src/perception/lane_detection/CMakeLists.txt b/src/perception/lane_detection/CMakeLists.txt index 7b6550cf..b3cfae5d 100644 --- a/src/perception/lane_detection/CMakeLists.txt +++ b/src/perception/lane_detection/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/perception/lane_detection/package.xml b/src/perception/lane_detection/package.xml index 230486dd..90308912 100644 --- a/src/perception/lane_detection/package.xml +++ b/src/perception/lane_detection/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/perception/lidar_object_detection/CMakeLists.txt b/src/perception/lidar_object_detection/CMakeLists.txt index e5e82c44..3a5b0750 100644 --- a/src/perception/lidar_object_detection/CMakeLists.txt +++ b/src/perception/lidar_object_detection/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/perception/lidar_object_detection/package.xml b/src/perception/lidar_object_detection/package.xml index 83c42a2c..5dc0a5df 100644 --- a/src/perception/lidar_object_detection/package.xml +++ b/src/perception/lidar_object_detection/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/perception/radar_object_detection/radar_object_detection_launch/CMakeLists.txt b/src/perception/radar_object_detection/radar_object_detection_launch/CMakeLists.txt index a41331fc..50905aa9 100644 --- a/src/perception/radar_object_detection/radar_object_detection_launch/CMakeLists.txt +++ b/src/perception/radar_object_detection/radar_object_detection_launch/CMakeLists.txt @@ -11,12 +11,6 @@ endif() find_package(ament_cmake REQUIRED) -option(BUILD_TESTING "Build tests" ON) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - ament_lint_auto_find_test_dependencies() -endif() - install(DIRECTORY launch DESTINATION share/${PROJECT_NAME}) diff --git a/src/perception/radar_object_detection/radar_object_detection_launch/package.xml b/src/perception/radar_object_detection/radar_object_detection_launch/package.xml index 85d080b8..f4921d4f 100644 --- a/src/perception/radar_object_detection/radar_object_detection_launch/package.xml +++ b/src/perception/radar_object_detection/radar_object_detection_launch/package.xml @@ -10,8 +10,6 @@ ament_cmake radar_vis - ament_lint_auto - ament_cmake diff --git a/src/perception/radar_object_detection/radar_vis/CMakeLists.txt b/src/perception/radar_object_detection/radar_vis/CMakeLists.txt index 0edaf3f2..adae2738 100644 --- a/src/perception/radar_object_detection/radar_vis/CMakeLists.txt +++ b/src/perception/radar_object_detection/radar_vis/CMakeLists.txt @@ -26,16 +26,6 @@ option(BUILD_TESTING "Build tests" ON) if(BUILD_TESTING) find_package(ament_cmake_gtest REQUIRED) - find_package(ament_lint_auto REQUIRED) - find_package(ament_lint_common REQUIRED) - - list(APPEND AMENT_LINT_AUTO_EXCLUDE - ament_cmake_cpplint - ament_cmake_copyright) - - ament_cpplint(FILTERS "-legal/copyright") - - ament_lint_auto_find_test_dependencies() ament_add_gtest(radar_vis_test test/radar_vis_test.cpp) diff --git a/src/perception/radar_object_detection/radar_vis/include/radar_vis.hpp b/src/perception/radar_object_detection/radar_vis/include/radar_vis.hpp index 49b800b2..3e183384 100644 --- a/src/perception/radar_object_detection/radar_vis/include/radar_vis.hpp +++ b/src/perception/radar_object_detection/radar_vis/include/radar_vis.hpp @@ -6,19 +6,17 @@ #include "sensor_msgs/msg/point_cloud2.hpp" #include "sensor_msgs/msg/point_field.hpp" -#include "radar_msgs/msg/radar_packet.hpp" #include "radar_msgs/msg/radar_detection.hpp" +#include "radar_msgs/msg/radar_packet.hpp" -namespace visualization -{ +namespace visualization { -class RadarVis -{ -public: +class RadarVis { + public: RadarVis(); sensor_msgs::msg::PointCloud2 convert_packet_to_pointcloud( - const radar_msgs::msg::RadarPacket::SharedPtr msg); + const radar_msgs::msg::RadarPacket::SharedPtr msg); }; } // namespace visualization diff --git a/src/perception/radar_object_detection/radar_vis/include/radar_vis_node.hpp b/src/perception/radar_object_detection/radar_vis/include/radar_vis_node.hpp index 3ccd8fbf..6d34ce4c 100644 --- a/src/perception/radar_object_detection/radar_vis/include/radar_vis_node.hpp +++ b/src/perception/radar_object_detection/radar_vis/include/radar_vis_node.hpp @@ -5,30 +5,28 @@ #include "sensor_msgs/msg/point_cloud2.hpp" #include "sensor_msgs/msg/point_field.hpp" -#include "radar_msgs/msg/radar_packet.hpp" #include "radar_msgs/msg/radar_detection.hpp" +#include "radar_msgs/msg/radar_packet.hpp" #include "radar_vis.hpp" /** -* @brief Implementation of a Radar visualization node that listens to "processed" topic -*/ -class RadarVisNode : public rclcpp::Node -{ -public: + * @brief Implementation of a Radar visualization node that listens to "processed" topic + */ +class RadarVisNode : public rclcpp::Node { + public: RadarVisNode(); /** - * @brief A ROS2 subscription node callback used to unpack filtered radar data from the "processed" - * topic. The callback listens to radar packets on this topic and processes them - * in order to visualize them in tools like foxglove and RViz. - * - * @param msg a raw message from the "processed" topic - */ - void process_radar_data_callback( - const radar_msgs::msg::RadarPacket::SharedPtr msg); - -private: + * @brief A ROS2 subscription node callback used to unpack filtered radar data from the + * "processed" topic. The callback listens to radar packets on this topic and processes them in + * order to visualize them in tools like foxglove and RViz. + * + * @param msg a raw message from the "processed" topic + */ + void process_radar_data_callback(const radar_msgs::msg::RadarPacket::SharedPtr msg); + + private: // ROS2 Subscriber listening to "processed" topic. rclcpp::Subscription::SharedPtr raw_sub_; diff --git a/src/perception/radar_object_detection/radar_vis/package.xml b/src/perception/radar_object_detection/radar_vis/package.xml index 2a057a23..de80cb3b 100644 --- a/src/perception/radar_object_detection/radar_vis/package.xml +++ b/src/perception/radar_object_detection/radar_vis/package.xml @@ -12,8 +12,6 @@ radar_msgs sensor_msgs - ament_lint_auto - ament_lint_common ament_cmake_gtest diff --git a/src/perception/radar_object_detection/radar_vis/src/radar_vis.cpp b/src/perception/radar_object_detection/radar_vis/src/radar_vis.cpp index 62177b2a..bd4dedf5 100644 --- a/src/perception/radar_object_detection/radar_vis/src/radar_vis.cpp +++ b/src/perception/radar_object_detection/radar_vis/src/radar_vis.cpp @@ -2,18 +2,15 @@ #include "rclcpp/rclcpp.hpp" -#include "radar_vis_node.hpp" #include "radar_vis.hpp" +#include "radar_vis_node.hpp" -namespace visualization -{ +namespace visualization { -RadarVis::RadarVis() -{} +RadarVis::RadarVis() {} sensor_msgs::msg::PointCloud2 RadarVis::convert_packet_to_pointcloud( - const radar_msgs::msg::RadarPacket::SharedPtr msg) -{ + const radar_msgs::msg::RadarPacket::SharedPtr msg) { std::string radar_frame = "radar_fixed"; sensor_msgs::msg::PointCloud2 point_cloud; sensor_msgs::msg::PointField point_field; @@ -50,7 +47,7 @@ sensor_msgs::msg::PointCloud2 RadarVis::convert_packet_to_pointcloud( point_cloud.fields.push_back(point_field); // Convert data to 4 bytes (little endian) - uint8_t * tmp_ptr; + uint8_t *tmp_ptr; for (uint8_t index = 0; index < msg->detections.size(); index++) { // Position X - Point Cloud Conversion tmp_ptr = reinterpret_cast(&(msg->detections[index].pos_x)); diff --git a/src/perception/radar_object_detection/radar_vis/src/radar_vis_node.cpp b/src/perception/radar_object_detection/radar_vis/src/radar_vis_node.cpp index 9289d01d..2d100976 100644 --- a/src/perception/radar_object_detection/radar_vis/src/radar_vis_node.cpp +++ b/src/perception/radar_object_detection/radar_vis/src/radar_vis_node.cpp @@ -1,29 +1,22 @@ #include -#include "radar_vis_node.hpp" #include "radar_vis.hpp" +#include "radar_vis_node.hpp" -RadarVisNode::RadarVisNode() -: Node("radar_vis") -{ +RadarVisNode::RadarVisNode() : Node("radar_vis") { raw_sub_ = this->create_subscription( - "processed", - 1, std::bind( - &RadarVisNode::process_radar_data_callback, - this, std::placeholders::_1)); + "processed", 1, + std::bind(&RadarVisNode::process_radar_data_callback, this, std::placeholders::_1)); raw_pub_ = this->create_publisher("visualization", 20); } -void RadarVisNode::process_radar_data_callback( - const radar_msgs::msg::RadarPacket::SharedPtr msg) -{ +void RadarVisNode::process_radar_data_callback(const radar_msgs::msg::RadarPacket::SharedPtr msg) { sensor_msgs::msg::PointCloud2 publish_packet_point_cloud; publish_packet_point_cloud = packet_converter_.convert_packet_to_pointcloud(msg); raw_pub_->publish(publish_packet_point_cloud); } -int main(int argc, char ** argv) -{ +int main(int argc, char** argv) { rclcpp::init(argc, argv); rclcpp::spin(std::make_shared()); rclcpp::shutdown(); diff --git a/src/perception/radar_object_detection/radar_vis/test/radar_vis_test.cpp b/src/perception/radar_object_detection/radar_vis/test/radar_vis_test.cpp index 9530d437..a88dfbc8 100644 --- a/src/perception/radar_object_detection/radar_vis/test/radar_vis_test.cpp +++ b/src/perception/radar_object_detection/radar_vis/test/radar_vis_test.cpp @@ -7,9 +7,7 @@ #include "radar_vis.hpp" #include "radar_vis_node.hpp" - -TEST(RadarVisNodeTest, CheckConvertPacketToPointCloud) -{ +TEST(RadarVisNodeTest, CheckConvertPacketToPointCloud) { visualization::RadarVis test_vis; auto msg = std::make_shared(); radar_msgs::msg::RadarDetection msg_detection; diff --git a/src/perception/semantic_segmentation/CMakeLists.txt b/src/perception/semantic_segmentation/CMakeLists.txt index e4ae980b..01396d95 100644 --- a/src/perception/semantic_segmentation/CMakeLists.txt +++ b/src/perception/semantic_segmentation/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/perception/semantic_segmentation/package.xml b/src/perception/semantic_segmentation/package.xml index c0b8c408..f90d0c8c 100644 --- a/src/perception/semantic_segmentation/package.xml +++ b/src/perception/semantic_segmentation/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/perception/tracking/CMakeLists.txt b/src/perception/tracking/CMakeLists.txt index ba2b8618..ffb74e71 100644 --- a/src/perception/tracking/CMakeLists.txt +++ b/src/perception/tracking/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/perception/tracking/package.xml b/src/perception/tracking/package.xml index 5ee19ef1..bff8967c 100644 --- a/src/perception/tracking/package.xml +++ b/src/perception/tracking/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/perception/traffic_light_detection/CMakeLists.txt b/src/perception/traffic_light_detection/CMakeLists.txt index f281b473..dddf3ded 100644 --- a/src/perception/traffic_light_detection/CMakeLists.txt +++ b/src/perception/traffic_light_detection/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/perception/traffic_light_detection/package.xml b/src/perception/traffic_light_detection/package.xml index ba2e3e5c..1ceb0795 100644 --- a/src/perception/traffic_light_detection/package.xml +++ b/src/perception/traffic_light_detection/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/perception/traffic_sign_detection/CMakeLists.txt b/src/perception/traffic_sign_detection/CMakeLists.txt index dc87ca5c..b968c4cf 100644 --- a/src/perception/traffic_sign_detection/CMakeLists.txt +++ b/src/perception/traffic_sign_detection/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/perception/traffic_sign_detection/package.xml b/src/perception/traffic_sign_detection/package.xml index 12346c2d..48d6de51 100644 --- a/src/perception/traffic_sign_detection/package.xml +++ b/src/perception/traffic_sign_detection/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/samples/cpp/aggregator/CMakeLists.txt b/src/samples/cpp/aggregator/CMakeLists.txt index bc85e072..405ba0ff 100644 --- a/src/samples/cpp/aggregator/CMakeLists.txt +++ b/src/samples/cpp/aggregator/CMakeLists.txt @@ -34,18 +34,6 @@ option(BUILD_TESTING "Build tests" ON) if(BUILD_TESTING) # Search for dependencies required for building tests + linting find_package(ament_cmake_gtest REQUIRED) - find_package(ament_lint_auto REQUIRED) - find_package(ament_lint_common REQUIRED) - - # Remove the default C++ and copyright linter - list(APPEND AMENT_LINT_AUTO_EXCLUDE - ament_cmake_cpplint - ament_cmake_copyright) - - # Reinstall cpplint ignoring copyright errors - ament_cpplint(FILTERS "-legal/copyright") - - ament_lint_auto_find_test_dependencies() # Create test executable from source files ament_add_gtest(aggregator_test test/aggregator_test.cpp) diff --git a/src/samples/cpp/aggregator/include/aggregator_core.hpp b/src/samples/cpp/aggregator/include/aggregator_core.hpp index 7912f7df..830f724c 100644 --- a/src/samples/cpp/aggregator/include/aggregator_core.hpp +++ b/src/samples/cpp/aggregator/include/aggregator_core.hpp @@ -3,19 +3,17 @@ #include "rclcpp/rclcpp.hpp" -#include "sample_msgs/msg/unfiltered.hpp" #include "sample_msgs/msg/filtered_array.hpp" +#include "sample_msgs/msg/unfiltered.hpp" -namespace samples -{ +namespace samples { /** * Implementation of the internal logic used by the Aggregator Node to * calculate the operating frequency of topics. */ -class AggregatorCore -{ -public: +class AggregatorCore { + public: /** * Aggregator constructor. * @@ -44,18 +42,16 @@ class AggregatorCore * * @param msg */ - void add_raw_msg( - const sample_msgs::msg::Unfiltered::SharedPtr msg); + void add_raw_msg(const sample_msgs::msg::Unfiltered::SharedPtr msg); /** * Used to keep track of latest timestamp and number of messages received * over the "filtered" topic. Should be called before filtered_frequency(). * * @param msg */ - void add_filtered_msg( - const sample_msgs::msg::FilteredArray::SharedPtr msg); + void add_filtered_msg(const sample_msgs::msg::FilteredArray::SharedPtr msg); -private: + private: // Number of message received on "unfiltered" and "filtered" topics. int raw_msg_count_; int filtered_msg_count_; diff --git a/src/samples/cpp/aggregator/include/aggregator_node.hpp b/src/samples/cpp/aggregator/include/aggregator_node.hpp index 0255fed3..a528c7fa 100644 --- a/src/samples/cpp/aggregator/include/aggregator_node.hpp +++ b/src/samples/cpp/aggregator/include/aggregator_node.hpp @@ -3,8 +3,8 @@ #include "rclcpp/rclcpp.hpp" -#include "sample_msgs/msg/unfiltered.hpp" #include "sample_msgs/msg/filtered_array.hpp" +#include "sample_msgs/msg/unfiltered.hpp" #include "aggregator_core.hpp" @@ -12,9 +12,8 @@ * Implementation of a ROS2 node that listens to the "unfiltered" and "filtered" * topics and echoes the operating frequency of the topic to the console. */ -class AggregatorNode : public rclcpp::Node -{ -public: +class AggregatorNode : public rclcpp::Node { + public: // Configure pubsub nodes to keep last 20 messages. // https://docs.ros.org/en/foxy/Concepts/About-Quality-of-Service-Settings.html static constexpr int ADVERTISING_FREQ = 20; @@ -24,15 +23,14 @@ class AggregatorNode : public rclcpp::Node */ AggregatorNode(); -private: + private: /** * A ROS2 subscription node callback used to unpack raw data from the "unfiltered" * topic and echo the operating frequency of the topic to the console. * * @param msg a raw message from the "unfiltered" topic */ - void unfiltered_callback( - const sample_msgs::msg::Unfiltered::SharedPtr msg); + void unfiltered_callback(const sample_msgs::msg::Unfiltered::SharedPtr msg); /** * A ROS2 subscription node callback used to unpack processed data from the @@ -40,8 +38,7 @@ class AggregatorNode : public rclcpp::Node * * @param msg a processed message from the "filtered" topic */ - void filtered_callback( - const sample_msgs::msg::FilteredArray::SharedPtr msg); + void filtered_callback(const sample_msgs::msg::FilteredArray::SharedPtr msg); // ROS2 subscriber listening to the unfiltered topic. rclcpp::Subscription::SharedPtr raw_sub_; diff --git a/src/samples/cpp/aggregator/package.xml b/src/samples/cpp/aggregator/package.xml index 156c9064..978b8247 100644 --- a/src/samples/cpp/aggregator/package.xml +++ b/src/samples/cpp/aggregator/package.xml @@ -12,8 +12,6 @@ rclcpp sample_msgs - ament_lint_auto - ament_lint_common ament_cmake_gtest diff --git a/src/samples/cpp/aggregator/src/aggregator_core.cpp b/src/samples/cpp/aggregator/src/aggregator_core.cpp index 4cfb8ea1..eacec029 100644 --- a/src/samples/cpp/aggregator/src/aggregator_core.cpp +++ b/src/samples/cpp/aggregator/src/aggregator_core.cpp @@ -2,44 +2,38 @@ #include "aggregator_core.hpp" -namespace samples -{ +namespace samples { AggregatorCore::AggregatorCore(int64_t timestamp) -: raw_msg_count_(0), filtered_msg_count_(0), start_(timestamp), - latest_raw_time_(-1), latest_filtered_time_(-1) -{} + : raw_msg_count_(0), + filtered_msg_count_(0), + start_(timestamp), + latest_raw_time_(-1), + latest_filtered_time_(-1) {} -double AggregatorCore::raw_frequency() const -{ +double AggregatorCore::raw_frequency() const { if (latest_raw_time_ <= start_) { return 0.0; } return static_cast(raw_msg_count_) / (latest_raw_time_ - start_); } -double AggregatorCore::filtered_frequency() const -{ +double AggregatorCore::filtered_frequency() const { if (latest_filtered_time_ <= start_) { return 0.0; } return static_cast(filtered_msg_count_) / (latest_filtered_time_ - start_); } -void AggregatorCore::add_raw_msg( - const sample_msgs::msg::Unfiltered::SharedPtr msg) -{ - latest_raw_time_ = std::max( - static_cast(msg->timestamp), latest_raw_time_); +void AggregatorCore::add_raw_msg(const sample_msgs::msg::Unfiltered::SharedPtr msg) { + latest_raw_time_ = std::max(static_cast(msg->timestamp), latest_raw_time_); raw_msg_count_++; } -void AggregatorCore::add_filtered_msg( - const sample_msgs::msg::FilteredArray::SharedPtr msg) -{ +void AggregatorCore::add_filtered_msg(const sample_msgs::msg::FilteredArray::SharedPtr msg) { for (auto filtered_msg : msg->packets) { - latest_filtered_time_ = std::max( - static_cast(filtered_msg.timestamp), latest_filtered_time_); + latest_filtered_time_ = + std::max(static_cast(filtered_msg.timestamp), latest_filtered_time_); } filtered_msg_count_++; } diff --git a/src/samples/cpp/aggregator/src/aggregator_node.cpp b/src/samples/cpp/aggregator/src/aggregator_node.cpp index 679e3aff..3341d99e 100644 --- a/src/samples/cpp/aggregator/src/aggregator_node.cpp +++ b/src/samples/cpp/aggregator/src/aggregator_node.cpp @@ -4,44 +4,30 @@ #include "aggregator_node.hpp" AggregatorNode::AggregatorNode() -: Node("aggregator"), - aggregator_( - samples::AggregatorCore( - std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()).count())) -{ + : Node("aggregator"), + aggregator_(samples::AggregatorCore(std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count())) { raw_sub_ = this->create_subscription( - "/unfiltered_topic", ADVERTISING_FREQ, - std::bind( - &AggregatorNode::unfiltered_callback, this, - std::placeholders::_1)); + "/unfiltered_topic", ADVERTISING_FREQ, + std::bind(&AggregatorNode::unfiltered_callback, this, std::placeholders::_1)); filtered_sub_ = this->create_subscription( - "/filtered_topic", ADVERTISING_FREQ, - std::bind( - &AggregatorNode::filtered_callback, this, - std::placeholders::_1)); + "/filtered_topic", ADVERTISING_FREQ, + std::bind(&AggregatorNode::filtered_callback, this, std::placeholders::_1)); } -void AggregatorNode::unfiltered_callback( - const sample_msgs::msg::Unfiltered::SharedPtr msg) -{ +void AggregatorNode::unfiltered_callback(const sample_msgs::msg::Unfiltered::SharedPtr msg) { aggregator_.add_raw_msg(msg); - RCLCPP_INFO( - this->get_logger(), "Raw Frequency(msg/s): %f", - aggregator_.raw_frequency() * 1000); + RCLCPP_INFO(this->get_logger(), "Raw Frequency(msg/s): %f", aggregator_.raw_frequency() * 1000); } -void AggregatorNode::filtered_callback( - const sample_msgs::msg::FilteredArray::SharedPtr msg) -{ +void AggregatorNode::filtered_callback(const sample_msgs::msg::FilteredArray::SharedPtr msg) { aggregator_.add_filtered_msg(msg); - RCLCPP_INFO( - this->get_logger(), "Filtered Frequency(msg/s): %f", - aggregator_.filtered_frequency() * 1000); + RCLCPP_INFO(this->get_logger(), "Filtered Frequency(msg/s): %f", + aggregator_.filtered_frequency() * 1000); } -int main(int argc, char ** argv) -{ +int main(int argc, char** argv) { rclcpp::init(argc, argv); rclcpp::spin(std::make_shared()); rclcpp::shutdown(); diff --git a/src/samples/cpp/aggregator/test/aggregator_test.cpp b/src/samples/cpp/aggregator/test/aggregator_test.cpp index a7add4bc..627b9416 100644 --- a/src/samples/cpp/aggregator/test/aggregator_test.cpp +++ b/src/samples/cpp/aggregator/test/aggregator_test.cpp @@ -6,8 +6,7 @@ #include "aggregator_core.hpp" -TEST(AggregatorTest, RawDivisionByZero) -{ +TEST(AggregatorTest, RawDivisionByZero) { samples::AggregatorCore aggregator(0); auto msg = std::make_shared(); msg->timestamp = 0; @@ -16,8 +15,7 @@ TEST(AggregatorTest, RawDivisionByZero) EXPECT_DOUBLE_EQ(0.0, aggregator.raw_frequency()); } -TEST(AggregatorTest, FilteredDivisionByZero) -{ +TEST(AggregatorTest, FilteredDivisionByZero) { samples::AggregatorCore aggregator(1); auto filtered_packet = std::make_shared(); std::vector msgs; @@ -30,8 +28,7 @@ TEST(AggregatorTest, FilteredDivisionByZero) EXPECT_DOUBLE_EQ(0.0, aggregator.filtered_frequency()); } -TEST(AggregatorTest, RawFrequencyAddSingleMessage) -{ +TEST(AggregatorTest, RawFrequencyAddSingleMessage) { samples::AggregatorCore aggregator(0); auto msg = std::make_shared(); @@ -40,8 +37,7 @@ TEST(AggregatorTest, RawFrequencyAddSingleMessage) EXPECT_DOUBLE_EQ(0.5, aggregator.raw_frequency()); } -TEST(AggregatorTest, RawFrequencyAddMultipleMessages) -{ +TEST(AggregatorTest, RawFrequencyAddMultipleMessages) { samples::AggregatorCore aggregator(0); auto msg = std::make_shared(); @@ -58,8 +54,7 @@ TEST(AggregatorTest, RawFrequencyAddMultipleMessages) EXPECT_DOUBLE_EQ(0.6, aggregator.raw_frequency()); } -TEST(AggregatorTest, FilteredUnorderedTimestamps) -{ +TEST(AggregatorTest, FilteredUnorderedTimestamps) { samples::AggregatorCore aggregator(0); auto filtered_packet = std::make_shared(); std::vector msgs; diff --git a/src/samples/cpp/producer/CMakeLists.txt b/src/samples/cpp/producer/CMakeLists.txt index 32536074..25b6c402 100644 --- a/src/samples/cpp/producer/CMakeLists.txt +++ b/src/samples/cpp/producer/CMakeLists.txt @@ -34,18 +34,6 @@ option(BUILD_TESTING "Build tests" ON) if(BUILD_TESTING) # Search for dependencies required for building tests + linting find_package(ament_cmake_gtest REQUIRED) - find_package(ament_lint_auto REQUIRED) - find_package(ament_lint_common REQUIRED) - - # Remove the default C++ and copyright linter - list(APPEND AMENT_LINT_AUTO_EXCLUDE - ament_cmake_cpplint - ament_cmake_copyright) - - # Reinstall cpplint ignoring copyright errors - ament_cpplint(FILTERS "-legal/copyright") - - ament_lint_auto_find_test_dependencies() # Create test executable from source files ament_add_gtest(producer_test test/producer_test.cpp) diff --git a/src/samples/cpp/producer/include/producer_core.hpp b/src/samples/cpp/producer/include/producer_core.hpp index 8a126492..76581b87 100644 --- a/src/samples/cpp/producer/include/producer_core.hpp +++ b/src/samples/cpp/producer/include/producer_core.hpp @@ -3,16 +3,14 @@ #include "sample_msgs/msg/unfiltered.hpp" -namespace samples -{ +namespace samples { /** * Implementation of the internal logic used by the Producer Node to * serialize and update coordinates. */ -class ProducerCore -{ -public: +class ProducerCore { + public: /** * Producer constructor. * @@ -51,9 +49,9 @@ class ProducerCore * * @param[out] msg an unfiltered message with empty data field */ - void serialize_coordinates(sample_msgs::msg::Unfiltered & msg) const; + void serialize_coordinates(sample_msgs::msg::Unfiltered& msg) const; -private: + private: // Coordinate values double pos_x_; double pos_y_; diff --git a/src/samples/cpp/producer/include/producer_node.hpp b/src/samples/cpp/producer/include/producer_node.hpp index a52ab959..1361a4d7 100644 --- a/src/samples/cpp/producer/include/producer_node.hpp +++ b/src/samples/cpp/producer/include/producer_node.hpp @@ -3,8 +3,8 @@ #include -#include "rclcpp/rclcpp.hpp" #include "rcl_interfaces/msg/set_parameters_result.hpp" +#include "rclcpp/rclcpp.hpp" #include "sample_msgs/msg/unfiltered.hpp" @@ -14,9 +14,8 @@ * Implementation of a ROS2 node that generates unfiltered ROS2 messages on a * time interval. */ -class ProducerNode : public rclcpp::Node -{ -public: +class ProducerNode : public rclcpp::Node { + public: // Configure pubsub nodes to keep last 20 messages. // https://docs.ros.org/en/foxy/Concepts/About-Quality-of-Service-Settings.html static constexpr int ADVERTISING_FREQ = 20; @@ -28,7 +27,7 @@ class ProducerNode : public rclcpp::Node */ explicit ProducerNode(int delay_ms); -private: + private: /** * ROS timer callback used to trigger data generation and publish result * to the "unfiltered" topic. @@ -42,7 +41,7 @@ class ProducerNode : public rclcpp::Node * @returns status message indicating whether update was successful */ rcl_interfaces::msg::SetParametersResult parameters_callback( - const std::vector & parameters); + const std::vector& parameters); // ROS2 publisher sending raw messages to the unfiltered topic. rclcpp::Publisher::SharedPtr data_pub_; diff --git a/src/samples/cpp/producer/package.xml b/src/samples/cpp/producer/package.xml index ec55d4de..5575724c 100644 --- a/src/samples/cpp/producer/package.xml +++ b/src/samples/cpp/producer/package.xml @@ -12,8 +12,6 @@ rclcpp sample_msgs - ament_lint_auto - ament_lint_common ament_cmake_gtest diff --git a/src/samples/cpp/producer/src/producer_core.cpp b/src/samples/cpp/producer/src/producer_core.cpp index ffa27d7e..851791ed 100644 --- a/src/samples/cpp/producer/src/producer_core.cpp +++ b/src/samples/cpp/producer/src/producer_core.cpp @@ -3,37 +3,28 @@ #include "producer_core.hpp" -namespace samples -{ +namespace samples { ProducerCore::ProducerCore(float x, float y, float z) -: pos_x_(x), pos_y_(y), pos_z_(z), velocity_(0) -{ -} + : pos_x_(x), pos_y_(y), pos_z_(z), velocity_(0) {} -void ProducerCore::update_velocity(int velocity) -{ - velocity_ = velocity; -} +void ProducerCore::update_velocity(int velocity) { velocity_ = velocity; } -void ProducerCore::update_position(double pos_x, double pos_y, double pos_z) -{ +void ProducerCore::update_position(double pos_x, double pos_y, double pos_z) { pos_x_ = pos_x; pos_y_ = pos_y; pos_z_ = pos_z; } -void ProducerCore::update_coordinates() -{ +void ProducerCore::update_coordinates() { pos_x_ += velocity_ / sqrt(3); pos_y_ += velocity_ / sqrt(3); pos_z_ += velocity_ / sqrt(3); } -void ProducerCore::serialize_coordinates(sample_msgs::msg::Unfiltered & msg) const -{ +void ProducerCore::serialize_coordinates(sample_msgs::msg::Unfiltered& msg) const { msg.data = "x:" + std::to_string(pos_x_) + ";y:" + std::to_string(pos_y_) + - ";z:" + std::to_string(pos_z_) + ";"; + ";z:" + std::to_string(pos_z_) + ";"; msg.valid = true; } diff --git a/src/samples/cpp/producer/src/producer_node.cpp b/src/samples/cpp/producer/src/producer_node.cpp index b313eca6..73e5bf51 100644 --- a/src/samples/cpp/producer/src/producer_node.cpp +++ b/src/samples/cpp/producer/src/producer_node.cpp @@ -4,15 +4,12 @@ #include "producer_node.hpp" -ProducerNode::ProducerNode(int delay_ms) -: Node("producer"), producer_(samples::ProducerCore()) -{ +ProducerNode::ProducerNode(int delay_ms) : Node("producer"), producer_(samples::ProducerCore()) { data_pub_ = - this->create_publisher("/unfiltered_topic", ADVERTISING_FREQ); + this->create_publisher("/unfiltered_topic", ADVERTISING_FREQ); - timer_ = this->create_wall_timer( - std::chrono::milliseconds(delay_ms), - std::bind(&ProducerNode::timer_callback, this)); + timer_ = this->create_wall_timer(std::chrono::milliseconds(delay_ms), + std::bind(&ProducerNode::timer_callback, this)); // Define the default values for parameters if not defined in params.yaml this->declare_parameter("pos_x", 0.0); @@ -29,16 +26,16 @@ ProducerNode::ProducerNode(int delay_ms) producer_.update_velocity(velocity.as_double()); param_cb_ = this->add_on_set_parameters_callback( - std::bind(&ProducerNode::parameters_callback, this, std::placeholders::_1)); + std::bind(&ProducerNode::parameters_callback, this, std::placeholders::_1)); } -void ProducerNode::timer_callback() -{ +void ProducerNode::timer_callback() { producer_.update_coordinates(); auto msg = sample_msgs::msg::Unfiltered(); msg.timestamp = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()).count(); + std::chrono::system_clock::now().time_since_epoch()) + .count(); producer_.serialize_coordinates(msg); RCLCPP_INFO(this->get_logger(), "Publishing: %s", msg.data.c_str()); @@ -46,16 +43,14 @@ void ProducerNode::timer_callback() } rcl_interfaces::msg::SetParametersResult ProducerNode::parameters_callback( - const std::vector & parameters) -{ + const std::vector& parameters) { rcl_interfaces::msg::SetParametersResult result; result.successful = false; result.reason = ""; - for (const auto & parameter : parameters) { + for (const auto& parameter : parameters) { if (parameter.get_name() == "velocity" && - parameter.get_type() == rclcpp::ParameterType::PARAMETER_INTEGER) - { + parameter.get_type() == rclcpp::ParameterType::PARAMETER_INTEGER) { producer_.update_velocity(parameter.as_int()); RCLCPP_INFO(this->get_logger(), "Velocity successfully set to %d", parameter.as_int()); result.successful = true; @@ -64,8 +59,7 @@ rcl_interfaces::msg::SetParametersResult ProducerNode::parameters_callback( return result; } -int main(int argc, char ** argv) -{ +int main(int argc, char** argv) { rclcpp::init(argc, argv); rclcpp::spin(std::make_shared(500)); rclcpp::shutdown(); diff --git a/src/samples/cpp/producer/test/producer_test.cpp b/src/samples/cpp/producer/test/producer_test.cpp index fd594405..6dac461b 100644 --- a/src/samples/cpp/producer/test/producer_test.cpp +++ b/src/samples/cpp/producer/test/producer_test.cpp @@ -2,8 +2,7 @@ #include "producer_core.hpp" -TEST(ProducerTest, ValidSerialization) -{ +TEST(ProducerTest, ValidSerialization) { auto producer = samples::ProducerCore(11, -12, 0); auto msg = sample_msgs::msg::Unfiltered(); producer.serialize_coordinates(msg); @@ -12,8 +11,7 @@ TEST(ProducerTest, ValidSerialization) EXPECT_EQ(msg.data, "x:11.000000;y:-12.000000;z:0.000000;"); } -TEST(ProducerTest, NoCoordinateUpdate) -{ +TEST(ProducerTest, NoCoordinateUpdate) { auto producer = samples::ProducerCore(); producer.update_coordinates(); @@ -22,8 +20,7 @@ TEST(ProducerTest, NoCoordinateUpdate) EXPECT_EQ(msg.data, "x:0.000000;y:0.000000;z:0.000000;"); } -TEST(ProducerTest, MultipleCoordinateUpdate) -{ +TEST(ProducerTest, MultipleCoordinateUpdate) { auto producer = samples::ProducerCore(); auto msg = sample_msgs::msg::Unfiltered(); diff --git a/src/samples/cpp/transformer/CMakeLists.txt b/src/samples/cpp/transformer/CMakeLists.txt index c8ea13a6..0e3e5fc6 100644 --- a/src/samples/cpp/transformer/CMakeLists.txt +++ b/src/samples/cpp/transformer/CMakeLists.txt @@ -37,18 +37,6 @@ option(BUILD_TESTING "Build tests" ON) if(BUILD_TESTING) # Search for dependencies required for building tests + linting find_package(ament_cmake_gtest REQUIRED) - find_package(ament_lint_auto REQUIRED) - find_package(ament_lint_common REQUIRED) - - # Remove the default C++ and copyright linter - list(APPEND AMENT_LINT_AUTO_EXCLUDE - ament_cmake_cpplint - ament_cmake_copyright) - - # Reinstall cpplint ignoring copyright errors - ament_cpplint(FILTERS "-legal/copyright") - - ament_lint_auto_find_test_dependencies() # Create test executable from source files ament_add_gtest(transformer_test test/transformer_test.cpp) diff --git a/src/samples/cpp/transformer/include/transformer_core.hpp b/src/samples/cpp/transformer/include/transformer_core.hpp index 8bb2d387..300ca850 100644 --- a/src/samples/cpp/transformer/include/transformer_core.hpp +++ b/src/samples/cpp/transformer/include/transformer_core.hpp @@ -3,23 +3,21 @@ #include -#include "sample_msgs/msg/unfiltered.hpp" #include "sample_msgs/msg/filtered.hpp" +#include "sample_msgs/msg/unfiltered.hpp" -namespace samples -{ +namespace samples { /** * Implementation for the internal logic for the Transformer ROS2 * node performing data processing and validation. */ -class TransformerCore -{ -public: +class TransformerCore { + public: // Size of buffer before processed messages are published. static constexpr int BUFFER_CAPACITY = 10; -public: + public: /** * Transformer constructor. */ @@ -45,8 +43,7 @@ class TransformerCore * @param unfiltered a raw message * @returns whether message's 'valid' field is set */ - bool validate_message( - const sample_msgs::msg::Unfiltered::SharedPtr unfiltered); + bool validate_message(const sample_msgs::msg::Unfiltered::SharedPtr unfiltered); /** * Enqueue message into an array of processed messages to "filtered" topic. @@ -55,7 +52,7 @@ class TransformerCore * @param msg a processed message to be published * @returns whether buffer is full after adding new message */ - bool enqueue_message(const sample_msgs::msg::Filtered & msg); + bool enqueue_message(const sample_msgs::msg::Filtered& msg); /** * Deserializes the data field of the unfiltered ROS2 message. @@ -65,11 +62,10 @@ class TransformerCore * @param[out] filtered the processed message containing deserialized data * @returns whether deserialization was successful */ - bool deserialize_coordinate( - const sample_msgs::msg::Unfiltered::SharedPtr unfiltered, - sample_msgs::msg::Filtered & filtered); + bool deserialize_coordinate(const sample_msgs::msg::Unfiltered::SharedPtr unfiltered, + sample_msgs::msg::Filtered& filtered); -private: + private: // Buffer storing processed messages until BUFFER_CAPACITY. Clear after // messages are published. std::vector buffer_; diff --git a/src/samples/cpp/transformer/include/transformer_node.hpp b/src/samples/cpp/transformer/include/transformer_node.hpp index ffda282c..5dce7b23 100644 --- a/src/samples/cpp/transformer/include/transformer_node.hpp +++ b/src/samples/cpp/transformer/include/transformer_node.hpp @@ -17,9 +17,8 @@ * and odd timestamps. Once the node collects BUFFER_CAPACITY messages it packs * the processed messages into an array and publishes it to the "filtered" topic. */ -class TransformerNode : public rclcpp::Node -{ -public: +class TransformerNode : public rclcpp::Node { + public: // Configure pubsub nodes to keep last 20 messages. // https://docs.ros.org/en/foxy/Concepts/About-Quality-of-Service-Settings.html static constexpr int ADVERTISING_FREQ = 20; @@ -29,15 +28,14 @@ class TransformerNode : public rclcpp::Node */ TransformerNode(); -private: + private: /** * A ROS2 subscription node callback used to process raw data from the * "unfiltered" topic and publish to the "filtered" topic. * * @param msg a raw message from the "unfiltered" topic */ - void unfiltered_callback( - const sample_msgs::msg::Unfiltered::SharedPtr msg); + void unfiltered_callback(const sample_msgs::msg::Unfiltered::SharedPtr msg); // ROS2 subscriber listening to the unfiltered topic. rclcpp::Subscription::SharedPtr raw_sub_; diff --git a/src/samples/cpp/transformer/package.xml b/src/samples/cpp/transformer/package.xml index 1cb147f6..41a28c0f 100644 --- a/src/samples/cpp/transformer/package.xml +++ b/src/samples/cpp/transformer/package.xml @@ -12,8 +12,6 @@ rclcpp sample_msgs - ament_lint_auto - ament_lint_common ament_cmake_gtest diff --git a/src/samples/cpp/transformer/src/transformer_core.cpp b/src/samples/cpp/transformer/src/transformer_core.cpp index e62d3f96..35c3f015 100644 --- a/src/samples/cpp/transformer/src/transformer_core.cpp +++ b/src/samples/cpp/transformer/src/transformer_core.cpp @@ -3,30 +3,19 @@ #include "transformer_core.hpp" -namespace samples -{ +namespace samples { -TransformerCore::TransformerCore() -{} +TransformerCore::TransformerCore() {} -std::vector TransformerCore::buffer_messages() const -{ - return buffer_; -} +std::vector TransformerCore::buffer_messages() const { return buffer_; } -void TransformerCore::clear_buffer() -{ - buffer_.clear(); -} +void TransformerCore::clear_buffer() { buffer_.clear(); } -bool TransformerCore::validate_message( - const sample_msgs::msg::Unfiltered::SharedPtr unfiltered) -{ +bool TransformerCore::validate_message(const sample_msgs::msg::Unfiltered::SharedPtr unfiltered) { return unfiltered->valid; } -bool TransformerCore::enqueue_message(const sample_msgs::msg::Filtered & msg) -{ +bool TransformerCore::enqueue_message(const sample_msgs::msg::Filtered& msg) { if (buffer_.size() < BUFFER_CAPACITY) { buffer_.push_back(msg); } @@ -34,16 +23,13 @@ bool TransformerCore::enqueue_message(const sample_msgs::msg::Filtered & msg) } bool TransformerCore::deserialize_coordinate( - const sample_msgs::msg::Unfiltered::SharedPtr unfiltered, - sample_msgs::msg::Filtered & filtered) -{ + const sample_msgs::msg::Unfiltered::SharedPtr unfiltered, + sample_msgs::msg::Filtered& filtered) { std::string serialized_position = unfiltered->data; auto start_pos = serialized_position.find("x:"); auto end_pos = serialized_position.find(";"); // Validate that the substrings were found - if (start_pos == std::string::npos || end_pos == std::string::npos || - end_pos < start_pos) - { + if (start_pos == std::string::npos || end_pos == std::string::npos || end_pos < start_pos) { return false; } // Offset index to start of x_pos @@ -53,9 +39,7 @@ bool TransformerCore::deserialize_coordinate( start_pos = serialized_position.find("y:", end_pos + 1); end_pos = serialized_position.find(";", end_pos + 1); - if (start_pos == std::string::npos || end_pos == std::string::npos || - end_pos < start_pos) - { + if (start_pos == std::string::npos || end_pos == std::string::npos || end_pos < start_pos) { return false; } // Offset index to start of y_pos @@ -64,9 +48,7 @@ bool TransformerCore::deserialize_coordinate( start_pos = serialized_position.find("z:", end_pos + 1); end_pos = serialized_position.find(";", end_pos + 1); - if (start_pos == std::string::npos || end_pos == std::string::npos || - end_pos < start_pos) - { + if (start_pos == std::string::npos || end_pos == std::string::npos || end_pos < start_pos) { return false; } // Offset index to start of z_pos diff --git a/src/samples/cpp/transformer/src/transformer_node.cpp b/src/samples/cpp/transformer/src/transformer_node.cpp index 95cada4f..51bd3399 100644 --- a/src/samples/cpp/transformer/src/transformer_node.cpp +++ b/src/samples/cpp/transformer/src/transformer_node.cpp @@ -2,24 +2,19 @@ #include "transformer_node.hpp" -TransformerNode::TransformerNode() -: Node("transformer"), transformer_(samples::TransformerCore()) -{ +TransformerNode::TransformerNode() : Node("transformer"), transformer_(samples::TransformerCore()) { raw_sub_ = this->create_subscription( - "/unfiltered_topic", ADVERTISING_FREQ, - std::bind( - &TransformerNode::unfiltered_callback, this, - std::placeholders::_1)); + "/unfiltered_topic", ADVERTISING_FREQ, + std::bind(&TransformerNode::unfiltered_callback, this, std::placeholders::_1)); transform_pub_ = - this->create_publisher("/filtered_topic", ADVERTISING_FREQ); + this->create_publisher("/filtered_topic", ADVERTISING_FREQ); // Define the default values for parameters if not defined in params.yaml this->declare_parameter("version", rclcpp::ParameterValue(0)); this->declare_parameter("compression_method", rclcpp::ParameterValue(0)); } -void TransformerNode::unfiltered_callback(const sample_msgs::msg::Unfiltered::SharedPtr msg) -{ +void TransformerNode::unfiltered_callback(const sample_msgs::msg::Unfiltered::SharedPtr msg) { if (!transformer_.validate_message(msg)) { return; } @@ -31,8 +26,7 @@ void TransformerNode::unfiltered_callback(const sample_msgs::msg::Unfiltered::Sh filtered.timestamp = msg->timestamp; filtered.metadata.version = this->get_parameter("version").as_int(); - filtered.metadata.compression_method = - this->get_parameter("compression_method").as_int(); + filtered.metadata.compression_method = this->get_parameter("compression_method").as_int(); if (transformer_.enqueue_message(filtered)) { RCLCPP_INFO(this->get_logger(), "Buffer Capacity Reached. PUBLISHING..."); @@ -42,15 +36,14 @@ void TransformerNode::unfiltered_callback(const sample_msgs::msg::Unfiltered::Sh transformer_.clear_buffer(); // Construct FilteredArray object - for (auto & packet : buffer) { + for (auto& packet : buffer) { filtered_msgs.packets.push_back(packet); } transform_pub_->publish(filtered_msgs); } } -int main(int argc, char ** argv) -{ +int main(int argc, char** argv) { rclcpp::init(argc, argv); rclcpp::spin(std::make_shared()); rclcpp::shutdown(); diff --git a/src/samples/cpp/transformer/test/transformer_test.cpp b/src/samples/cpp/transformer/test/transformer_test.cpp index 48fe847d..0d103350 100644 --- a/src/samples/cpp/transformer/test/transformer_test.cpp +++ b/src/samples/cpp/transformer/test/transformer_test.cpp @@ -13,18 +13,16 @@ * the amount of boilerplate code in each test. For more information checkout * https://google.github.io/googletest/primer.html#same-data-multiple-tests */ -class TransformerFixtureTest : public ::testing::Test -{ -public: - void SetUp(int enqueue_count) - { +class TransformerFixtureTest : public ::testing::Test { + public: + void SetUp(int enqueue_count) { auto filtered = sample_msgs::msg::Filtered(); for (int i = 0; i < enqueue_count; i++) { transformer.enqueue_message(filtered); } } -protected: + protected: samples::TransformerCore transformer; }; @@ -34,14 +32,12 @@ class TransformerFixtureTest : public ::testing::Test * https://google.github.io/googletest/advanced.html#value-parameterized-tests */ class TransformerParameterizedTest - : public ::testing::TestWithParam> -{ -protected: + : public ::testing::TestWithParam> { + protected: samples::TransformerCore transformer; }; -TEST(TransformerTest, FilterInvalidField) -{ +TEST(TransformerTest, FilterInvalidField) { auto unfiltered = std::make_shared(); unfiltered->valid = false; @@ -50,8 +46,7 @@ TEST(TransformerTest, FilterInvalidField) EXPECT_FALSE(valid); } -TEST_F(TransformerFixtureTest, BufferCapacity) -{ +TEST_F(TransformerFixtureTest, BufferCapacity) { SetUp(samples::TransformerCore::BUFFER_CAPACITY - 1); // Place last message that fits in buffer @@ -68,8 +63,7 @@ TEST_F(TransformerFixtureTest, BufferCapacity) EXPECT_EQ(size, 10); } -TEST_F(TransformerFixtureTest, ClearBuffer) -{ +TEST_F(TransformerFixtureTest, ClearBuffer) { // Place 3 messages in buffer SetUp(3); @@ -81,8 +75,7 @@ TEST_F(TransformerFixtureTest, ClearBuffer) EXPECT_EQ(size, 0); } -TEST_P(TransformerParameterizedTest, SerializationValidation) -{ +TEST_P(TransformerParameterizedTest, SerializationValidation) { auto [serialized_field, valid] = GetParam(); auto filtered = sample_msgs::msg::Filtered(); auto unfiltered = std::make_shared(); @@ -92,12 +85,10 @@ TEST_P(TransformerParameterizedTest, SerializationValidation) // Parameterized testing lets us validate all edge cases for serialization // using one test case. -INSTANTIATE_TEST_CASE_P( - Serialization, TransformerParameterizedTest, - ::testing::Values( - std::make_tuple("x:1;y:2;z:3", false), - std::make_tuple("z:1;y:2;x:3;", false), - std::make_tuple("x:1,y:2,z:3", false), - std::make_tuple("x:3;", false), - std::make_tuple("x:3;y:2;z:3;", true), - std::make_tuple("x:3;y:22; z:11;", true))); +INSTANTIATE_TEST_CASE_P(Serialization, TransformerParameterizedTest, + ::testing::Values(std::make_tuple("x:1;y:2;z:3", false), + std::make_tuple("z:1;y:2;x:3;", false), + std::make_tuple("x:1,y:2,z:3", false), + std::make_tuple("x:3;", false), + std::make_tuple("x:3;y:2;z:3;", true), + std::make_tuple("x:3;y:22; z:11;", true))); diff --git a/src/samples/python/aggregator/test/test_copyright.py b/src/samples/python/aggregator/test/test_copyright.py deleted file mode 100755 index cc8ff03f..00000000 --- a/src/samples/python/aggregator/test/test_copyright.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, 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. - -from ament_copyright.main import main -import pytest - - -@pytest.mark.copyright -@pytest.mark.linter -def test_copyright(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found errors' diff --git a/src/samples/python/aggregator/test/test_flake8.py b/src/samples/python/aggregator/test/test_flake8.py deleted file mode 100755 index 27ee1078..00000000 --- a/src/samples/python/aggregator/test/test_flake8.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2017 Open Source Robotics Foundation, 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. - -from ament_flake8.main import main_with_errors -import pytest - - -@pytest.mark.flake8 -@pytest.mark.linter -def test_flake8(): - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ - '\n'.join(errors) diff --git a/src/samples/python/aggregator/test/test_pep257.py b/src/samples/python/aggregator/test/test_pep257.py deleted file mode 100755 index b234a384..00000000 --- a/src/samples/python/aggregator/test/test_pep257.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, 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. - -from ament_pep257.main import main -import pytest - - -@pytest.mark.linter -@pytest.mark.pep257 -def test_pep257(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' diff --git a/src/samples/python/producer/test/test_copyright.py b/src/samples/python/producer/test/test_copyright.py deleted file mode 100755 index cc8ff03f..00000000 --- a/src/samples/python/producer/test/test_copyright.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, 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. - -from ament_copyright.main import main -import pytest - - -@pytest.mark.copyright -@pytest.mark.linter -def test_copyright(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found errors' diff --git a/src/samples/python/producer/test/test_flake8.py b/src/samples/python/producer/test/test_flake8.py deleted file mode 100755 index 27ee1078..00000000 --- a/src/samples/python/producer/test/test_flake8.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2017 Open Source Robotics Foundation, 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. - -from ament_flake8.main import main_with_errors -import pytest - - -@pytest.mark.flake8 -@pytest.mark.linter -def test_flake8(): - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ - '\n'.join(errors) diff --git a/src/samples/python/producer/test/test_pep257.py b/src/samples/python/producer/test/test_pep257.py deleted file mode 100755 index b234a384..00000000 --- a/src/samples/python/producer/test/test_pep257.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, 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. - -from ament_pep257.main import main -import pytest - - -@pytest.mark.linter -@pytest.mark.pep257 -def test_pep257(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' diff --git a/src/samples/python/transformer/test/test_copyright.py b/src/samples/python/transformer/test/test_copyright.py deleted file mode 100755 index cc8ff03f..00000000 --- a/src/samples/python/transformer/test/test_copyright.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, 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. - -from ament_copyright.main import main -import pytest - - -@pytest.mark.copyright -@pytest.mark.linter -def test_copyright(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found errors' diff --git a/src/samples/python/transformer/test/test_flake8.py b/src/samples/python/transformer/test/test_flake8.py deleted file mode 100755 index 27ee1078..00000000 --- a/src/samples/python/transformer/test/test_flake8.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2017 Open Source Robotics Foundation, 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. - -from ament_flake8.main import main_with_errors -import pytest - - -@pytest.mark.flake8 -@pytest.mark.linter -def test_flake8(): - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ - '\n'.join(errors) diff --git a/src/samples/python/transformer/test/test_pep257.py b/src/samples/python/transformer/test/test_pep257.py deleted file mode 100755 index b234a384..00000000 --- a/src/samples/python/transformer/test/test_pep257.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, 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. - -from ament_pep257.main import main -import pytest - - -@pytest.mark.linter -@pytest.mark.pep257 -def test_pep257(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' diff --git a/src/world_modeling/hd_map/CMakeLists.txt b/src/world_modeling/hd_map/CMakeLists.txt index 0639c7f0..5d52d5eb 100644 --- a/src/world_modeling/hd_map/CMakeLists.txt +++ b/src/world_modeling/hd_map/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/world_modeling/hd_map/package.xml b/src/world_modeling/hd_map/package.xml index 825033e4..b4655894 100644 --- a/src/world_modeling/hd_map/package.xml +++ b/src/world_modeling/hd_map/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/world_modeling/localization/CMakeLists.txt b/src/world_modeling/localization/CMakeLists.txt index 46388462..2ca2488f 100644 --- a/src/world_modeling/localization/CMakeLists.txt +++ b/src/world_modeling/localization/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/world_modeling/localization/package.xml b/src/world_modeling/localization/package.xml index 6d4bbea6..cd036ff7 100644 --- a/src/world_modeling/localization/package.xml +++ b/src/world_modeling/localization/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/world_modeling/motion_forecasting/CMakeLists.txt b/src/world_modeling/motion_forecasting/CMakeLists.txt index 9229833b..2d4114f5 100644 --- a/src/world_modeling/motion_forecasting/CMakeLists.txt +++ b/src/world_modeling/motion_forecasting/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/world_modeling/motion_forecasting/package.xml b/src/world_modeling/motion_forecasting/package.xml index cbc229a2..4a07a614 100644 --- a/src/world_modeling/motion_forecasting/package.xml +++ b/src/world_modeling/motion_forecasting/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/world_modeling/occupancy/CMakeLists.txt b/src/world_modeling/occupancy/CMakeLists.txt index cfd12117..4dce0a6d 100644 --- a/src/world_modeling/occupancy/CMakeLists.txt +++ b/src/world_modeling/occupancy/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/world_modeling/occupancy/package.xml b/src/world_modeling/occupancy/package.xml index 00320dd4..35048da4 100644 --- a/src/world_modeling/occupancy/package.xml +++ b/src/world_modeling/occupancy/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/src/world_modeling/occupancy_segmentation/CMakeLists.txt b/src/world_modeling/occupancy_segmentation/CMakeLists.txt index d77be9f4..dfa8b8bb 100644 --- a/src/world_modeling/occupancy_segmentation/CMakeLists.txt +++ b/src/world_modeling/occupancy_segmentation/CMakeLists.txt @@ -11,16 +11,4 @@ find_package(ament_cmake REQUIRED) # further dependencies manually. # find_package( REQUIRED) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - ament_package() diff --git a/src/world_modeling/occupancy_segmentation/package.xml b/src/world_modeling/occupancy_segmentation/package.xml index ff12b5f6..57c0712d 100644 --- a/src/world_modeling/occupancy_segmentation/package.xml +++ b/src/world_modeling/occupancy_segmentation/package.xml @@ -9,8 +9,6 @@ ament_cmake - ament_lint_auto - ament_lint_common ament_cmake diff --git a/watod-config.sh b/watod-config.sh index 609febfa..38299dea 100755 --- a/watod-config.sh +++ b/watod-config.sh @@ -12,7 +12,7 @@ ## - simulation : starts simulation ## - samples : starts sample ROS2 pubsub nodes -# ACTIVE_MODULES="" +ACTIVE_MODULES="perception" ############################## OPTIONAL CONFIGURATIONS ############################## ## Name to append to docker containers. DEFAULT = ""