Skip to content

Commit

Permalink
Merge branch 'ros2' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthou committed Jun 26, 2024
2 parents 613896c + ca6427e commit f650cc3
Show file tree
Hide file tree
Showing 201 changed files with 12,561 additions and 9,476 deletions.
55 changes: 55 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
BasedOnStyle: Microsoft
AlignArrayOfStructures: Left
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakArrays: false
BreakBeforeTernaryOperators: false
BreakInheritanceList: AfterComma
BreakStringLiterals: false
ColumnLimit: 0
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
IncludeBlocks: Regroup
IndentRequiresClause: false
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: false
PenaltyBreakTemplateDeclaration: 1000000
PointerAlignment: Left
SpaceAfterTemplateKeyword: false
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterControlStatements: false
AfterForeachMacros: false
AfterIfMacros: false
SpacesInContainerLiterals: false
TabWidth: 2
BracedInitializerIndentWidth: 2
NamespaceIndentation: All
IncludeCategories:
- Regex: '^\<.*\>'
Priority: 1
CaseSensitive: false
- Regex: '^".*"'
Priority: 2
CaseSensitive: false
100 changes: 100 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
Checks: >
-*,
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-branch-clone,
-bugprone-unchecked-optional-access,
cppcoreguidelines-avoid-goto,
cppcoreguidelines-init-variables,
cppcoreguidelines-no-malloc,
cppcoreguidelines-prefer-member-initializer,
cppcoreguidelines-virtual-class-destructor,
misc-const-correctness,
misc-header-include-cycle,
misc-include-cleaner,
misc-misleading-identifier,
misc-misplaced-const,
misc-new-delete-overloads,
misc-non-copyable-objects,
misc-redundant-expression,
misc-static-assert,
misc-throw-by-value-catch-by-reference,
misc-unconventional-assign-operator,
misc-uniqueptr-reset-release,
misc-unused-*,
modernize-avoid-*,
-modernize-avoid-bind,
modernize-concat-nested-namespaces,
modernize-deprecated-*,
modernize-loop-convert,
modernize-make-*,
modernize-min-max-use-initializer-list,
modernize-raw-string-literal,
modernize-redundant-void-arg,
modernize-replace-*,
modernize-unary-static-assert,
modernize-use-bool-literals,
modernize-use-emplace,
modernize-use-equals-*,
modernize-use-noexcept,
modernize-use-nullptr,
modernize-use-override,
modernize-use-starts-ends-with,
modernize-use-using,
boost-use-to-string,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-*,
-performance-inefficient-string-concatenation,
performance-move-const-arg,
performance-no-automatic-move,
performance-noexcept-destructor,
performance-noexcept-swap,
performance-trivially-destructible,
performance-type-promotion-in-math-fn,
performance-unnecessary-*,
readability-avoid-*,
readability-const-return-type,
readability-container-*,
readability-static-accessed-through-instance,
readability-delete-null-pointer,
readability-duplicate-include,
readability-identifier-naming,
readability-implicit-bool-conversion,
readability-inconsistent-declaration-parameter-name,
readability-make-member-function-const,
readability-math-missing-parentheses,
readability-misleading-indentation,
readability-misplaced-array-index,
readability-named-parameter,
readability-non-const-parameter,
readability-operators-representation,
readability-qualified-auto,
readability-redundant-*,
readability-reference-to-constructed-temporary,
readability-simplify-subscript-expr,
readability-string-compare,
readability-use-std-min-max
HeaderFilterRegex: 'mementar/include/mementar/*'
CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.StructCase, value: CamelCase }
- { key: readability-identifier-naming.StructSuffix, value: _t }
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
- { key: readability-identifier-naming.VariableCase, value: lower_case }
- { key: readability-identifier-naming.PrivateMemberCase, value: lower_case }
- { key: readability-identifier-naming.PrivateMemberSuffix, value: _ }
- { key: readability-identifier-naming.EnumCase, value: CamelCase }
- { key: readability-identifier-naming.EnumSuffix, value: _e }
- { key: readability-identifier-naming.EnumConstantCase, value: lower_case }
- { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.StaticConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.StaticVariableCase, value: lower_case }
- { key: readability-identifier-naming.StaticVariableSuffix, value: _ }
- { key: readability-operators-representation.BinaryOperators, value: '&&;&=;&;|;~;!;!=;||;|=;^;^=' }
- { key: misc-const-correctness.AnalyzeValues, value: false }
- { key: misc-include-cleaner.DeduplicateFindings, value: false }
ExtraArgsBefore:
- '-frelaxed-template-template-args'
78 changes: 78 additions & 0 deletions .github/run_clang_tidy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env python

