From 89440834286757a08d32680ca7088bd93dd7a546 Mon Sep 17 00:00:00 2001 From: ARK3r Date: Tue, 29 Jul 2025 17:16:20 +0000 Subject: [PATCH 1/3] devcontainer working with rolling and gps wpf tested Signed-off-by: ARK3r --- .devcontainer/Dockerfile | 32 ++++++++++++++++++++++ .devcontainer/devcontainer.json | 47 +++++++++++++++++++++++++++++++++ README.md | 4 +++ 3 files changed, 83 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..9176a8d --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,32 @@ +ARG ROS_DISTRO=rolling +FROM ros:rolling + +ARG USERNAME=ros_user +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# Delete user if it exists in container (e.g Ubuntu Noble: ubuntu) +RUN if id -u $USER_UID ; then userdel `id -un $USER_UID` ; fi + +# Create the user +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ + # + # [Optional] Add sudo support. Omit if you don't need to install software after connecting. + && apt-get update \ + && apt-get install -y sudo \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME +RUN apt-get update && apt-get upgrade -y +RUN apt-get install -y python3-pip + +# Create workspace directory with proper ownership +RUN mkdir -p /home/ws && chown -R $USERNAME:$USERNAME /home/ws + +RUN git clone https://github.com/ros-navigation/navigation2.git -b main /home/ws/src/navigation2 + +ENV SHELL=/bin/bash + +# [Optional] Set the default user. Omit if you want to keep the default as root. +USER $USERNAME +CMD ["/bin/bash"] \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..0d52820 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,47 @@ +{ + "name": "Navigation2 Tutorials Development Container", + "privileged": true, + "remoteUser": "ros_user", + "build": { + "dockerfile": "Dockerfile", + "args": { + "USERNAME": "ros_user", + "ROS_DISTRO": "rolling" + } + }, + "workspaceFolder": "/home/ws", + "workspaceMount": "source=${localWorkspaceFolder},target=/home/ws/src/navigation2_tutorials,type=bind", + "customizations": { + "vscode": { + "extensions": [ + "ms-vscode.cpptools", + "ms-vscode.cpptools-themes", + "twxs.cmake", + "donjayamanne.python-extension-pack", + "eamodio.gitlens", + "ms-iot.vscode-ros", + "ms-vscode.cmake-tools", + "ms-python.python", + "ms-python.flake8", + "charliermarsh.ruff" + ] + } + }, + "containerEnv": { + "DISPLAY": "unix:0", + "ROS_AUTOMATIC_DISCOVERY_RANGE": "LOCALHOST", + "ROS_DOMAIN_ID": "42", + "ROS_DISTRO": "${ROS_DISTRO}" + }, + "runArgs": [ + "--net=host", + "--pid=host", + "--ipc=host", + "-e", "DISPLAY=${env:DISPLAY}" + ], + "mounts": [ + "source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached", + "source=/dev/dri,target=/dev/dri,type=bind,consistency=cached" + ], + "postCreateCommand": "sudo rosdep update && sudo rosdep install --from-paths src --ignore-src -r -y" +} \ No newline at end of file diff --git a/README.md b/README.md index 846b5d6..001a539 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # navigation2_tutorials Tutorial code referenced in https://docs.nav2.org/ + +## Quick Start with Dev Container + +This repository includes a VS Code development container for easy setup. Open in VS Code and select "Reopen in Container" when prompted or by using the shortcut Ctrl+Shift+P to bring up the command palette and selecting "Dev containers: Rebuild and Reopen in Container". For detailed setup instructions, see the [official ROS 2 documentation](https://docs.ros.org/en/rolling/How-To-Guides/Setup-ROS-2-with-VSCode-and-Docker-Container.html). From 9319470bc1446bfd9b7fd3d0b35ce3a47b6af05e Mon Sep 17 00:00:00 2001 From: ARK3r Date: Tue, 29 Jul 2025 16:35:18 -0400 Subject: [PATCH 2/3] use ghcr.io/ros-navigation/nav2_docker img Signed-off-by: ARK3r --- .devcontainer/Dockerfile | 32 ------------- .devcontainer/devcontainer.json | 79 +++++++++++++++++---------------- 2 files changed, 41 insertions(+), 70 deletions(-) delete mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 9176a8d..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -ARG ROS_DISTRO=rolling -FROM ros:rolling - -ARG USERNAME=ros_user -ARG USER_UID=1000 -ARG USER_GID=$USER_UID - -# Delete user if it exists in container (e.g Ubuntu Noble: ubuntu) -RUN if id -u $USER_UID ; then userdel `id -un $USER_UID` ; fi - -# Create the user -RUN groupadd --gid $USER_GID $USERNAME \ - && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ - # - # [Optional] Add sudo support. Omit if you don't need to install software after connecting. - && apt-get update \ - && apt-get install -y sudo \ - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME -RUN apt-get update && apt-get upgrade -y -RUN apt-get install -y python3-pip - -# Create workspace directory with proper ownership -RUN mkdir -p /home/ws && chown -R $USERNAME:$USERNAME /home/ws - -RUN git clone https://github.com/ros-navigation/navigation2.git -b main /home/ws/src/navigation2 - -ENV SHELL=/bin/bash - -# [Optional] Set the default user. Omit if you want to keep the default as root. -USER $USERNAME -CMD ["/bin/bash"] \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0d52820..4cdb228 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,47 +1,50 @@ { - "name": "Navigation2 Tutorials Development Container", - "privileged": true, - "remoteUser": "ros_user", - "build": { - "dockerfile": "Dockerfile", - "args": { - "USERNAME": "ros_user", - "ROS_DISTRO": "rolling" + "name": "Nav2", + "image": "ghcr.io/ros-navigation/nav2_docker:rolling-nightly", + "runArgs": [ + "--name=nav2", + // "--cap-add=SYS_PTRACE", // enable debugging, e.g. gdb + "--ipc=host", // shared memory transport with host, e.g. rviz GUIs + "--network=host", // network access to host interfaces, e.g. eth0 + "--pid=host", // DDS discovery with host, without --network=host + "--privileged", // device access to host peripherals, e.g. USB + // "--security-opt=seccomp=unconfined", // enable debugging, e.g. gdb + "--volume=/tmp/.X11-unix:/tmp/.X11-unix:rw", // X11 socket for GUI applications + "--shm-size=1000mb", // shared memory size for DDS/ROS communication + "--gpus=all" // access to all GPUs, e.g. for GPU-accelerated applications + ], + "workspaceFolder": "/root/nav2_ws", + "workspaceMount": "source=${localWorkspaceFolder},target=/root/nav2_ws/src/navigation2_tutorials,type=bind", + "remoteEnv": { + "OVERLAY_MIXINS": "release ccache lld", + "CCACHE_DIR": "/tmp/.ccache", + "QT_X11_NO_MITSHM": "1", // disable MIT-SHM for X11 forwarding + "DISPLAY": "${localEnv:DISPLAY}" // X11 forwarding + }, + "mounts": [ + { + "source": "${localEnv:XAUTHORITY}", + "target": "/root/.Xauthority", + "type": "bind" } + ], + "features": { + // "ghcr.io/devcontainers/features/desktop-lite:1": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} }, - "workspaceFolder": "/home/ws", - "workspaceMount": "source=${localWorkspaceFolder},target=/home/ws/src/navigation2_tutorials,type=bind", "customizations": { + "codespaces": {}, "vscode": { + "settings": {}, "extensions": [ - "ms-vscode.cpptools", - "ms-vscode.cpptools-themes", - "twxs.cmake", - "donjayamanne.python-extension-pack", - "eamodio.gitlens", + "althack.ament-task-provider", + "eamodio.gitlens", + "esbenp.prettier-vscode", + "GitHub.copilot", "ms-iot.vscode-ros", - "ms-vscode.cmake-tools", - "ms-python.python", - "ms-python.flake8", - "charliermarsh.ruff" + "streetsidesoftware.code-spell-checker", + "twxs.cmake" ] } - }, - "containerEnv": { - "DISPLAY": "unix:0", - "ROS_AUTOMATIC_DISCOVERY_RANGE": "LOCALHOST", - "ROS_DOMAIN_ID": "42", - "ROS_DISTRO": "${ROS_DISTRO}" - }, - "runArgs": [ - "--net=host", - "--pid=host", - "--ipc=host", - "-e", "DISPLAY=${env:DISPLAY}" - ], - "mounts": [ - "source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached", - "source=/dev/dri,target=/dev/dri,type=bind,consistency=cached" - ], - "postCreateCommand": "sudo rosdep update && sudo rosdep install --from-paths src --ignore-src -r -y" -} \ No newline at end of file + } +} \ No newline at end of file From 97cc7d758f8d99110ae7aae25cdffa8ab616245d Mon Sep 17 00:00:00 2001 From: ARK3r Date: Tue, 29 Jul 2025 18:26:17 -0400 Subject: [PATCH 3/3] use nav2 docker image with root user and postcreatecommand Signed-off-by: ARK3r --- .devcontainer/Dockerfile | 7 +++++++ .devcontainer/devcontainer.json | 13 +++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..3543692 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,7 @@ +ARG ROS_DISTRO=rolling +ARG BASE_IMAGE=ghcr.io/ros-navigation/nav2_docker:${ROS_DISTRO}-nightly +FROM ${BASE_IMAGE} + +ENV SHELL=/bin/bash + +CMD ["/bin/bash"] \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4cdb228..51c1122 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,14 @@ { "name": "Nav2", - "image": "ghcr.io/ros-navigation/nav2_docker:rolling-nightly", + "privileged": true, + "remoteUser": "root", + "build": { + "dockerfile": "Dockerfile", + "args": { + "USERNAME": "root", + "ROS_DISTRO": "rolling" + } + }, "runArgs": [ "--name=nav2", // "--cap-add=SYS_PTRACE", // enable debugging, e.g. gdb @@ -46,5 +54,6 @@ "twxs.cmake" ] } - } + }, + "postCreateCommand": "sudo apt-get update && rosdep update && sudo rosdep install --from-paths src --ignore-src -y -r" } \ No newline at end of file