Skip to content

Commit

Permalink
add docker files
Browse files Browse the repository at this point in the history
  • Loading branch information
harpun11 committed Oct 22, 2024
1 parent b1ee8a7 commit cb3d4ed
Show file tree
Hide file tree
Showing 10 changed files with 375 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
compose.yaml
devcontainer.json
Dockerfile
71 changes: 71 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
FROM osrf/ros:humble-desktop

SHELL ["/bin/bash", "-c"]

ENV RCUTILS_COLORIZED_OUTPUT=1

RUN apt update && \
apt install -y \
build-essential \
cmake \
git \
curl lsb-release gnupg \
libbullet-dev \
python3-colcon-common-extensions \
python3-flake8 \
python3-pip \
python3-pytest-cov \
python3-rosdep \
python3-setuptools \
python3-vcstool \
python3-colcon-clean \
wget \
clang-format && \
python3 -m pip install -U \
argcomplete \
flake8-blind-except \
flake8-builtins \
flake8-class-newline \
flake8-comprehensions \
flake8-deprecated \
flake8-docstrings \
flake8-import-order \
flake8-quotes \
pytest-repeat \
pytest-rerunfailures \
pytest

RUN pip3 install \
kconfiglib \
jsonschema \
jinja2 \
pyros-genmsg \
future


# Install Gazebo Harmonic - Default Gazebo version in ROS2 Humble is Fortress
RUN curl https://packages.osrfoundation.org/gazebo.gpg --output /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
RUN apt-get update -y
RUN apt-get install -y ros-humble-ros-gzharmonic
RUN apt install -y ros-humble-turtle-tf2-py ros-humble-tf2-tools

RUN apt-get update -y
RUN apt-get upgrade -y

RUN useradd -rm -d /home/developer -s /bin/bash -g root -G sudo -u 1001 developer && \
echo 'developer:developer' | chpasswd && \
adduser developer sudo
USER developer

# RUN git clone https://github.com/PX4/PX4-Autopilot.git ~/PX4-Autopilot --recursive -b main && \
# echo developer | sudo -S bash /home/developer/PX4-Autopilot/Tools/setup/ubuntu.sh

COPY . /home/developer/ros2_ws
WORKDIR /home/developer/ros2_ws


RUN echo ". /opt/ros/$ROS_DISTRO/setup.bash" >> ~/.bashrc \
&& echo ". /home/developer/ros2_ws/install/setup.bash" >> ~/.bashrc

CMD [ "sleep", "infinity" ]
10 changes: 10 additions & 0 deletions .devcontainer/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

# Set the default build type
BUILD_TYPE=RelWithDebInfo
colcon build \
--merge-install \
--symlink-install \
--cmake-args "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" "-DCMAKE_EXPORT_COMPILE_COMMANDS=On" \
-Wall -Wextra -Wpedantic
22 changes: 22 additions & 0 deletions .devcontainer/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
workspace:
build: .
ipc: host
network_mode: host
privileged: true
tty: true
runtime: nvidia
stdin_open: true
security_opt:
- seccomp:unconfined
- apparmor:unconfined
volumes:
- ../:/home/developer/ros2_ws/src:cached
- /tmp/.X11-unix:/tmp/.X11-unix
devices:
- /dev:/dev
environment:
- DISPLAY
- "QT_X11_NO_MITSHM=1"
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=compute,utility,display
33 changes: 33 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"dockerComposeFile": [
"compose.yaml"
],
"initializeCommand": "xhost +local:docker",
// "onCreateCommand": "/bin/bash /home/developer/ros2_ws/setup.sh",
"service": "workspace",
"workspaceFolder": "/home/developer/ros2_ws/src",
"shutdownAction": "stopCompose",
// Set *default* container specific settings.json values on container create.
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"icon": "terminal-bash"
}
},
"terminal.integrated.defaultProfile.linux": "bash"
},
"extensions": [
"ms-vscode.cpptools",
"ms-python.python",
"ajshort.msg",
"twxs.cmake",
"redhat.vscode-xml",
"actboy168.tasks",
"brpaz.file-templates"
]
}
}
}
9 changes: 9 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e

cd /home/developer/ros2_ws

# vcs import --recursive < /home/developer/ros2_ws/src/px4.repos src

rosdep update --rosdistro $ROS_DISTRO
rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y
6 changes: 6 additions & 0 deletions .devcontainer/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

if [ -f install/setup.bash ]; then source install/setup.bash; fi
colcon test --merge-install
colcon test-result
19 changes: 19 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"/home/developer/ros2_ws/src",
"/opt/ros/humble/include/**",
"/usr/include/ignition/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"compileCommands": "/home/developer/ros2_ws/build/compile_commands.json",
"cStandard": "c99",
"cppStandard": "c++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
50 changes: 50 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
// Example launch of a python file
{
"name": "Python: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
},
// Example gdb launch of a ros executable
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/install/lib/${input:package}/${input:program}",
"args": [],
"preLaunchTask": "build",
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
],
"inputs": [
{
"id": "package",
"type": "promptString",
"description": "Package name",
"default": "examples_rclcpp_minimal_publisher"
},
{
"id": "program",
"type": "promptString",
"description": "Program name",
"default": "publisher_member_function"
}
]
}
152 changes: 152 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
{
"editor.tabSize": 2,
"editor.rulers": [
100
],
"files.associations": {
"*.repos": "yaml",
"*.world": "xml",
"*.xacro": "xml",
"chrono": "cpp",
"iosfwd": "cpp",
"fstream": "cpp",
"*.tcc": "cpp",
"regex": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"bit": "cpp",
"bitset": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"semaphore": "cpp",
"shared_mutex": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cfenv": "cpp",
"cinttypes": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"variant": "cpp",
"climits": "cpp",
"valarray": "cpp",
"*.ipp": "cpp"
},
"python.analysis.extraPaths": [
"/opt/ros/humble/lib/python3.10/site-packages/"
],
// Autocomplete from ros python packages
"python.autoComplete.extraPaths": [
"/opt/ros/humble/lib/python3.10/site-packages/"
],
// Environment file lets vscode find python files within workspace
"python.envFile": "${workspaceFolder}/.env",
// Use the system installed version of autopep8
"python.formatting.autopep8Path": "/usr/bin/autopep8",
"python.formatting.autopep8Args": [
"--max-line-length=100"
],
"C_Cpp.default.intelliSenseMode": "linux-gcc-x86",
"C_Cpp.formatting": "Disabled",
"uncrustify.configPath.linux": "/opt/ros/galactic/lib/python3.8/site-packages/ament_uncrustify/configuration/ament_code_style.cfg",
"[cpp]": {
"editor.defaultFormatter": "zachflower.uncrustify"
},
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true,
"**/build": true,
"**/install": true,
"**/log": true
},
"cSpell.words": [
"RTPS",
"athackst",
"autopep",
"cmake",
"cppcheck",
"cpplint",
"DCMAKE",
"deque",
"devcontainer",
"ints",
"noqa",
"pytest",
"rclcpp",
"rclpy",
"repos",
"rosdep",
"rosdistro",
"rosidl",
"RTPS",
"uncrustify",
"Wextra",
"Wpedantic",
"xmllint"
],
"cSpell.allowCompoundWords": true,
"cSpell.ignorePaths": [
"**/package-lock.json",
"**/node_modules/**",
"**/vscode-extension/**",
"**/.git/objects/**",
".vscode",
".vscode-insiders",
".devcontainer/devcontainer.json"
]
}

0 comments on commit cb3d4ed

Please sign in to comment.