Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/docker #5

Merged
merged 19 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
69 changes: 69 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "RPMPLv2-dev",
"remoteUser": "roboticsETF",
"containerEnv": {
"SHELL": "/bin/bash"
},
"build": {
"context": "..",
"dockerfile": "../.docker/Dockerfile",
"target": "rpmplv2-dev-container"
},
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers-contrib/features/bash-command:1": {},
"ghcr.io/devcontainers/features/common-utils:2": {
"upgradePackages": false,
"username": "roboticsETF"
},
"ghcr.io/stuartleeks/dev-container-features/shell-history:0": {
"version": "latest"
}
},
"customizations": {
"vscode": {
"extensions": [
// language support
"ms-python.python",
"ms-vscode.cpptools",
"josetr.cmake-language-support-vscode", // cmake syntax support
"ms-azuretools.vscode-docker", // dockerfile and linting support
"mrmlnc.vscode-json5",
// formatters
"llvm-vs-code-extensions.vscode-clangd", // linting and code-formatting
"foxundermoon.shell-format", // shell script formatting
"redhat.vscode-yaml", // yaml syntax highlighting and formatting
"charliermarsh.ruff", // fast python formatting
// productivity
"mhutchie.git-graph",
"matepek.vscode-catch2-test-adapter",
"ms-iot.vscode-ros",
],
"settings": {}
}
},
"runArgs": [
"-e",
"CCACHE_DIR=${containerWorkspaceFolder}/.ccache",
"--net",
"host",
"--privileged",
"-e",
"DISPLAY=${env:DISPLAY}",
"-v",
"/tmp/.X11-unix:/tmp/.X11-unix:rw",
"-v",
"${env:HOME}/.ssh:/home/roboticsETF/.ssh:ro",
"-v",
"/var/run/dbus:/var/run/dbus:rw",
"-v",
"/run/dbus:/run/dbus:rw",
"-v",
"/dev:/dev",
// For HW accelerated graphics
"--device",
"/dev/dri:/dev/dri",
"--gpus",
"all"
],
}
52 changes: 52 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
FROM ubuntu:22.04 as rpmplv2-dev-container

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
curl \
wget \
gnupg \
make \
cmake \
lsb-release \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libeigen3-dev libkdl-parser-dev libgflags-dev libgoogle-glog-dev liborocos-kdl-dev \
libgtest-dev libyaml-cpp-dev liburdf-dev python3-pip libfcl-dev libnanoflann-dev \
&& pip3 install trimesh urdfpy \
&& rm -rf /var/lib/apt/lists/*

ENV CLANG_VERSION=18
RUN wget https://apt.llvm.org/llvm.sh && \
sed -i "s/add-apt-repository \"${REPO_NAME}\"/add-apt-repository \"${REPO_NAME}\" -y/g" llvm.sh && \
chmod +x llvm.sh && \
./llvm.sh $CLANG_VERSION -y && \
apt-get install -y --no-install-recommends clang-$CLANG_VERSION clang-tidy-$CLANG_VERSION clang-format-$CLANG_VERSION \
llvm-$CLANG_VERSION-dev libc++-$CLANG_VERSION-dev libomp-$CLANG_VERSION-dev libc++abi-$CLANG_VERSION-dev libunwind-$CLANG_VERSION-dev && \
rm -rf /var/lib/apt/lists/*

RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-$CLANG_VERSION $CLANG_VERSION \
--slave /usr/bin/clang++ clang++ /usr/bin/clang++-$CLANG_VERSION \
--slave /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-$CLANG_VERSION \
--slave /usr/bin/clang-format clang-format /usr/bin/clang-format-$CLANG_VERSION

RUN ln -s /usr/bin/clangd-${CLANG_VERSION} /usr/bin/clangd

ARG USERNAME=roboticsETF
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 sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

USER $USERNAME
35 changes: 35 additions & 0 deletions .github/workflows/rpmplv2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build with CMake (Linux)

on:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1

- name: Install dependencies
run: |
sudo apt update && sudo apt upgrade && sudo apt install -y libunwind-dev apt-transport-https \
ca-certificates curl wget gnupg make cmake lsb-release software-properties-common \
libeigen3-dev libkdl-parser-dev libgflags-dev libgoogle-glog-dev liborocos-kdl-dev \
libgtest-dev libyaml-cpp-dev liburdf-dev python3-pip libfcl-dev libnanoflann-dev \
&& pip3 install trimesh urdfpy
shell: bash

- name: Configure with CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=Release

- name: Build
run: |
mkdir -p build
cmake --build build --config Release

- name: Test (optional)
run: |
if [ -d build/tests ]; then
ctest --test-dir build/tests -C Release --output-on-failure
fi
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ build
install
log
.vscode
data/xarm6/scenario_real_time/DRGBMTstar
data/xarm6/scenario_real_time/DRGBTConnect
*.log
13 changes: 2 additions & 11 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
[submodule "external/glog"]
path = external/glog
url = https://github.com/google/glog.git
[submodule "external/nanoflann"]
path = external/nanoflann
url = https://github.com/jlblancoc/nanoflann.git
[submodule "external/googletest"]
path = external/googletest
url = https://github.com/google/googletest
[submodule "external/QuadProgpp"]
path = external/QuadProgpp
url = https://github.com/liuq/QuadProgpp.git
path = external/QuadProgpp
url = https://github.com/liuq/QuadProgpp.git
16 changes: 7 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ project(

# Only do these if this is the main project, and not if it is included through add_subdirectory
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)

# Optionally set things like CMAKE_CXX_STANDARD, CMAKE_POSITION_INDEPENDENT_CODE here

# Let's ensure -std=c++xx instead of -std=g++xx
Expand All @@ -20,7 +19,6 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")


# Testing only available if this is the main app
# Note this needs to be done in the main CMakeLists
# since it calls enable_testing, which must be in the
Expand All @@ -29,6 +27,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)

# Docs only available if this is the main app
find_package(Doxygen)

if(Doxygen_FOUND)
add_subdirectory(docs)
else()
Expand All @@ -45,21 +44,21 @@ include_directories(${OROCOS_KDL_INCLUDE_DIR})

find_package(yaml-cpp REQUIRED)
find_package(fcl 0.7 REQUIRED)
find_package(nanoflann REQUIRED)

add_subdirectory(external/glog)
add_subdirectory(external/nanoflann)
add_subdirectory(external/googletest)
# add_subdirectory(external/QuadProgpp)
set(PROJECT_LIBRARIES gtest glog gflags nanoflann::nanoflann kdl_parser orocos-kdl fcl ccd yaml-cpp

set(PROJECT_LIBRARIES gtest glog::glog nanoflann kdl_parser orocos-kdl fcl ccd yaml-cpp
# quadprog
)

set(MAIN_PROJECT_BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data)
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/apps/data)

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/visualizer/
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/visualizer)
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/apps/visualizer)

# The compiled library code is here
add_subdirectory(src)
Expand All @@ -69,7 +68,6 @@ add_subdirectory(apps)

# Testing only available if this is the main app
# Emergency override MODERN_CMAKE_BUILD_TESTING provided as well

if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR MODERN_CMAKE_BUILD_TESTING) AND BUILD_TESTING)
add_subdirectory(tests)
endif()
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.PHONY: clean build dependencies source-dirs sim

dependencies:
rosdep install --from-paths src --ignore-src -r -y
.PHONY: clean build run_tests

clean:
rm -r ./build/ ./install/ ./log/
rm -r ./build

build:
colcon build --symlink-install --cmake-args " -DCMAKE_BUILD_TYPE=RelWithDebInfo"
mkdir -p build
cd build && cmake .. && make

run_tests:

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Available planners are:
The development and test environment are tested on Ubuntu 22.04 + ROS2 Humble.

# 2. How to use
## 2.0 Use docker and devcontainer

If VS Code (or any other IDE with a support for VS Code's devcontainers), then just open and use "Rebuild and open in container" option. Then proceed with 2.5. Otherwise, continue with 2.1.

## 2.1 Obtain source code of "RPMPLv2" repository
Choose the location for a target workspace, e.g.:
```
Expand Down
2 changes: 1 addition & 1 deletion apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ install(TARGETS
test_rgbtconnect
test_drgbt
test_rgbmtstar
DESTINATION apps)
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin)
33 changes: 0 additions & 33 deletions external/QuadProgpp/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions external/QuadProgpp/CMakeLists.txt

This file was deleted.

21 changes: 0 additions & 21 deletions external/QuadProgpp/LICENSE

This file was deleted.

23 changes: 0 additions & 23 deletions external/QuadProgpp/README.md

This file was deleted.

Loading