Files
kinect-bot 9b5a0255e2
ci / Linux C++ core (cmake + ctest) (push) Canceled after 0s
ci / Python root tests (pytest, no tracker deps) (push) Canceled after 0s
ci / Python tracker (pytest, tracker/.venv) (push) Canceled after 0s
feat(windows): usbip-win runbook ([~]) + clean-room Kinect10.dll NUI shim (x86+x64 export-verified) (wave 9; todo 14 done, 12/13 blocked)
2026-11-25 06:00:12 -05:00

76 lines
3.1 KiB
PowerShell

#requires -Version 5.1
<#
.SYNOPSIS
Attach the three virtual Kinect v1 busids (camera/audio/motor) from the attach/linux
UsbipServer into this Windows box's USB tree via the installed usbip-win VHCI client.
.DESCRIPTION
[~] BLOCKED in the kinect build environment (no Windows). RUN THIS ON THE USER'S WINDOWS BOX,
elevated, AFTER:
1. Install-UsbIpWin.ps1 installed a VHCI client (and, for the legacy client, Enable-TestSigning
+ reboot).
2. The OS-agnostic server is running on the host named in config\kinect-usbip.json:
kinect_attach serve --port 3240 (built from attach/linux on a Linux host/VM/WSL2)
It reads config\kinect-usbip.json for the server host/port and the busid list, then runs one
'usbip.exe attach -r <host> -b <busid>' per device. All three are required for the MS NUI
runtime to see a complete sensor.
.PARAMETER UsbipExe
Path to usbip.exe. Defaults to 'usbip.exe' (on PATH after usbip-win2 install) or, if absent,
"C:\Program Files\USBip\usbip.exe".
.PARAMETER ConfigPath
Path to kinect-usbip.json. Defaults to ..\config\kinect-usbip.json relative to this script.
.PARAMETER ServerHost
Override the server host from the config (e.g. a Linux VM IP). ($Host is a PowerShell
automatic variable, so the parameter is named ServerHost.)
#>
[CmdletBinding()]
param(
[string]$UsbipExe,
[string]$ConfigPath,
[string]$ServerHost
)
$ErrorActionPreference = 'Stop'
function Resolve-Usbip([string]$explicit) {
if ($explicit) { return $explicit }
$onPath = Get-Command usbip.exe -ErrorAction SilentlyContinue
if ($onPath) { return $onPath.Source }
$default = Join-Path ${env:ProgramFiles} 'USBip\usbip.exe'
if (Test-Path $default) { return $default }
throw 'usbip.exe not found. Install a client with Install-UsbIpWin.ps1 or pass -UsbipExe.'
}
if (-not $ConfigPath) {
$ConfigPath = Join-Path $PSScriptRoot '..\config\kinect-usbip.json'
}
if (-not (Test-Path $ConfigPath)) { throw "Config not found: $ConfigPath" }
$config = Get-Content -Raw -Path $ConfigPath | ConvertFrom-Json
$targetHost = if ($ServerHost) { $ServerHost } else { $config.server.host }
$usbip = Resolve-Usbip $UsbipExe
Write-Host "=== Attaching virtual Kinect v1 from $targetHost (server port $($config.server.port)) ===" -ForegroundColor Cyan
Write-Host "usbip client: $usbip"
$failures = @()
foreach ($dev in $config.devices) {
Write-Host ("Attaching {0,-6} busid {1} ({2}:{3})" -f $dev.function, $dev.busid, $dev.vid, $dev.pid) -ForegroundColor Green
& $usbip attach -r $targetHost -b $dev.busid
if ($LASTEXITCODE -ne 0) {
$failures += $dev.busid
Write-Warning "attach failed for busid $($dev.busid) (function $($dev.function))."
}
}
if ($failures.Count -gt 0) {
Write-Warning "Attach incomplete. Failed busids: $($failures -join ', '). Check: server running? firewall allows TCP $($config.server.port)? VHCI driver loaded (Device Manager)?"
exit 1
}
Write-Host 'All three Kinect busids attached. Run Verify-KinectDevice.ps1 to confirm the MS Kinect driver bound.' -ForegroundColor Cyan