generated from DHBW-Smart-Rollerz/ros2_example_package
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 194901e
Showing
21 changed files
with
750 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Build Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- jazzy* | ||
pull_request: | ||
branches: | ||
- jazzy* | ||
|
||
jobs: | ||
call-build-and-test: | ||
uses: DHBW-Smart-Rollerz/smarty_workspace/.github/workflows/base.yaml@jazzy | ||
with: | ||
branch_pattern: 'jazzy*' | ||
type: 'python' | ||
package_name: 'ros2_example_package' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# pdm | ||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
#pdm.lock | ||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | ||
# in version control. | ||
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control | ||
.pdm.toml | ||
.pdm-python | ||
.pdm-build/ | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 23.1.0 # Use the latest version | ||
hooks: | ||
- id: black | ||
args: | ||
- --line-length=88 | ||
|
||
- repo: https://github.com/pre-commit/mirrors-isort | ||
rev: v5.10.1 # Use the latest version | ||
hooks: | ||
- id: isort | ||
args: | ||
- --profile=black | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.1.0 # this is optional, use `pre-commit autoupdate` to get the latest rev! | ||
hooks: | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: check-added-large-files | ||
args: | ||
- --maxkb=30000000 | ||
- id: check-ast | ||
- id: check-json | ||
- id: check-shebang-scripts-are-executable | ||
- id: check-xml | ||
- id: pretty-format-json | ||
args: | ||
- --autofix | ||
|
||
- repo: https://github.com/pycqa/pydocstyle | ||
rev: 4.0.0 # pick a git hash / tag to point to | ||
hooks: | ||
- id: pydocstyle | ||
args: | ||
- --ignore=D401,D417,D100,D407,D406,D413,D212,D203,D104,D205 | ||
|
||
- repo: https://github.com/DHBW-Smart-Rollerz/smarty_hooks | ||
rev: v0.1.1 | ||
hooks: | ||
- id: ament_uncrustify | ||
|
||
exclude: '.vscode/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 DHBW Smart Rollerz | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# ROS2 Example Package | ||
|
||
[![Build Test](https://github.com/DHBW-Smart-Rollerz/ros2_exaple_package/actions/workflows/build-test.yaml/badge.svg)](https://github.com/DHBW-Smart-Rollerz/ros2_exaple_package/actions/workflows/build-test.yaml) | ||
|
||
This repository contains an example package for ros2 (python). | ||
|
||
## Usage | ||
|
||
This repository can be used as template. Simply select this repo when creating a new repository under template. | ||
|
||
Alternatively, you can create python ros packages with: | ||
|
||
```bash | ||
# If not already created | ||
mkdir -p ~/ros2_ws/src | ||
cd ~/ros2_ws/src | ||
|
||
# Create package | ||
ros2 pkg create my_package --build-type ament_python --dependencies rclpy | ||
|
||
# Build | ||
cd ~/ros2_ws/src | ||
colcon build --symlink-install --packages-select my_package | ||
``` | ||
|
||
## Structure | ||
|
||
- `config/`: All configurations (most of the time yaml files) | ||
- `launch/`: Contains all launch files. Launch files can start multiple nodes with yaml-configurations | ||
- `models/`: Contains all models (optional) and only necessary for machine learning nodes | ||
- `resource/`: Contains the package name (required to build with colcon) | ||
- `ros2_example_package`: Contains all nodes and sources for the ros package | ||
- `test/`: Contains all tests | ||
- `package.xml`: Contains metadata about the package | ||
- `setup.py`: Used for Python package configuration | ||
- `setup.cfg`: Additional configuration for the package | ||
- `requirements.txt`: Python dependencies | ||
|
||
## Contributing | ||
|
||
Thank you for considering contributing to this repository! Here are a few guidelines to get you started: | ||
|
||
1. Fork the repository and clone it locally. | ||
2. Create a new branch for your contribution. | ||
3. Make your changes and ensure they are properly tested. | ||
4. Commit your changes and push them to your forked repository. | ||
5. Submit a pull request with a clear description of your changes. | ||
|
||
We appreciate your contributions and look forward to reviewing them! | ||
|
||
## License | ||
|
||
This repository is licensed under the MIT license. See [LICENSE](LICENSE) for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Config of the model. Independent of the ROS system. | ||
|
||
model_path: 'models/model.pkl' | ||
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This file contains example node parameters. | ||
ros2_example_node: | ||
ros__parameters: | ||
# Path of the debug image | ||
image_path: 'resources/img/example.png' | ||
|
||
# Path of the model | ||
model_config_path: 'config/model.yaml' | ||
|
||
# Topics for an example publisher and subscriber | ||
image_topic: '/camera/undistorted' | ||
result_topic: '/example/result' | ||
debug_image_topic: '/example/debug_image' | ||
|
||
# Some example value with a unit | ||
example_value: 500 # in px |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import os | ||
|
||
from ament_index_python import get_package_share_directory | ||
from launch_ros.actions import Node | ||
|
||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.substitutions import LaunchConfiguration | ||
|
||
|
||
def generate_launch_description(): | ||
""" | ||
Generate the launch description. | ||
Returns: | ||
LaunchDescription -- The launch description. | ||
""" | ||
debug = LaunchConfiguration("debug") | ||
params_file = LaunchConfiguration("params_file") | ||
|
||
return LaunchDescription( | ||
[ | ||
DeclareLaunchArgument( | ||
"debug", default_value="False", description="Enable debug mode" | ||
), | ||
DeclareLaunchArgument( | ||
"params_file", | ||
default_value=os.path.join( | ||
get_package_share_directory("ros2_example_package"), | ||
"config", | ||
"ros_params.yaml", | ||
), | ||
description="Path to the ROS parameters file", | ||
), | ||
Node( | ||
package="ros2_example_package", | ||
namespace="ros2_example", | ||
executable="ros2_example_node", | ||
name="ros2_example_node", | ||
parameters=[ | ||
{"debug": debug}, | ||
params_file, | ||
], | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>ros2_example_package</name> | ||
<version>0.0.0</version> | ||
<description>TODO: Package description</description> | ||
<maintainer email="info@dhbw-smartrollerz.org">Smart Rollerz</maintainer> | ||
<license>TODO: License declaration</license> | ||
|
||
<depend>rclpy</depend> | ||
|
||
<test_depend>ament_copyright</test_depend> | ||
<test_depend>ament_flake8</test_depend> | ||
<test_depend>ament_pep257</test_depend> | ||
<test_depend>python3-pytest</test_depend> | ||
|
||
<exec_depend>ros2launch</exec_depend> | ||
|
||
<export> | ||
<build_type>ament_python</build_type> | ||
</export> | ||
</package> |
Oops, something went wrong.