From 9179baf9f1eb26b5efd0b5da326631a88854e2da Mon Sep 17 00:00:00 2001 From: rafal-gorecki Date: Thu, 14 Dec 2023 14:03:19 +0100 Subject: [PATCH] Update pre-commit --- .github/workflows/ros-docker-image.yaml | 129 +++++++++--------- .../workflows/vulcanexus-docker-image.yaml | 123 +++++++++-------- .pre-commit-config.yaml | 93 ++++++------- Dockerfile.gazebo | 2 +- README.md | 4 +- demo/compose.gazebo.yaml | 2 +- demo/compose.yaml | 4 +- demo/namespace/compose.yaml | 6 +- demo/namespace/filter.yaml | 7 +- healthcheck.cpp | 4 +- sync_with_rosbot.sh | 8 +- 11 files changed, 193 insertions(+), 189 deletions(-) diff --git a/.github/workflows/ros-docker-image.yaml b/.github/workflows/ros-docker-image.yaml index f8fd7e0..53d3439 100644 --- a/.github/workflows/ros-docker-image.yaml +++ b/.github/workflows/ros-docker-image.yaml @@ -2,77 +2,80 @@ name: Build/Publish ROS Docker Image on: - workflow_dispatch: - inputs: - build_type: - description: Is it a "development" or a "stable" release? - required: true - default: development - type: choice - options: - - development - - stable - target_distro: - description: In case of "stable" release specify the ROS distro of the existing docker image (eg. humble) - type: string - default: ardent - target_release: - description: In case of "stable" release specify the version of the existing docker image (eg. 1.0.12) - type: string - default: 0.0.0 - target_date: - description: In case of "stable" release specify the date of the existing docker image in format YYYYMMDD (eg. 20220124) - type: string - default: '20131206' - repository_dispatch: - types: [rebuild, ros-package-update] - pull_request: - types: - - closed - - opened + workflow_dispatch: + inputs: + build_type: + description: Is it a "development" or a "stable" release? + required: true + default: development + type: choice + options: + - development + - stable + target_distro: + description: In case of "stable" release specify the ROS distro of the existing docker image (eg. + humble) + type: string + default: ardent + target_release: + description: In case of "stable" release specify the version of the existing docker image (eg. + 1.0.12) + type: string + default: 0.0.0 + target_date: + description: In case of "stable" release specify the date of the existing docker image in format + YYYYMMDD (eg. 20220124) + type: string + default: '20131206' + repository_dispatch: + types: [rebuild, ros-package-update] + pull_request: + types: + - closed + - opened jobs: - build: - runs-on: ubuntu-22.04 - strategy: - fail-fast: false - matrix: + build: + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: - include: - - dockerfile: Dockerfile.hardware - repo_name: '' - platforms: linux/amd64, linux/arm64 - ros_distro: humble - - dockerfile: Dockerfile.gazebo - repo_name: rosbot-gazebo - platforms: linux/amd64 - ros_distro: humble - - dockerfile: Dockerfile.hardware - repo_name: '' - platforms: linux/amd64, linux/arm64 - ros_distro: iron + include: + - dockerfile: Dockerfile.hardware + repo_name: '' + platforms: linux/amd64, linux/arm64 + ros_distro: humble + - dockerfile: Dockerfile.gazebo + repo_name: rosbot-gazebo + platforms: linux/amd64 + ros_distro: humble + - dockerfile: Dockerfile.hardware + repo_name: '' + platforms: linux/amd64, linux/arm64 + ros_distro: iron # - dockerfile: Dockerfile.gazebo # repo_name: rosbot-gazebo # platforms: linux/amd64 # ros_distro: iron - steps: + steps: - - name: Checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 - - name: ${{ matrix.dockerfile }} | ${{ matrix.ros_distro }} | Build - uses: husarion-ci/ros-docker-img-action@v0.4 - with: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} - main_branch_name: ros2 - dockerfile: ${{ matrix.dockerfile }} - repo_name: ${{ matrix.repo_name }} - build_type: ${{ inputs.build_type }} - ros_distro: ${{ matrix.ros_distro }} - platforms: ${{ matrix.platforms }} + - name: ${{ matrix.dockerfile }} | ${{ matrix.ros_distro }} | Build + uses: husarion-ci/ros-docker-img-action@v0.4 + with: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} + main_branch_name: ros2 + dockerfile: ${{ matrix.dockerfile }} + repo_name: ${{ matrix.repo_name }} + build_type: ${{ inputs.build_type }} + ros_distro: ${{ matrix.ros_distro }} + platforms: ${{ matrix.platforms }} # variables important only for stable release - target_distro: ${{ inputs.target_distro }} - target_release: ${{ inputs.target_release }} - target_date: ${{ inputs.target_date }} + target_distro: ${{ inputs.target_distro }} + target_release: ${{ inputs.target_release }} + target_date: ${{ inputs.target_date }} diff --git a/.github/workflows/vulcanexus-docker-image.yaml b/.github/workflows/vulcanexus-docker-image.yaml index 4f64b52..f204b19 100644 --- a/.github/workflows/vulcanexus-docker-image.yaml +++ b/.github/workflows/vulcanexus-docker-image.yaml @@ -2,70 +2,73 @@ name: Build/Publish Vulcanexus Docker Image on: - workflow_dispatch: - inputs: - build_type: - description: Is it a "development" or a "stable" release? - required: true - default: development - type: choice - options: - - development - - stable - target_distro: - description: In case of "stable" release specify the ROS distro of the existing docker image (eg. humble) - type: string - default: ardent - target_release: - description: In case of "stable" release specify the version of the existing docker image (eg. 1.0.12) - type: string - default: 0.0.0 - target_date: - description: In case of "stable" release specify the date of the existing docker image in format YYYYMMDD (eg. 20220124) - type: string - default: '20131206' - repository_dispatch: - types: [rebuild, ros-package-update] - pull_request: - types: - - closed - - opened + workflow_dispatch: + inputs: + build_type: + description: Is it a "development" or a "stable" release? + required: true + default: development + type: choice + options: + - development + - stable + target_distro: + description: In case of "stable" release specify the ROS distro of the existing docker image (eg. + humble) + type: string + default: ardent + target_release: + description: In case of "stable" release specify the version of the existing docker image (eg. + 1.0.12) + type: string + default: 0.0.0 + target_date: + description: In case of "stable" release specify the date of the existing docker image in format + YYYYMMDD (eg. 20220124) + type: string + default: '20131206' + repository_dispatch: + types: [rebuild, ros-package-update] + pull_request: + types: + - closed + - opened jobs: - build: - runs-on: ubuntu-22.04 - strategy: - fail-fast: false - matrix: + build: + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: - include: - - dockerfile: Dockerfile.hardware - repo_name: '' - platforms: linux/amd64, linux/arm64 - ros_distro: humble - - dockerfile: Dockerfile.gazebo - repo_name: rosbot-gazebo - platforms: linux/amd64 - ros_distro: humble + include: + - dockerfile: Dockerfile.hardware + repo_name: '' + platforms: linux/amd64, linux/arm64 + ros_distro: humble + - dockerfile: Dockerfile.gazebo + repo_name: rosbot-gazebo + platforms: linux/amd64 + ros_distro: humble - steps: + steps: - - name: Checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 - - name: ${{ matrix.dockerfile }} | ${{ matrix.ros_distro }} | Build - uses: husarion-ci/ros-docker-img-action@v0.4 - with: - dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} - dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} - main_branch_name: ros2 - dockerfile: ${{ matrix.dockerfile }} - repo_name: ${{ matrix.repo_name }} - build_type: ${{ inputs.build_type }} - ros_distro: ${{ matrix.ros_distro }} - platforms: ${{ matrix.platforms }} - prefix: vulcanexus- + - name: ${{ matrix.dockerfile }} | ${{ matrix.ros_distro }} | Build + uses: husarion-ci/ros-docker-img-action@v0.4 + with: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} + main_branch_name: ros2 + dockerfile: ${{ matrix.dockerfile }} + repo_name: ${{ matrix.repo_name }} + build_type: ${{ inputs.build_type }} + ros_distro: ${{ matrix.ros_distro }} + platforms: ${{ matrix.platforms }} + prefix: vulcanexus- # variables important only for stable release - target_distro: ${{ inputs.target_distro }} - target_release: ${{ inputs.target_release }} - target_date: ${{ inputs.target_date }} + target_distro: ${{ inputs.target_distro }} + target_release: ${{ inputs.target_release }} + target_date: ${{ inputs.target_date }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 20d9500..5a105ad 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,58 +1,55 @@ --- repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 - hooks: - - id: check-merge-conflict - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-xml - - id: check-added-large-files - - id: check-ast - - id: check-json - - id: name-tests-test - files: ^.*\/test\/.*$ - args: [--pytest-test-first] + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-merge-conflict + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-xml + - id: check-added-large-files + - id: check-ast + - id: check-json + - id: name-tests-test + files: ^.*\/test\/.*$ + args: [--pytest-test-first] - - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 - hooks: - - id: codespell - name: codespell - description: Checks for common misspellings in text files. - entry: codespell * - language: python - types: [text] + - repo: https://github.com/codespell-project/codespell + rev: v2.2.6 + hooks: + - id: codespell + entry: codespell * - - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt - rev: 0.2.3 - hooks: - - id: yamlfmt - files: ^.github|./\.yaml + - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt + rev: 0.2.3 + hooks: + - id: yamlfmt + files: ^(?!.*compose).*$ + args: [--mapping, '2', --sequence, '4', --offset, '2', --width, '100'] - - repo: https://github.com/psf/black - rev: 23.11.0 - hooks: - - id: black - args: ["--line-length=99"] + - repo: https://github.com/psf/black + rev: 23.12.0 + hooks: + - id: black + args: [--line-length=99] - - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 - hooks: - - id: flake8 - args: ["--ignore=E501,W503"] # ignore too long line and line break before binary operator, + - repo: https://github.com/PyCQA/flake8 + rev: 6.1.0 + hooks: + - id: flake8 + args: ['--ignore=E501,W503'] # ignore too long line and line break before binary operator, # black checks it # Docs - RestructuredText hooks - - repo: https://github.com/PyCQA/doc8 - rev: v1.1.1 - hooks: - - id: doc8 - args: ['--max-line-length=100', '--ignore=D001'] - exclude: ^.*\/CHANGELOG\.rst/.*$ + - repo: https://github.com/PyCQA/doc8 + rev: v1.1.1 + hooks: + - id: doc8 + args: [--max-line-length=100, --ignore=D001] + exclude: ^.*\/CHANGELOG\.rst/.*$ - - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v17.0.4 - hooks: - - id: clang-format + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v17.0.6 + hooks: + - id: clang-format diff --git a/Dockerfile.gazebo b/Dockerfile.gazebo index d281b69..02d62d2 100644 --- a/Dockerfile.gazebo +++ b/Dockerfile.gazebo @@ -24,7 +24,7 @@ RUN mkdir src && \ install(TARGETS healthcheck_node DESTINATION lib/${PROJECT_NAME})' \ /ros2_ws/src/healthcheck_pkg/CMakeLists.txt -COPY healthcheck.cpp src/healthcheck_pkg/src/ +COPY healthcheck.cpp src/healthcheck_pkg/src/ RUN MYDISTRO=${PREFIX:-ros}; MYDISTRO=${MYDISTRO//-/} && \ source /opt/$MYDISTRO/$ROS_DISTRO/setup.bash && \ diff --git a/README.md b/README.md index 7202b4e..97ce8a5 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,9 @@ services: environment: - ROS_DOMAIN_ID=30 command: > - ros2 launch rosbot_bringup combined.launch.py + ros2 launch rosbot_bringup combined.launch.py mecanum:=${MECANUM:-False} - serial_port:=$SERIAL_PORT + serial_port:=$SERIAL_PORT serial_baudrate:=576000 namespace:=robot1 ``` diff --git a/demo/compose.gazebo.yaml b/demo/compose.gazebo.yaml index 8e67483..f450ea7 100644 --- a/demo/compose.gazebo.yaml +++ b/demo/compose.gazebo.yaml @@ -1,5 +1,5 @@ # Quick Start -# +# # 1. run `xhost +local:docker && docker compose -f compose.gazebo.yaml up` on the laptop # 2. open a shell inside a docker container `docker compose -f compose.gazebo.yaml exec -it rosbot bash` # 2. run `ros2 run teleop_twist_keyboard teleop_twist_keyboard` inside the container diff --git a/demo/compose.yaml b/demo/compose.yaml index 860f4ee..666f3f3 100644 --- a/demo/compose.yaml +++ b/demo/compose.yaml @@ -1,7 +1,7 @@ # Quick Start -# +# # 1. run `docker compose up` on the robot -# 2. run `ROS_DOMAIN_ID=10 ros2 run teleop_twist_keyboard teleop_twist_keyboard` in the robot termianl +# 2. run `ROS_DOMAIN_ID=10 ros2 run teleop_twist_keyboard teleop_twist_keyboard` in the robot terminal services: diff --git a/demo/namespace/compose.yaml b/demo/namespace/compose.yaml index cd43ed2..4cc0ba4 100644 --- a/demo/namespace/compose.yaml +++ b/demo/namespace/compose.yaml @@ -1,5 +1,5 @@ # Quick Start -# +# # 1. run `docker compose up` on the robot # 2. On the second host in LAN you will see only single ros2 topic: # $ ros2 topic list @@ -26,9 +26,9 @@ services: - ROS_DOMAIN_ID=30 - ROS_NAMESPACE=robot1 # For healthckeck node command: > - ros2 launch rosbot_bringup combined.launch.py + ros2 launch rosbot_bringup combined.launch.py mecanum:=${MECANUM:-False} - serial_port:=$SERIAL_PORT + serial_port:=$SERIAL_PORT serial_baudrate:=576000 namespace:=robot1 diff --git a/demo/namespace/filter.yaml b/demo/namespace/filter.yaml index a6da4ee..7b798cb 100644 --- a/demo/namespace/filter.yaml +++ b/demo/namespace/filter.yaml @@ -1,5 +1,6 @@ +--- allowlist: - - name: "rt/robot1/cmd_vel" - type: "geometry_msgs::msg::dds_::Twist_" + - name: rt/robot1/cmd_vel + type: geometry_msgs::msg::dds_::Twist_ blocklist: [] -builtin-topics: [] \ No newline at end of file +builtin-topics: [] diff --git a/healthcheck.cpp b/healthcheck.cpp index 8218c90..ead3df9 100644 --- a/healthcheck.cpp +++ b/healthcheck.cpp @@ -34,9 +34,9 @@ void healthy_check() { int main(int argc, char *argv[]) { rclcpp::init(argc, argv); - + std::string topic = "odometry/filtered"; - if(const char* ns = std::getenv("ROS_NAMESPACE")) { + if (const char *ns = std::getenv("ROS_NAMESPACE")) { topic = std::string(ns) + "/" + topic; } diff --git a/sync_with_rosbot.sh b/sync_with_rosbot.sh index f4a2738..17e3d2a 100755 --- a/sync_with_rosbot.sh +++ b/sync_with_rosbot.sh @@ -3,8 +3,8 @@ # If your ROSbot's IP addr is 10.5.10.64 execute: # ./sync_with_rosbot.sh 10.5.10.64 -sshpass -p "husarion" rsync -vRr --delete ./ husarion@$1:/home/husarion/${PWD##*/} +sshpass -p "husarion" rsync -vRr --delete ./ husarion@$1:/home/husarion/${PWD##*/} -while inotifywait -r -e modify,create,delete,move ./ ; do - sshpass -p "husarion" rsync -vRr --delete ./ husarion@$1:/home/husarion/${PWD##*/} -done \ No newline at end of file +while inotifywait -r -e modify,create,delete,move ./ ; do + sshpass -p "husarion" rsync -vRr --delete ./ husarion@$1:/home/husarion/${PWD##*/} +done