Skip to content

Commit

Permalink
Added project configuration files
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-palmer committed Apr 4, 2023
1 parent 83f9cea commit 8cdc68d
Show file tree
Hide file tree
Showing 17 changed files with 925 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 100
MaxEmptyLinesToKeep: 1

IndentWidth: 2
TabWidth: 2
UseTab: Never
AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 2
DerivePointerAlignment: false
PointerAlignment: Middle
PackConstructorInitializers: Never

# Configure brace wrapping cases
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
80 changes: 80 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
Checks: >
-*,
abseil-*,
bugprone-*,
google-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-google-readability-braces-around-statements,
-google-readability-namespace-comments,
-google-runtime-references,
-misc-non-private-member-variables-in-classes,
-modernize-return-braced-init-list,
-modernize-use-trailing-return-type,
-performance-move-const-arg,
-readability-braces-around-statements,
-readability-identifier-length,
-readability-magic-numbers,
-readability-named-parameter,
-readability-redundant-declaration,
-readability-function-cognitive-complexity,
-bugprone-narrowing-conversions,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-modernize-avoid-bind
WarningsAsErrors: "*"
CheckOptions:
- key: readability-braces-around-statements.ShortStatementLines
value: "2"
- 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.TemplateParameterCase,
value: CamelCase,
- key: readability-identifier-naming.FunctionCase
value: camelBack
- key: readability-identifier-naming.MethodCase
value: camelBack
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.ClassMemberCase
value: lower_case
- key: readability-identifier-naming.ClassMemberSuffix
value: _
- key: readability-identifier-naming.PrivateMemberSuffix
value: _
- key: readability-identifier-naming.ProtectedMemberSuffix
value: _
- key: readability-identifier-naming.EnumConstantCase
value: CamelCase
- key: readability-identifier-naming.EnumConstantPrefix
value: k
- key: readability-identifier-naming.ConstexprVariableCase
value: CamelCase
- key: readability-identifier-naming.ConstexprVariablePrefix
value: k
- key: readability-identifier-naming.GlobalConstantCase
value: CamelCase
- key: readability-identifier-naming.GlobalConstantPrefix
value: k
- key: readability-identifier-naming.MemberConstantCase
value: CamelCase
- key: readability-identifier-naming.MemberConstantPrefix
value: k
- key: readability-identifier-naming.StaticConstantCase
value: CamelCase
- key: readability-identifier-naming.StaticConstantPrefix
value: k
- key: readability-implicit-bool-conversion.AllowIntegerConditions
value: 1
- key: readability-implicit-bool-conversion.AllowPointerConditions
value: 1
- key: readability-function-cognitive-complexity.IgnoreMacros
value: 1
118 changes: 118 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"dockerFile": ".docker/Dockerfile",
"context": ".",
"build": {
"args": {
"WORKSPACE": "${containerWorkspaceFolder}",
"ROS_DISTRO": "humble"
}
},
"remoteUser": "dev",
"runArgs": [
"--network=host",
"--cap-add=SYS_PTRACE",
"--security-opt=seccomp:unconfined",
"--security-opt=apparmor:unconfined",
"--volume=/dev:/dev",
"--privileged"
],
"containerEnv": {
"DISPLAY": "${localEnv:DISPLAY}",
"WAYLAND_DISPLAY": "${localEnv:WAYLAND_DISPLAY}",
"XDG_RUNTIME_DIR": "${localEnv:XDG_RUNTIME_DIR}",
"PULSE_SERVER": "${localEnv:PULSE_SERVER}"
},
"customizations": {
"vscode": {
"settings": {
"files.associations": {
"*.repos": "yaml",
"*.world": "xml",
"*.xacro": "xml",
"*.srdf": "xml",
"*.rviz": "yaml"
},
"terminal.integrated.defaultProfile.linux": "bash",
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"editor.formatOnSave": true,
"xml.format.maxLineWidth": 100,
"json.format.enable": true,
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.pylintEnabled": false,
"python.linting.pydocstyleEnabled": true,
"python.linting.mypyEnabled": true,
"python.formatting.provider": "black",
"autoDocstring.startOnNewLine": false,
"autoDocstring.docstringFormat": "google",
"isort.args": ["--profile", "black"],
"isort.check": true,
"python.autoComplete.extraPaths": [
"/opt/ros/humble/lib/python3.10/site-packages/"
],
"python.analysis.extraPaths": [
"/opt/ros/humble/lib/python3.10/site-packages/"
],
"C_Cpp.default.intelliSenseMode": "linux-gcc-x86",
"C_Cpp.clang_format_fallbackStyle": "Google",
"C_Cpp.codeAnalysis.clangTidy.enabled": true,
"C_Cpp.codeAnalysis.clangTidy.runAutomatically": true,
"clang-format.executable": "/usr/bin/clang-format-14",
"[cpp]": {
"editor.rulers": [100],
"editor.tabSize": 2,
"editor.defaultFormatter": "xaver.clang-format"
},
"[python]": {
"editor.tabSize": 4,
"editor.rulers": [90],
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"[dockerfile]": {
"editor.quickSuggestions": {
"strings": true
},
"editor.defaultFormatter": "ms-azuretools.vscode-docker",
"editor.tabSize": 4
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[xml]": {
"editor.defaultFormatter": "redhat.vscode-xml"
},
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
},
"[markdown]": {
"editor.rulers": [80],
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
},
"search.exclude": {
"**/build": true,
"**/install": true,
"**/log": true
}
},
"extensions": [
"ms-azuretools.vscode-docker",
"ms-python.python",
"njpwerner.autodocstring",
"cschlosser.doxdocgen",
"ms-vscode.cpptools",
"redhat.vscode-xml",
"redhat.vscode-yaml",
"josetr.cmake-language-support-vscode",
"smilerobotics.urdf",
"DavidAnson.vscode-markdownlint",
"esbenp.prettier-vscode",
"xaver.clang-format",
"ms-python.isort",
"ms-python.flake8"
]
}
}
}
123 changes: 123 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
ARG ROS_DISTRO=rolling
FROM ros:$ROS_DISTRO-ros-base as ci

