Skip to content

Commit

Permalink
Add format files and CI job (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
pac48 authored Nov 10, 2024
1 parent d74df2e commit ebba857
Show file tree
Hide file tree
Showing 24 changed files with 1,016 additions and 746 deletions.
68 changes: 68 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
BasedOnStyle: Google
AccessModifierOffset: -2
ConstructorInitializerIndentWidth: 2
AlignEscapedNewlinesLeft: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: BeforeComma
BinPackParameters: true
ColumnLimit: 90
ConstructorInitializerAllOnOneLineOrOnePerLine: true
DerivePointerBinding: false
PointerBindsToType: true
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 60
PenaltyBreakString: 1
PenaltyBreakFirstLessLess: 1000
PenaltyExcessCharacter: 1000
PenaltyReturnTypeOnItsOwnLine: 90
SpacesBeforeTrailingComments: 2
Cpp11BracedListStyle: false
Standard: Auto
IndentWidth: 2
TabWidth: 2
UseTab: Never
IndentFunctionDeclarationAfterType: false
SpacesInParentheses: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Never
ContinuationIndentWidth: 4
SortIncludes: false
SpaceAfterCStyleCast: false
ReflowComments: false

# Configure each individual brace in BraceWrapping
BreakBeforeBraces: Custom

# Control of individual brace wrapping cases
BraceWrapping: {
AfterClass: 'true',
AfterControlStatement: 'true',
AfterEnum : 'true',
AfterFunction : 'true',
AfterNamespace : 'true',
AfterStruct : 'true',
AfterUnion : 'true',
BeforeCatch : 'true',
BeforeElse : 'true',
IndentBraces : 'false',
SplitEmptyFunction: 'false'
}
...
68 changes: 34 additions & 34 deletions .github/workflows/cmake-single-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ name: CMake on a single platform

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
Expand All @@ -20,35 +20,35 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install urdf-parser-py jinja2 numpy
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target install

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}

- name: Configure CMake For Fetch Content
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build_fetch -S ${{github.workspace}}/test/fetch_content_test -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build For Fetch Content
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build_fetch --config ${{env.BUILD_TYPE}}
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install urdf-parser-py jinja2 numpy
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target install

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}

- name: Configure CMake For Fetch Content
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build_fetch -S ${{github.workspace}}/test/fetch_content_test -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build For Fetch Content
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build_fetch --config ${{env.BUILD_TYPE}}
15 changes: 15 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: format

on:
# Run action on certain pull request events
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
pre-commit:
name: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]
67 changes: 67 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
repos:

# Runs pre-commit hooks and other file format checks.
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: forbid-new-submodules
- id: mixed-line-ending
- id: name-tests-test
- id: requirements-txt-fixer
- id: sort-simple-yaml
- id: trailing-whitespace

# Autoformats Python code.
- repo: https://github.com/psf/black.git
rev: 24.10.0
hooks:
- id: black

# Finds spelling issues in code.
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell

# Finds issues in YAML files.
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
args:
[
"--no-warnings",
"--config-data",
"{extends: default, rules: {line-length: disable, braces: {max-spaces-inside: 1}}}",
]
types: [text]
files: \.(yml|yaml)$

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

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
files: \.(c|cc|cxx|cpp|h|hpp|hxx|)$
args: ["-fallback-style=none"]
58 changes: 30 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,45 @@ include(CTest)
include(fast_forward_kinematics.cmake)

