diff --git a/.devcontainer/robot/Dockerfile b/.devcontainer/robot/Dockerfile new file mode 100644 index 00000000..f10cb1e8 --- /dev/null +++ b/.devcontainer/robot/Dockerfile @@ -0,0 +1,31 @@ +# +# Dockerfile for *-robot development container +# +ARG BLUE_GITHUB_REPO=Robotic-Decision-Making-Lab/blue +ARG ROS_DISTRO=rolling +FROM ${BLUE_GITHUB_REPO}:${ROS_DISTRO}-robot + +# Install ROS dependencies +# This is done in a previous stage, but we include it again here in case anyone wants to +# add new dependencies during development +ENV USERNAME=blue +ENV USER_WORKSPACE=/home/$USERNAME/ws_blue +WORKDIR $USER_WORKSPACE + +COPY --chown=$USER_UID:$USER_GID . src/blue +RUN sudo apt-get -q update \ + && sudo apt-get -q -y upgrade \ + && rosdep update \ + && rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --skip-keys="gz-transport12 gz-sim7 gz-math7 gz-msgs9 gz-plugin2" \ + && sudo apt-get autoremove -y \ + && sudo apt-get clean -y \ + && sudo rm -rf /var/lib/apt/lists/* + +# Install debugging/linting Python packages +RUN python3 -m pip install \ + pre-commit \ + mypy + +# Disable the setuputils installation warning +# This prevents us from needing to pin the setuputils version (which doesn't always work) +ENV PYTHONWARNINGS="ignore" diff --git a/.devcontainer/robot/devcontainer.json b/.devcontainer/robot/devcontainer.json new file mode 100644 index 00000000..d57e5f09 --- /dev/null +++ b/.devcontainer/robot/devcontainer.json @@ -0,0 +1,40 @@ +{ + "name": "Robot Dev Container", + "build": { + "dockerfile": "Dockerfile", + "context": "../..", + "args": { + "BLUE_GITHUB_REPO": "ghcr.io/robotic-decision-making-lab/blue", + "ROS_DISTRO": "rolling" + } + }, + "workspaceMount": "source=${localWorkspaceFolder},target=/home/blue/ws_blue/src/blue,type=bind", + "workspaceFolder": "/home/blue/ws_blue/src/blue", + "remoteUser": "blue", + "runArgs": [ + "--network=host", + "--cap-add=SYS_PTRACE", + "--security-opt=seccomp:unconfined", + "--security-opt=apparmor:unconfined", + "--volume=/dev:/dev", + "--privileged", + "--volume=/run/user/1000:/run/user/1000" + ], + "containerEnv": {}, + "customizations": { + "vscode": { + "extensions": [ + "ms-azuretools.vscode-docker", + "ms-python.python", + "njpwerner.autodocstring", + "redhat.vscode-xml", + "redhat.vscode-yaml", + "smilerobotics.urdf", + "esbenp.prettier-vscode", + "charliermarsh.ruff", + "josetr.cmake-language-support-vscode", + "unifiedjs.vscode-mdx" + ] + } + } +} diff --git a/.docker/Dockerfile b/.docker/Dockerfile index c5982eab..b309cdd2 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -26,7 +26,8 @@ RUN apt-get -q update \ && apt-get clean -y \ && rm -rf /var/lib/apt/lists/* -# Install all ROS dependencies +# Install all ROS dependencies for _just_ blue +# (we have not imported other repos from .repos files) RUN apt-get -q update \ && apt-get -q -y upgrade \ && rosdep update \ @@ -36,6 +37,14 @@ RUN apt-get -q update \ && apt-get clean -y \ && rm -rf /var/lib/apt/lists/* +# This stage includes +# - Switching to the non-root user +# - Copying 'blue' source from this repo into the non-root user's workspace +# - Installing blue deps using pip, apt and rosdep +# - Installs the remaining blue dependencies from blue_robot.repos +# - Installs deps from rosdep for all src dependencies +# - colcon build +# FROM ci AS robot # Configure a new non-root user @@ -88,14 +97,20 @@ RUN sudo apt-get -q update \ && sudo apt-get clean -y \ && sudo rm -rf /var/lib/apt/lists/* +WORKDIR $USER_WORKSPACE RUN sudo apt-get -q update \ && sudo apt-get -q -y upgrade \ + && vcs import src < src/blue/blue.repos \ && rosdep update \ && rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} \ && sudo apt-get autoremove -y \ && sudo apt-get clean -y \ && sudo rm -rf /var/lib/apt/lists/* +# Actually build workspace +RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \ + && colcon build + RUN echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \ && echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashrc @@ -161,7 +176,7 @@ RUN [ "/bin/bash" , "-c" , " \ WORKDIR $USER_WORKSPACE RUN sudo apt-get -q update \ && sudo apt-get -q -y upgrade \ - && vcs import src < src/blue/blue.repos \ + && vcs import src < src/blue/sim.repos \ && rosdep update \ && rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} \ && sudo apt-get autoremove -y \ diff --git a/.docker/compose/robot.yaml b/.docker/compose/robot.yaml new file mode 100644 index 00000000..faf1be02 --- /dev/null +++ b/.docker/compose/robot.yaml @@ -0,0 +1,21 @@ +services: + blue: + image: ghcr.io/robotic-decision-making-lab/blue:rolling-robot + build: + dockerfile: .docker/Dockerfile + target: robot + context: ../../ + network_mode: host + privileged: true + cap_add: + - SYS_PTRACE + security_opt: + - seccomp:unconfined + - apparmor:unconfined + volumes: + - /dev:/dev + - /run/user/1000:/run/user/1000 + - type: bind + source: ../../ + target: /home/blue/ws_blue/src/blue + command: tail -f /dev/null diff --git a/.dockerignore b/.dockerignore index 211fad8d..ae633710 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,5 +7,6 @@ !blue_description !blue_demos !blue.repos +!sim.repos !.docker/entrypoints !requirements-build.txt diff --git a/blue.repos b/blue.repos index ca3abd91..20a32377 100644 --- a/blue.repos +++ b/blue.repos @@ -1,10 +1,5 @@ repositories: - ros_gz: - type: git - url: https://github.com/gazebosim/ros_gz - version: ros2 - hydrodynamics: type: git url: https://github.com/Robotic-Decision-Making-Lab/hydrodynamics.git diff --git a/sim.repos b/sim.repos new file mode 100644 index 00000000..91c14acd --- /dev/null +++ b/sim.repos @@ -0,0 +1,11 @@ +# +# Note this is _in addition to_ blue.repos +# (i.e. you need to vcs import both files independently) +# +repositories: + + # ROS-Gazebo integration + ros_gz: + type: git + url: https://github.com/gazebosim/ros_gz + version: ros2