# Run clang-tidy recursively and parallel on directory
# Usage: run-clang-tidy sourcedir builddir excludedirs extensions
# extensions and excludedirs are specified as comma-separated
# string without dot, e.g. 'c,cpp'
# e.g. run-clang-tidy . build test,other c,cpp file

import os, sys, subprocess, multiprocessing
import json

manager = multiprocessing.Manager()
failedfiles = manager.list()

# Get absolute paths from arguments
print("Arguments: " + str(sys.argv))
sourcedir = os.path.abspath(sys.argv[1])
print("Source directory: " + sourcedir)
builddir = os.path.abspath(sys.argv[2])
print("Build directory: " + builddir)
# If exclude dirs is not empty, split it into a tuple
excludedirs = ()
if len(sys.argv) > 3 and sys.argv[3]:
excludedirs = tuple([os.path.join(sourcedir, s) for s in sys.argv[3].split(',')])
# If the build directory is not the same as the source directory, exclude it
if not sourcedir == builddir:
excludedirs = excludedirs + (builddir,)

print("Exclude directories: " + str(excludedirs))
# Split extensions into a tuple
extensions = ()
if(len(sys.argv) >= 4):
extensions = tuple([("." + s) for s in sys.argv[4].split(',')])
print("Extensions: " + str(extensions))

def runclangtidy(filepath):
print("Checking: " + filepath)
proc = subprocess.Popen(f'clang-tidy -warnings-as-errors=* -p {builddir} {filepath}', shell=True)
if proc.wait() != 0:
failedfiles.append(filepath)

def collectfiles(dir, exclude, exts):
collectedfiles = []
for root, dirs, files in os.walk(dir):
root = os.path.abspath(root)
for file in files:
filepath = os.path.join(root, file)
if (len(exclude) == 0 or not filepath.startswith(exclude)) and filepath.endswith(exts):
collectedfiles.append(filepath)
return collectedfiles

def collectcompiledfiles(dir, builddir):
collectedfiles = []
if(builddir):
compile_file = open(builddir + '/compile_commands.json')
if compile_file is not None:
compile_data = json.load(compile_file)
for line in compile_data:
filepath = line["file"]
if dir in filepath and not builddir in filepath:
collectedfiles.append(filepath)

return collectedfiles

# Define the pool AFTER the global variables and subprocess function because WTF python
# See: https://stackoverflow.com/questions/41385708/multiprocessing-example-giving-attributeerror
pool = multiprocessing.Pool()
files = collectcompiledfiles(sourcedir, builddir)
if len(files) == 0:
files = collectfiles(sourcedir, excludedirs, extensions)
pool.map(runclangtidy, files)
pool.close()
pool.join()
if len(failedfiles) > 0:
print("Errors in " + str(len(failedfiles)) + " files")
sys.exit(1)
print("No errors found")
sys.exit(0)
68 changes: 68 additions & 0 deletions .github/workflows/ROS1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: ROS1 CI

on:
push:
paths-ignore:
- 'docs/**'
- 'launch/ros2/**'
- 'resources/*'
pull_request:
paths-ignore:
- 'docs/**'
- 'launch/ros2/**'
- 'resources/*'

