Skip to content

Commit b0c897f

Browse files
authored
Merge pull request #2 from husarion/0.1.0-20241004
ROS 2 support fo Wibotic Wireless Charger
2 parents bb77b73 + fc5d44f commit b0c897f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1844
-756
lines changed

.clang-format

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Language: Cpp
2+
BasedOnStyle: Google
3+
4+
AccessModifierOffset: -2
5+
AlignAfterOpenBracket: AlwaysBreak
6+
BraceWrapping:
7+
AfterClass: true
8+
AfterFunction: true
9+
AfterNamespace: true
10+
AfterStruct: true
11+
BreakBeforeBraces: Custom
12+
ColumnLimit: 100
13+
ConstructorInitializerIndentWidth: 0
14+
ContinuationIndentWidth: 2
15+
DerivePointerAlignment: false
16+
PointerAlignment: Middle
17+
ReflowComments: true
18+
IncludeBlocks: Preserve
19+
AlignOperands: true
20+
PenaltyBreakAssignment: 21
21+
PenaltyBreakBeforeFirstCallParameter: 1

.github/pull_request_template.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### Description
2+
3+
-
4+
5+
### Requirements
6+
7+
- [ ] Code style guidelines followed
8+
- [ ] Documentation updated
9+
10+
### Tests 🧪
11+
12+
- [ ] Robot
13+
- [ ] Container
14+
- [ ] Simulation

.github/workflows/pre-commit.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: Pre-Commit
3+
4+
on:
5+
push:
6+
7+
jobs:
8+
pre-commit:
9+
uses: ros-controls/ros2_control_ci/.github/workflows/reusable-pre-commit.yml@master
10+
with:
11+
ros_distro: humble
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Validate PR head branch
3+
on:
4+
pull_request:
5+
branches:
6+
- ros2
7+
8+
jobs:
9+
check-head-branch:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check allowed branches
13+
run: |
14+
pattern="^[0-9]+\.[0-9]+\.[0-9]+-[0-9]{8}$" # This regex matches the X.X.X-YYYYMMDD pattern
15+
if [[ "${{ github.head_ref }}" == *"hotfix"* ]]; then
16+
echo "PR from a branch containing 'hotfix' is allowed."
17+
exit 0
18+
elif [[ "${{ github.head_ref }}" =~ $pattern ]]; then
19+
echo "PR from a branch matching X.X.X-YYYYMMDD pattern is allowed."
20+
exit 0
21+
else
22+
echo "PRs must come from branches containing 'hotfix' phrase or matching X.X.X-YYYYMMDD pattern."
23+
exit 1
24+
fi