add_library(fast_forward_kinematics_header INTERFACE)
target_include_directories(fast_forward_kinematics_header INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
if (BUILD_TESTING)
add_subdirectory(test)
endif ()

target_include_directories(
fast_forward_kinematics_header
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
if(BUILD_TESTING)
add_subdirectory(test)
endif()

include(CMakePackageConfigHelpers)

configure_package_config_file(fast_forward_kinematics-config.cmake.in fast_forward_kinematics-config.cmake
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/fast_forward_kinematics"
PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
configure_package_config_file(
fast_forward_kinematics-config.cmake.in fast_forward_kinematics-config.cmake
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/fast_forward_kinematics"
PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR
NO_CHECK_REQUIRED_COMPONENTS_MACRO)

write_basic_package_version_file(fast_forward_kinematics-config-version.cmake
VERSION ${FFK_VERSION} COMPATIBILITY AnyNewerVersion)
write_basic_package_version_file(
fast_forward_kinematics-config-version.cmake
VERSION ${FFK_VERSION}
COMPATIBILITY AnyNewerVersion)

install(FILES
"${CMAKE_BINARY_DIR}/fast_forward_kinematics-config.cmake"
install(
FILES "${CMAKE_BINARY_DIR}/fast_forward_kinematics-config.cmake"
"${CMAKE_BINARY_DIR}/fast_forward_kinematics-config-version.cmake"
"${CMAKE_SOURCE_DIR}/fast_forward_kinematics.cmake"
DESTINATION "${CMAKE_INSTALL_DATADIR}/fast_forward_kinematics/cmake")
DESTINATION "${CMAKE_INSTALL_DATADIR}/fast_forward_kinematics/cmake")

install(DIRECTORY "${CMAKE_SOURCE_DIR}/code_generation" DESTINATION "${CMAKE_INSTALL_DATADIR}/fast_forward_kinematics/cmake")
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/fast_forward_kinematics")
install(DIRECTORY "${CMAKE_SOURCE_DIR}/code_generation"
DESTINATION "${CMAKE_INSTALL_DATADIR}/fast_forward_kinematics/cmake")
install(DIRECTORY include/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/fast_forward_kinematics")

# Create an export set
install(TARGETS fast_forward_kinematics_header EXPORT fast_forward_kinematicsTargets)
install(TARGETS fast_forward_kinematics_header
EXPORT fast_forward_kinematicsTargets)
# Targets files
export(
EXPORT fast_forward_kinematicsTargets
FILE ${CMAKE_CURRENT_BINARY_DIR}/fast_forward_kinematics-targets.cmake
)
export(EXPORT fast_forward_kinematicsTargets
FILE ${CMAKE_CURRENT_BINARY_DIR}/fast_forward_kinematics-targets.cmake)
install(
EXPORT fast_forward_kinematicsTargets
FILE fast_forward_kinematics-targets.cmake
DESTINATION lib/cmake/fast_forward_kinematics
)
EXPORT fast_forward_kinematicsTargets
FILE fast_forward_kinematics-targets.cmake
DESTINATION lib/cmake/fast_forward_kinematics)
8 changes: 4 additions & 4 deletions code_generation/get_num_joints.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

def run():
parser = argparse.ArgumentParser()
parser.add_argument('urdf_file')
parser.add_argument('root_link_name')
parser.add_argument('tip_link_name')
parser.add_argument("urdf_file")
parser.add_argument("root_link_name")
parser.add_argument("tip_link_name")
args = parser.parse_args()

root_link_name = args.root_link_name
Expand All @@ -18,7 +18,7 @@ def run():
while tip_link_name != root_link_name:
tip_joint_name, tip_link_name = robot.parent_map[tip_link_name]
joint = robot.joint_map[tip_joint_name]
if not joint.type == 'fixed':
if not joint.type == "fixed":
joint_names.append(tip_joint_name)

print(f"FAST_FK_NUMBER_OF_JOINTS={len(joint_names)}", end="")
Expand Down
2 changes: 1 addition & 1 deletion code_generation/robot_config.cpp.template
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,4 @@ namespace fast_fk::internal {
}

}
#endif
#endif
2 changes: 1 addition & 1 deletion code_generation/robot_config.cu.template
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,4 @@ namespace fast_fk::internal {
if (cudaerr != cudaSuccess)
std::printf("kernel launch failed with error \"%s\".\n", cudaGetErrorString(cudaerr));
}
}
}
Loading

0 comments on commit ebba857

Please sign in to comment.