Skip to content

Commit

Permalink
Add devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuebel committed Aug 29, 2024
1 parent e8b9174 commit 9ee670f
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 8 deletions.
66 changes: 66 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
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
BreakConstructorInitializersBeforeComma: true
BinPackParameters: true
ColumnLimit: 120
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
ContinuationIndentWidth: 4
IncludeBlocksStyle: Preserve
SortIncludes: CaseInsensitive
SpaceAfterCStyleCast: 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",
}
Empty file added .clang-tidy
Empty file.
52 changes: 52 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# @license BSD-3 https://opensource.org/licenses/BSD-3-Clause
# Copyright (c) 2021, Institute of Automatic Control - RWTH Aachen University
# All rights reserved.

# Choose from melodic or noetic tags
FROM ros:noetic-robot

# Add your own additional packages
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get install -y \
# Check if GUI and 3D acceleration works
mesa-utils x11-apps \
# Nice plots for debugging
ros-${ROS_DISTRO}-plotjuggler-ros \
&& apt-get upgrade -y \
&& rm -rf /var/lib/apt/lists/*

# git-lfs
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \
apt-get update && \
apt-get install git-lfs -y --no-install-recommends && \
rm -rf /var/lib/apt/lists/* && \
git lfs install
# ROS additional essential packages
RUN apt-get update && apt-get install -y --no-install-recommends\
python3-catkin-tools python3-catkin-lint python3-rosdep python3-rosinstall python3-rosinstall-generator python3-vcstool python3-wstool build-essential python3-osrf-pycommon \
ros-${ROS_DISTRO}-ros-control ros-${ROS_DISTRO}-ros-controllers ros-${ROS_DISTRO}-rqt-controller-manager && \
rm -rf /var/lib/apt/lists/*

ENV DEBIAN_FRONTEND=dialog

# Setup non-root user to solve file permission problems with rootfull docker
ARG USERNAME=vscode
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 install -y --no-install-recommends sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

# Autocompletion for root user
RUN echo "if [ -f /etc/bash_completion ] && ! shopt -oq posix; then\n . /etc/bash_completion\nfi" >> /root/.bashrc

# Create for vscode
RUN sudo mkdir -p /workspace/src && chown -R vscode:vscode /workspace
# Use non-root user to avoid permission problems
USER vscode
63 changes: 63 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// @license BSD-3 https://opensource.org/licenses/BSD-3-Clause
// Copyright (c) 2021, Institute of Automatic Control - RWTH Aachen University
// All rights reserved.
{
"dockerComposeFile": "docker-compose.yml",
"service": "ros-devcontainer",
"workspaceFolder": "/workspace/src/lbrmed-ros",
// Source the ROS workspace, the ${containerWorkspaceFolder} variable only gets replaced in this .json
// Install dependencies for workspace except Gazebo packages as the OSRF version is installed
"postCreateCommand": "echo 'source /opt/ros/${ROS_DISTRO}/setup.bash' >> ${HOME}/.bashrc && echo 'source ${containerWorkspaceFolder}/devel/setup.bash' >> ${HOME}/.bashrc && /bin/sh .devcontainer/postCreate.sh",
"customizations": {
"vscode": {
"extensions": [
"dotjoshjohnson.xml",
"epivision.vscode-file-header",
"gruntfuggly.todo-tree",
"mhutchie.git-graph",
"ms-azuretools.vscode-docker",
"ms-iot.vscode-ros",
"ms-python.black-formatter",
"ms-python.flake8",
"ms-python.python",
"ms-vscode.cmake-tools",
"ms-vscode.cpptools",
"ms-vsliveshare.vsliveshare",
"oderwat.indent-rainbow",
"redhat.vscode-yaml",
"streetsidesoftware.code-spell-checker",
"twxs.cmake",
"valentjn.vscode-ltex",
"visualstudioexptteam.vscodeintellicode"
],
// Set *default* container specific settings.json values on container create.
"settings": {
// Use C/C++ extension for formatting, linting and debugging
"C_Cpp.clang_format_style": "file",
"C_Cpp.codeAnalysis.clangTidy.enabled": true,
"C_Cpp.default.cppStandard": "c++14",
"C_Cpp.default.cStandard": "c11",
"C_Cpp.formatting": "clangFormat",
"[cpp]": {
"editor.defaultFormatter": "ms-vscode.cpptools"
},
// Other settings
"editor.formatOnSave": true,
"editor.tabSize": 2,
"git.repositoryScanMaxDepth": 3,
"powerHeader.autoInsert.enable": true,
"powerHeader.commentMode": "line",
"powerHeader.template": "file://${containerWorkspaceFolder}/.vscode/copyright_template.txt",
"python.formatting.provider": "autopep8",
"python.autoComplete.extraPaths": [
"/opt/ros/${env:ROS_DISTRO}/lib/python3/dist-packages"
],
"python.analysis.extraPaths": [
"/opt/ros/${env:ROS_DISTRO}/lib/python3/dist-packages"
],
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.gpuAcceleration": "on"
}
}
}
}
43 changes: 43 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Use this, if you run a full Linux installation
services:
ros-devcontainer:
build:
# context: ..
dockerfile: Dockerfile
# Optional: Access external devices, e.g., USB cameras
privileged: true
volumes:
- ..:/workspace/src/lbrmed-ros:cached
# GUI support
- /tmp/.X11-unix:/tmp/.X11-unix
# Avoid Qt glitches
ipc: host
network_mode: host
environment:
# GUI support
DISPLAY: $DISPLAY
WAYLAND_DISPLAY: WAYLAND_DISPLAY
XDG_RUNTIME_DIR: XDG_RUNTIME_DIR
PULSE_SERVER: PULSE_SERVER
# Optional: Use NVIDIA GPU for rendering
# __NV_PRIME_RENDER_OFFLOAD: 1
# __GLX_VENDOR_LIBRARY_NAME: nvidia
devices:
# Accelerated 3D graphics
- /dev/dri
# Optional: Enable CUDA
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# capabilities: [gpu]
# count: 1 # limit number of GPUs used by container
# Required for ptrace-based debuggers like C++
cap_add:
- SYS_PTRACE
security_opt:
- apparmor:unconfined
- seccomp:unconfined
# Avoid shutting down after process ends
command: sleep infinity
25 changes: 25 additions & 0 deletions .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# @license BSD-3 https://opensource.org/licenses/BSD-3-Clause
# Copyright (c) 2021, Institute of Automatic Control - RWTH Aachen University
# All rights reserved.

# /workspace/src/lbrmed-ros
cd /workspace

# If it exists: extend workspace from source built MoveIt (which extends /opt/ros/...)
if [ -d "/moveit_ws/devel" ]; then
catkin config --init --extend /moveit_ws/devel --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 #-DCMAKE_CXX_STANDARD=17
else
catkin config --init --extend /opt/ros/$ROS_DISTRO --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 #-DCMAKE_CXX_STANDARD=17
fi

# install workspace dependencies, src is one level above the lbrmed-ros workspace
wstool init src
wstool merge -t src src/lbrmed-ros/.rosinstall
wstool update -t src
rosdep update && sudo apt-get update
rosdep install --from-paths src --ignore-src -r -q -y --skip-keys 'gazebo gazebo_dev gazebo_plugins gazebo_ros gazebo_ros_control'
# install other system dependencies, note that they are not cached for rebuilds of the devcontainer
# frequently used dependencies should be install in my.Dockerfile

# Check rendering support
glxinfo -B
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.catkin_tools
.vscode
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,43 @@ Please look at the READMEs in the specific hardware packages.
**When using the real robot, always keep a safe distance and set up your safety configuration as required**.

# Install
## Create a catkin workspace
## Devcontainer
This is the easiest way to get started
When opening this repository in Visual Studio Code, you should be prompted to reopen it in a container.
On launch, the container will setup all required dependencies via rosinstall and rosdep.

This repository also ships **VS Code tasks** for:
- Building the workspace `catkin build workspace`
- Building the package of the current file only `catkin build package`
- Clean the catkin build files `catkin clean`

After starting the container, the lbrmed-ros package will be opened as **workspace**.
The folder structure is `/workspace/src/lbrmed-ros`, so you will want to `cd` to a top-level folder when using low-level catkin commands

## Manual steps
### Create a catkin workspace
* Create a catkin workspace folder (e.g. ~/catkin_workspace)
* Create a src folder in that workspace (e.g. ~/catkin_workspace/src)
* Initialize the catkin workspace (e.g. `cd ~/catkin_workspace && catkin init`)

## Cloning the repository
### Cloning the repository
We use [`git-lfs`](https://packagecloud.io/github/git-lfs/install) which should be installed before cloning.
Otherwise, you might get errors when the STL files of the robot or the jar files are being loaded.

For the Sunrise Project you have two ways to proceed:
* (a) Clone the repository into the src folder of the catkin workspace
* (b) (preferable) Clone the repository into a separate folder (e.g. ~/git-repos) and symlink it (e.g. `ln -s ~/git-repos/kuka_MED_Stack ~/catkin_workspace/src`, the target of the symlink must be an absolute path)

## Installing Dependencies
### Installing Dependencies
In the catkin workspace, run the following commands to install all workspace and system dependencies.
```bash
wstool init src
wstool merge -t src src/lbrmed-stack/.rosinstall
wstool merge -t src src/lbrmed-ros/.rosinstall
wstool update -t src
rosdep install --from-paths src --ignore-src -r -y
```

## Building the workspace
### Building the workspace
To build the packages in parallel, we use the [catkin_tools](https://catkin-tools.readthedocs.io/en/latest/installing.html). After installing them, run:
```bash
cd ~/catkin_workspace
Expand Down
3 changes: 0 additions & 3 deletions lbrmed_hw_fri/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ Calls the `set_impedance_fri` service of the `lbrmed_hw_fri_node` to set the sti
## Acknowledgment
Based on [lbr_fri_ros2_stack](https://github.com/KCL-BMEIS/lbr_fri_ros2_stack/tree/noetic) which has a noetic branch.

# Setup
For the internal irt setup take a look at the [gitlab wiki](https://git-ce.rwth-aachen.de/g-med-irt-robotik/lbrmed-stack/-/wikis/Robot%20Hardware%20Usage) and the [irt wiki](https://wiki.irt.rwth-aachen.de/wiki/KUKA_LBR).

## Setup the Controller
The controller (Sunrise Cabinet) receives commands from the ROS machine via the FRI. Therefore, the server application has to be pushed onto the Sunrise Cabinet.
- Connect an ethernet cable to port X66 on the Sunrise Cabinet
Expand Down

0 comments on commit 9ee670f

Please sign in to comment.