diff --git a/.github/workflows/turtlebot4-discovery-jazzy-dev.yml b/.github/workflows/turtlebot4-discovery-jazzy-dev.yml new file mode 100644 index 0000000..f61e9e3 --- /dev/null +++ b/.github/workflows/turtlebot4-discovery-jazzy-dev.yml @@ -0,0 +1,68 @@ +name: Turtlebot4 Discovery Jazzy Dev Build + +on: + workflow_dispatch: + + push: + branches: + - develop + paths: + - turtlebot4-discovery/** + - .github/workflows/turtlebot4-discovery-jazzy-dev.yml + + pull_request: + branches: + - develop + paths: + - turtlebot4-discovery/** + - .github/workflows/turtlebot4-discovery-jazzy-dev.yml + + +env: + REGISTRY: ghcr.io + OWNER: collaborativeroboticslab + IMAGE_NAME: turtlebot4-discovery + +# https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + # only cancel in-progress jobs or runs for the current workflow - matches against branch & tags + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + build-and-push-image: + runs-on: ubuntu-latest + + permissions: + contents: write + packages: write + + steps: + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + + - name: Check out the repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + run: | + docker login --username ${{ env.OWNER }} --password ${{ secrets.ACCESS_TOKEN }} ghcr.io + + - name: Build and Push + uses: docker/build-push-action@v5 + with: + context: ./turtlebot4-discovery + file: turtlebot4-discovery/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:dev \ No newline at end of file diff --git a/.github/workflows/turtlebot4-rviz-jazzy-dev.yml b/.github/workflows/turtlebot4-rviz-jazzy-dev.yml new file mode 100644 index 0000000..ccc4fba --- /dev/null +++ b/.github/workflows/turtlebot4-rviz-jazzy-dev.yml @@ -0,0 +1,66 @@ +name: Turtlebot4 Rviz Jazzy Dev Build + +on: + workflow_dispatch: + + push: + branches: + - develop + paths: + - turtlebot4-rviz/** + - .github/workflows/turtlebot4-rviz-jazzy-dev.yml + + pull_request: + branches: + - develop + paths: + - turtlebot4-rviz/** + - .github/workflows/turtlebot4-rviz-jazzy-dev.yml + +env: + REGISTRY: ghcr.io + OWNER: collaborativeroboticslab + IMAGE_NAME: turtlebot4-rviz + +# https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + # only cancel in-progress jobs or runs for the current workflow - matches against branch & tags + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + + permissions: + contents: write + packages: write + + steps: + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + + - name: Check out the repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + run: | + docker login --username ${{ env.OWNER }} --password ${{ secrets.ACCESS_TOKEN }} ghcr.io + + - name: Build and Push + uses: docker/build-push-action@v5 + with: + context: ./turtlebot4-rviz + file: turtlebot4-rviz/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:dev diff --git a/.github/workflows/turtlebot4-simulation-jazzy-dev.yml b/.github/workflows/turtlebot4-simulation-jazzy-dev.yml new file mode 100644 index 0000000..6b0254b --- /dev/null +++ b/.github/workflows/turtlebot4-simulation-jazzy-dev.yml @@ -0,0 +1,68 @@ +name: Turtlebot4 GZ Simulation Jazzy Dev Build + +on: + workflow_dispatch: + + push: + branches: + - develop + paths: + - turtlebot4-simulation/** + - .github/workflows/turtlebot4-simulation-jazzy-dev.yml + + pull_request: + branches: + - develop + paths: + - turtlebot4-simulation/** + - .github/workflows/turtlebot4-simulation-jazzy-dev.yml + + +env: + REGISTRY: ghcr.io + OWNER: collaborativeroboticslab + IMAGE_NAME: turtlebot4-simulation + +# https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + # only cancel in-progress jobs or runs for the current workflow - matches against branch & tags + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + build-and-push-image: + runs-on: ubuntu-latest + + permissions: + contents: write + packages: write + + steps: + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + + - name: Check out the repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + run: | + docker login --username ${{ env.OWNER }} --password ${{ secrets.ACCESS_TOKEN }} ghcr.io + + - name: Build and Push + uses: docker/build-push-action@v5 + with: + context: . + file: turtlebot4-simulation/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:dev \ No newline at end of file diff --git a/.github/workflows/turtlebot4-workspace-jazzy-dev.yml b/.github/workflows/turtlebot4-workspace-jazzy-dev.yml new file mode 100644 index 0000000..a395d75 --- /dev/null +++ b/.github/workflows/turtlebot4-workspace-jazzy-dev.yml @@ -0,0 +1,68 @@ +name: Turtlebot4 Workspace Jazzy Dev Build + +on: + workflow_dispatch: + + push: + branches: + - develop + paths: + - turtlebot4-workspace/** + - .github/workflows/turtlebot4-workspace-jazzy-dev.yml + + pull_request: + branches: + - develop + paths: + - turtlebot4-workspace/** + - .github/workflows/turtlebot4-workspace-jazzy-dev.yml + + +env: + REGISTRY: ghcr.io + OWNER: collaborativeroboticslab + IMAGE_NAME: turtlebot4-workspace + +# https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + # only cancel in-progress jobs or runs for the current workflow - matches against branch & tags + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + build-and-push-image: + runs-on: ubuntu-latest + + permissions: + contents: write + packages: write + + steps: + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + + - name: Check out the repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + run: | + docker login --username ${{ env.OWNER }} --password ${{ secrets.ACCESS_TOKEN }} ghcr.io + + - name: Build and Push + uses: docker/build-push-action@v5 + with: + context: ./turtlebot4-workspace + file: turtlebot4-workspace/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:dev \ No newline at end of file diff --git a/.gitignore b/.gitignore index 13c1c1d..69c3115 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ turtlebot4-simulation/gazebo_data -turtlebot4-simulation/rviz \ No newline at end of file +turtlebot4-simulation/rviz +turtlebot4-workspace/code-server +turtlebot4-workspace/workspace \ No newline at end of file diff --git a/README.md b/README.md index c3c6daa..ee2640c 100644 --- a/README.md +++ b/README.md @@ -54,11 +54,17 @@ Pull the latest docker containers docker compose pull ``` -Allow permission for UI interfaces from docker containers -```bash -# Allow local-root X11 access for GUI apps in containers -xhost +local:root -``` +### Workspace via code-server + +When the stack is up, the workspace container serves a web VS Code at http://127.0.0.1:8080. + +- Default password: `student` (set via `PASSWORD` in compose) +- Workspace folder: `/workspace` (mounted from `./turtlebot4-workspace/workspace`) +- Settings/extensions persist to: + - `./turtlebot4-workspace/code-server/config` → `/root/.config/code-server` + - `./turtlebot4-workspace/code-server/data` → `/root/.local/share/code-server` + +To change the password, edit the `PASSWORD` env in [compose.yaml](compose.yaml) under the `turtlebot4-workspace` service.
@@ -78,6 +84,12 @@ Start the docker containers docker compose up ``` +For GUI containers (simulation, rviz), allow X11 access on the host if needed: +```bash +# Allow local-root X11 access for GUI apps in containers +xhost +local:root +``` + ## Using the Physical robot and remote pc ### Mapping @@ -147,4 +159,17 @@ docker compose -f compose-physical.yaml up ## Doing custom work -Copy your packages or create your pacakges within `/turtlebot4-workspace/turtle_ws/src` this folder is mounted into the workspace container and packages can be compiled and executed within the container. +Use code-server to edit files under `/workspace` (mounted from `./turtlebot4-workspace/workspace`). We recommend creating a ROS 2 colcon workspace inside `/workspace`: + +```bash +# In the code-server terminal (already sourced via ros entrypoint) +mkdir -p /workspace/turtle_ws/src +cd /workspace +colcon build --merge-install + +# Use the overlay +source /workspace/install/setup.bash +ros2 pkg list +``` + +Place your packages in `/workspace/turtle_ws/src`, build with `colcon`, and run as usual. The code-server terminal is ROS-ready (environment is sourced by the container entrypoint). diff --git a/compose-physical.yaml b/compose-physical.yaml index 3e6469e..76bc574 100644 --- a/compose-physical.yaml +++ b/compose-physical.yaml @@ -1,6 +1,6 @@ services: turtlebot4-rviz: - image: ghcr.io/collaborativeroboticslab/turtlebot4-rviz:jazzy + image: ghcr.io/collaborativeroboticslab/turtlebot4-rviz:dev command: ["ros2", "launch", "turtlebot4_viz", "view_navigation.launch.py"] # command: ["ros2", "launch", "turtlebot4_viz", "view_diagnostics.launch.py"] environment: @@ -28,32 +28,18 @@ services: - /tmp/.X11-unix:/tmp/.X11-unix:rw # GUI related turtlebot4-workspace: - image: ghcr.io/collaborativeroboticslab/turtlebot4-workspace:jazzy - command: ["/usr/local/bin/launch-terminal.sh"] + image: ghcr.io/collaborativeroboticslab/turtlebot4-workspace:dev environment: - - PYTHONUNBUFFERED=1 # GUI related - - DISPLAY # GUI related - - QT_X11_NO_MITSHM=1 # GUI related - - NVIDIA_VISIBLE_DEVICES=all # GUI related - - NVIDIA_DRIVER_CAPABILITIES=all # GUI related + - PASSWORD=student # code-server login - ROS_DOMAIN_ID=10 - RMW_IMPLEMENTATION=rmw_fastrtps_cpp - ROS_DISCOVERY_SERVER=10.42.0.1:11811 - ROS_SUPER_CLIENT=1 - NO_AT_BRIDGE=1 restart: unless-stopped - privileged: true - deploy: - resources: - reservations: - devices: - - driver: nvidia - count: 1 - capabilities: [gpu] network_mode: host ipc: host tty: true stdin_open: true volumes: - - /tmp/.X11-unix:/tmp/.X11-unix:rw # GUI related - - ./turtlebot4-workspace/turtle_ws/src:/turtle_ws/src:rw \ No newline at end of file + - ./turtlebot4-workspace/workspace:/workspace:rw \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index 755c9f4..898ef47 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,6 +1,6 @@ services: turtlebot4-discovery: - image: ghcr.io/collaborativeroboticslab/turtlebot4-discovery:jazzy + image: ghcr.io/collaborativeroboticslab/turtlebot4-discovery:dev environment: - ROS_DOMAIN_ID=0 - RMW_IMPLEMENTATION=rmw_fastrtps_cpp @@ -12,8 +12,8 @@ services: restart: unless-stopped turtlebot4-simulation: - image: ghcr.io/collaborativeroboticslab/turtlebot4-simulation:jazzy - command: ["ros2", "launch", "turtlebot4_gz_bringup", "turtlebot4_gz.launch.py", "nav2:=true", "localization:=true", "slam:=false", "use_sim_time:=true"] + image: ghcr.io/collaborativeroboticslab/turtlebot4-simulation:dev + command: ["ros2", "launch", "turtlebot4_gz_bringup", "turtlebot4_gz.launch.py", "use_sim_time:=true"] environment: - PYTHONUNBUFFERED=1 # GUI related - DISPLAY # GUI related @@ -23,6 +23,7 @@ services: - ROS_DOMAIN_ID=0 - RMW_IMPLEMENTATION=rmw_fastrtps_cpp - ROS_DISCOVERY_SERVER=127.0.0.1:11811 + - ROS_SUPER_CLIENT=1 restart: unless-stopped privileged: true deploy: @@ -42,7 +43,7 @@ services: - turtlebot4-discovery turtlebot4-rviz: - image: ghcr.io/collaborativeroboticslab/turtlebot4-rviz:jazzy + image: ghcr.io/collaborativeroboticslab/turtlebot4-rviz:dev command: ["ros2", "launch", "turtlebot4_viz", "view_navigation.launch.py", "use_sim_time:=true"] environment: - PYTHONUNBUFFERED=1 # GUI related @@ -50,9 +51,10 @@ services: - QT_X11_NO_MITSHM=1 # GUI related - NVIDIA_VISIBLE_DEVICES=all # GUI related - NVIDIA_DRIVER_CAPABILITIES=all # GUI related - - ROS_DOMAIN_ID=10 + - ROS_DOMAIN_ID=0 - RMW_IMPLEMENTATION=rmw_fastrtps_cpp - ROS_DISCOVERY_SERVER=127.0.0.1:11811 + - ROS_SUPER_CLIENT=1 restart: unless-stopped privileged: true deploy: @@ -70,33 +72,22 @@ services: - turtlebot4-discovery turtlebot4-workspace: - image: ghcr.io/collaborativeroboticslab/turtlebot4-workspace:jazzy - command: ["/usr/local/bin/launch-terminal.sh"] + image: ghcr.io/collaborativeroboticslab/turtlebot4-workspace:dev environment: - - PYTHONUNBUFFERED=1 # GUI related - - DISPLAY # GUI related - - QT_X11_NO_MITSHM=1 # GUI related - - NVIDIA_VISIBLE_DEVICES=all # GUI related - - NVIDIA_DRIVER_CAPABILITIES=all # GUI related - - ROS_DOMAIN_ID=10 + - PASSWORD=student # code-server login + - ROS_DOMAIN_ID=0 - RMW_IMPLEMENTATION=rmw_fastrtps_cpp - ROS_DISCOVERY_SERVER=127.0.0.1:11811 + - ROS_SUPER_CLIENT=1 - NO_AT_BRIDGE=1 restart: unless-stopped - privileged: true - deploy: - resources: - reservations: - devices: - - driver: nvidia - count: 1 - capabilities: [gpu] tty: true stdin_open: true network_mode: host ipc: host volumes: - - /tmp/.X11-unix:/tmp/.X11-unix:rw # GUI related - - ./turtlebot4-workspace/turtle_ws/src:/turtle_ws/src:rw + - ./turtlebot4-workspace/workspace:/workspace:rw + - ./turtlebot4-workspace/code-server/config:/root/.config/code-server:rw + - ./turtlebot4-workspace/code-server/data:/root/.local/share/code-server:rw depends_on: - turtlebot4-discovery \ No newline at end of file diff --git a/docs/containers.md b/docs/containers.md index d5c9f95..b636fcb 100644 --- a/docs/containers.md +++ b/docs/containers.md @@ -67,7 +67,7 @@ Works as a client of turtlebot4-discovery, and thus update the following variabl ## `Turtlebot4-workspace` container -This container provide a workspace environment that connects to Turtlebot4 simulation (or a physical robot). +This container provides a browser-based VS Code (code-server) environment that connects to Turtlebot4 simulation (or a physical robot). Works out-of-box as a client of turtlebot4-discovery, and thus update the following variables if turtlebot4-discovery settings change. @@ -75,9 +75,24 @@ Works out-of-box as a client of turtlebot4-discovery, and thus update the follow - ROS_DOMAIN_ID=0 - RMW_IMPLEMENTATION=rmw_fastrtps_cpp - ROS_DISCOVERY_SERVER=127.0.0.1:11811 + - PASSWORD=student ``` **Parameter descriptions** - `ROS_DOMAIN_ID`: Same domain as simulation and discovery. - `RMW_IMPLEMENTATION`: Keep Fast DDS for discovery server support. -- `ROS_DISCOVERY_SERVER`: Discovery server endpoint as above. \ No newline at end of file +- `ROS_DISCOVERY_SERVER`: Discovery server endpoint as above. + - `PASSWORD`: code-server login password (default `student`). Set in compose. + +**Access & Folders** +- URL: `http://127.0.0.1:8080` (served by the workspace container) +- Workspace root: `/workspace` (mounted from `./turtlebot4-workspace/workspace`) +- Persistent settings/extensions: + - `./turtlebot4-workspace/code-server/config` → `/root/.config/code-server` + - `./turtlebot4-workspace/code-server/data` → `/root/.local/share/code-server` + +**ROS Development inside workspace** +- The entrypoint sources ROS automatically for the integrated terminal. +- Create a ROS 2 overlay inside `/workspace` if desired: + - `mkdir -p /workspace/turtle_ws/src && cd /workspace && colcon build --merge-install` + - `source /workspace/install/setup.bash` \ No newline at end of file diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index b8f1d2a..df1ece4 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -22,4 +22,8 @@ Ensure `ROS_DISCOVERY_SERVER` uses a concrete address (not `0.0.0.0`). - Inside `turtlebot4-simulation`, run `ros2 topic list`, check `/map`, `/tf`, and Nav2 nodes (`planner_server`, `controller_server`). - Ensure transforms between `map`, `odom`, and `base_link` are present. -- Check the robot namespace \ No newline at end of file +- Check the robot namespace + +## ROS2 topic list doesnot print the list + +- try running the `ros2 daemon stop && ros2 daemon start` command once and wait few seconds \ No newline at end of file diff --git a/turtlebot4-discovery/Dockerfile b/turtlebot4-discovery/Dockerfile index f0439b4..fb56093 100644 --- a/turtlebot4-discovery/Dockerfile +++ b/turtlebot4-discovery/Dockerfile @@ -1,27 +1,21 @@ FROM ros:jazzy -# Install dependencies - -RUN apt update && \ - apt install -y --no-install-recommends ros-jazzy-rmw-fastrtps-cpp - -# Clean up -RUN apt-get clean && rm -rf /var/lib/apt/lists/* - -# Set environment variables -ENV RMW_IMPLEMENTATION=rmw_fastrtps_cpp -ENV ROS_DOMAIN_ID=0 -ENV SERVER_ID=0 -ENV SERVER_IP=127.0.0.1 -ENV SERVER_PORT=11811 +ENV DEBIAN_FRONTEND=noninteractive \ + RMW_IMPLEMENTATION=rmw_fastrtps_cpp \ + ROS_DOMAIN_ID=0 \ + SERVER_ID=0 \ + SERVER_IP=127.0.0.1 \ + SERVER_PORT=11811 + +# Install only the needed RMW implementation and clean up in one layer +RUN apt-get update && \ + apt-get install -y --no-install-recommends ros-jazzy-rmw-fastrtps-cpp && \ + rm -rf /var/lib/apt/lists/* # Expose Fast DDS Discovery Server UDP port (optional if server runs here) EXPOSE ${SERVER_PORT}/udp -# Copy entrypoint script -COPY ros_entrypoint.sh ros_entrypoint.sh - -# Ensure entrypoint is executable and used +COPY ros_entrypoint.sh /ros_entrypoint.sh RUN chmod +x /ros_entrypoint.sh ENTRYPOINT ["/ros_entrypoint.sh"] diff --git a/turtlebot4-rviz/Dockerfile b/turtlebot4-rviz/Dockerfile index 7a5a382..08047dc 100644 --- a/turtlebot4-rviz/Dockerfile +++ b/turtlebot4-rviz/Dockerfile @@ -1,44 +1,28 @@ FROM ros:jazzy +FROM ros:jazzy -# Install dependencies - -RUN apt update && \ - apt install -y --no-install-recommends ros-jazzy-turtlebot4-description \ - ros-jazzy-turtlebot4-msgs \ - ros-jazzy-turtlebot4-navigation \ - ros-jazzy-turtlebot4-node \ - ros-jazzy-turtlebot4-desktop \ - ros-jazzy-rmw-fastrtps-cpp \ - ros-jazzy-navigation2 \ - ros-jazzy-nav2-bringup \ - ros-jazzy-slam-toolbox - -# Install x11 apps dependencies +ENV DEBIAN_FRONTEND=noninteractive \ + RMW_IMPLEMENTATION=rmw_fastrtps_cpp \ + ROS_DOMAIN_ID=0 \ + ROS_DISCOVERY_SERVER=127.0.0.1:11811 \ + QT_X11_NO_MITSHM=1 +# Install only required ROS packages; rely on their GUI deps RUN apt-get update && \ - apt-get install -y --no-install-recommends libx11-6 \ - libxext6 \ - libxrender1 \ - libxtst6 \ - libxi6 \ - libgtk-3-0 \ - x11-xserver-utils \ - ffmpeg \ - libsm6 \ - unzip \ - findutils - -# Clean up -RUN apt-get clean && rm -rf /var/lib/apt/lists/* - -# Set environment variables -ENV RMW_IMPLEMENTATION=rmw_fastrtps_cpp -ENV ROS_DOMAIN_ID=0 -ENV ROS_DISCOVERY_SERVER=127.0.0.1:11811 + apt-get install -y --no-install-recommends \ + ros-jazzy-turtlebot4-description \ + ros-jazzy-turtlebot4-msgs \ + ros-jazzy-turtlebot4-navigation \ + ros-jazzy-turtlebot4-node \ + ros-jazzy-turtlebot4-desktop \ + ros-jazzy-rmw-fastrtps-cpp \ + ros-jazzy-navigation2 \ + ros-jazzy-nav2-bringup \ + ros-jazzy-slam-toolbox && \ + rm -rf /var/lib/apt/lists/* # Copy entrypoint script -COPY ros_entrypoint.sh ros_entrypoint.sh - +COPY ros_entrypoint.sh /ros_entrypoint.sh RUN chmod +x /ros_entrypoint.sh -ENTRYPOINT [ "/ros_entrypoint.sh" ] \ No newline at end of file +ENTRYPOINT ["/ros_entrypoint.sh"] \ No newline at end of file diff --git a/turtlebot4-simulation/Dockerfile b/turtlebot4-simulation/Dockerfile index 9015585..bb6e559 100644 --- a/turtlebot4-simulation/Dockerfile +++ b/turtlebot4-simulation/Dockerfile @@ -1,69 +1,48 @@ -FROM ros:jazzy AS base +FROM ros:jazzy -# Install dependencies +ENV DEBIAN_FRONTEND=noninteractive \ + WORKSPACE_ROOT=/turtle_ws \ + RMW_IMPLEMENTATION=rmw_fastrtps_cpp \ + ROS_DOMAIN_ID=0 \ + ROS_DISCOVERY_SERVER=127.0.0.1:11811 \ + QT_X11_NO_MITSHM=1 -RUN apt update && \ - apt install -y --no-install-recommends \ +# Core ROS dependencies and build tools +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ git \ + ros-dev-tools \ ros-jazzy-irobot-create-* \ ros-jazzy-rmw-fastrtps-cpp \ - ros-dev-tools \ ros-jazzy-navigation2 \ ros-jazzy-nav2-bringup \ - ros-jazzy-slam-toolbox - -# Install Gazebo packages - -RUN apt install -y curl && \ + ros-jazzy-slam-toolbox \ + curl && \ curl https://packages.osrfoundation.org/gazebo.gpg --output /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg && \ - 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" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null && \ - apt update && \ - apt install --no-install-recommends -y gz-harmonic - -# Install x11 apps dependencies -RUN apt-get update && \ - apt-get install -y --no-install-recommends libx11-6 \ - libxext6 \ - libxrender1 \ - libxtst6 \ - libxi6 \ - libgtk-3-0 \ - x11-xserver-utils \ - ffmpeg \ - libsm6 \ - unzip \ - findutils - -# Clean up -RUN apt-get clean && rm -rf /var/lib/apt/lists/* + 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" > /etc/apt/sources.list.d/gazebo-stable.list && \ + apt-get update && \ + apt-get install -y --no-install-recommends gz-harmonic && \ + rm -rf /var/lib/apt/lists/* ## Set up workspace -ENV WORKSPACE_ROOT=/turtle_ws - -# Create and clone workspace WORKDIR ${WORKSPACE_ROOT}/src -# Clone turtlebot4 simulation packages (with modified render engine) -RUN git clone -b jazzy https://github.com/CollaborativeRoboticsLab/turtlebot4.git -RUN git clone -b jazzy https://github.com/turtlebot/turtlebot4_simulator.git -RUN git clone -b jazzy https://github.com/turtlebot/turtlebot4_desktop.git +# Clone turtlebot4 simulation packages +RUN git clone -b jazzy https://github.com/CollaborativeRoboticsLab/turtlebot4.git && \ + git clone -b jazzy https://github.com/turtlebot/turtlebot4_simulator.git && \ + git clone -b jazzy https://github.com/turtlebot/turtlebot4_desktop.git WORKDIR ${WORKSPACE_ROOT} -## Build the workspace -RUN . /opt/ros/jazzy/setup.sh && \ - colcon build +## Build the workspace (merged install to reduce size) +RUN . /opt/ros/jazzy/setup.sh && colcon build -WORKDIR / +RUN rm -rf build/ src/ log/ -# Set environment variables -ENV RMW_IMPLEMENTATION=rmw_fastrtps_cpp -ENV ROS_DOMAIN_ID=0 -ENV ROS_DISCOVERY_SERVER=127.0.0.1:11811 +WORKDIR / # Copy entrypoint script -COPY turtlebot4-simulation/ros_entrypoint.sh ros_entrypoint.sh - +COPY turtlebot4-simulation/ros_entrypoint.sh /ros_entrypoint.sh RUN chmod +x /ros_entrypoint.sh -ENTRYPOINT [ "/ros_entrypoint.sh" ] \ No newline at end of file +ENTRYPOINT ["/ros_entrypoint.sh"] \ No newline at end of file diff --git a/turtlebot4-workspace/Dockerfile b/turtlebot4-workspace/Dockerfile index ecd7761..ddb7963 100644 --- a/turtlebot4-workspace/Dockerfile +++ b/turtlebot4-workspace/Dockerfile @@ -1,43 +1,23 @@ FROM ros:jazzy -# Install dependencies - -RUN apt-get update && \ - apt-get install -y --no-install-recommends ros-jazzy-turtlebot4-description \ - ros-jazzy-turtlebot4-msgs \ - ros-jazzy-turtlebot4-navigation \ - ros-jazzy-turtlebot4-node \ - ros-jazzy-rmw-fastrtps-cpp \ - ros-jazzy-navigation2 \ - ros-jazzy-nav2-bringup \ - ros-jazzy-slam-toolbox - -# Install x11 apps dependencies +## Install ROS dependencies and code-server +ARG CODE_SERVER_VERSION=4.91.0 RUN apt-get update && \ - apt-get install -y --no-install-recommends libx11-6 \ - libxext6 \ - libxrender1 \ - libxtst6 \ - libxi6 \ - libgtk-3-0 \ - x11-xserver-utils \ - ffmpeg \ - libsm6 \ - unzip \ - findutils \ - gnome-terminal \ - dbus-x11 \ - gsettings-desktop-schemas \ - dconf-service \ - libglib2.0-bin \ - libcanberra-gtk3-module \ - libcanberra-gtk-module \ - at-spi2-core \ - libatk-bridge2.0-0 \ - xterm - -# Clean up -RUN apt-get clean && rm -rf /var/lib/apt/lists/* + apt-get install -y --no-install-recommends \ + ros-jazzy-turtlebot4-description \ + ros-jazzy-turtlebot4-msgs \ + ros-jazzy-turtlebot4-navigation \ + ros-jazzy-turtlebot4-node \ + ros-jazzy-rmw-fastrtps-cpp \ + ros-jazzy-navigation2 \ + ros-jazzy-nav2-bringup \ + ros-jazzy-slam-toolbox \ + curl \ + ca-certificates && \ + curl -fOL https://github.com/coder/code-server/releases/download/v${CODE_SERVER_VERSION}/code-server_${CODE_SERVER_VERSION}_amd64.deb && \ + apt-get install -y --no-install-recommends ./code-server_${CODE_SERVER_VERSION}_amd64.deb && \ + rm -f code-server_${CODE_SERVER_VERSION}_amd64.deb && \ + rm -rf /var/lib/apt/lists/* # Set environment variables ENV RMW_IMPLEMENTATION=rmw_fastrtps_cpp @@ -45,16 +25,20 @@ ENV ROS_DOMAIN_ID=0 ENV ROS_DISCOVERY_SERVER=127.0.0.1:11811 ENV TERM=xterm-256color ENV NO_AT_BRIDGE=1 +ENV QT_X11_NO_MITSHM=1 ENV LANG=C.UTF-8 ENV LC_ALL=C.UTF-8 +# Default workspace served by code-server +WORKDIR /workspace + +# Expose code-server port +EXPOSE 8080 + # Copy entrypoint script COPY ros_entrypoint.sh /ros_entrypoint.sh RUN chmod +x /ros_entrypoint.sh -# Terminal launcher script -COPY launch-terminal.sh /usr/local/bin/launch-terminal.sh -RUN chmod +x /usr/local/bin/launch-terminal.sh - # Ensure the entrypoint script is used ENTRYPOINT ["/ros_entrypoint.sh"] +CMD ["/usr/bin/code-server", "--bind-addr", "0.0.0.0:8080", "--auth", "password", "--disable-telemetry", "/workspace"] diff --git a/turtlebot4-workspace/launch-terminal.sh b/turtlebot4-workspace/launch-terminal.sh deleted file mode 100644 index 79ef16f..0000000 --- a/turtlebot4-workspace/launch-terminal.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -e - -# Prefer gnome-terminal via dbus-launch; fallback to xterm -if command -v gnome-terminal >/dev/null 2>&1; then - if command -v dbus-launch >/dev/null 2>&1; then - dbus-launch gnome-terminal --wait -- bash -i && exit 0 - else - gnome-terminal --wait -- bash -i && exit 0 - fi -fi - -# Fallback to xterm -exec xterm -fa 'Monospace' -fs 11 -geometry 120x30 -e bash -i