diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..ef08ca0 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,21 @@ +{ + "name": "WayBionic ROS 2 Jazzy", + "build": { + "dockerfile": "../docker/Dockerfile", + "context": "..", + "target": "development" + }, + "workspaceMount": "source=${localWorkspaceFolder},target=/waybionic_ws/src/waybionic_ground_station,type=bind", + "workspaceFolder": "/waybionic_ws/src/waybionic_ground_station", + "remoteUser": "ubuntu", + "updateRemoteUserUID": true, + "init": true, + "postCreateCommand": "bash -c 'source /opt/ros/jazzy/setup.bash && cd /waybionic_ws && colcon build --symlink-install'", + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.cwd": "/waybionic_ws" + } + } + } +} \ No newline at end of file diff --git a/.dockerignore b/.dockerignore index ca2376a..78721cd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,11 @@ -**install -**build -**log -docker/Dockerfile +.git +.vscode +**/build +**/install +**/log +**/__pycache__ +**/*.py[cod] +**/.env +**/.env.* +**/easy_handeye2 +**/ros2_aruco diff --git a/.gitattributes b/.gitattributes index d9bd16b..61d299b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ *.py text eol=lf +*.sh text eol=lf diff --git a/.github/workflows/ros2_build_test.yml b/.github/workflows/ros2_build_test.yml index 7642107..5f9fe46 100644 --- a/.github/workflows/ros2_build_test.yml +++ b/.github/workflows/ros2_build_test.yml @@ -1,4 +1,4 @@ -name: ROS 2 Jazzy Build and Test +name: ROS 2 Jazzy Docker Build and Test on: push: @@ -6,33 +6,36 @@ on: pull_request: branches: [ "main" ] +permissions: + contents: read + jobs: build-and-test: runs-on: ubuntu-24.04 - container: - image: ros:jazzy steps: - name: Checkout Repository uses: actions/checkout@v4 - with: - path: src/${{ github.event.repository.name }} - - name: Install Dependencies (rosdep) + - name: Validate Compose Configuration run: | - apt-get update - rosdep update - rosdep install --from-paths src --ignore-src -r -y + docker compose -f compose.yaml config --quiet + docker compose -f compose.yaml -f docker/compose.wslg.yaml config --quiet - - name: Build Packages - shell: bash - run: | - source /opt/ros/jazzy/setup.bash - colcon build + - name: Build and Test Docker Image + run: docker build --progress=plain --target test --file docker/Dockerfile --tag waybionic-ground-station:ci . + + build-and-test-arm64: + runs-on: ubuntu-24.04-arm + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 - - name: Run Tests - shell: bash + - name: Validate Compose Configuration run: | - source /opt/ros/jazzy/setup.bash - colcon test - colcon test-result --all + docker compose -f compose.yaml config --quiet + docker compose -f compose.yaml -f docker/compose.wslg.yaml config --quiet + + - name: Build and Test Docker Image + run: docker build --progress=plain --target test --file docker/Dockerfile --tag waybionic-ground-station:ci . diff --git a/BuildInstructions.md b/BuildInstructions.md index e332d05..fd176eb 100644 --- a/BuildInstructions.md +++ b/BuildInstructions.md @@ -1,30 +1,448 @@ -Basic placeholder robot with a base box and moveable cylinder arm. +# Ground Station Setup, Build, and Launch -## Setup workspace and Clone repo (*Skip if repo already cloned*) -- Run these commands inside the terminal in Ubuntu: +The ground station currently uses a placeholder robot with a base box and +moveable cylinder arm. The primary development target is **Ubuntu 24.04 (Noble) +with ROS 2 Jazzy**. + +Use **Docker for development and headless build/test checks**. ROS and its build +tools live inside the container; you do not need a host ROS installation for +this path. Windows users can [view the demo through WSLg](#windows-wslg-demo) +without a second ROS installation. Other graphical RViz options are the +[native Ubuntu/WSL setup](#native-ubuntu-setup-for-rviz) or +[macOS RoboStack setup](#macos-apple-silicon). + +Run commands one at a time and stop at the first error. Do not share passwords +or access tokens in chat or issues. + +## Docker Setup (Default) + +### 1. Install Docker for your platform + +**Windows 11:** if WSL is not installed, open **PowerShell as Administrator** and +run: + +```powershell +wsl --install --no-distribution +``` + +Restart Windows when requested. Then check WSL in a normal PowerShell terminal: + +```powershell +wsl --version +``` + +Docker Desktop requires WSL 2.1.5 or later. Follow the +[Microsoft WSL commands](https://learn.microsoft.com/en-us/windows/wsl/basic-commands) +if an existing WSL installation needs updating. The Docker-only path does not +require a separate Ubuntu distribution. Enabling WSL needs administrator rights; +do not try to bypass an elevation or virtualization error. + +Install [Docker Desktop for Windows](https://docs.docker.com/desktop/setup/install/windows-install/) +using its per-user installation and WSL2 backend, then start Docker Desktop. +Review its license terms locally. Use Linux containers, not Windows containers. + +After installation, close and reopen existing terminal and VS Code windows so +they pick up Docker's updated `PATH`. Otherwise, PowerShell may report that +`docker` is not recognized, or a build may report that `docker-credential-desktop` +cannot be found even when Docker Desktop is running. + +**macOS:** install [Docker Desktop for Mac](https://docs.docker.com/desktop/setup/install/mac-install/) +for your processor type, then start it. Apple Silicon uses Linux ARM64 containers; +Intel Macs use Linux x86-64 containers. Do not force x86-64 emulation on Apple Silicon. + +**Linux:** install [Docker Engine](https://docs.docker.com/engine/install/) +using the instructions for your distribution. Configure Docker access according +to that guide; never make the Docker socket world-writable. + +On every platform, verify that Docker can reach its engine: + +```console +docker version +``` + +Both **Client** and **Server** information must appear. A missing Server section +or daemon connection error must be resolved before building. + +### 2. Open the repository and build + +Use your existing repository clone. New members need [Git](https://git-scm.com/downloads) +and repository access, then can run: + +```console +git clone https://github.com/Waybionic/waybionic_ground_station.git +cd waybionic_ground_station +``` + +From the **repository root**, run this same command in PowerShell, Bash, or zsh: + +```console +docker build --progress=plain --target test --file docker/Dockerfile --tag waybionic-ground-station:jazzy . +``` + +The image installs package dependencies, builds all workspace packages, and runs +their headless tests. A build or test failure fails the Docker build. The first +build downloads ROS and Qt dependencies; later builds can reuse cached layers. +Rebuild after source changes because this image contains a snapshot of the source. + +[CI](.github/workflows/ros2_build_test.yml) runs this Docker test target on native +x86-64 and ARM64 Linux runners. A passing container build does not verify RViz +windows, camera access, USB devices, GPU acceleration, or networking with a robot. + +#### Headless Demo + +Start the ground station with simulated diagnostics and no GUI: + +```console +docker run --rm --init --stop-signal SIGINT --name waybionic-demo --env ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST waybionic-ground-station:jazzy ros2 launch waybionic_bringup ground_station.launch.py launch_rviz:=false use_joint_state_publisher_gui:=false start_temporary_diagnostics_publisher:=true +``` + +In a second host terminal, read one message from that container: + +```console +docker exec waybionic-demo /entrypoint.sh ros2 topic echo /diagnostics --once +``` + +Expect a timestamped array containing temperature, current, and IMU demo values. +Press **Ctrl+C** in the first terminal to stop and remove the demo container. + +#### Compose Demo + +Compose provides a checked-in alternative to the `docker run` settings above. +It uses the same Dockerfile's `test` target, so a failed build or test prevents +startup. Docker Desktop includes Compose; on native Linux, install the +[Compose plugin](https://docs.docker.com/compose/install/linux/) if +`docker compose version` is unavailable. The direct Docker commands and VS Code +Dev Container remain supported; do not start both demo launchers at once. + +From the repository root: + +```console +docker compose up --build +``` + +In a second host terminal, inspect the service rather than assuming a container +name: + +```console +docker compose exec ground-station /entrypoint.sh ros2 topic echo /diagnostics --once +docker compose logs --tail 50 ground-station +``` + +Press **Ctrl+C** in the launch terminal to stop the service, then remove its +container and project network: + +```console +docker compose down +``` + +The [base configuration](./compose.yaml) runs the existing headless launch with +mock diagnostics, a non-root image user, an init process, and SIGINT shutdown. +There is no automatic restart policy, host port publication, display mount, or +hardware-device access. Rebuild with `--build` after source changes; this is a +source snapshot, not the editable Dev Container. + +All ROS nodes remain in one service with localhost-only discovery. Adding more +services to a Compose network does not make this configuration a distributed +ROS setup. Cross-container discovery, robot networking, USB, and CAN require +separate configuration and validation. Do not add privileged mode or broad +device mounts to the demo. + +### 3. Develop in VS Code + +Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers), +open the repository folder in VS Code, and run **Dev Containers: Reopen in Container** +from the Command Palette. Docker must already be running. + +The checked-in [configuration](.devcontainer/devcontainer.json) uses the +`development` stage of the same [Dockerfile](docker/Dockerfile). It mounts your +source checkout, uses a non-root Linux user, and builds the workspace on creation. +Terminals start in `/waybionic_ws` with ROS sourced. After editing, run inside the +Dev Container: + +```bash +cd /waybionic_ws +colcon build --symlink-install +source install/setup.bash +colcon test --return-code-on-test-failure --event-handlers console_direct+ +colcon test-result --verbose +``` + +Source edits persist in your host checkout. Build outputs stay inside the +container, outside the mounted checkout, and may be discarded when it is rebuilt. +Copied source in build/test images remains root-owned; only `build`, `install`, +and `log` are writable in those workspaces. These output directories link to +the container user's home so Dev Container UID updates work without `sudo`. +The development source bind mount stays editable. +After changing package dependencies, run **Dev Containers: Rebuild Container**. +When adding a package, also add its manifest to the Dockerfile's dependency-stage +`COPY` instructions. Run the clean Docker test command above before a PR. + +### Reproducibility and GUI boundaries + +The ROS/Ubuntu base is pinned by multi-platform image digest, and local development +and CI share the dependency recipe. Ubuntu and ROS package repositories are still +resolved when that layer is rebuilt, so builds on different dates are not a fully +frozen dependency lock. Keep the built image when reproducing a problem; record +its identifier with: + +```console +docker image inspect waybionic-ground-station:jazzy --format '{{.Id}}' +``` + +CI currently builds and tests images; it does not publish a shared development +image. Sharing an immutable, verified project image is a follow-up once the +container build has been validated. Base-image updates must pass both CI +architectures before adoption. + +The default container configuration is **headless**. For RViz, use the Windows +WSLg demo below or a native path. Do not add privileged containers, broad +display-server permissions, or device mounts just to get the build working. + +## Windows WSLg Demo + +This command was verified on Windows 11 with Docker Desktop's WSL2 backend. +It uses the image built in [Docker setup](#docker-setup-default) and WSL's existing +graphics service; a separate Ubuntu distribution or host ROS install is not needed. + +With Docker Desktop running, open **Windows PowerShell** from the Start menu. +The prompt should start with `PS`, not `docker-desktop:~#`. Do not run this in +Docker Desktop's internal WSL distribution or inside the Dev Container. If an +unfinished command leaves you at a `>` prompt, press **Ctrl+C** to cancel it. + +Run the following as **one line**. It uses the per-user Docker installation from +the setup above directly, so it also works in a terminal with an outdated `PATH`: + +```powershell +& "$env:LOCALAPPDATA\Programs\DockerDesktop\resources\bin\docker.exe" run --rm -it --init --stop-signal SIGINT --env DISPLAY=:0 --env QT_X11_NO_MITSHM=1 --env LIBGL_ALWAYS_SOFTWARE=1 --env ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST --mount "type=bind,source=/mnt/host/wslg/.X11-unix,target=/tmp/.X11-unix,readonly" waybionic-ground-station:jazzy ros2 launch waybionic_bringup ground_station.launch.py +``` + +RViz and the Joint State Publisher GUI open as separate windows. Move the slider +to move the placeholder arm, and use the diagnostics panel's mock controls to +try normal and fault states. This demo uses simulated data, not a physical arm. +Press **Ctrl+C** in PowerShell to stop it. + +The display socket path is specific to Docker Desktop's WSL2 backend. Software +rendering avoids requiring GPU passthrough. If the socket mount is unavailable, +stop and check Docker/WSL rather than creating an empty replacement directory. + +### Compose with WSLg + +From the repository root, the optional +[WSLg override](./docker/compose.wslg.yaml) enables RViz and the joint-state GUI +in the same service: + +```console +docker compose -f compose.yaml -f docker/compose.wslg.yaml up --build +``` + +In PowerShell, use the Docker executable path shown above if `docker` is not on +the current terminal's PATH. Stop with Ctrl+C and clean up with the same files: + +```console +docker compose -f compose.yaml -f docker/compose.wslg.yaml down +``` + +This override adds only the display environment variables and the read-only +WSLg socket mount. A missing socket directory is an error; Compose will not +create an empty substitute. It is Windows/WSL2-specific and does not replace +the native Linux or macOS GUI instructions. CI validates both Compose files, +but GUI rendering still requires the platform-specific runtime check. + +Qt may report a default `XDG_RUNTIME_DIR`, and RViz may report that stereo is not +supported; neither prevented this demo from starting. On Ctrl+C, the joint GUI +can report exit code `-2`, indicating the requested SIGINT interruption. + +## Native Ubuntu Setup for RViz + +Only follow this section if you need ROS and RViz outside the container. It is +not required for Docker-only development or tests. + +Windows users start at step 1. Native Ubuntu users start at step 2. Apple Silicon +users should use the [macOS instructions](#macos-apple-silicon) below instead. +If Ubuntu, ROS 2 Jazzy, and the build tools are already configured, go to +[workspace setup](#setup-workspace-and-clone-repo). + +Run commands one at a time. If a command fails, stop and record the command and +error before continuing. Installation, a required restart, and Linux password +prompts must be completed locally; do not share passwords in chat or issues. + +### 1. Windows: install WSL2 and Ubuntu 24.04 + +On Windows 11, open **PowerShell as Administrator** and run: + +```powershell +wsl --install -d Ubuntu-24.04 +``` + +Use the explicit `Ubuntu-24.04` distribution name, not an unversioned Ubuntu +install: a newer Ubuntu release is not the target for ROS 2 Jazzy. The install +command enables the required Windows features and uses WSL2 by default. +Restart Windows when requested before proceeding. + +After the restart, open Ubuntu 24.04 from the Start menu, or run this in a normal +Windows PowerShell terminal: + +```powershell +wsl -d Ubuntu-24.04 +``` + +Complete Ubuntu's first-run Linux username and password prompts. Password input +does not display characters. In a separate Windows PowerShell terminal, check: + +```powershell +wsl --list --verbose +``` + +The `Ubuntu-24.04` row must show `VERSION` **2**. Stop here if installation fails, +the distribution is missing, or the version is not 2. Do not run the Ubuntu +commands below in PowerShell. + +### 2. Ubuntu: check the version and locale + +Run this and all remaining Linux commands **inside Ubuntu's Bash terminal**: + +```bash +cat /etc/os-release +locale +``` + +Confirm `VERSION_ID="24.04"` and a UTF-8 locale. If a valid UTF-8 locale is already +configured, no locale changes are needed. Otherwise run: + +```bash +sudo apt update +sudo apt install locales +sudo locale-gen en_US en_US.UTF-8 +sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 +export LANG=en_US.UTF-8 +locale +``` + +### 3. Ubuntu: configure the ROS package repository + +Enable Ubuntu Universe and install the tools needed to fetch the official ROS +repository configuration: + +```bash +sudo apt update +sudo apt install software-properties-common +sudo add-apt-repository universe +sudo apt update +sudo apt install curl python3 +``` + +Fetch and install `ros2-apt-source`. The `noble` suffix below is specifically for +the Ubuntu 24.04 version checked in step 2. The release response is parsed as JSON. + +```bash +ROS_APT_SOURCE_VERSION=$(curl -fsSL https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | python3 -c 'import json, sys; print(json.load(sys.stdin)["tag_name"])') +curl -fL -o /tmp/ros2-apt-source.deb "https://github.com/ros-infrastructure/ros-apt-source/releases/download/${ROS_APT_SOURCE_VERSION}/ros2-apt-source_${ROS_APT_SOURCE_VERSION}.noble_all.deb" +sudo dpkg -i /tmp/ros2-apt-source.deb ``` + +### 4. Ubuntu: install ROS 2 and initialize the build tools + +Update Ubuntu packages, then install ROS 2 Jazzy Desktop, which includes RViz: + +```bash +sudo apt update +sudo apt upgrade +sudo apt install ros-jazzy-desktop +source /opt/ros/jazzy/setup.bash +``` + +Do not also install `ros-jazzy-ros-base`: Desktop already includes the base ROS +functionality. The AR4, Gazebo, and MoveIt demo commands in the older ROS README +are separate learning exercises, not steps for building this repository. + +Install Git, the C++ build toolchain, colcon, and rosdep: + +```bash +sudo apt install git build-essential python3-colcon-common-extensions python3-rosdep +sudo rosdep init +rosdep update +``` + +Run `sudo rosdep init` only once per Ubuntu installation. If it reports that its +configuration already exists, use `rosdep update`; do not delete the existing +configuration. Run `rosdep update` as your normal Linux user, without `sudo`. + +Check the environment before moving on: + +```bash +printenv ROS_DISTRO +command -v ros2 colcon rosdep git g++ +``` + +The distribution must be `jazzy`, and each command must resolve to a path. + +Installation references: [Microsoft WSL installation](https://learn.microsoft.com/en-us/windows/wsl/install) +and [ROS 2 Jazzy Ubuntu installation](https://docs.ros.org/en/jazzy/Installation/Ubuntu-Install-Debs.html). + +## Setup workspace and Clone repo + +For the native RViz path, run these commands inside Ubuntu. Keep the workspace in the Linux home directory +(`~/waybionic_ws`), not under `/mnt/c`. An existing Windows clone does not replace +this Linux workspace; keep any uncommitted Windows work intact. Choose the path +below that matches your native workspace. + +### New clone + +Run this only when `~/waybionic_ws/src/waybionic_ground_station` does not exist: + +```bash mkdir -p ~/waybionic_ws/src cd ~/waybionic_ws/src git clone https://github.com/Waybionic/waybionic_ground_station.git cd ~/waybionic_ws ``` -## Build and Launch -- Run these commands from the root of your workspace (`~/waybionic_ws`) to install dependencies and build the foundation: +### Existing workspace + +If `~/waybionic_ws/src/waybionic_ground_station` already exists, use it without +cloning again. Leave any local changes intact and continue from the workspace root: + +```bash +cd ~/waybionic_ws ``` + +## Build and Launch +- For native Ubuntu/WSL, run these commands from the root of your workspace (`~/waybionic_ws`) to install dependencies and build the foundation: +```bash +cd ~/waybionic_ws source /opt/ros/jazzy/setup.bash rosdep install --from-paths src --ignore-src -r -y -colcon build +colcon build --symlink-install source install/setup.bash ``` -- Launch ground station using: +- Validate the full workspace before launching: +```bash +colcon test +colcon test-result --verbose +bash src/waybionic_ground_station/scripts/check_waybionic_ws.sh ``` +- Launch ground station using: +```bash ros2 launch waybionic_bringup ground_station.launch.py ``` - **RViz** and **Joint State Publisher GUI** (separate small window) will pop up after the last command - RViz opens pre-configured with `base_link` fixed frame, `RobotModel`, and `TF` displays already loaded - Move the slider in the Joint State Publisher GUI (small window) to move the arm +For mock and live diagnostics checks, continue with the +[diagnostics guide](waybionic_rviz_plugins/README.md). For team access, branches, +and pull requests, read [CONTRIBUTING.md](CONTRIBUTING.md). + +### Every new Ubuntu terminal + +After the first successful build, source both environments before running ROS +commands. Rebuilding is only necessary after changes that require it. + +```bash +source /opt/ros/jazzy/setup.bash +source ~/waybionic_ws/install/setup.bash +``` + ## macOS (Apple Silicon) The workspace runs natively through RoboStack. Docker and XQuartz are not required. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f92dfcb..087357a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,26 +67,23 @@ Refs #2 ## Before you open a PR -There's no CI yet, so validation is on you. From the workspace root, on a clean build: +CI builds and tests the shared Dockerfile on Linux x86-64 and ARM64. Run the same +test target from the **repository root** before opening a PR: -```bash -source /opt/ros/jazzy/setup.bash -rosdep install --from-paths . --ignore-src -r -y -colcon build -colcon test # if the package has tests +```console +docker build --progress=plain --target test --file docker/Dockerfile --tag waybionic-ground-station:jazzy . ``` -If you touched Python, lint it: - -```bash -flake8 . # or: colcon test --packages-select (runs ament_flake8) -``` +Package lint checks registered with colcon run with the tests. Run any additional +Python lint checks inside the Dev Container, not against an arbitrary host Python +environment. For RViz or other visual changes, also validate the relevant +GUI path in [BuildInstructions.md](./BuildInstructions.md); Docker tests are headless. Make sure: - [ ] Branch is up to date with `main` (`git pull origin main` or rebase). -- [ ] `colcon build` succeeds from a clean tree. -- [ ] Tests pass (if the package has any). +- [ ] The Docker `test` target builds successfully from the current source. +- [ ] Both architecture jobs pass in CI. - [ ] No lint errors on Python you changed. - [ ] No build artifacts committed (`build/`, `install/`, `log/` are gitignored — keep it that way). - [ ] No personal or machine-specific paths committed (absolute paths, local `.vscode` settings, etc.). @@ -110,12 +107,16 @@ Make sure: ## Development environment -Full build and launch steps are in [BuildInstructions.md](./BuildInstructions.md). Quick notes: +Full first-time setup, build, and launch steps are in +[BuildInstructions.md](./BuildInstructions.md). Quick notes: -- **Target:** ROS 2 **Jazzy** on **Ubuntu 24.04**. -- **Windows:** use **WSL2** with Ubuntu 24.04. -- **Linux:** native, no extra setup. -- **macOS (Apple Silicon):** use the native RoboStack workflow in +- **Default development/test environment:** Docker with ROS 2 **Jazzy** on + **Ubuntu 24.04**, using the repository Dev Container or Docker test target. +- **Windows Docker backend:** WSL2; a separate Ubuntu/ROS install is unnecessary + unless you also need the native RViz path. +- **Native RViz on Windows/Linux:** Ubuntu 24.04 with ROS 2 Jazzy, under WSL2 + on Windows. +- **Native RViz on macOS (Apple Silicon):** use the RoboStack workflow in [BuildInstructions.md](./BuildInstructions.md). Do not commit Mac-specific local paths into shared config. diff --git a/README.md b/README.md index 08416a1..159c75f 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,42 @@ Currently, this repository contains the clean foundation and placeholder robot m Hardware description, URDF/Xacro files, and meshes. (Currently using a geometric placeholder model until mechanical exports are finalized). - **`waybionic_bringup`** Launch files and RViz configurations to bring up the robot state and visualization. +- **`waybionic_rviz_plugins`** + Engineer diagnostics panel, mock/live diagnostics sources, and a temporary diagnostics publisher. + +## Docker Development and Tests + +Docker is the default development and headless build/test path. See +[BuildInstructions.md](./BuildInstructions.md#docker-setup-default) for first-time +Windows, macOS, or Linux setup; no host ROS installation is required for this path. + +From the repository root: + +```console +docker build --progress=plain --target test --file docker/Dockerfile --tag waybionic-ground-station:jazzy . +``` + +To build, test, and start the headless mock demo with the checked-in Compose +configuration: + +```console +docker compose up --build +``` + +Press Ctrl+C to stop, then run `docker compose down` to remove the demo container +and network. See the [Compose demo](./BuildInstructions.md#compose-demo) for +diagnostics commands and the optional Windows WSLg configuration. Compose reuses +the same Dockerfile and ROS launch; it does not enable hardware access. + +For editing, open the repository with VS Code's **Dev Containers: Reopen in Container**. +Local development and CI use the same Dockerfile, with CI jobs for x86-64 and ARM64. +The default container is headless. Windows users can run the +[RViz demo through WSLg](./BuildInstructions.md#windows-wslg-demo); native GUI +options are also documented below. ## macOS (Apple Silicon) -Install Miniforge once, then clone and set up the native RoboStack environment: +For native RViz, install Miniforge once, then clone and set up the RoboStack environment: ```bash brew install --cask miniforge @@ -26,6 +58,8 @@ Launch the ground station visualization: ./scripts/macos.sh launch ``` -## Building and Launching +## Environment Setup, Build, and Launch -Please refer to [BuildInstructions.md](./BuildInstructions.md) for complete instructions on how to build the workspace and launch the ground station visualization. +Use [BuildInstructions.md](./BuildInstructions.md) for Docker-first setup and the +separate native Ubuntu/WSL and macOS RViz instructions. Team access and contribution +workflow are covered in [CONTRIBUTING.md](./CONTRIBUTING.md). diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..2b70007 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,21 @@ +services: + ground-station: + image: waybionic-ground-station:jazzy + build: + context: . + dockerfile: docker/Dockerfile + target: test + init: true + restart: "no" + stop_signal: SIGINT + stop_grace_period: 20s + environment: + ROS_AUTOMATIC_DISCOVERY_RANGE: LOCALHOST + command: + - ros2 + - launch + - waybionic_bringup + - ground_station.launch.py + - launch_rviz:=false + - use_joint_state_publisher_gui:=false + - start_temporary_diagnostics_publisher:=true \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 355bd46..3579b56 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,17 +1,41 @@ -FROM ros:jazzy +FROM ros@sha256:386d06ec6d4188f731bae5678e07b4cb64a4e4d4152090c0bd1f881dcf7706f5 AS development -SHELL ["/bin/bash", "-c"] +SHELL ["/bin/bash", "-o", "pipefail", "-c"] WORKDIR /waybionic_ws -COPY . /waybionic_ws/src -RUN apt update -RUN rosdep update -RUN rosdep install --from-paths src --ignore-src -r -y +COPY waybionic_description/package.xml src/waybionic_ground_station/waybionic_description/package.xml +COPY waybionic_bringup/package.xml src/waybionic_ground_station/waybionic_bringup/package.xml +COPY waybionic_rviz_plugins/package.xml src/waybionic_ground_station/waybionic_rviz_plugins/package.xml -RUN source /opt/ros/jazzy/setup.bash && colcon build --symlink-install +RUN apt-get update \ + && rosdep update --rosdistro jazzy \ + && rosdep install --from-paths src --ignore-src --rosdistro jazzy -y \ + && rm -rf /var/lib/apt/lists/* -COPY ./docker/entrypoint.sh /entrypoint.sh +RUN if ! id -u ubuntu >/dev/null 2>&1; then \ + useradd --create-home --user-group --uid 1000 --shell /bin/bash ubuntu; \ + fi \ + && install -d -o ubuntu -g ubuntu /home/ubuntu/.waybionic_ws/{build,install,log} \ + && ln -s /home/ubuntu/.waybionic_ws/{build,install,log} /waybionic_ws/ +COPY --chmod=755 docker/entrypoint.sh /entrypoint.sh + +RUN printf '\nsource /opt/ros/jazzy/setup.bash\nif [[ -f /waybionic_ws/install/setup.bash ]]; then\n source /waybionic_ws/install/setup.bash\nfi\n' >> /etc/bash.bashrc + +USER ubuntu ENTRYPOINT ["/entrypoint.sh"] CMD ["bash"] + +FROM development AS build + +COPY . /waybionic_ws/src/waybionic_ground_station + +RUN source /opt/ros/jazzy/setup.bash \ + && colcon build --symlink-install + +FROM build AS test + +RUN source install/setup.bash \ + && colcon test --return-code-on-test-failure --event-handlers console_direct+ \ + && colcon test-result --verbose diff --git a/docker/compose.wslg.yaml b/docker/compose.wslg.yaml new file mode 100644 index 0000000..e416e2c --- /dev/null +++ b/docker/compose.wslg.yaml @@ -0,0 +1,21 @@ +services: + ground-station: + environment: + DISPLAY: ":0" + QT_X11_NO_MITSHM: "1" + LIBGL_ALWAYS_SOFTWARE: "1" + volumes: + - type: bind + source: /mnt/host/wslg/.X11-unix + target: /tmp/.X11-unix + read_only: true + bind: + create_host_path: false + command: + - ros2 + - launch + - waybionic_bringup + - ground_station.launch.py + - launch_rviz:=true + - use_joint_state_publisher_gui:=true + - start_temporary_diagnostics_publisher:=true \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 02e44f5..141dd94 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,6 +1,10 @@ #!/bin/bash set -e -source /waybionic_ws/install/setup.bash +source /opt/ros/jazzy/setup.bash + +if [[ -f /waybionic_ws/install/setup.bash ]]; then + source /waybionic_ws/install/setup.bash +fi exec "$@"