From 9e9988ab6d71963e14d4274aa4492547e2cdc090 Mon Sep 17 00:00:00 2001 From: Yassin Soliman <108886216+yassinsolim@users.noreply.github.com> Date: Sat, 14 Nov 2026 06:21:06 -0600 Subject: [PATCH 1/6] Run the macOS app test in CI test_macos_app.py was linted by ament but never registered with colcon, so CI never ran it. It passes in the CI image, so register it like the other bringup tests. --- waybionic_bringup/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/waybionic_bringup/CMakeLists.txt b/waybionic_bringup/CMakeLists.txt index 4529bc2..285e722 100644 --- a/waybionic_bringup/CMakeLists.txt +++ b/waybionic_bringup/CMakeLists.txt @@ -31,6 +31,7 @@ if(BUILD_TESTING) add_launch_test(test/test_old_arm_arduino_launch.py ${isolated}) ament_add_pytest_test(test_launch_checks test/test_launch_checks.py TIMEOUT 60) ament_add_pytest_test(test_launch_options test/test_launch_options.py) + ament_add_pytest_test(test_macos_app test/test_macos_app.py) endif() install(PROGRAMS scripts/joint_demo.py scripts/camera_follower.py From 074fb0f7c16ce303ffd6a6d95c220622fbe7a37b Mon Sep 17 00:00:00 2001 From: Yassin Soliman <108886216+yassinsolim@users.noreply.github.com> Date: Sat, 14 Nov 2026 06:21:06 -0600 Subject: [PATCH 2/6] Let windows-arm.ps1 run from a release bundle and check itself In a release bundle the folder holds its own Python and compose.release.yaml, which runs the tested image by digest, so the script now: - prefers python\python.exe beside it to a Python on the PATH; - runs `docker compose -f compose.release.yaml run` with no --build, and pulls the image first with a message that says what to do if it is unauthorized; - takes -SelfTest, which checks Docker, Python, pyserial and that the bridges import, and starts nothing. From a checkout it behaves as before. The cheap checks (Python, pyserial) now come before starting Docker Desktop, which can take minutes, so a missing Python is reported at once. --- scripts/windows-arm.ps1 | 98 +++++++++++++++++++++++++++++++---------- 1 file changed, 75 insertions(+), 23 deletions(-) diff --git a/scripts/windows-arm.ps1 b/scripts/windows-arm.ps1 index b54c5d1..cd9696d 100644 --- a/scripts/windows-arm.ps1 +++ b/scripts/windows-arm.ps1 @@ -4,7 +4,10 @@ # Run windows-arm.cmd, or: powershell -ExecutionPolicy Bypass -File scripts\windows-arm.ps1 # The bridge finds the carrier's COM port itself. With several Arduinos or USB serial devices # plugged in, name it: windows-arm.cmd COM5 (or set WAYBIONIC_CARRIER=COM5). -param([string]$Port = $env:WAYBIONIC_CARRIER) +# Run from a release bundle, this folder holds its own Python and a compose file that runs the +# tested image instead of building one. windows-arm.cmd -SelfTest checks the prerequisites and +# starts nothing. +param([string]$Port = $env:WAYBIONIC_CARRIER, [switch]$SelfTest) $root = Split-Path -Parent $PSScriptRoot $teleop = Join-Path $root 'waybionic_teleop' @@ -20,6 +23,67 @@ if (-not (Test-Path $docker)) { $docker = $command.Source } +$python = $null +$pythonArguments = @() +$bundledPython = Join-Path $root 'python\python.exe' +if (Test-Path $bundledPython) { + $python = [pscustomobject]@{ Source = $bundledPython } +} +foreach ($name in 'python', 'python3', 'py') { + if ($python) { + break + } + $command = Get-Command $name -ErrorAction SilentlyContinue + if (-not $command) { + continue + } + $prefix = if ($command.Name -eq 'py.exe') { @('-3') } else { @() } + & $command.Source @prefix -c 'import sys; sys.exit(sys.version_info[0] != 3)' *> $null + if ($LASTEXITCODE -eq 0) { + $python, $pythonArguments = $command, $prefix + break + } +} +if (-not $python) { + Write-Error 'The real arm needs Python 3 on Windows for the carrier bridge.' + exit 1 +} +& $python.Source @pythonArguments -c 'import serial' *> $null +if ($LASTEXITCODE -ne 0) { + Write-Error 'The carrier bridge needs pyserial: python -m pip install pyserial' + exit 1 +} + +$release = Join-Path $root 'compose.release.yaml' +$composeFiles = @() +$buildFlag = @('--build') +if (Test-Path $release) { + $composeFiles = @('-f', $release) + $buildFlag = @() +} + +if ($SelfTest) { + Push-Location $teleop + try { + & $python.Source @pythonArguments -c 'import waybionic_teleop.carrier_relay, waybionic_teleop.xinput_bridge' *> $null + $bridges = $LASTEXITCODE + } finally { + Pop-Location + } + if ($bridges -ne 0) { + Write-Error 'The carrier and controller bridges do not start; the bundle may be damaged.' + exit 1 + } + Write-Host "Docker: $docker" + Write-Host "Python: $($python.Source), with pyserial" + Write-Host 'The carrier and controller bridges start.' + if ($composeFiles.Count -gt 0) { + Write-Host ('Image: ' + ((Get-Content (Join-Path $root 'VERSION')) -join '; ')) + } + Write-Host 'Self-test passed.' + exit 0 +} + & $docker info *> $null if ($LASTEXITCODE -ne 0) { $app = @( @@ -43,29 +107,17 @@ if ($LASTEXITCODE -ne 0) { } } -$python = $null -$pythonArguments = @() -foreach ($name in 'python', 'python3', 'py') { - $command = Get-Command $name -ErrorAction SilentlyContinue - if (-not $command) { - continue - } - $prefix = if ($command.Name -eq 'py.exe') { @('-3') } else { @() } - & $command.Source @prefix -c 'import sys; sys.exit(sys.version_info[0] != 3)' *> $null - if ($LASTEXITCODE -eq 0) { - $python, $pythonArguments = $command, $prefix - break +if ($composeFiles.Count -gt 0) { + Write-Host 'Checking the ground station image; the first start downloads it, several GB...' + & $docker compose @composeFiles pull wslg-arm + if ($LASTEXITCODE -ne 0) { + Write-Error ('The ground station image could not be downloaded. Check the internet ' + + 'connection. If it says unauthorized, the image is not public yet: ask a software ' + + 'lead, or log in once with: docker login ghcr.io') + exit 1 } } -if (-not $python) { - Write-Error 'The real arm needs Python 3 on Windows for the carrier bridge.' - exit 1 -} -& $python.Source @pythonArguments -c 'import serial' *> $null -if ($LASTEXITCODE -ne 0) { - Write-Error 'The carrier bridge needs pyserial: python -m pip install pyserial' - exit 1 -} + # The bridge also writes what it says here, so that this script can show it if the bridge fails. $bridgeLog = Join-Path $env:TEMP 'waybionic-carrier-bridge.log' @@ -109,7 +161,7 @@ try { Write-Host 'Starting the ground station; press Ctrl+C here to stop.' Write-Host ('When RViz opens, follow its Arm setup panel: put the arm in its zero pose, ' + 'press Zero the arm, then press Start (Menu) on the controller. Close RViz to stop.') - & $docker compose run --rm --build --service-ports wslg-arm + & $docker compose @composeFiles run --rm @buildFlag --service-ports wslg-arm } finally { Pop-Location } From 869dd3cf43bf3a20b89388b67bdecc910b930060 Mon Sep 17 00:00:00 2001 From: Yassin Soliman <108886216+yassinsolim@users.noreply.github.com> Date: Sat, 14 Nov 2026 06:21:06 -0600 Subject: [PATCH 3/6] Build the Windows and macOS release bundles packaging/make_bundles.py builds two reproducible zips (the same inputs give the same bytes): - Windows: the launcher scripts, the host-side bridges and the modules they import, an embedded Python with pyserial, and compose.release.yaml, which is the wslg-arm service from compose.yaml run from the tested image pinned by digest. Docker Desktop is the only prerequisite. The bundle fails to build if a bridge imports anything it does not carry, or if the image is not pinned by digest. - macOS: the source at the tag, with Install WayBionic.command, which keeps a copy in ~/WayBionic and installs the app, and the version stamped in the app. The embedded Python and pyserial are pinned by hash: the Python zip is the one python.org signs with Sigstore as hugo@python.org (verified when the pin was made), and pyserial is installed with --require-hashes. The tests cover the compose file, the pin, the bridge imports, the bundle contents (ASCII PowerShell, CRLF text, the _pth file), reproducibility and the macOS stamping. --- packaging/macos/Install WayBionic.command | 34 +++ packaging/macos/README.txt | 32 +++ packaging/make_bundles.py | 218 ++++++++++++++++++ packaging/windows/Check WayBionic Setup.cmd | 6 + packaging/windows/README.txt | 38 +++ packaging/windows/Start WayBionic Arm.cmd | 6 + packaging/windows/python-embed.json | 8 + packaging/windows/requirements.txt | 4 + waybionic_bringup/CMakeLists.txt | 1 + waybionic_bringup/package.xml | 1 + .../test/test_release_bundles.py | 134 +++++++++++ 11 files changed, 482 insertions(+) create mode 100755 packaging/macos/Install WayBionic.command create mode 100644 packaging/macos/README.txt create mode 100644 packaging/make_bundles.py create mode 100644 packaging/windows/Check WayBionic Setup.cmd create mode 100644 packaging/windows/README.txt create mode 100644 packaging/windows/Start WayBionic Arm.cmd create mode 100644 packaging/windows/python-embed.json create mode 100644 packaging/windows/requirements.txt create mode 100644 waybionic_bringup/test/test_release_bundles.py diff --git a/packaging/macos/Install WayBionic.command b/packaging/macos/Install WayBionic.command new file mode 100755 index 0000000..bdc64a4 --- /dev/null +++ b/packaging/macos/Install WayBionic.command @@ -0,0 +1,34 @@ +#!/bin/bash +# Double-click to install the WayBionic ground station on this Mac. +# +# The app starts the station from a folder, so this keeps a copy of this one in ~/WayBionic +# and puts "WayBionic Ground Station" in ~/Applications. It does not set up the environment: +# the app offers that the first time it is opened. + +set -euo pipefail + +HERE="$(cd "$(dirname "$0")" && pwd)" +VERSION="$(head -n 1 "$HERE/VERSION")" +DEST="$HOME/WayBionic/ground-station-$VERSION" + +echo "WayBionic Ground Station $VERSION" +if [[ "$HERE" == "$DEST" ]]; then + echo "This folder is already in place." +elif [[ -e "$DEST" ]]; then + echo "$DEST already exists; using it." +else + mkdir -p "$HOME/WayBionic" + echo "Copying to $DEST ..." + cp -R "$HERE" "$DEST" + # macOS marks the files of a download, which would stop the app from opening. Clear that on + # this copy, which the person installing has chosen to run. + xattr -cr "$DEST" 2>/dev/null || true +fi + +cd "$DEST" +./scripts/macos.sh app +echo +echo "Installed. Open \"WayBionic Ground Station\" from ~/Applications, which is opening now." +echo "The first time, it offers to set up the environment: 30 to 60 minutes and a few GB, once." +open "$HOME/Applications" 2>/dev/null || true +read -r -p "Press Return to close this window. " _ || true diff --git a/packaging/macos/README.txt b/packaging/macos/README.txt new file mode 100644 index 0000000..2b2546b --- /dev/null +++ b/packaging/macos/README.txt @@ -0,0 +1,32 @@ +WayBionic Ground Station $version for macOS +=========================================== + +This is the ground station's source with an installer. The Mac app runs ROS natively, so the +first start builds the workspace on your Mac; nothing here is prebuilt. + +What you need + - An Apple Silicon Mac on macOS 13 or newer. Intel Macs are untested. + - About 10 GB of free disk space and an internet connection for the first start. + - The arm's carrier board (Arduino UNO R4 WiFi) on USB, and a game controller. + +Install it + 1. Unzip this folder. + 2. Double-click "Install WayBionic.command". If macOS says it cannot be opened because it + is from an unidentified developer, right-click it and choose Open; on the newest macOS, + use System Settings > Privacy & Security > Open Anyway. + It copies this folder to ~/WayBionic and puts "WayBionic Ground Station" in + ~/Applications. + 3. Open "WayBionic Ground Station" from ~/Applications. The first time, say yes when it + offers to set up the environment: 30 to 60 minutes and a few GB, once. + +Use it + Plug in the carrier and the controller, then open the app. It says what to do if + something is missing. When RViz opens, follow its Arm setup panel: put the arm in its zero + pose, press "Zero the arm", then press Start (Menu) on the controller. Close RViz to stop. + Its log is in ~/Library/Logs/WayBionic. + +About this download + Version $version. Check the file you downloaded against SHA256SUMS on the release page, + or with + gh attestation verify --repo Waybionic/waybionic_ground_station + docs/operator_guide.md in this folder says more. diff --git a/packaging/make_bundles.py b/packaging/make_bundles.py new file mode 100644 index 0000000..b8ff010 --- /dev/null +++ b/packaging/make_bundles.py @@ -0,0 +1,218 @@ +#!/usr/bin/env python3 +""" +Build the release bundles that start the real arm without a developer setup. + +windows: a zip with the launcher scripts, the host-side bridges, an embedded Python with + pyserial, and a compose file that pulls the tested image by digest. Docker Desktop is the + only thing the laptop needs. +macos: the source tree at the tag with a double-click installer, since the Mac app runs the + workspace natively and cannot ship a prebuilt one. + +The zips are reproducible: the same inputs give the same bytes. Set SOURCE_DATE_EPOCH to the +commit time. See docs/RELEASING.md. +""" + +import argparse +import ast +import os +from pathlib import Path +import plistlib +import re +import stat +import string +import sys +import time +import zipfile + +import yaml + +ROOT = Path(__file__).resolve().parents[1] +VERSION_PATTERN = re.compile(r'^\d+\.\d+\.\d+(-[0-9A-Za-z.]+)?$') +IMAGE_PATTERN = re.compile(r'^ghcr\.io/[a-z0-9._/-]+@sha256:[0-9a-f]{64}$') +# The service the Windows launcher runs, and the bridges that run on the host beside it. +SERVICE = 'wslg-arm' +HOST_BRIDGES = ('carrier_relay', 'xinput_bridge') +# Outside the standard library, the host bridges may import only what the bundle carries. +HOST_THIRD_PARTY = {'serial'} +APP = 'packaging/macos/WayBionic Ground Station.app' + + +def zip_time(): + """Return the timestamp every file in a zip gets; zips cannot hold dates before 1980.""" + return time.gmtime(max(int(os.environ.get('SOURCE_DATE_EPOCH', '0')), 315532800))[:6] + + +class Bundle: + """Collect files under one top folder and write them as a reproducible zip.""" + + def __init__(self, top): + self.top = top + self.files = {} + + def add(self, name, data, executable=False): + if isinstance(data, str): + data = data.encode('utf-8') + if name in self.files: + raise ValueError(f'{name} is added twice') + self.files[name] = (data, executable) + + def add_path(self, name, path): + self.add(name, path.read_bytes(), bool(path.stat().st_mode & stat.S_IXUSR)) + + def write(self, path): + path.parent.mkdir(parents=True, exist_ok=True) + with zipfile.ZipFile(path, 'w', zipfile.ZIP_DEFLATED) as archive: + for name in sorted(self.files): + data, executable = self.files[name] + info = zipfile.ZipInfo(f'{self.top}/{name}', zip_time()) + info.compress_type = zipfile.ZIP_DEFLATED + info.create_system = 3 + info.external_attr = (stat.S_IFREG | (0o755 if executable else 0o644)) << 16 + archive.writestr(info, data) + + +def crlf(text): + """Return text with Windows line endings, for files opened in Notepad or run by cmd.""" + return text.replace('\r\n', '\n').replace('\n', '\r\n') + + +def check_version(version): + if not VERSION_PATTERN.match(version): + raise ValueError(f'{version!r} is not a version like 1.2.3 or 1.2.3-rc1') + + +def release_compose(compose_text, image): + """Return a compose file with the arm service alone, run from the pinned image.""" + if not IMAGE_PATTERN.match(image): + raise ValueError(f'{image!r} is not an image pinned by digest') + service = dict(yaml.safe_load(compose_text)['services'][SERVICE]) + # The bundle has no source to build from, and a lone service needs no profile. + service.pop('build', None) + service.pop('profiles', None) + service['image'] = image + for volume in service.get('volumes', []): + source = volume.get('source', '') if isinstance(volume, dict) else str(volume) + if source.startswith('.'): + raise ValueError(f'{SERVICE} mounts {source}, which is not in the bundle') + return ('# Generated by packaging/make_bundles.py from compose.yaml: the arm service, run\n' + '# from the image the release was tested with, pinned by digest.\n' + + yaml.safe_dump({'services': {SERVICE: service}}, sort_keys=False)) + + +def host_modules(package_dir): + """Return the waybionic_teleop modules the host bridges import, themselves included.""" + seen, queue = set(), list(HOST_BRIDGES) + while queue: + name = queue.pop() + if name in seen: + continue + seen.add(name) + tree = ast.parse((package_dir / f'{name}.py').read_text(encoding='utf-8')) + for node in ast.walk(tree): + if isinstance(node, ast.Import): + modules, names = [alias.name.split('.') for alias in node.names], [] + elif isinstance(node, ast.ImportFrom): + if node.level: + raise ValueError(f'{name} has a relative import; the bundle check needs ' + 'absolute ones') + modules, names = [node.module.split('.')], [alias.name for alias in node.names] + else: + continue + for parts in modules: + if parts[0] == 'waybionic_teleop': + queue.extend(parts[1:2] or names) + elif parts[0] not in sys.stdlib_module_names | HOST_THIRD_PARTY: + raise ValueError(f'{name} imports {parts[0]}, which the Windows bundle ' + 'does not carry') + return sorted(seen) + + +def add_python(bundle, python_zip, site_packages): + """Unpack the embeddable Python, point it at the bridges and add pyserial.""" + with zipfile.ZipFile(python_zip) as archive: + for info in archive.infolist(): + if info.is_dir(): + continue + data = archive.read(info) + if info.filename.endswith('._pth'): + # In this mode Python ignores PYTHONPATH and the working directory, so the + # bridges' package and pyserial are named here, relative to this file. + stem = info.filename[:-len('._pth')] + data = f'{stem}.zip\r\n.\r\n..\\waybionic_teleop\r\nsite-packages\r\n' + bundle.add(f'python/{info.filename}', data, info.filename.endswith('.exe')) + for path in sorted(site_packages.rglob('*')): + relative = path.relative_to(site_packages) + if (path.is_file() and relative.parts[0] != 'bin' + and '__pycache__' not in relative.parts): + bundle.add('python/site-packages/' + relative.as_posix(), path.read_bytes()) + + +def build_windows(args): + check_version(args.version) + package_dir = ROOT / 'waybionic_teleop' / 'waybionic_teleop' + bundle = Bundle(f'WayBionic-Ground-Station-{args.version}') + bundle.add_path('scripts/windows-arm.ps1', ROOT / 'scripts' / 'windows-arm.ps1') + for name, path in (('scripts/windows-arm.cmd', ROOT / 'scripts' / 'windows-arm.cmd'), + ('Start WayBionic Arm.cmd', + ROOT / 'packaging' / 'windows' / 'Start WayBionic Arm.cmd'), + ('Check WayBionic Setup.cmd', + ROOT / 'packaging' / 'windows' / 'Check WayBionic Setup.cmd')): + bundle.add(name, crlf(path.read_text(encoding='utf-8'))) + for module in host_modules(package_dir) + ['__init__']: + bundle.add_path(f'waybionic_teleop/waybionic_teleop/{module}.py', + package_dir / f'{module}.py') + bundle.add('compose.release.yaml', + release_compose((ROOT / 'compose.yaml').read_text(encoding='utf-8'), args.image)) + bundle.add('VERSION', crlf(f'{args.version}\ncommit {args.commit}\nimage {args.image}\n')) + readme = string.Template((ROOT / 'packaging' / 'windows' / 'README.txt').read_text( + encoding='utf-8')) + bundle.add('README.txt', crlf(readme.substitute(version=args.version, image=args.image))) + add_python(bundle, args.python_zip, args.site_packages) + path = args.out / f'waybionic-ground-station-windows-{args.version}.zip' + bundle.write(path) + return path + + +def build_macos(args): + check_version(args.version) + source = args.source + bundle = Bundle(f'WayBionic-Ground-Station-{args.version}') + for path in sorted(source.rglob('*')): + relative = path.relative_to(source).as_posix() + if path.is_symlink(): + raise ValueError(f'{relative} is a symlink, which the bundle does not hold') + if path.is_file() and not relative.startswith('.git/'): + bundle.add_path(relative, path) + plist = f'{APP}/Contents/Info.plist' + info = plistlib.loads(bundle.files[plist][0]) + info['CFBundleShortVersionString'] = info['CFBundleVersion'] = args.version + bundle.files[plist] = (plistlib.dumps(info), False) + bundle.add('Install WayBionic.command', + (ROOT / 'packaging' / 'macos' / 'Install WayBionic.command').read_bytes(), True) + bundle.add('README-macOS.txt', + (ROOT / 'packaging' / 'macos' / 'README.txt').read_text(encoding='utf-8')) + bundle.add('VERSION', f'{args.version}\ncommit {args.commit}\n') + path = args.out / f'waybionic-ground-station-macos-{args.version}.zip' + bundle.write(path) + return path + + +def main(argv=None): + parser = argparse.ArgumentParser(description=__doc__.split('\n\n')[0]) + commands = parser.add_subparsers(dest='command', required=True) + for name in ('windows', 'macos'): + command = commands.add_parser(name) + command.add_argument('--version', required=True) + command.add_argument('--commit', required=True) + command.add_argument('--out', type=Path, required=True) + windows, macos = commands.choices['windows'], commands.choices['macos'] + windows.add_argument('--image', required=True, help='repository@sha256:digest') + windows.add_argument('--python-zip', type=Path, required=True) + windows.add_argument('--site-packages', type=Path, required=True) + macos.add_argument('--source', type=Path, required=True, help='the tag, from git archive') + args = parser.parse_args(argv) + print(build_windows(args) if args.command == 'windows' else build_macos(args)) + + +if __name__ == '__main__': + main() diff --git a/packaging/windows/Check WayBionic Setup.cmd b/packaging/windows/Check WayBionic Setup.cmd new file mode 100644 index 0000000..3050d00 --- /dev/null +++ b/packaging/windows/Check WayBionic Setup.cmd @@ -0,0 +1,6 @@ +@echo off +rem Checks that this laptop can start the ground station: Docker, the bundled Python and the +rem bridges. It starts nothing and does not touch the arm. +call "%~dp0scripts\windows-arm.cmd" -SelfTest +echo. +pause diff --git a/packaging/windows/README.txt b/packaging/windows/README.txt new file mode 100644 index 0000000..91795d7 --- /dev/null +++ b/packaging/windows/README.txt @@ -0,0 +1,38 @@ +WayBionic Ground Station $version for Windows +============================================= + +This starts the ground station for the real arm. Python is included; you only need Docker. + +What you need + - Windows 11 with WSL 2 version 2.1.5 or newer ("wsl --version" shows yours; if WSL is + missing, run "wsl --install --no-distribution" in an administrator PowerShell and restart). + - Docker Desktop with the WSL 2 backend and Linux containers, installed. + - The arm's carrier board (Arduino UNO R4 WiFi) on USB, and the Xbox controller. + +Start it + 1. Unzip this folder somewhere permanent, for example C:\WayBionic. Do not run it from + inside the zip. + 2. Start Docker Desktop and wait until it says it is running. + 3. Plug in the carrier and the controller. + 4. Double-click "Start WayBionic Arm.cmd". + The first start downloads the ground station image, several GB, which can take a while. + Later starts are quick. + 5. When RViz opens, follow its Arm setup panel: put the arm in its zero pose, press + "Zero the arm", then press Start (Menu) on the controller. Close RViz to stop. + +If something is wrong + - Double-click "Check WayBionic Setup.cmd". It checks Docker, Python and the bridges, and + starts nothing. + - "The carrier bridge is not ready": plug in only the carrier, or name its port. In a + Command Prompt in this folder: "Start WayBionic Arm.cmd" COM5 + - "unauthorized" while downloading the image: the image is not public yet. Ask a software + lead, or log in once with: docker login ghcr.io (a GitHub user and a token with + read:packages). + - RViz does not open: restart Docker Desktop, then run "wsl --update". + +About this download + Version $version. It runs this exact, tested image: + $image + Check the file you downloaded against SHA256SUMS on the release page, or with + gh attestation verify --repo Waybionic/waybionic_ground_station + The release notes and docs/operator_guide.md in the repository say more. diff --git a/packaging/windows/Start WayBionic Arm.cmd b/packaging/windows/Start WayBionic Arm.cmd new file mode 100644 index 0000000..fd305f7 --- /dev/null +++ b/packaging/windows/Start WayBionic Arm.cmd @@ -0,0 +1,6 @@ +@echo off +rem Starts the WayBionic ground station for the real arm. Plug in the carrier and the controller +rem first. To name the carrier's COM port: run this from a Command Prompt as "Start WayBionic Arm.cmd" COM5 +call "%~dp0scripts\windows-arm.cmd" %* +echo. +pause diff --git a/packaging/windows/python-embed.json b/packaging/windows/python-embed.json new file mode 100644 index 0000000..7303e38 --- /dev/null +++ b/packaging/windows/python-embed.json @@ -0,0 +1,8 @@ +{ + "version": "3.14.10", + "url": "https://www.python.org/ftp/python/3.14.10/python-3.14.10-embed-amd64.zip", + "sha256": "90905e64a840557d8c1bc4f5b74db3d7ee85e3ffb217611cac1c7813acea4159", + "sigstore_bundle": "https://www.python.org/ftp/python/3.14.10/python-3.14.10-embed-amd64.zip.sigstore", + "sigstore_identity": "hugo@python.org", + "sigstore_issuer": "https://github.com/login/oauth" +} diff --git a/packaging/windows/requirements.txt b/packaging/windows/requirements.txt new file mode 100644 index 0000000..aa107e5 --- /dev/null +++ b/packaging/windows/requirements.txt @@ -0,0 +1,4 @@ +# The only Python package the Windows launcher's carrier bridge needs. Installed with +# pip install --require-hashes --no-deps --target -r requirements.txt +pyserial==3.5 \ + --hash=sha256:c4451db6ba391ca6ca299fb3ec7bae67a5c55dde170964c7a14ceefec02f2cf0 diff --git a/waybionic_bringup/CMakeLists.txt b/waybionic_bringup/CMakeLists.txt index 285e722..724cfb3 100644 --- a/waybionic_bringup/CMakeLists.txt +++ b/waybionic_bringup/CMakeLists.txt @@ -32,6 +32,7 @@ if(BUILD_TESTING) ament_add_pytest_test(test_launch_checks test/test_launch_checks.py TIMEOUT 60) ament_add_pytest_test(test_launch_options test/test_launch_options.py) ament_add_pytest_test(test_macos_app test/test_macos_app.py) + ament_add_pytest_test(test_release_bundles test/test_release_bundles.py) endif() install(PROGRAMS scripts/joint_demo.py scripts/camera_follower.py diff --git a/waybionic_bringup/package.xml b/waybionic_bringup/package.xml index 84aa794..55c5c7a 100644 --- a/waybionic_bringup/package.xml +++ b/waybionic_bringup/package.xml @@ -36,6 +36,7 @@ ament_lint_auto ament_lint_common launch_testing_ament_cmake + python3-yaml ament_cmake diff --git a/waybionic_bringup/test/test_release_bundles.py b/waybionic_bringup/test/test_release_bundles.py new file mode 100644 index 0000000..5f3f5a5 --- /dev/null +++ b/waybionic_bringup/test/test_release_bundles.py @@ -0,0 +1,134 @@ +"""The release bundles hold what the launchers need, and the image they run is pinned.""" + +import importlib.util +from pathlib import Path +import plistlib +import shutil +import subprocess +import types +import zipfile + +import pytest +import yaml + +ROOT = Path(__file__).resolve().parents[2] +PACKAGE = ROOT / 'waybionic_teleop' / 'waybionic_teleop' +IMAGE = 'ghcr.io/waybionic/waybionic_ground_station@sha256:' + 'a' * 64 + +_spec = importlib.util.spec_from_file_location('make_bundles', + ROOT / 'packaging' / 'make_bundles.py') +make_bundles = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(make_bundles) + + +def test_the_release_compose_is_the_arm_service_run_from_the_pinned_image(): + text = (ROOT / 'compose.yaml').read_text(encoding='utf-8') + original = yaml.safe_load(text)['services'][make_bundles.SERVICE] + release = yaml.safe_load(make_bundles.release_compose(text, IMAGE)) + assert list(release['services']) == [make_bundles.SERVICE] + service = release['services'][make_bundles.SERVICE] + assert service['image'] == IMAGE + assert 'build' not in service and 'profiles' not in service + # Whatever else the arm needs is what compose.yaml says, so the two cannot drift apart. + assert ({key: value for key, value in service.items() if key != 'image'} + == {key: value for key, value in original.items() + if key not in ('image', 'build', 'profiles')}) + + +@pytest.mark.parametrize('image', [ + 'ghcr.io/waybionic/waybionic_ground_station:jazzy', + 'ghcr.io/waybionic/waybionic_ground_station@sha256:abc', + 'docker.io/library/ros@sha256:' + 'a' * 64, +]) +def test_a_release_never_runs_an_image_that_is_not_pinned_by_digest(image): + with pytest.raises(ValueError, match='pinned by digest'): + make_bundles.release_compose((ROOT / 'compose.yaml').read_text(encoding='utf-8'), image) + + +@pytest.mark.parametrize('version', ['v1.2.3', '1.2', '1.2.3 ', 'latest', '1.2.3/x']) +def test_only_a_plain_version_names_a_release(version): + with pytest.raises(ValueError, match='not a version'): + make_bundles.check_version(version) + + +def test_the_host_bridges_import_only_what_the_windows_bundle_carries(tmp_path): + modules = make_bundles.host_modules(PACKAGE) + assert {'carrier_relay', 'xinput_bridge', 'gamepad'} <= set(modules) + (tmp_path / 'carrier_relay.py').write_text('import socket\nimport rclpy\n', encoding='utf-8') + (tmp_path / 'xinput_bridge.py').write_text('import ctypes\n', encoding='utf-8') + with pytest.raises(ValueError, match='rclpy'): + make_bundles.host_modules(tmp_path) + + +def fake_python(tmp_path): + python_zip = tmp_path / 'python.zip' + with zipfile.ZipFile(python_zip, 'w') as archive: + archive.writestr('python.exe', 'exe') + archive.writestr('python399.zip', 'stdlib') + archive.writestr('python399._pth', 'python399.zip\n.\n#import site\n') + site = tmp_path / 'site' + (site / 'serial').mkdir(parents=True) + (site / 'serial' / '__init__.py').write_text('', encoding='utf-8') + (site / 'serial' / '__pycache__').mkdir() + (site / 'serial' / '__pycache__' / 'x.pyc').write_bytes(b'x') + (site / 'bin').mkdir() + (site / 'bin' / 'pyserial-ports').write_text('x', encoding='utf-8') + return python_zip, site + + +def test_the_windows_bundle_holds_the_launcher_its_python_and_the_pinned_compose_file( + tmp_path): + python_zip, site = fake_python(tmp_path) + arguments = types.SimpleNamespace(version='1.2.3', commit='abc', image=IMAGE, + python_zip=python_zip, site_packages=site) + path = make_bundles.build_windows(types.SimpleNamespace(**vars(arguments), + out=tmp_path / 'one')) + top = 'WayBionic-Ground-Station-1.2.3/' + with zipfile.ZipFile(path) as archive: + names = set(archive.namelist()) + for name in ('scripts/windows-arm.cmd', 'scripts/windows-arm.ps1', + 'Start WayBionic Arm.cmd', 'Check WayBionic Setup.cmd', 'README.txt', + 'compose.release.yaml', 'VERSION', 'python/python.exe', + 'python/site-packages/serial/__init__.py', + 'waybionic_teleop/waybionic_teleop/__init__.py', + 'waybionic_teleop/waybionic_teleop/carrier_relay.py', + 'waybionic_teleop/waybionic_teleop/xinput_bridge.py'): + assert top + name in names, name + assert not [name for name in names if '/bin/' in name or '__pycache__' in name] + # In this mode Python ignores PYTHONPATH and the working directory. + assert (archive.read(top + 'python/python399._pth').decode().splitlines() + == ['python399.zip', '.', '..\\waybionic_teleop', 'site-packages']) + # Windows PowerShell 5.1 reads a script without a byte order mark as ANSI. + assert archive.read(top + 'scripts/windows-arm.ps1').isascii() + for name in ('scripts/windows-arm.cmd', 'Start WayBionic Arm.cmd', 'README.txt'): + text = archive.read(top + name) + assert b'\r\n' in text and b'\n' not in text.replace(b'\r\n', b''), name + assert IMAGE in archive.read(top + 'compose.release.yaml').decode() + assert IMAGE in archive.read(top + 'README.txt').decode() + # The same inputs give the same bytes, so a rebuild can be checked against a release. + again = make_bundles.build_windows(types.SimpleNamespace(**vars(arguments), + out=tmp_path / 'two')) + assert path.read_bytes() == again.read_bytes() + + +def test_the_macos_bundle_stamps_the_version_and_holds_the_installer(tmp_path): + source = tmp_path / 'source' + app = source / make_bundles.APP + (app / 'Contents').mkdir(parents=True) + shutil.copy(ROOT / make_bundles.APP / 'Contents' / 'Info.plist', + app / 'Contents' / 'Info.plist') + (source / 'scripts').mkdir() + (source / 'scripts' / 'macos.sh').write_text('#!/bin/bash\n', encoding='utf-8') + (source / 'scripts' / 'macos.sh').chmod(0o755) + path = make_bundles.build_macos(types.SimpleNamespace( + version='1.2.3', commit='abc', source=source, out=tmp_path / 'out')) + top = 'WayBionic-Ground-Station-1.2.3/' + with zipfile.ZipFile(path) as archive: + info = plistlib.loads(archive.read(top + make_bundles.APP + '/Contents/Info.plist')) + assert info['CFBundleShortVersionString'] == info['CFBundleVersion'] == '1.2.3' + assert archive.read(top + 'VERSION').splitlines()[0] == b'1.2.3' + assert archive.getinfo(top + 'scripts/macos.sh').external_attr >> 16 & 0o111 + installer = archive.getinfo(top + 'Install WayBionic.command') + assert installer.external_attr >> 16 & 0o111 + (tmp_path / 'installer').write_bytes(archive.read(installer)) + assert subprocess.run(['bash', '-n', str(tmp_path / 'installer')]).returncode == 0 From b90e8d77ac70438d189f05c6734334c5480724dd Mon Sep 17 00:00:00 2001 From: Yassin Soliman <108886216+yassinsolim@users.noreply.github.com> Date: Sat, 14 Nov 2026 06:21:06 -0600 Subject: [PATCH 4/6] Add a release workflow that tests and drafts the bundles Pushing a tag vX.Y.Z builds the bundles, checks them on Windows and macOS runners, writes SHA256SUMS, attests where the files came from, tags the image and drafts a GitHub Release. A lead publishes the draft; nothing is public before that. The release is only of a commit on main that has an image CI already tested: the workflow re-tags that image by digest instead of rebuilding it, pins the Windows bundle to the digest, and never moves a version tag that exists. Pull requests that touch the packaging, and manual runs, build and test the same bundles without publishing anything. Actions are pinned by commit. --- .github/workflows/release.yml | 323 ++++++++++++++++++++++++++++++++++ 1 file changed, 323 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..59eec59 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,323 @@ +name: Release + +# Pushing a tag like v1.2.3 on a commit of main builds the Windows and macOS bundles, tags the +# image that CI already tested for that commit, and drafts a GitHub Release. Nothing is public +# until a software lead publishes the draft. Pull requests that touch the packaging, and manual +# runs, build and test the same bundles without publishing anything. See docs/RELEASING.md. +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' + pull_request: + paths: + - .github/workflows/release.yml + - packaging/** + - scripts/windows-arm.* + - compose.yaml + workflow_dispatch: + inputs: + version: + description: Build the bundles as this version, without publishing (a dry run) + required: true + default: 0.0.0-test + +permissions: + contents: read + +env: + IMAGE: ghcr.io/waybionic/waybionic_ground_station + +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false + +jobs: + plan: + runs-on: ubuntu-24.04 + timeout-minutes: 10 + permissions: + contents: read + packages: read + outputs: + version: ${{ steps.plan.outputs.version }} + publish: ${{ steps.plan.outputs.publish }} + image: ${{ steps.plan.outputs.image }} + steps: + - name: Check out the repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Decide what this run builds + id: plan + shell: bash + env: + GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }} + INPUT_VERSION: ${{ inputs.version }} + run: | + set -euo pipefail + pattern='^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$' + if [[ "$GITHUB_EVENT_NAME" == push ]]; then + version="${GITHUB_REF_NAME#v}" + if [[ ! "$version" =~ $pattern ]]; then + echo "::error::$GITHUB_REF_NAME is not a version tag like v1.2.3 or v1.2.3-rc1" + exit 1 + fi + # Only a commit that went through a pull request into main can be released. + git fetch --no-tags origin main + if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then + echo "::error::$GITHUB_REF_NAME points at a commit that is not on main. Release a commit of main." + exit 1 + fi + printf '%s' "$GHCR_TOKEN" | docker login ghcr.io --username "$GITHUB_ACTOR" --password-stdin + # main's CI publishes the image it tested for each commit as :. + digest=$(docker buildx imagetools inspect "$IMAGE:${GITHUB_SHA::7}" \ + --format '{{json .Manifest.Digest}}' 2>/dev/null | tr -d '"' || true) + if [[ ! "$digest" =~ ^sha256:[0-9a-f]{64}$ ]]; then + echo "::error::There is no tested image for ${GITHUB_SHA::7}. Wait for the CI run on main for this commit to finish and pass, then run this workflow again." + exit 1 + fi + publish=true + else + # A dry run: the same bundles, with a made-up image digest, and nothing published. + version="${INPUT_VERSION:-0.0.0-pr.$GITHUB_RUN_NUMBER}" + if [[ ! "$version" =~ $pattern ]]; then + echo "::error::$version is not a version like 1.2.3 or 1.2.3-rc1" + exit 1 + fi + digest="sha256:$(printf '0%.0s' {1..64})" + publish=false + fi + { + echo "version=$version" + echo "publish=$publish" + echo "image=$IMAGE@$digest" + } >> "$GITHUB_OUTPUT" + + bundles: + needs: plan + runs-on: ubuntu-24.04 + timeout-minutes: 20 + steps: + - name: Check out the repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Fetch the pinned Python and pyserial + shell: bash + run: | + set -euo pipefail + mkdir -p build + url=$(python3 -c "import json; print(json.load(open('packaging/windows/python-embed.json'))['url'])") + sha=$(python3 -c "import json; print(json.load(open('packaging/windows/python-embed.json'))['sha256'])") + curl --fail --silent --show-error --location --output build/python-embed.zip "$url" + echo "$sha build/python-embed.zip" | sha256sum --check + python3 -m pip install --quiet --require-hashes --no-deps --only-binary=:all: \ + --target build/site-packages -r packaging/windows/requirements.txt + + - name: Build the bundles + shell: bash + env: + VERSION: ${{ needs.plan.outputs.version }} + IMAGE_REF: ${{ needs.plan.outputs.image }} + run: | + set -euo pipefail + SOURCE_DATE_EPOCH=$(git log -1 --format=%ct) + export SOURCE_DATE_EPOCH + python3 packaging/make_bundles.py windows --version "$VERSION" --commit "$GITHUB_SHA" \ + --image "$IMAGE_REF" --python-zip build/python-embed.zip \ + --site-packages build/site-packages --out dist + mkdir build/source + git archive HEAD | tar -x -C build/source + python3 packaging/make_bundles.py macos --version "$VERSION" --commit "$GITHUB_SHA" \ + --source build/source --out dist + ls -l dist + + - name: Keep the bundles for the checks and the release + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: bundles + path: dist/*.zip + if-no-files-found: error + + compose: + needs: [plan, bundles] + runs-on: ubuntu-24.04 + timeout-minutes: 10 + steps: + - name: Fetch the bundles + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: bundles + path: dist + + - name: The release compose file is valid, pinned by digest and builds nothing + shell: bash + env: + IMAGE_REF: ${{ needs.plan.outputs.image }} + run: | + set -euo pipefail + unzip -q dist/waybionic-ground-station-windows-*.zip -d unpacked + cd unpacked/*/ + docker compose -f compose.release.yaml config > resolved.yaml + cat resolved.yaml + grep -q "image: $IMAGE_REF" resolved.yaml + if grep -q '^ *build:' resolved.yaml; then + echo "::error::compose.release.yaml would build an image" + exit 1 + fi + + windows: + needs: [plan, bundles] + runs-on: windows-latest + timeout-minutes: 15 + steps: + - name: Fetch the bundles + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: bundles + path: dist + + - name: Unpack the Windows bundle + shell: pwsh + run: Expand-Archive -Path (Get-ChildItem dist\waybionic-ground-station-windows-*.zip).FullName -DestinationPath unpacked + + - name: The launcher script parses in Windows PowerShell 5.1 + shell: powershell + run: | + $bundle = (Get-ChildItem unpacked)[0].FullName + Write-Host "Windows PowerShell $($PSVersionTable.PSVersion)" + $errors = $null + [System.Management.Automation.Language.Parser]::ParseFile("$bundle\scripts\windows-arm.ps1", [ref]$null, [ref]$errors) | Out-Null + $errors | ForEach-Object { Write-Host $_.Message } + if ($errors.Count -gt 0) { throw 'windows-arm.ps1 does not parse in Windows PowerShell 5.1' } + + - name: The bundled Python is the PSF's and starts with pyserial + shell: powershell + run: | + $bundle = (Get-ChildItem unpacked)[0].FullName + $python = "$bundle\python\python.exe" + $signature = Get-AuthenticodeSignature $python + Write-Host "python.exe: $($signature.Status), $($signature.SignerCertificate.Subject)" + if ($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Subject -notmatch 'Python Software Foundation') { + throw 'python.exe is not signed by the Python Software Foundation' + } + & $python -c "import serial, ctypes, sys; print(sys.version); print('pyserial', serial.__version__)" + if ($LASTEXITCODE -ne 0) { throw 'the bundled Python could not import pyserial' } + + - name: The launcher's self-test passes, from the unpacked bundle, in Windows PowerShell 5.1 + shell: cmd + run: | + for /d %%d in (unpacked\*) do ( + call "%%d\scripts\windows-arm.cmd" -SelfTest + if errorlevel 1 exit /b 1 + ) + + macos: + needs: [plan, bundles] + runs-on: macos-latest + timeout-minutes: 15 + steps: + - name: Fetch the bundles + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: bundles + path: dist + + - name: The installer and the app are in place and well formed + shell: bash + env: + VERSION: ${{ needs.plan.outputs.version }} + run: | + set -euo pipefail + unzip -q dist/waybionic-ground-station-macos-*.zip -d unpacked + cd unpacked/*/ + bash -n "Install WayBionic.command" + bash -n scripts/macos.sh + test -x "Install WayBionic.command" + plutil -lint "packaging/macos/WayBionic Ground Station.app/Contents/Info.plist" + test "$(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' "packaging/macos/WayBionic Ground Station.app/Contents/Info.plist")" = "$VERSION" + test "$(head -n 1 VERSION)" = "$VERSION" + + release: + if: needs.plan.outputs.publish == 'true' + needs: [plan, bundles, compose, windows, macos] + runs-on: ubuntu-24.04 + timeout-minutes: 20 + permissions: + contents: write # the draft release + packages: write # the version tag on the image + id-token: write # the build attestations + attestations: write + steps: + - name: Fetch the bundles + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: bundles + path: dist + + - name: Write the checksums + shell: bash + run: | + set -euo pipefail + cd dist + sha256sum -- *.zip | tee SHA256SUMS + + - name: Attest where the bundles came from + uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 + with: + subject-path: | + dist/*.zip + dist/SHA256SUMS + + - name: Tag the tested image with the version + shell: bash + env: + GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{ needs.plan.outputs.version }} + IMAGE_REF: ${{ needs.plan.outputs.image }} + run: | + set -euo pipefail + printf '%s' "$GHCR_TOKEN" | docker login ghcr.io --username "$GITHUB_ACTOR" --password-stdin + # A released version never moves. + existing=$(docker buildx imagetools inspect "$IMAGE:v$VERSION" \ + --format '{{json .Manifest.Digest}}' 2>/dev/null | tr -d '"' || true) + if [[ -n "$existing" && "$IMAGE@$existing" != "$IMAGE_REF" ]]; then + echo "::error::$IMAGE:v$VERSION already exists with another digest; versions are never moved" + exit 1 + fi + docker buildx imagetools create --tag "$IMAGE:v$VERSION" "$IMAGE_REF" + tagged=$(docker buildx imagetools inspect "$IMAGE:v$VERSION" \ + --format '{{json .Manifest.Digest}}' | tr -d '"') + test "$IMAGE@$tagged" = "$IMAGE_REF" + + - name: Draft the release + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{ needs.plan.outputs.version }} + IMAGE_REF: ${{ needs.plan.outputs.image }} + run: | + set -euo pipefail + cat > notes.md < --repo $GITHUB_REPOSITORY\`. + + Read \`docs/handover.md\` before first use on the arm. + EOF + flags=(--draft --verify-tag --generate-notes --notes-file notes.md) + if [[ "$VERSION" == *-* ]]; then + flags+=(--prerelease) + fi + gh release create "$GITHUB_REF_NAME" dist/*.zip dist/SHA256SUMS \ + --title "WayBionic Ground Station $VERSION" "${flags[@]}" From 116877d17d20e5436aad4d9d61d6adfc16603662 Mon Sep 17 00:00:00 2001 From: Yassin Soliman <108886216+yassinsolim@users.noreply.github.com> Date: Sat, 14 Nov 2026 06:23:17 -0600 Subject: [PATCH 5/6] Document how to release, what works on the arm and what to check README: a "Run the real arm" section that leads with the release bundles for Windows and macOS, ahead of the developer quick start. docs/RELEASING.md: the one-time setup (a public image, restricting who can tag), cutting a release with a dry run and a checklist, what the workflow guarantees, undoing a bad release, and updating the pinned Python, pyserial and actions. docs/handover.md: what has been shown to work and how, what has not (the motion modes, the CAD joint limits and the E-stop on the real arm), the known problems, what to check before relying on each, the hardware facts that cost time to find, and the code conventions CI enforces. --- README.md | 25 ++++++++++- docs/RELEASING.md | 109 ++++++++++++++++++++++++++++++++++++++++++++++ docs/handover.md | 97 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 229 insertions(+), 2 deletions(-) create mode 100644 docs/RELEASING.md create mode 100644 docs/handover.md diff --git a/README.md b/README.md index cf28107..4353a08 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,25 @@ This is a student research prototype, not a medical device. Everything runs in simulation unless you choose the real drives, and powered tests need a lead present. -## Quick start +## Run the real arm + +Download the latest bundle from the +[Releases](https://github.com/Waybionic/waybionic_ground_station/releases) page, unzip it +and double-click the launcher. Plug in the carrier board and the controller first. + +| Platform | Download | Then | +| --- | --- | --- | +| Windows 11 | `waybionic-ground-station-windows-.zip` | Start Docker Desktop, then double-click `Start WayBionic Arm.cmd`. Docker Desktop is the only prerequisite; Python is included. | +| macOS (Apple Silicon) | `waybionic-ground-station-macos-.zip` | Double-click `Install WayBionic.command`, then open **WayBionic Ground Station** from Applications. The first start sets up the environment (30 to 60 minutes, once). | + +RViz opens with an Arm setup panel that says what to do next: put the arm in its zero +pose, zero it, then press Start on the controller. Check a download against `SHA256SUMS` +or with `gh attestation verify --repo Waybionic/waybionic_ground_station`. +Powered tests need a lead present. [docs/handover.md](docs/handover.md) says what has +been shown to work and what to check before relying on it, and +[docs/RELEASING.md](docs/RELEASING.md) says how to publish a release. + +## Build and test (developers) [Install Docker](BuildInstructions.md#1-install-docker), then build the workspace and run its tests: @@ -36,6 +54,8 @@ Then open the arm in RViz: | --- | --- | | [BuildInstructions.md](BuildInstructions.md) | Installing, building, testing and opening RViz on Windows, macOS and Linux | | [Operator guide](docs/operator_guide.md) | Controllers, the self-running demo, the doctor-view camera and the real arm | +| [Handover](docs/handover.md) | What has been shown to work on the arm, what to check next, and the hardware facts | +| [Releasing](docs/RELEASING.md) | Cutting a release: the bundles, the image, the checks and the one-time setup | | [Launch options](waybionic_bringup/README.md) | Every argument of `ground_station.launch.py` | | [Diagnostics](waybionic_rviz_plugins/README.md) | The engineering monitor panel | | [CAN and the carrier board](waybionic_can/README.md) | The MKS protocol, the carrier firmware and CAN simulation | @@ -55,7 +75,8 @@ Then open the arm in RViz: | `waybionic_control`, `waybionic_diagnostics` | The earlier CAN-FD host and the diagnostics command-line tool | | `waybionic_hardware`, `waybionic_motion_test` | The old four-servo arm's Arduino bridge and motion tests | | `firmware/tool_board` | Firmware for the biomedical tool's motor board | -| `scripts` | `macos.sh`, `linux-gui.sh`, `windows-demo.cmd` and the CAD tools | +| `scripts` | `macos.sh`, `linux-gui.sh`, the Windows launchers and the CAD tools | +| `packaging` | The Mac app, and what builds the Windows and macOS release bundles | | `docker`, `compose.yaml`, `.devcontainer` | The container image, its services and the VS Code Dev Container | ## Contributing diff --git a/docs/RELEASING.md b/docs/RELEASING.md new file mode 100644 index 0000000..8680bd0 --- /dev/null +++ b/docs/RELEASING.md @@ -0,0 +1,109 @@ +# Releasing + +A release is a version tag such as `v1.2.3` on a commit of `main`. Pushing the tag builds the +Windows and macOS bundles, tests them, tags the image that CI already tested for that commit, +and drafts a GitHub Release. Nothing is public until a software lead publishes the draft. + +What people download: + +| File | For | What it is | +| --- | --- | --- | +| `waybionic-ground-station-windows-.zip` | Windows 11 | The launcher scripts, an embedded Python with pyserial, and a compose file that pulls the tested image by digest. Docker Desktop is the only prerequisite. | +| `waybionic-ground-station-macos-.zip` | macOS (Apple Silicon) | The source at the tag with `Install WayBionic.command`. The Mac app runs ROS natively, so the first start builds the workspace on the Mac. | +| `SHA256SUMS` | both | The checksums of the two zips. | +| `ghcr.io/waybionic/waybionic_ground_station:v` | Linux, or anyone using `docker compose` | The image the bundles run. | + +Linux has no bundle: use the image with `docker compose` as in [BuildInstructions.md](../BuildInstructions.md). +Windows on ARM and Intel Macs are not built or tested. + +## One-time setup (a GitHub organisation owner) + +1. **Make the image public**, so a Windows laptop can pull it without logging in. Organisation + > Packages > `waybionic_ground_station` > Package settings > Danger Zone > Change + visibility > Public. Check it from a machine that is not logged in: + `docker pull ghcr.io/waybionic/waybionic_ground_station:jazzy`. While it is private, the + launcher tells people to run `docker login ghcr.io` with a token that has `read:packages`. +2. **Restrict who can start a release.** Anyone with write access can push a tag, and a tag + starts the workflow. The workflow only releases a commit on `main` that has a tested image + and only drafts a release, so a stray tag does little harm, but restrict it anyway: + Settings > Rules > Rulesets > New tag ruleset, target `v*`, restrict creations, updates and + deletions, with the software leads on the bypass list. +3. Optional: an Actions environment with required reviewers, if you want a second person to + approve each release. + +## Cutting a release + +1. Merge what belongs in it. The CI run on `main` for the commit you release must have + finished and passed, because it publishes the image the release is made from. +2. **Dry run** (recommended before the first release, and after changing anything in + `packaging/`): Actions > Release > Run workflow, with a version like `0.0.0-test`. It + builds both bundles, tests them on Windows and macOS runners and keeps them as an + artifact. Pull requests that touch the packaging run the same thing. Nothing is + published. +3. Tag the commit and push the tag: + + ```console + git switch main && git pull + git tag -a v1.2.3 -m "WayBionic Ground Station 1.2.3" + git push origin v1.2.3 + ``` + + Use a suffix such as `v1.2.3-rc1` for a release candidate; it is marked as a pre-release. +4. Watch the Release workflow. It stops early, with a message, if the commit is not on `main` + or has no tested image yet; in the second case wait for CI and re-run the workflow. +5. Open the draft on the Releases page and read the notes. Before publishing a release that + people will use on the arm, tick through this: + - [ ] The Windows zip was unpacked on a Windows 11 laptop with Docker Desktop: + `Check WayBionic Setup.cmd` passes, and `Start WayBionic Arm.cmd` reaches the Arm setup + panel with the carrier plugged in. + - [ ] On a Mac, `Install WayBionic.command` installs the app and the app opens. + - [ ] The notes say if the arm's behaviour changed, for example its joint limits (see + [handover.md](handover.md)). +6. Publish the draft. + +## What the workflow guarantees + +- **Only reviewed, tested code is released.** The tag must be on a commit that is an ancestor + of `main`, so it went through a pull request, and that commit must already have an image + from the CI run on `main`. +- **The image is not rebuilt.** The release adds a version tag to the image CI tested, by digest, + and the Windows bundle names that digest, so what runs on the laptop is what the tests ran. + A version tag that already exists with another digest is an error: versions never move. +- **The Windows bundle is checked on Windows.** The runner unpacks it, parses the launcher in + Windows PowerShell 5.1, checks that the bundled `python.exe` is signed by the Python + Software Foundation, imports pyserial, and runs the launcher's `-SelfTest`. The macOS runner + checks the installer, the app and the version stamp. The compose file is validated with + `docker compose config`, pinned by digest and with nothing to build. +- **Downloads can be checked.** `SHA256SUMS` lists the zips, and every file has a build + attestation: `gh attestation verify --repo Waybionic/waybionic_ground_station`. +- **The zips are reproducible.** The same inputs give the same bytes (`SOURCE_DATE_EPOCH` is + the commit time), so a rebuild can be compared with a release. +- Actions are pinned by commit and the workflow has the least permission each job needs. + +## If something goes wrong + +- **The workflow failed before the draft:** fix the cause and re-run the failed jobs. If the tag + itself was wrong, delete it (`git push origin :refs/tags/v1.2.3`), fix, and tag again. +- **A bad release was published:** delete or unpublish the release and cut a new patch + version. The image tag stays, because versions never move; saying so in the new notes is + enough. +- **A Windows user gets "unauthorized":** the image is still private; see the one-time setup. + +## Updating what the bundles pin + +- **Python** (`packaging/windows/python-embed.json`): pick the new embeddable zip from + python.org, download it with its `.sigstore` file, and verify it before pinning its SHA-256: + + ```console + python -m pip install sigstore + python -m sigstore verify identity --bundle .sigstore \ + --cert-identity --cert-oidc-issuer https://github.com/login/oauth + ``` + + The release manager's identity for each Python series is listed at + (3.14 is `hugo@python.org`). Then + open a pull request; its dry run tests the new Python on Windows. +- **pyserial** (`packaging/windows/requirements.txt`): update the version and the SHA-256 of + the wheel from PyPI. +- **Actions** (`.github/workflows/release.yml`): replace the commit SHAs by hand, taking each + from the release you want (`gh api repos/actions/checkout/git/ref/tags/`). diff --git a/docs/handover.md b/docs/handover.md new file mode 100644 index 0000000..b15fb60 --- /dev/null +++ b/docs/handover.md @@ -0,0 +1,97 @@ +# Handover: what works, how it was shown, and what to check next + +Written on 14 November 2026 when the software leads changed. Gianna and Karis lead; Yassin +and Mujtaba advise. It records what has been shown to work on the arm and what has not, so +nobody has to rediscover it. PR numbers below are a snapshot; the pull requests say what +happened to them. + +## What has been shown to work + +| Part | Shown how | Not shown | +| --- | --- | --- | +| Carrier link: laptop USB, UNO R4 WiFi, MCP2515 at 500 kbit/s, five MKS drives, 120 Hz | On the arm, from a Mac. Through the Windows relay and Docker: a simulated carrier at 120 Hz over five drives, about 120 replies/s per drive | A long soak of the Mac read path on the real carrier | +| Zero, gear ratios and directions | On the arm: zero, Start, then moving, with all five drives. The tests follow the directions that were checked | The tool (it has no drive) | +| Arm setup panel (the start-up guide) | On the arm from a Mac, and in a real RViz window for the panel's behaviour | | +| Mac app (`WayBionic Ground Station.app`) | Its decisions are tested without a screen (`test_macos_app.py`) and it was tried by hand on a Mac. The station it starts, `./scripts/macos.sh arm`, is what ran the arm | Intel Macs; an install from the release zip on a clean Mac | +| Windows: `scripts\windows-arm.cmd` | On one Windows laptop with the arm, at the version in #57. The first run said "carrier bridge not ready" until the board was replugged, hence the COM port re-detection | The clone-board and log-file changes (#59); the Windows release bundle, which CI unpacks and self-tests but nobody has run on the arm | +| Chicken head and demo modes (#58) | The simulated drives and a real RViz window with real mouse clicks (28 checks) | **The real arm** | +| CAD joint limits (#44) | Geometry against the CAD meshes at 308,026 poses, and tests | **The powered arm** | +| E-stop status and interlock (draft #60) | The simulated source and tests | The real E-stop: the carrier cannot sense it yet | + +## Known problems + +- **The Joint control panel did not work properly on the bench.** The drive node and teleop + sides are tested; the panel needs a pass on the fully wired arm. The Arm setup panel is + separate and fine. +- **The carrier's CAN error counter climbed during bench runs** (from 14 to about 1400 in + one). The cause is not established. The counters survive a serial reopen, so judge a run by + the change from a baseline taken at its start, not by the total (CAN errors are 16 bits; + failed writes and refusals are 8). +- **No gravity compensation and no hand-guiding.** The MKS drives (firmware V1.0.9) take only + position and speed commands and report no current or torque, so a torque feed-forward is + not possible with them. See the operator guide, "Powered hand-guiding". +- **Joint 1 and joint 5 are limited to +/-360 degrees in #44 only because nothing models the + cables.** Check that the cables allow it before the arm uses those limits. +- **`waybionic_can/docs/HARDWARE_BRINGUP_CHECKLIST.md` still has a step that changes the drives + to 1 Mbit/s.** The arm's MCP2515 carrier tops out at 500 kbit/s (an 8 MHz crystal) and the + drives stay at their factory 500 kbit/s. Do not follow that step on this arm. +- **The Windows `wslg` service is only a viewer.** It has no teleop and no setup guide. The + arm needs `scripts\windows-arm.cmd`, which runs the carrier and controller bridges on the + host, because Docker cannot open a COM port. + +## Check before relying on it + +1. **Powered limits (#44).** Mechanical confirms each joint's travel, then someone checks each + limit with the arm powered at the lowest speed with the stop in reach, as the operator + guide's "Joint limits and collision checks" says. With #44 merged the real arm gets the new + limits as soon as it is launched; nothing caps it at the old ones. +2. **The motion modes on the arm (#58).** First run at the lowest speed level, with the + emergency stop within reach. Demo mode moves the arm by itself. +3. **The Windows launcher on a clean laptop**, including the release bundle: run + `Check WayBionic Setup.cmd`, then start the arm. Try it with the carrier unplugged, with + two serial devices plugged in, and with a clone board if anyone has one (#59). +4. **A release from a clean Mac**, using the release zip rather than a checkout. +5. **The E-stop.** The software interlock (#60) is no substitute for the physical stop, which + must be within reach of anyone near the arm. Electrical still has to sense the E-stop + circuit and the motor supply at the carrier (`TODO(hardware-TBD)` in `carrier_bridge.ino` and + `BenchTelemetry.h`). + +## Hardware facts that cost time to find + +- The carrier is an **Arduino UNO R4 WiFi with an MCP2515 module** (CS on D10, INT on D2, 8 MHz + crystal). Flash `carrier_bridge_mcp2515`, never `carrier_bridge`, which is for the R4's own + CAN. CAN runs at 500 kbit/s. +- The MCP2515 must receive with RXM=00 and zero acceptance masks. RXM=11 admits partial, + errored frames and must not be used as an accept-all shortcut. +- The serial read must take a fixed chunk (`READ_CHUNK`), never `in_waiting`: pyserial's + `socket://` port reports at most one byte waiting, which starved the Windows relay path to + 0.1 to 7 replies a second. +- The MKS drives have no torque or current command or readback. A PID write (`96h`) is + acknowledged but reads back the factory value and changes nothing. +- The arm profile (`~/.waybionic/arm_profile.yaml` on a Mac, `arm_profile_bench.yaml` on + Windows) lists the fitted drives and locks the joints that have none: today only the tool. + +## Working in the code + +- Run what CI runs, from the repository root: `docker compose --progress plain build test`. +- A new RViz panel needs its name in the layout's `QMainWindow State` blob in + `waybionic_unified.rviz`, once; `test_default_window_geometry` checks it. When a panel is + removed or renamed, rebuild the blob from one that predates it, or a placeholder with the + old name stays. +- A new teleop motion mode needs a ROS contract module in `waybionic_teleop` and a `ModeSpec` + entry in `mode_model.cpp`; `test_motion_modes_panel.py` checks that they agree. +- A node's `main()` that spins must re-raise a `RuntimeError` unless + `waybionic_teleop.ros_shutdown.is_shutdown_error(error)`; the SIGINT race otherwise fails + launch tests at random. +- An ament Python package needs at least one pytest file, or CI's `colcon test` fails on + empty discovery. +- `.gitignore` ignores `*.app`; the Mac app under `packaging/macos` is un-ignored by negation + rules, so check that new files there are tracked. + +## Who and where + +- Releases: [RELEASING.md](RELEASING.md). Operating the arm: [operator_guide.md](operator_guide.md). +- Old branches that hold unmerged work are kept on purpose; `git log origin/main..origin/` + shows what each has. `feature/estop-status-malik` is the one worth reviving (#60). +- Teammates who ran the Windows launcher from `feature/joint-enable` should switch to `main` + once #57 is merged; that branch can then be deleted. From bd863c4d71868eccc892bf23a3c4164fafc36a0a Mon Sep 17 00:00:00 2001 From: Yassin Soliman <108886216+yassinsolim@users.noreply.github.com> Date: Sat, 14 Nov 2026 06:51:45 -0600 Subject: [PATCH 6/6] Record the one-time release setup that is done and what blocked it Making the image public turned out to need more than the package page: its Public option is greyed out ("Setting is disabled by organization administrators") until the organisation's Packages policy allows public packages. RELEASING.md did not say so, so whoever recreated the package would have been stuck. It now gives the steps in order, including switching the policy off again afterwards, and a check that needs no login. It also says that the image is public and that the "Protect release tags" ruleset exists (both done on 14 November 2026), and handover.md lists the repository settings changed at the handover, so the new leads know what state the repository is in. --- docs/RELEASING.md | 30 ++++++++++++++++++++++-------- docs/handover.md | 14 ++++++++++++++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 8680bd0..9cf52f8 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -18,16 +18,30 @@ Windows on ARM and Intel Macs are not built or tested. ## One-time setup (a GitHub organisation owner) -1. **Make the image public**, so a Windows laptop can pull it without logging in. Organisation - > Packages > `waybionic_ground_station` > Package settings > Danger Zone > Change - visibility > Public. Check it from a machine that is not logged in: - `docker pull ghcr.io/waybionic/waybionic_ground_station:jazzy`. While it is private, the - launcher tells people to run `docker login ghcr.io` with a token that has `read:packages`. +Steps 1 and 2 were done on 14 November 2026 and are kept here for the day the package is +deleted and recreated, which makes it private again. + +1. **Make the image public**, so a Windows laptop can pull it without logging in. GitHub has no + API for this; use the web page. The **Public** option is greyed out ("Setting is disabled + by organization administrators") until the organisation allows it, so: + 1. Organisation settings > Packages > Package creation: tick **Public** and Save. + 2. Organisation > Packages > `waybionic_ground_station` > Package settings > Danger Zone > + Change visibility > Public, and type the package name to confirm. + 3. Untick **Public** in the organisation setting again and Save, so members still cannot + create public packages. The package stays public. + + Check it from a machine that is not logged in, for example + `curl -s "https://ghcr.io/token?service=ghcr.io&scope=repository:waybionic/waybionic_ground_station:pull"`, + which returns a token only when the package is public (a private one answers 401). While + it is private, the launcher tells people to run `docker login ghcr.io` with a token that has + `read:packages`. 2. **Restrict who can start a release.** Anyone with write access can push a tag, and a tag starts the workflow. The workflow only releases a commit on `main` that has a tested image - and only drafts a release, so a stray tag does little harm, but restrict it anyway: - Settings > Rules > Rulesets > New tag ruleset, target `v*`, restrict creations, updates and - deletions, with the software leads on the bypass list. + and only drafts a release, so a stray tag does little harm, but it is restricted anyway: + the ruleset "Protect release tags" (Settings > Rules > Rulesets) stops anyone creating, + moving or deleting a `v*` tag unless they are in the `maintainers` team, the team that can + also bypass "Protect main". Add a new lead to that team (organisation > Teams) so they can + tag; repository admins can change the ruleset itself. 3. Optional: an Actions environment with required reviewers, if you want a second person to approve each release. diff --git a/docs/handover.md b/docs/handover.md index b15fb60..18f6f82 100644 --- a/docs/handover.md +++ b/docs/handover.md @@ -95,3 +95,17 @@ happened to them. shows what each has. `feature/estop-status-malik` is the one worth reviving (#60). - Teammates who ran the Windows launcher from `feature/joint-enable` should switch to `main` once #57 is merged; that branch can then be deleted. + +## Repository settings changed at the handover (14 November 2026) + +- **The container image is public**, so a Windows laptop can pull it without logging in. The + organisation's Packages policy ("Package creation") still does not allow members to create + public packages: it was switched on for a minute to make this one package public, then + switched off again. See [RELEASING.md](RELEASING.md) to redo it. +- **A tag ruleset, "Protect release tags"**, lets only the `maintainers` team create, move or + delete `v*` tags. "Protect main" is unchanged. +- **Merged branches are deleted automatically** (the repository setting is on), and the 39 + branches that were provably merged were deleted. Branches with unmerged work were kept. +- **PRs #51 and #54 were closed** as superseded by #55 and #57, with comments crediting their + authors. +- Secret scanning and Dependabot are off on this repository. They were not changed.