Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .github/workflows/cpp-lint.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .github/workflows/pre-commit_prek.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: Pre-commit (Prek)

on: [push]

jobs:
prek:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: j178/prek-action@v1
218 changes: 60 additions & 158 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,159 +1,61 @@
# Config based on:
# https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver/blob/humble/.pre-commit-config.yaml
# To use:
#
# pre-commit run -a
#
# Or:
#
# pre-commit install # (runs every time you commit in git)
#
# To update this file:
#
# pre-commit autoupdate
#
# See https://github.com/pre-commit/pre-commit

repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-byte-order-marker # Forbid UTF-8 byte-order markers
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
- id: check-symlinks
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace

# Python hooks
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py310-plus]

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: ["--line-length=100"]

- repo: https://github.com/pycqa/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyle
args:
[
"--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D401,D404",
]

- repo: https://github.com/pycqa/flake8
rev: 3.9.0
hooks:
- id: flake8
args: ["--ignore=E501,W503"]

# CPP hooks
# The same options as in ament_cppcheck are used, but its not working...
#- repo: https://github.com/pocc/pre-commit-hooks
#rev: v1.1.1
#hooks:
#- id: cppcheck
#args: ['--error-exitcode=1', '-f', '--inline-suppr', '-q', '-rp', '--suppress=internalAstError', '--suppress=unknownMacro', '--verbose']

- repo: local
hooks:
- id: ament_cppcheck
name: ament_cppcheck
description: Static code analysis of C/C++ files.
stages: [commit]
entry: env AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS=1 ament_cppcheck
language: system
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$

# Maybe use https://github.com/cpplint/cpplint instead
# TODO(macale) run it before release
# - repo: local
# hooks:
# - id: ament_cpplint
# name: ament_cpplint
# description: Static code analysis of C/C++ files.
# stages: [commit]
# entry: ament_cpplint
# language: system
# files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
# args: ["--linelength=120"]

- repo: local
hooks:
- id: clang-format
name: clang-format
description: Format files with ClangFormat.
entry: clang-format-14
language: system
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
args: ["-fallback-style=none", "-i"]

# Cmake hooks
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.10
hooks:
# Note: Do not use format - the wrapping function is bugged
# https://github.com/cheshirekow/cmake_format/issues/180
- id: cmake-lint
args: ["--disable", "C0103"]
- repo: local
hooks:
- id: ament_lint_cmake
name: ament_lint_cmake
description: Check format of CMakeLists.txt files.
stages: [commit]
entry: ament_lint_cmake
args: ["--filter=-readability/wonkycase"]
language: system
files: CMakeLists.txt$

# Copyright
# TODO: turn on on public code release
# - 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
# args: ['--exclude', 'ur_robot_driver/doc/conf.py']

# Docs - RestructuredText hooks
- repo: https://github.com/PyCQA/doc8
rev: 0.9.0a1
hooks:
- id: doc8
args: ["--max-line-length=100", "--ignore=D001"]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.8.0
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

# Spellcheck in comments and docs
# skipping of *.svg files is not working...
- repo: https://github.com/codespell-project/codespell
rev: v2.0.0
hooks:
- id: codespell
args: ["--write-changes"]
exclude: \.(svg|pyc|drawio)$
- repo: https://gitlab.com/vojko.pribudic.foss/pre-commit-update
rev: v0.9.0
hooks:
- id: pre-commit-update

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-xml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
- id: check-yaml
- id: pretty-format-json
args: ["--autofix", "--no-sort-keys", "--indent", "2"]

- repo: https://github.com/codespell-project/codespell
rev: v2.4.2
hooks:
- id: codespell
args: [-w]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.8
hooks:
- id: ruff-check
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
- id: cmake-lint

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v22.1.1
hooks:
- id: clang-format
types_or: [c++, proto]

- repo: https://github.com/tier4/pre-commit-hooks-ros
rev: v0.10.2
hooks:
- id: prettier-xacro
- id: prettier-package-xml
- id: ros-include-guard
- id: sort-package-xml
52 changes: 13 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,25 @@ find_package(moveit_ros_planning_interface REQUIRED)
find_package(std_msgs REQUIRED)
find_package(yaml-cpp REQUIRED)
include(FetchContent)
FetchContent_Declare(
argparse
GIT_REPOSITORY https://github.com/p-ranav/argparse.git
)
FetchContent_Declare(argparse
GIT_REPOSITORY https://github.com/p-ranav/argparse.git)
FetchContent_MakeAvailable(argparse)

set(
SOURCE_FILES
src/args_parser.cpp
src/scene_objects_manager.cpp
src/spawner.cpp
src/yaml_parser.cpp
)
set(SOURCE_FILES src/args_parser.cpp src/scene_objects_manager.cpp
src/spawner.cpp src/yaml_parser.cpp)

add_executable(${PROJECT_NAME} ${SOURCE_FILES})
ament_target_dependencies(
${PROJECT_NAME}
moveit_ros_planning_interface
rclcpp
std_msgs
)
ament_target_dependencies(${PROJECT_NAME} moveit_ros_planning_interface rclcpp
std_msgs)

target_include_directories(
${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
${argparse_SOURCE_DIR}/argparse/include
)

target_link_libraries(
${PROJECT_NAME}
argparse
yaml-cpp
)

install(
TARGETS ${PROJECT_NAME}
DESTINATION lib/${PROJECT_NAME}
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
set(ament_cmake_copyright_FOUND TRUE)
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
${argparse_SOURCE_DIR}/argparse/include)

target_link_libraries(${PROJECT_NAME} argparse yaml-cpp)

install(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME})

ament_package()
6 changes: 3 additions & 3 deletions include/scene_objects_manager/args_parser.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef ARGS_PARSER_HPP_INCLUDED
#define ARGS_PARSER_HPP_INCLUDED
#ifndef SCENE_OBJECTS_MANAGER__ARGS_PARSER_HPP_
#define SCENE_OBJECTS_MANAGER__ARGS_PARSER_HPP_

#include <filesystem>
#include <string>
Expand All @@ -20,4 +20,4 @@ const LaunchArguments parse_args(
const std::vector<std::string>& input_args);

} // namespace sobjmanager
#endif // ARGS_PARSER_HPP_INCLUDED
#endif // SCENE_OBJECTS_MANAGER__ARGS_PARSER_HPP_
Loading