Skip to content

Commit

Permalink
added and applied precommit
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Delicat <jakub.delicat@husarion.com>
  • Loading branch information
delihus committed Oct 24, 2023
1 parent 94795ff commit e6b02eb
Show file tree
Hide file tree
Showing 38 changed files with 270 additions and 135 deletions.
107 changes: 53 additions & 54 deletions .github/workflows/bump_version.yaml
Original file line number Diff line number Diff line change
@@ -1,60 +1,59 @@
---
name: Bump version
on:
workflow_dispatch:
inputs:
name:
description: "Version to bump (major, minor, patch)"
default: "patch"
required: true
pull_request:
branches: master
types: [closed]
workflow_dispatch:
inputs:
name:
description: Version to bump (major, minor, patch)
default: patch
required: true
pull_request:
branches: master
types: [closed]

jobs:
get-bump:
name: Get version bump
runs-on: ubuntu-latest
outputs:
bump: ${{ env.BUMP }}
steps:
- if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
get-bump:
name: Get version bump
id: get-version-bump
uses: husarion-ci/action-get-version-bump@v0.3.0
- if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
run: echo "BUMP=${{ steps.get-version-bump.outputs.bump }}" >> $GITHUB_ENV
- if: github.event_name == 'workflow_dispatch'
run: echo "BUMP=${{ github.event.inputs.name }}" >> $GITHUB_ENV
runs-on: ubuntu-latest
outputs:
bump: ${{ env.BUMP }}
steps:
- if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
name: Get version bump
id: get-version-bump
uses: husarion-ci/action-get-version-bump@v0.3.0
- if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
run: echo "BUMP=${{ steps.get-version-bump.outputs.bump }}" >> $GITHUB_ENV
- if: github.event_name == 'workflow_dispatch'
run: echo "BUMP=${{ github.event.inputs.name }}" >> $GITHUB_ENV

catkin-release:
name: Bump version
runs-on: ubuntu-latest
needs: get-bump
outputs:
new_version: ${{ steps.catkin-release.outputs.new_version }}
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Catkin release
id: catkin-release
uses: husarion-ci/action-catkin-release@v0.1.4
with:
bump: ${{ needs.get-bump.outputs.bump }}
github_token: ${{ secrets.GITHUB_TOKEN }}
git_user: action-bot
git_email: action-bot@action-bot.com

