Skip to content

Commit

Permalink
improve dev environment
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelsadok committed Jan 24, 2024
1 parent a4ef938 commit cb92039
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 8 deletions.
81 changes: 81 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
BasedOnStyle: Google
IndentWidth: '4'
ColumnLimit: '120'

IncludeCategories:
# main include automatically assigned to Priority 0
- Regex: '^".*_(conf|config)\.(hpp|h)"$' # config headers
Priority: 3
- Regex: '^".*"$' # sibling & project headers
Priority: 1
- Regex: '^<.*>$' # system & library headers
Priority: 2

# Format function arguments and parameters
BinPackArguments: 'false'
BinPackParameters: 'false'
AllowAllArgumentsOnNextLine: 'false'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AlignAfterOpenBracket: BlockIndent
SpaceBeforeParens: ControlStatements

# Constructor Formatting
PackConstructorInitializers: CurrentLine
IndentAccessModifiers: 'false'
AccessModifierOffset: '-4'
SpaceBeforeCtorInitializerColon: 'true'
BreakConstructorInitializers: BeforeColon
LambdaBodyIndentation: OuterScope

AllowShortCaseLabelsOnASingleLine: 'true'
AllowShortBlocksOnASingleLine: 'false'
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: 'false'
AllowShortEnumsOnASingleLine: 'true'
AllowShortFunctionsOnASingleLine: 'Inline'
AllowShortLambdasOnASingleLine: 'All'

# Switch / Case
IndentCaseLabels: 'true'
IndentCaseBlocks: 'false'

# Preprocessor stuff
AlignConsecutiveMacros: 'true'
AlignEscapedNewlines: Right
AlignTrailingComments: 'false'
SpacesBeforeTrailingComments: 1

# Alignment of procedural code
AlignConsecutiveAssignments: 'false'
AlignConsecutiveDeclarations: 'false'
AlignConsecutiveBitFields: Consecutive

AlignOperands: AlignAfterOperator
# BreakBeforeTernaryOperators: 'false'
BreakBeforeBinaryOperators: 'true'

# Pointers and East/West Const
DerivePointerAlignment: 'false'
PointerAlignment: Left
QualifierAlignment: Leave
# QualifierOrder: ['volatile', 'constexpr', 'static', 'inline', 'type', 'const']

Cpp11BracedListStyle: 'true'

# Vertical Whitespace
SeparateDefinitionBlocks: Leave
EmptyLineBeforeAccessModifier: Always
EmptyLineAfterAccessModifier: Never

# AlignArrayOfStructures: Right
# InsertTrailingCommas: 'Wrapped'


AlwaysBreakAfterReturnType: None
PenaltyReturnTypeOnItsOwnLine: 9999 # We really hate breaking after return types
PenaltyBreakAssignment: 999 # Prefer not to break around =

FixNamespaceComments: 'true'
# NamespaceIndentation: All
...
13 changes: 9 additions & 4 deletions .devcontainer/humble/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
],
"workspaceMount": "source=${localWorkspaceFolder},target=/${localWorkspaceFolderBasename},type=bind",
"workspaceFolder": "/${localWorkspaceFolderBasename}",
"mounts": [

]
}
"mounts": [],
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools"
]
}
}
}
30 changes: 30 additions & 0 deletions .devcontainer/iron-remote/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM ros:iron-ros-base

# Add vscode user with same UID and GID as your host system
# (copied from https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user)
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# Switch from root to user
USER $USERNAME

# Add user to video group to allow access to webcam
RUN sudo usermod --append --groups video $USERNAME

# Update all packages
RUN sudo apt update && sudo apt upgrade -y

# Install Git
RUN sudo apt install -y git

# Rosdep update
RUN rosdep update

# Source the ROS setup file
RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> ~/.bashrc
18 changes: 18 additions & 0 deletions .devcontainer/iron-remote/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "iron-remote",
"dockerFile": "Dockerfile",
"runArgs": [
"--privileged",
"--network=host"
],
"workspaceMount": "source=/home/pi/odrive_can,target=/${localWorkspaceFolderBasename},type=bind,consistency=cached",
"workspaceFolder": "/${localWorkspaceFolderBasename}",
"mounts": [],
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools"
]
}
}
}
13 changes: 9 additions & 4 deletions .devcontainer/iron/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
],
"workspaceMount": "source=${localWorkspaceFolder},target=/${localWorkspaceFolderBasename},type=bind",
"workspaceFolder": "/${localWorkspaceFolderBasename}",
"mounts": [

]
}
"mounts": [],
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools"
]
}
}
}
18 changes: 18 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/opt/ros/iron/include/hardware_interface",
"/opt/ros/iron/include/rcpputils"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-arm64"
}
],
"version": 4
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"C_Cpp.autoAddFileAssociations": false,
}
22 changes: 22 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "colcon build --symlink-install",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"clear": true
},
"problemMatcher": [
"$gcc"
],
},
]
}

0 comments on commit cb92039

Please sign in to comment.