Skip to content

Commit

Permalink
Merge pull request #38 from husarion/ros2-add-precommit
Browse files Browse the repository at this point in the history
ROS 2 add precommit
  • Loading branch information
delihus authored Nov 8, 2023
2 parents 7bbbf4f + 8f48429 commit 7f18f3f
Show file tree
Hide file tree
Showing 14 changed files with 247 additions and 187 deletions.
135 changes: 68 additions & 67 deletions .github/workflows/ros-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -1,77 +1,78 @@
---
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.simulation
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.simulation
repo_name: "rosbot-gazebo"
platforms: "linux/amd64"
ros_distro: "iron"
include:
- dockerfile: Dockerfile.hardware
repo_name: ''
platforms: linux/amd64, linux/arm64
ros_distro: humble
- dockerfile: Dockerfile.simulation
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.simulation
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/[email protected]
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/[email protected]
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 }}
121 changes: 61 additions & 60 deletions .github/workflows/vulcanexus-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -1,70 +1,71 @@
---
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.simulation
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.simulation
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/[email protected]
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/[email protected]
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 }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rosbot_ros/
rosbot_ros/
57 changes: 57 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
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/codespell-project/codespell
rev: v1.16.0
hooks:
- id: codespell
name: codespell
description: Checks for common misspellings in text files.
entry: codespell *
language: python
types: [text]

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.1
hooks:
- id: yamlfmt
files: ^.github|./\.yaml

- repo: https://github.com/psf/black
rev: 22.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,
# 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/pre-commit/mirrors-clang-format
rev: v16.0.6
hooks:
- id: clang-format
2 changes: 1 addition & 1 deletion Dockerfile.simulation
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ RUN MYDISTRO=${PREFIX:-ros}; MYDISTRO=${MYDISTRO//-/} && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN echo $(cat /ros2_ws/src/rosbot_gazebo/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') > /version.txt
RUN echo $(cat /ros2_ws/src/rosbot_gazebo/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') > /version.txt
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ In *docker-compose.yaml* you have to change `device` passed to docker. For more
docker run \
--rm -it --privileged \
husarion/rosbot:humble \
print-serial-number.py
print-serial-number.py
```

## ROS node
Expand All @@ -49,6 +49,21 @@ For more details on what is being published and subscribed by nodes running in t
- [rosbot_ros](https://github.com/husarion/rosbot_ros/tree/humble)
- [rosbot_ros2_firmware](https://github.com/husarion/rosbot_ros2_firmware/)


## Developing
[pre-commit configuration](.pre-commit-config.yaml) prepares plenty of tests helping for developing and contributing. Usage:

```bash
# install pre-commit
pip install pre-commit

# initialize pre-commit workspace
pre-commit install

# manually run tests
pre-commit run -a
```

## How to use `rosbot` Docker image?

Find available projects below:
Expand All @@ -57,5 +72,5 @@ Find available projects below:
| - | - |
| [rosbot-sensors](https://github.com/husarion/rosbot-sensors) | Visualize all ROSbot sensors |
| [rosbot-gamepad](https://github.com/husarion/rosbot-gamepad) | Control the robot manually using a Logitech F710 gamepad |
| [rosbot-mapping](https://github.com/husarion/rosbot-mapping) | Create a map (using [slam_toolbox](https://github.com/SteveMacenski/slam_toolbox)) of the unknow environment with ROSbot controlled in LAN or over the Internet |
| [rosbot-mapping](https://github.com/husarion/rosbot-mapping) | Create a map (using [slam_toolbox](https://github.com/SteveMacenski/slam_toolbox)) of the unknown environment with ROSbot controlled in LAN or over the Internet |
| [rosbot-navigation](https://github.com/husarion/rosbot-navigation) | Autonomous navigation (using [navigation2](https://github.com/ros-planning/navigation2)) on a given map. |
2 changes: 1 addition & 1 deletion demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ and run inside `teleop_twist_keyboard` to drive the ROSbot
ros2 run teleop_twist_keyboard teleop_twist_keyboard
```

With keys `i`, `j`, `l`, `,` you can drive forward, counter clockwise, clockwise and backwards. If you are using macanum wheels (see `demo/.env` file) hold `Shift` key that way the ROSbot goes left and right with `j` and `l` keys instead rotates.
With keys `i`, `j`, `l`, `,` you can drive forward, counter clockwise, clockwise and backwards. If you are using macanum wheels (see `demo/.env` file) hold `Shift` key that way the ROSbot goes left and right with `j` and `l` keys instead rotates.
2 changes: 1 addition & 1 deletion demo/compose.simulation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ services:
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- /dev:/dev
command: ros2 launch rosbot_gazebo simulation.launch.py mecanum:=${MECANUM:-False}
command: ros2 launch rosbot_gazebo simulation.launch.py mecanum:=${MECANUM:-False}
Loading

0 comments on commit 7f18f3f

Please sign in to comment.