jobs:
build:

runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
include:
#- operating-system: ubuntu-18.04
# ros_distro: melodic
# distro: bionic
- operating-system: ubuntu-20.04
ros_distro: noetic
distro: focal
env:
ROS_CI_DESKTOP: ${{ matrix.distro }}
CI_SOURCE_PATH: $(pwd)
# Set the python path manually to include /usr/-/python2.7/dist-packages
# as this is where apt-get installs python packages.
PYTHONPATH: $PYTHONPATH:/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages:/usr/lib/python3.8/dist-packages:/usr/local/lib/python3.8/dist-packages
ROS_DISTRO: ${{ matrix.ros_distro }}
steps:
- uses: actions/checkout@v1
- name: Install ROS1
run: |
sudo sh -c "echo \"deb http://packages.ros.org/ros/ubuntu $ROS_CI_DESKTOP main\" > /etc/apt/sources.list.d/ros-latest.list"
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update -qq
sudo apt install dpkg
sudo apt install -y ros-$ROS_DISTRO-desktop qtbase5-dev qtdeclarative5-dev
sudo apt install -y libcppunit-dev libcurl4-openssl-dev
sudo apt-get install python3-rosdep
source /opt/ros/$ROS_DISTRO/setup.bash
sudo rosdep init
rosdep update --include-eol-distros # Support EOL distros.
- name: build
run: |
source /opt/ros/$ROS_DISTRO/setup.bash
cmake --version
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin_make
source devel/setup.bash
cd ~/catkin_ws/src
ln -s ~/work # $CI_SOURCE_PATH
git clone https://github.com/sarthou/ontologenius.git
cd ..
catkin_make
- name: rostest
run: |
cd ~/catkin_ws
source devel/setup.bash
catkin_make run_tests_mementar_rostest -j1 && catkin_make test -j1 -DCATKIN_WHITELIST_PACKAGES="mementar"
66 changes: 66 additions & 0 deletions .github/workflows/ROS2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: ROS2 CI

on:
push:
paths-ignore:
- 'docs/**'
- 'resources/*'
pull_request:
paths-ignore:
- 'docs/**'
- 'resources/*'

jobs:
build:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
include:
- operating-system: ubuntu-22.04
ros_distro: humble
distro: jammy
- operating-system: ubuntu-22.04
ros_distro: iron
distro: jammy
env:
ROS_CI_DESKTOP: ${{ matrix.distro }}
CI_SOURCE_PATH: $(pwd)
ROS_DISTRO: ${{ matrix.ros_distro }}
steps:
- name: Setup ROS
uses: ros-tooling/[email protected]
with:
required-ros-distributions: ${{ matrix.ros_distro }}

- name: Install deps
run: |
sudo apt install dpkg
sudo apt install -y qtbase5-dev qtdeclarative5-dev
sudo apt install -y libcppunit-dev libcurl4-openssl-dev
sudo apt-get install python3-rosdep
sudo apt install ros-cmake-modules
sudo apt install ros-$ROS_DISTRO-std-msgs ros-$ROS_DISTRO-pluginlib
source /opt/ros/$ROS_DISTRO/setup.bash
- name: Setup Workspace
run: |
source /opt/ros/$ROS_DISTRO/setup.bash
cmake --version
cd $GITHUB_WORKSPACE
mkdir -p ros2_ws/src/mementar
cd $GITHUB_WORKSPACE/ros2_ws/src
git clone https://github.com/sarthou/ontologenius.git
cd $GITHUB_WORKSPACE/ros2_ws
colcon build --symlink-install
- name: Checkout
uses: actions/checkout@v4
with:
path: ros2_ws/src/mementar

- name: Build
run: |
cd $GITHUB_WORKSPACE/ros2_ws
source install/setup.bash
export ROS_LOCALHOST_ONLY=1
colcon build --symlink-install
Loading

0 comments on commit f650cc3

Please sign in to comment.