.github/workflows/run-unit-tests.yaml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
name: Run unit tests
3+
4+
on:
5+
workflow_dispatch:
6+
# TODO: ENABLE WHEN READY
7+
# pull_request:
8+
# branches:
9+
# - ros2-devel
10+
11+
jobs:
12+
test:
13+
name: Run unit tests
14+
runs-on: self-hosted
15+
env:
16+
HUSARION_ROS_BUILD_TYPE: hardware
17+
ROS_DISTRO: humble
18+
TEST_RESULT_FILENAME: last_run_results.txt
19+
COVERAGE_RESULT_FILENAME: coverage_results.log
20+
steps:
21+
- name: Prepare filesystem
22+
working-directory: ${{ runner.temp }}
23+
run: |
24+
touch ${{ env.TEST_RESULT_FILENAME }}
25+
touch ${{ env.COVERAGE_RESULT_FILENAME }}
26+
27+
- name: Checkout repository
28+
uses: actions/checkout@v3
29+
with:
30+
ref: ${{ github.ref }}
31+
path: ros2_ws/src/wibotic_ros
32+
33+
- name: Resolve dependencies
34+
working-directory: ros2_ws
35+
run: |
36+
sudo apt update
37+
rosdep update --rosdistro $ROS_DISTRO
38+
rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y
39+
40+
- name: Build
41+
working-directory: ros2_ws
42+
run: |
43+
source /opt/ros/$ROS_DISTRO/setup.bash
44+
if [ -f install/setup.bash ]; then source install/setup.bash; fi
45+
colcon build --symlink-install --parallel-workers $(nproc) --packages-up-to panther --cmake-args -DCMAKE_CXX_FLAGS='-fprofile-arcs -ftest-coverage'
46+
47+
- name: Test
48+
working-directory: ros2_ws
49+
run: |
50+
source install/setup.bash
51+
colcon test --packages-up-to panther --retest-until-pass 10 --event-handlers console_cohesion+ --return-code-on-test-failure
52+
echo "result=$?" >> ${{ runner.temp }}/${{ env.TEST_RESULT_FILENAME }}
53+
colcon lcov-result --packages-up-to panther --verbose >> ${{ runner.temp }}/${{ env.COVERAGE_RESULT_FILENAME }}
54+
lines_cov=$(cat ${{ runner.temp }}/${{ env.COVERAGE_RESULT_FILENAME }} | grep -E 'lines' | head -1)
55+
functions_cov=$(cat ${{ runner.temp }}/${{ env.COVERAGE_RESULT_FILENAME }} | grep -E 'functions' | head -1)
56+
branches_cov=$(cat ${{ runner.temp }}/${{ env.COVERAGE_RESULT_FILENAME }} | grep -E 'branches' | head -1)
57+
echo "lines_cov=$lines_cov">> ${{ runner.temp }}/${{ env.TEST_RESULT_FILENAME }}
58+
echo "functions_cov=$functions_cov" >> ${{ runner.temp }}/${{ env.TEST_RESULT_FILENAME }}
59+
echo "branches_cov=$branches_cov" >> ${{ runner.temp }}/${{ env.TEST_RESULT_FILENAME }}
60+
61+
- name: Collect unit tests output
62+
working-directory: ${{ runner.temp }}
63+
id: unit-tests-output
64+
run: cat ${{ env.TEST_RESULT_FILENAME }} >> "$GITHUB_OUTPUT"
65+
66+
- name: Validate tests result
67+
uses: nick-fields/assert-action@v1
68+
with:
69+
expected: 0
70+
actual: ${{ steps.unit-tests-output.outputs.result }}
71+
72+
- name: Comment PR
73+
uses: thollander/actions-comment-pull-request@v2
74+
with:
75+
message: |
76+
**Test coverage of modified packages:**
77+
${{ steps.unit-tests-output.outputs.lines_cov }}
78+
${{ steps.unit-tests-output.outputs.functions_cov }}
79+
${{ steps.unit-tests-output.outputs.branches_cov }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__pycache__

.pre-commit-config.yaml

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: check-added-large-files
6+
# mesh files has to be taken into account
7+
args: ["--maxkb=3000"]
8+
- id: check-ast
9+
- id: check-json
10+
# vscode .json files do not follow the standard JSON format
11+
exclude: ^.vscode/
12+
- id: check-merge-conflict
13+
- id: check-symlinks
14+
- id: check-xml
15+
- id: check-yaml
16+
- id: debug-statements
17+
- id: destroyed-symlinks
18+
- id: detect-private-key
19+
- id: end-of-file-fixer
20+
- id: fix-byte-order-marker
21+
- id: name-tests-test
22+
- id: mixed-line-ending
23+
- id: trailing-whitespace
24+
25+
- repo: https://github.com/PyCQA/isort
26+
rev: 5.13.2
27+
hooks:
28+
- id: isort
29+
args: ["--profile", "black"]
30+
31+
- repo: https://github.com/cheshirekow/cmake-format-precommit
32+
rev: v0.6.13
33+
hooks:
34+
- id: cmake-format
35+
36+
- repo: https://github.com/pre-commit/mirrors-clang-format
37+
rev: v18.1.8
38+
hooks:
39+
- id: clang-format
40+
41+
- repo: https://github.com/codespell-project/codespell
42+
rev: v2.3.0
43+
hooks:
44+
- id: codespell
45+
name: codespell
46+
description: Checks for common misspellings in text files.
47+
entry: codespell
48+
args:
49+
[
50+
"--ignore-words-list",
51+
"ned" # north, east, down (NED)
52+
]
53+
exclude_types: [rst, svg]
54+
language: python
55+
types: [text]
56+
57+
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
58+
rev: 0.2.3
59+
hooks:
60+
- id: yamlfmt
61+
files: ^.github|./\.yaml
62+
args: [--mapping, '2', --sequence, '4', --offset, '2', --width, '100']
63+
64+
- repo: https://github.com/psf/black
65+
rev: 24.8.0
66+
hooks:
67+
- id: black
68+
args: ["--line-length=99"]
69+
70+
- repo: https://github.com/PyCQA/flake8
71+
rev: 7.1.1
72+
hooks:
73+
- id: flake8
74+
args:
75+
["--ignore=E501,W503"] # ignore too long line and line break before binary operator,
76+
# black checks it
77+
78+
- repo: local
79+
hooks:
80+
- id: ament_copyright
81+
name: ament_copyright
82+
description: Check if copyright notice is available in all files.
83+
stages: [commit]
84+
entry: ament_copyright
85+
language: system
86+
87+
# Docs - RestructuredText hooks
88+
- repo: https://github.com/PyCQA/doc8
89+
rev: v1.1.1
90+
hooks:
91+
- id: doc8
92+
args: ["--max-line-length=100", "--ignore=D001"]
93+
exclude: ^.*\/CHANGELOG\.rst/.*$
94+
95+
- repo: https://github.com/tier4/pre-commit-hooks-ros
96+
rev: v0.10.0
97+
hooks:
98+
- id: prettier-package-xml
99+
- id: sort-package-xml

0 commit comments

Comments
 (0)