build-and-push-docker-image:
name: Create new docker image
runs-on: ubuntu-latest
needs: catkin-release
steps:
- name: trigger the endpoint
run: >
curl -X POST
-H "Accept: application/vnd.github+json"
-H "Authorization: Bearer ${{ secrets.GH_PAT }}"
https://api.github.com/repos/husarion/rosbot-xl-docker/dispatches
-d '{"event_type":"ros-package-update","client_payload":{"image_version":"${{ needs.catkin-release.outputs.new_version }}"}}'
catkin-release:
name: Bump version
runs-on: ubuntu-latest
needs: get-bump
outputs:
new_version: ${{ steps.catkin-release.outputs.new_version }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Catkin release
id: catkin-release
uses: husarion-ci/action-catkin-release@v0.1.4
with:
bump: ${{ needs.get-bump.outputs.bump }}
github_token: ${{ secrets.GITHUB_TOKEN }}
git_user: action-bot
git_email: action-bot@action-bot.com

build-and-push-docker-image:
name: Create new docker image
runs-on: ubuntu-latest
needs: catkin-release
steps:
- name: trigger the endpoint
run: >
curl -X POST
-H "Accept: application/vnd.github+json"
-H "Authorization: Bearer ${{ secrets.GH_PAT }}"
https://api.github.com/repos/husarion/rosbot-xl-docker/dispatches
-d '{"event_type":"ros-package-update","client_payload":{"image_version":"${{ needs.catkin-release.outputs.new_version }}"}}'
41 changes: 20 additions & 21 deletions .github/workflows/industrial_ci.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
---
name: Industrial CI
on:
workflow_call:
pull_request:
push:
branches:
- master
workflow_call:
pull_request:
push:
branches:
- master

jobs:
industrial_ci:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [humble]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Clone installation requirements
shell: bash
run : python3 -m pip install -U vcstool &&
vcs import . < ./rosbot_xl/rosbot_xl_hardware.repos &&
vcs import . < ./rosbot_xl/rosbot_xl_simulation.repos
- uses: ros-industrial/industrial_ci@master
env:
ROS_DISTRO: ${{matrix.ROS_DISTRO}}
industrial_ci:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [humble]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Clone installation requirements
shell: bash
run: python3 -m pip install -U vcstool && vcs import . < ./rosbot_xl/rosbot_xl_hardware.repos && vcs import . < ./rosbot_xl/rosbot_xl_simulation.repos
- uses: ros-industrial/industrial_ci@master
env:
ROS_DISTRO: ${{matrix.ROS_DISTRO}}
15 changes: 13 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@ demo/test/.env
demo/id
dev_utils/

# ROS2
# ROS 2 build folders
build/
install/
log/
__pycache__/
__pycache__/


# ROSbots submodules
rosbot_hardware_interfaces/
ros_components_description/
rosbot_controllers/
husarion/husarion_office_gz
gazebosim/gz_ros2_control

# pyspelling
*.dic
71 changes: 71 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
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

- repo: local
hooks:
- id: ament_lint_cmake
name: ament_lint_cmake
description: Check format of CMakeLists.txt files.
entry: ament_lint_cmake
language: system
files: CMakeLists\.txt$

- repo: local
hooks:
- id: ament_copyright
name: ament_copyright
description: Check if copyright notice is available in all files.
stages: [commit]
entry: ament_copyright
language: system

# 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/.*$
6 changes: 3 additions & 3 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ROSBOT XL ROS PACKAGE LICENSING
The default license for ROSbot XL ROS package is the Apache License, Version 2.0
(see LICENSE_APACHE2.txt); you may elect at your option to use the ROSbot XL ROS
package under the MIT License (see LICENSE_MIT.txt). Contributions must be
The default license for ROSbot XL ROS package is the Apache License, Version 2.0
(see LICENSE_APACHE2.txt); you may elect at your option to use the ROSbot XL ROS
package under the MIT License (see LICENSE_MIT.txt). Contributions must be
made under both licenses.
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ROS2 packages for ROSbot XL

### `rosbot_xl`

Metapackeage that contains dependencies to other repositories. It is also used to define whether simulation dependencies should be used.
Metapackeage that contains dependencies to other repositories. It is also used to define whether simulation dependencies should be used.

### `rosbot_xl_bringup`

Expand Down Expand Up @@ -78,7 +78,7 @@ colcon build
```

> **Prerequisites**
>
>
> Before starting the software on the robot please make sure that you're using the latest firmware and run the `micro-ROS` agent (as described in the *Usage on hardware* step).
Running:
Expand Down Expand Up @@ -109,6 +109,43 @@ Running:
source install/setup.bash
ros2 launch rosbot_xl_gazebo simulation.launch.py
```
## Testing package

### pre-commit
[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
```

After initialization [pre-commit configuration](.pre-commit-config.yaml) will applied on every commit.

### Industrial CI
```
colcon test
```

> [!NOTE]
> Command `colcon test` does not build the code. Remember to build your code after changes.
If tests finish with errors print logs:
```
colcon test-result --verbose
```

### Format python code with [Black](https://github.com/psf/black)
```
cd src/
black rosbot*
```


## Demos

Expand Down
10 changes: 5 additions & 5 deletions ROS_API.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Use `bringup.launch.py` from `rosbot_xl_bringup` to start all base functionalities for ROSbot XL. It consists of the following parts:
- `scan_to_scan_filter_chain` from `laser_filters`, it subscribes to `/scan` topic and removes all points that are within the robot's footprint (defined by config `laser_filter.yaml` in `rosbot_xl_bringup` package). Filtered laserscan is then published on `/scan_filtered` topic

**Subscribes**
- `/scan` (_sensor_msgs/LaserScan_)

**Publishes**
- `/scan_filtered` (_sensor_msgs/LaserScan_)

Expand All @@ -12,13 +12,13 @@ Use `bringup.launch.py` from `rosbot_xl_bringup` to start all base functionaliti
**Subscribes**
- `/rosbot_xl_base_controller/odom` (_nav_msgs/Odometry_)
- `/imu_broadcaster/imu` (_sensor_msgs/Imu_)

**Publishes**
- `/tf` (_tf2_msgs/TFMessage_) - `base_link`->`odom` transform
- `/odometry/filtered` (_nav_msgs/Odometry_)


- `controller.launch.py` from `rosbot_xl_controller`, it loads robot model defined in `rosbot_xl_description` as well as ros2 control [rosbot_hardware_interfaces](https://github.com/husarion/rosbot_hardware_interfaces). It also starts controllers:
- `controller.launch.py` from `rosbot_xl_controller`, it loads robot model defined in `rosbot_xl_description` as well as ros2 control [rosbot_hardware_interfaces](https://github.com/husarion/rosbot_hardware_interfaces). It also starts controllers:
* `joint_state_broadcaster`
* `rosbot_xl_base_controller` - depending on the value of `mecanum` argument it can be `DiffDriveController` or `MecanumDriveController`
* `imu_broadcaster`
Expand All @@ -27,7 +27,7 @@ Use `bringup.launch.py` from `rosbot_xl_bringup` to start all base functionaliti
- `/cmd_vel` (_geometry_msgs/Twist_)
- `/_motors_responses` (_sensor_msgs/JointState_)
- `/_imu/data_raw` (_sensor_msgs/Imu_)

**Publishes**
- `/tf` (_tf2_msgs/TFMessage_)
- `/tf_static` (_tf2_msgs/TFMessage_)
Expand Down
2 changes: 1 addition & 1 deletion rosbot_xl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ project(rosbot_xl)

find_package(ament_cmake REQUIRED)

ament_package()
ament_package()
2 changes: 1 addition & 1 deletion rosbot_xl/rosbot_xl_hardware.repos
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ repositories:
ros_components_description:
type: git
url: https://github.com/husarion/ros_components_description.git
version: ros2
version: ros2
4 changes: 2 additions & 2 deletions rosbot_xl/rosbot_xl_simulation.repos
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ repositories:
type: git
url: https://github.com/ros-controls/gz_ros2_control.git
# on branch humble hardware isn't activated
# recently on master API breaking change was introduced, it is necessay to use commit before this change
# recently on master API breaking change was introduced, it is necessary to use commit before this change
version: b296ff2f5c3758b637a70bd496fe6ed875ab03ce

husarion/gazebo_worlds:
type: git
url: https://github.com/husarion/gazebo_worlds.git
version: main
version: main
2 changes: 1 addition & 1 deletion rosbot_xl_bringup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ install(DIRECTORY
DESTINATION share/${PROJECT_NAME}
)

ament_package()
ament_package()
Loading

0 comments on commit e6b02eb

Please sign in to comment.