Move Quest access ownership to Muninn
This commit is contained in:
parent
09d0d3ad2e
commit
c1178512c4
9 changed files with 36 additions and 276 deletions
|
|
@ -127,13 +127,6 @@ if (args.Any(arg => string.Equals(arg, "--move-calibration-protocol-smoke", Stri
|
|||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (args.Any(arg => string.Equals(arg, "--quest-usb-preflight-smoke", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return await RunQuestUsbPreflightSmokeAsync(
|
||||
ParseStringOption(args, "--output", "artifacts/move-calibration/quest-usb-preflight.cc"))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (args.Any(arg => string.Equals(arg, "--import-obs-program-scene", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return await ImportObsProgramSceneAsync(
|
||||
|
|
@ -1918,172 +1911,6 @@ static async Task<int> RunMoveCalibrationProtocolSmokeAsync(string outputPath)
|
|||
: 1;
|
||||
}
|
||||
|
||||
static async Task<int> RunQuestUsbPreflightSmokeAsync(string outputPath)
|
||||
{
|
||||
var devices = await RunProcessCaptureAsync("adb", ["devices", "-l"]).ConfigureAwait(false);
|
||||
if (devices.ExitCode != 0)
|
||||
{
|
||||
Console.Error.WriteLine($"quest-usb-preflight-smoke failed: adb devices exited {devices.ExitCode}: {devices.Stderr.Trim()}");
|
||||
return 1;
|
||||
}
|
||||
|
||||
var quest = FindAuthorizedQuestDevice(devices.Stdout);
|
||||
if (quest is null)
|
||||
{
|
||||
Console.Error.WriteLine("quest-usb-preflight-smoke failed: no authorized Quest device found in adb devices -l");
|
||||
Console.Error.WriteLine(devices.Stdout.Trim());
|
||||
return 1;
|
||||
}
|
||||
|
||||
var serial = quest.Value.Serial;
|
||||
var fields = quest.Value.Fields;
|
||||
var product = fields.GetValueOrDefault("product", "");
|
||||
var model = fields.GetValueOrDefault("model", "");
|
||||
var device = fields.GetValueOrDefault("device", "");
|
||||
var transportId = fields.GetValueOrDefault("transport_id", "");
|
||||
var androidRelease = await GetAdbPropertyAsync(serial, "ro.build.version.release").ConfigureAwait(false);
|
||||
var androidSdk = await GetAdbPropertyAsync(serial, "ro.build.version.sdk").ConfigureAwait(false);
|
||||
var buildFingerprint = await GetAdbPropertyAsync(serial, "ro.build.fingerprint").ConfigureAwait(false);
|
||||
var batterySummary = await GetAdbBatterySummaryAsync(serial).ConfigureAwait(false);
|
||||
var document = MimirQuestUsbPreflight.Create(
|
||||
serial,
|
||||
"device",
|
||||
product,
|
||||
model,
|
||||
device,
|
||||
transportId,
|
||||
androidRelease,
|
||||
androidSdk,
|
||||
buildFingerprint,
|
||||
batterySummary);
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(outputPath)) ?? ".");
|
||||
using var cache = await CultCacheMessagePack.OpenAsync(outputPath, new CultCacheOpenOptions
|
||||
{
|
||||
PullOnOpen = File.Exists(outputPath)
|
||||
}).ConfigureAwait(false);
|
||||
await cache.UpsertAsync(
|
||||
document,
|
||||
new CultRecordHandle<MimirQuestUsbPreflightDocument>(new CultRecordKey($"mimir-quest-usb-preflight:{document.Serial}")))
|
||||
.ConfigureAwait(false);
|
||||
await cache.FlushAsync().ConfigureAwait(false);
|
||||
|
||||
Console.WriteLine(
|
||||
$"quest-usb-preflight-smoke path={outputPath} serial={document.Serial} model={document.Model} product={document.Product} android={document.AndroidRelease} sdk={document.AndroidSdk} pose={document.PoseCaptureStatus}");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static (string Serial, Dictionary<string, string> Fields)? FindAuthorizedQuestDevice(string adbDevicesOutput)
|
||||
{
|
||||
foreach (var rawLine in adbDevicesOutput.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
var tokens = rawLine.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
if (tokens.Length < 2 || tokens[0] == "List" || !string.Equals(tokens[1], "device", StringComparison.Ordinal))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var fields = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var token in tokens.Skip(2))
|
||||
{
|
||||
var split = token.IndexOf(':');
|
||||
if (split > 0 && split < token.Length - 1)
|
||||
{
|
||||
fields[token[..split]] = token[(split + 1)..];
|
||||
}
|
||||
}
|
||||
|
||||
var model = fields.GetValueOrDefault("model", "");
|
||||
var product = fields.GetValueOrDefault("product", "");
|
||||
if (model.Contains("Quest", StringComparison.OrdinalIgnoreCase) ||
|
||||
product.Contains("hollywood", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return (tokens[0], fields);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static async Task<string> GetAdbPropertyAsync(string serial, string property)
|
||||
{
|
||||
var result = await RunProcessCaptureAsync("adb", ["-s", serial, "shell", "getprop", property], 5_000).ConfigureAwait(false);
|
||||
return result.ExitCode == 0 ? result.Stdout.Trim() : "";
|
||||
}
|
||||
|
||||
static async Task<string> GetAdbBatterySummaryAsync(string serial)
|
||||
{
|
||||
var result = await RunProcessCaptureAsync("adb", ["-s", serial, "shell", "dumpsys", "battery"], 5_000).ConfigureAwait(false);
|
||||
if (result.ExitCode != 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
var usefulLines = result.Stdout.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(line => line.Trim())
|
||||
.Where(line =>
|
||||
line.StartsWith("AC powered:", StringComparison.OrdinalIgnoreCase) ||
|
||||
line.StartsWith("USB powered:", StringComparison.OrdinalIgnoreCase) ||
|
||||
line.StartsWith("Wireless powered:", StringComparison.OrdinalIgnoreCase) ||
|
||||
line.StartsWith("status:", StringComparison.OrdinalIgnoreCase) ||
|
||||
line.StartsWith("level:", StringComparison.OrdinalIgnoreCase) ||
|
||||
line.StartsWith("scale:", StringComparison.OrdinalIgnoreCase) ||
|
||||
line.StartsWith("voltage:", StringComparison.OrdinalIgnoreCase) ||
|
||||
line.StartsWith("temperature:", StringComparison.OrdinalIgnoreCase))
|
||||
.Take(12);
|
||||
return string.Join(" | ", usefulLines);
|
||||
}
|
||||
|
||||
static async Task<(int ExitCode, string Stdout, string Stderr)> RunProcessCaptureAsync(
|
||||
string fileName,
|
||||
IReadOnlyList<string> arguments,
|
||||
int timeoutMilliseconds = 10_000)
|
||||
{
|
||||
using var process = new Process();
|
||||
process.StartInfo = new ProcessStartInfo(fileName)
|
||||
{
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
UseShellExecute = false
|
||||
};
|
||||
|
||||
foreach (var argument in arguments)
|
||||
{
|
||||
process.StartInfo.ArgumentList.Add(argument);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!process.Start())
|
||||
{
|
||||
return (-1, "", $"could not start {fileName}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (ex is InvalidOperationException or System.ComponentModel.Win32Exception)
|
||||
{
|
||||
return (-1, "", $"could not start {fileName}: {ex.Message}");
|
||||
}
|
||||
|
||||
var stdoutTask = process.StandardOutput.ReadToEndAsync();
|
||||
var stderrTask = process.StandardError.ReadToEndAsync();
|
||||
var waitTask = process.WaitForExitAsync();
|
||||
var completed = await Task.WhenAny(waitTask, Task.Delay(timeoutMilliseconds)).ConfigureAwait(false);
|
||||
if (completed != waitTask)
|
||||
{
|
||||
try
|
||||
{
|
||||
process.Kill(entireProcessTree: true);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
}
|
||||
|
||||
return (-1, await stdoutTask.ConfigureAwait(false), $"timed out after {timeoutMilliseconds} ms");
|
||||
}
|
||||
|
||||
return (process.ExitCode, await stdoutTask.ConfigureAwait(false), await stderrTask.ConfigureAwait(false));
|
||||
}
|
||||
|
||||
static MoveTrackingSmokeContext BuildMoveTrackingSmokeHub()
|
||||
{
|
||||
var starfireDescriptor = new MimirStreamDescriptor(
|
||||
|
|
|
|||
|
|
@ -57,11 +57,10 @@ public static class MimirModuleLibrary
|
|||
"move-controller-fusion",
|
||||
"Mimir.Runtime + Fensalir",
|
||||
"Mimir fuses Muninn marker candidates, controller IMU/button state, calibration, and timing into resolved wand poses, then publishes them as a realtime CultMesh pose stream for interaction consumers.",
|
||||
["mimir.move_calibration_protocol.v1", "mimir.quest_usb_preflight.v1", "mimir.move_controller_pose.v1", "mimir.move_controller_pose_stream_frame.v1", "muninn.move_marker_candidate.v1", "muninn.move_controller_state.v1"],
|
||||
["mimir.move_calibration_protocol.v1", "mimir.move_controller_pose.v1", "mimir.move_controller_pose_stream_frame.v1", "muninn.quest_access.v1", "muninn.quest_pose_frame.v1", "muninn.move_marker_candidate.v1", "muninn.move_controller_state.v1"],
|
||||
[
|
||||
"dotnet run --project .\\src\\Mimir.BufferSmoke\\Mimir.BufferSmoke.csproj -- --move-tracking-contract-smoke",
|
||||
"dotnet run --project .\\src\\Mimir.BufferSmoke\\Mimir.BufferSmoke.csproj -- --move-calibration-protocol-smoke",
|
||||
"dotnet run --project .\\src\\Mimir.BufferSmoke\\Mimir.BufferSmoke.csproj -- --quest-usb-preflight-smoke",
|
||||
"dotnet run --project .\\src\\Mimir.BufferSmoke\\Mimir.BufferSmoke.csproj -- --move-fusion-smoke"
|
||||
]),
|
||||
new(
|
||||
|
|
|
|||
|
|
@ -1,64 +0,0 @@
|
|||
using GameCult.Caching;
|
||||
using MessagePack;
|
||||
|
||||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
[CultDocument("mimir.quest_usb_preflight", "mimir.quest_usb_preflight.v1")]
|
||||
[MessagePackObject]
|
||||
public sealed record MimirQuestUsbPreflightDocument(
|
||||
[property: Key(0)]
|
||||
[property: CultName]
|
||||
string PreflightId,
|
||||
[property: Key(1)] string CapturedAtUtc,
|
||||
[property: Key(2)] string Serial,
|
||||
[property: Key(3)] string ConnectionState,
|
||||
[property: Key(4)] string Product,
|
||||
[property: Key(5)] string Model,
|
||||
[property: Key(6)] string Device,
|
||||
[property: Key(7)] string TransportId,
|
||||
[property: Key(8)] string AndroidRelease,
|
||||
[property: Key(9)] string AndroidSdk,
|
||||
[property: Key(10)] string BuildFingerprint,
|
||||
[property: Key(11)] string BatterySummary,
|
||||
[property: Key(12)] string PoseCaptureStatus,
|
||||
[property: Key(13)] string RequiredNextStep,
|
||||
[property: Key(14)] string[] OperatorNotes);
|
||||
|
||||
public static class MimirQuestUsbPreflight
|
||||
{
|
||||
public const string AuthorizedNoPoseBridgeStatus = "usb-authorized-no-pose-bridge-yet";
|
||||
|
||||
public static MimirQuestUsbPreflightDocument Create(
|
||||
string serial,
|
||||
string connectionState,
|
||||
string product,
|
||||
string model,
|
||||
string device,
|
||||
string transportId,
|
||||
string androidRelease,
|
||||
string androidSdk,
|
||||
string buildFingerprint,
|
||||
string batterySummary,
|
||||
DateTimeOffset? capturedAt = null) =>
|
||||
new(
|
||||
PreflightId: $"quest-usb:{serial}",
|
||||
CapturedAtUtc: (capturedAt ?? DateTimeOffset.UtcNow).ToString("O"),
|
||||
Serial: serial,
|
||||
ConnectionState: connectionState,
|
||||
Product: product,
|
||||
Model: model,
|
||||
Device: device,
|
||||
TransportId: transportId,
|
||||
AndroidRelease: androidRelease,
|
||||
AndroidSdk: androidSdk,
|
||||
BuildFingerprint: buildFingerprint,
|
||||
BatterySummary: batterySummary,
|
||||
PoseCaptureStatus: AuthorizedNoPoseBridgeStatus,
|
||||
RequiredNextStep: "Run or deploy a Quest/OpenXR witness that publishes headset and controller poses into the Mimir calibration capture.",
|
||||
OperatorNotes:
|
||||
[
|
||||
"ADB authorization proves Starfire can query the Quest over USB; it does not expose tracked headset/controller poses by itself.",
|
||||
"Do not disturb the headset runtime from this preflight. Pose capture belongs to an explicit Quest/OpenXR witness bridge.",
|
||||
"Mimir may use Quest poses as optional external validation evidence, but Mimir still owns Move calibration and fusion promotion."
|
||||
]);
|
||||
}
|
||||
Loading…
Reference in a new issue