LABEL maintainer="Evan Palmer"
LABEL maintainer-email="[email protected]"

ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /root/ws_angler

COPY . src/angler

# Install apt packages
RUN apt-get -q update \
&& apt-get -q -y upgrade \
&& apt-get -q install --no-install-recommends -y \
git \
wget \
curl \
sudo \
clang \
clang-format-14 \
clang-tidy \
clang-tools \
software-properties-common \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Install MAVROS dependencies prior to installing ROS dependencies
RUN [ "/bin/bash" , "-c" , "\
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh \
&& chmod +x install_geographiclib_datasets.sh \
&& sudo ./install_geographiclib_datasets.sh" ]

# Install all ROS dependencies
RUN apt-get -q update \
&& apt-get -q -y upgrade \
&& rosdep update \
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --as-root=apt:false \
&& rm -rf src \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

FROM ci as source

ENV ROS_UNDERLAY /root/ws_angler/install
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR $ROS_UNDERLAY/..

COPY . src/angler

RUN apt-get -q update \
&& apt-get -q -y upgrade \
&& rosdep update \
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --as-root=apt:false \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
&& colcon build \
--cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
--ament-cmake-args -DCMAKE_BUILD_TYPE=Release \
--event-handlers desktop_notification- status- \
# Update /ros_entrypoint.sh to source the new workspace
&& sed -i "s#/opt/ros/\$ROS_DISTRO/setup.bash#$ROS_UNDERLAY/setup.sh#g" /ros_entrypoint.sh

FROM ci as develop

ENV ROS_UNDERLAY /root/ws_angler/install
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR $ROS_UNDERLAY/..

COPY . src/angler

RUN apt-get -q update \
&& apt-get -q -y upgrade \
&& rosdep update \
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --as-root=apt:false \
&& rm -rf src \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Install development tools
RUN apt-get -q update \
&& apt-get -q -y upgrade \
&& apt-get -q install --no-install-recommends -y \
python3-dev \
python3-pip \
iputils-ping \
net-tools \
gdb \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Install debugging/linting Python packages
RUN pip3 install \
pre-commit \
mypy \
isort \
flake8 \
black

# Configure a new non-root user
ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get update && apt-get upgrade -y \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& rm -rf /var/lib/apt/lists/* \
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc \
&& echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc

ARG WORKSPACE
RUN echo "if [ -f ${WORKSPACE}/install/setup.bash ]; then source ${WORKSPACE}/install/setup.bash; fi" >> /home/$USERNAME/.bashrc
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ignore everything
*
Loading

0 comments on commit 8cdc68d

Please sign in to comment.