Add Move tracking observation streams
This commit is contained in:
parent
28536681f6
commit
6dc18ecf18
16 changed files with 406 additions and 13 deletions
|
|
@ -862,6 +862,11 @@ direct
|
|||
return $"{buffer.Descriptor.Label} [{buffer.Descriptor.SourceId}]: {buffer.Count} {block.Channels}ch {block.SampleRate}Hz {block.SampleFormat} frames {block.FrameCount} bytes {latest.Value.ByteLength} edge {buffer.EdgeNs}";
|
||||
}
|
||||
|
||||
if (latest?.TrackingObservation is { } tracking)
|
||||
{
|
||||
return $"{buffer.Descriptor.Label} [{buffer.Descriptor.SourceId}]: {buffer.Count} {tracking.Kind} device={tracking.DeviceId} producer={tracking.ProducerId} host={tracking.HostId} confidence={tracking.Confidence:0.00} edge {buffer.EdgeNs}";
|
||||
}
|
||||
|
||||
return $"{buffer.Descriptor.Label} [{buffer.Descriptor.SourceId}]: {buffer.Count} edge {buffer.EdgeNs}";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ public static class MimirModuleLibrary
|
|||
new(
|
||||
"cultmesh-contracts",
|
||||
"Mimir.Runtime",
|
||||
"Typed state documents for codebooks, decoder state, acoustic path state, and actuator state.",
|
||||
["mimir.bioacoustic_codebook_state", "mimir.bioacoustic_decoder_state", "mimir.acoustic_path_state", "mimir.actuator_state"],
|
||||
"Typed state documents for codebooks, decoder state, acoustic path state, actuator state, program state, and Move tracking observations.",
|
||||
["mimir.bioacoustic_codebook_state", "mimir.bioacoustic_decoder_state", "mimir.acoustic_path_state", "mimir.actuator_state", "mimir.move_tracking_observation"],
|
||||
["dotnet run --project .\\src\\Mimir.BufferSmoke\\Mimir.BufferSmoke.csproj -- --perfect-machine-contract-smoke"]),
|
||||
new(
|
||||
"path-learning",
|
||||
|
|
|
|||
|
|
@ -132,6 +132,48 @@ public static class MimirNativeCaptureConfigurations
|
|||
Notes = "Remote co-streamer audio witness. It decodes locally and ships typed timing/path state back over CultMesh."
|
||||
};
|
||||
|
||||
public static MimirNativeCaptureDeviceProfile StarfirePsMoves { get; } = new(
|
||||
"starfire-ps-moves",
|
||||
"Starfire PS Move tracking witnesses",
|
||||
MimirStreamKind.Tracking,
|
||||
MimirNativeCaptureTransport.VendorSdk,
|
||||
MimirCaptureClockDomain.DeviceHardware,
|
||||
ChannelCount: 2,
|
||||
PreferredWidth: 0,
|
||||
PreferredHeight: 0,
|
||||
PreferredSampleRate: 0,
|
||||
PreferredFramesPerSecond: 120.0,
|
||||
DefaultRollingBufferSeconds,
|
||||
Required: false,
|
||||
OwnedOutputs: ["local-controller-pose-observations", "performance-motion-cues"],
|
||||
"USB-attached local Moves. Mimir buffers the observations; tracking code owns hardware pose estimation.");
|
||||
|
||||
public static MimirNativeCaptureDeviceProfile NightwingPsMoves { get; } = StarfirePsMoves with
|
||||
{
|
||||
Id = "nightwing-ps-moves",
|
||||
DisplayName = "Nightwing PS Move tracking witnesses",
|
||||
Transport = MimirNativeCaptureTransport.NetworkCultMesh,
|
||||
ClockDomain = MimirCaptureClockDomain.NetworkSender,
|
||||
OwnedOutputs = ["remote-controller-pose-observations", "performance-motion-cues"],
|
||||
Notes = "USB-attached Nightwing Moves. Muninn on Nightwing publishes typed pose/button observations; Odin owns discovery/schema projection; Mimir owns buffering and fusion."
|
||||
};
|
||||
|
||||
public static MimirNativeCaptureDeviceProfile OdinMoveTrackingCatalog { get; } = new(
|
||||
"odin-move-tracking-catalog",
|
||||
"Odin Move tracking discovery catalog",
|
||||
MimirStreamKind.Tracking,
|
||||
MimirNativeCaptureTransport.NetworkCultMesh,
|
||||
MimirCaptureClockDomain.CanonicalFitted,
|
||||
ChannelCount: 4,
|
||||
PreferredWidth: 0,
|
||||
PreferredHeight: 0,
|
||||
PreferredSampleRate: 0,
|
||||
PreferredFramesPerSecond: 120.0,
|
||||
DefaultRollingBufferSeconds,
|
||||
Required: false,
|
||||
OwnedOutputs: ["move-stream-discovery", "tracking-schema-rendezvous"],
|
||||
"Discovery/projection surface only. Odin names Starfire and Nightwing Move streams; it does not own pose capture or Mimir fusion.");
|
||||
|
||||
public static IReadOnlyList<MimirNativeCaptureDeviceProfile> LocalSixCameraProfiles { get; } =
|
||||
[
|
||||
LeapLeftIr,
|
||||
|
|
@ -146,6 +188,9 @@ public static class MimirNativeCaptureConfigurations
|
|||
[
|
||||
.. LocalSixCameraProfiles,
|
||||
ScarlettStarfire,
|
||||
ScarlettRaven
|
||||
ScarlettRaven,
|
||||
StarfirePsMoves,
|
||||
NightwingPsMoves,
|
||||
OdinMoveTrackingCatalog
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ public sealed class MimirNativeIngestStreamSource : IMimirStreamSource
|
|||
ulong payloadHandle,
|
||||
int byteLength = 0,
|
||||
ReadOnlyMemory<byte> data = default,
|
||||
MimirVideoFrameDescriptor? videoFrame = null)
|
||||
MimirVideoFrameDescriptor? videoFrame = null,
|
||||
MimirTrackingObservation? trackingObservation = null)
|
||||
{
|
||||
samples.Enqueue(new MimirStreamSample(
|
||||
Descriptor.SourceId,
|
||||
|
|
@ -32,7 +33,8 @@ public sealed class MimirNativeIngestStreamSource : IMimirStreamSource
|
|||
payloadHandle,
|
||||
byteLength,
|
||||
data,
|
||||
videoFrame));
|
||||
videoFrame,
|
||||
TrackingObservation: trackingObservation));
|
||||
}
|
||||
|
||||
public void PushVideoFrame(
|
||||
|
|
@ -54,6 +56,25 @@ public sealed class MimirNativeIngestStreamSource : IMimirStreamSource
|
|||
frame);
|
||||
}
|
||||
|
||||
public void PushTrackingObservation(MimirTrackingObservation observation)
|
||||
{
|
||||
if (Descriptor.Kind != MimirStreamKind.Tracking)
|
||||
{
|
||||
throw new InvalidOperationException("Tracking observations can only be pushed into a tracking stream source.");
|
||||
}
|
||||
|
||||
if (!string.Equals(observation.StreamId, Descriptor.SourceId, StringComparison.Ordinal))
|
||||
{
|
||||
throw new ArgumentException("Tracking observation stream id does not match this stream source.", nameof(observation));
|
||||
}
|
||||
|
||||
Push(
|
||||
observation.SourceTimestampNs,
|
||||
observation.ArrivalTimestampNs,
|
||||
payloadHandle: 0,
|
||||
trackingObservation: observation);
|
||||
}
|
||||
|
||||
public bool TryRead(out MimirStreamSample sample)
|
||||
{
|
||||
return samples.TryDequeue(out sample);
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ public static class MimirPerfectMachineProfiles
|
|||
[
|
||||
"muninn.telemetry_surface.v1",
|
||||
"muninn.capture_stream.v1",
|
||||
"mimir.move_tracking_observation.v1",
|
||||
"mimir.cultmesh_media_frame.v1"
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ public enum MimirStreamKind
|
|||
{
|
||||
Audio,
|
||||
Video,
|
||||
Tracking,
|
||||
}
|
||||
|
||||
public enum MimirStreamOrigin
|
||||
|
|
|
|||
|
|
@ -11,4 +11,5 @@ public readonly record struct MimirStreamSample(
|
|||
int ByteLength = 0,
|
||||
ReadOnlyMemory<byte> Data = default,
|
||||
MimirVideoFrameDescriptor? VideoFrame = null,
|
||||
MimirAudioBlockDescriptor? AudioBlock = null);
|
||||
MimirAudioBlockDescriptor? AudioBlock = null,
|
||||
MimirTrackingObservation? TrackingObservation = null);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,15 @@ public sealed class MimirSynchronizationHub : IDisposable
|
|||
public IReadOnlyList<MimirChirpBinCalibrationProfile> AudioChirpBinCalibrationProfiles =>
|
||||
audioSynchronization.LastCalibrationProfiles;
|
||||
|
||||
public IReadOnlyList<MimirTrackingObservation> TrackingObservations =>
|
||||
Buffers.Buffers
|
||||
.Where(buffer => buffer.Descriptor.Kind == MimirStreamKind.Tracking)
|
||||
.Select(buffer => buffer.Latest?.TrackingObservation)
|
||||
.Where(observation => observation != null)
|
||||
.Cast<MimirTrackingObservation>()
|
||||
.OrderBy(observation => observation.StreamId, StringComparer.Ordinal)
|
||||
.ToArray();
|
||||
|
||||
public MimirChirpBinCodebookPlan? ChirpBinEmissionPlan =>
|
||||
chirpBinCalibrationModel?.EmissionPlan;
|
||||
|
||||
|
|
@ -87,7 +96,8 @@ public sealed class MimirSynchronizationHub : IDisposable
|
|||
{
|
||||
var audio = Buffers.Buffers.Count(buffer => buffer.Descriptor.Kind == MimirStreamKind.Audio);
|
||||
var video = Buffers.Buffers.Count(buffer => buffer.Descriptor.Kind == MimirStreamKind.Video);
|
||||
return $"{video} video / {audio} audio buffers";
|
||||
var tracking = Buffers.Buffers.Count(buffer => buffer.Descriptor.Kind == MimirStreamKind.Tracking);
|
||||
return $"{video} video / {audio} audio / {tracking} tracking buffers";
|
||||
}
|
||||
|
||||
public IReadOnlyList<MimirAudioSynchronizationReport> AnalyzeAudioSynchronization(
|
||||
|
|
|
|||
|
|
@ -14,8 +14,10 @@ public sealed class MimirSynchronizationSettings
|
|||
var streams = new List<MimirStreamDescriptor>();
|
||||
AddStreams(streams, Environment.GetEnvironmentVariable("MIMIR_LOCAL_VIDEO_STREAMS"), MimirStreamKind.Video, MimirStreamOrigin.LocalDevice);
|
||||
AddStreams(streams, Environment.GetEnvironmentVariable("MIMIR_LOCAL_AUDIO_STREAMS"), MimirStreamKind.Audio, MimirStreamOrigin.LocalDevice);
|
||||
AddStreams(streams, Environment.GetEnvironmentVariable("MIMIR_LOCAL_TRACKING_STREAMS"), MimirStreamKind.Tracking, MimirStreamOrigin.LocalDevice);
|
||||
AddStreams(streams, Environment.GetEnvironmentVariable("MIMIR_NETWORK_VIDEO_STREAMS"), MimirStreamKind.Video, MimirStreamOrigin.Network);
|
||||
AddStreams(streams, Environment.GetEnvironmentVariable("MIMIR_NETWORK_AUDIO_STREAMS"), MimirStreamKind.Audio, MimirStreamOrigin.Network);
|
||||
AddStreams(streams, Environment.GetEnvironmentVariable("MIMIR_NETWORK_TRACKING_STREAMS"), MimirStreamKind.Tracking, MimirStreamOrigin.Network);
|
||||
|
||||
return new MimirSynchronizationSettings
|
||||
{
|
||||
|
|
|
|||
100
src/Mimir.Runtime/Synchronization/MimirTrackingObservation.cs
Normal file
100
src/Mimir.Runtime/Synchronization/MimirTrackingObservation.cs
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
using MessagePack;
|
||||
using GameCult.Caching;
|
||||
|
||||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
public enum MimirTrackingObservationKind
|
||||
{
|
||||
Unknown,
|
||||
PsMoveController,
|
||||
Hand,
|
||||
Headset,
|
||||
Tool,
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public readonly record struct MimirVector3Snapshot(
|
||||
[property: Key(0)] double X,
|
||||
[property: Key(1)] double Y,
|
||||
[property: Key(2)] double Z);
|
||||
|
||||
[MessagePackObject]
|
||||
public readonly record struct MimirQuaternionSnapshot(
|
||||
[property: Key(0)] double X,
|
||||
[property: Key(1)] double Y,
|
||||
[property: Key(2)] double Z,
|
||||
[property: Key(3)] double W);
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed record MimirTrackingButtonSnapshot(
|
||||
[property: Key(0)] string Id,
|
||||
[property: Key(1)] bool Pressed,
|
||||
[property: Key(2)] double Value);
|
||||
|
||||
[MessagePackObject]
|
||||
[CultDocument("mimir.move_tracking_observation", "mimir.move_tracking_observation.v1")]
|
||||
public sealed record MimirTrackingObservation(
|
||||
[property: Key(0)]
|
||||
[property: CultName]
|
||||
string ObservationId,
|
||||
[property: Key(1)] string StreamId,
|
||||
[property: Key(2)] string DeviceId,
|
||||
[property: Key(3)] MimirTrackingObservationKind Kind,
|
||||
[property: Key(4)] string ProducerId,
|
||||
[property: Key(5)] string HostId,
|
||||
[property: Key(6)] string DiscoveryProviderId,
|
||||
[property: Key(7)] string TrackingSpaceId,
|
||||
[property: Key(8)] string CalibrationId,
|
||||
[property: Key(9)] long SourceTimestampNs,
|
||||
[property: Key(10)] long ArrivalTimestampNs,
|
||||
[property: Key(11)] ulong Sequence,
|
||||
[property: Key(12)] MimirVector3Snapshot PositionMeters,
|
||||
[property: Key(13)] MimirQuaternionSnapshot Orientation,
|
||||
[property: Key(14)] MimirVector3Snapshot LinearVelocityMetersPerSecond,
|
||||
[property: Key(15)] MimirVector3Snapshot AngularVelocityRadiansPerSecond,
|
||||
[property: Key(16)] double Confidence,
|
||||
[property: Key(17)] double LatencyMilliseconds,
|
||||
[property: Key(18)] double Battery01,
|
||||
[property: Key(19)] MimirTrackingButtonSnapshot[] Buttons)
|
||||
{
|
||||
public static MimirTrackingObservation PsMove(
|
||||
string streamId,
|
||||
string deviceId,
|
||||
ulong sequence,
|
||||
long sourceTimestampNs,
|
||||
long arrivalTimestampNs,
|
||||
MimirVector3Snapshot positionMeters,
|
||||
MimirQuaternionSnapshot orientation,
|
||||
MimirVector3Snapshot linearVelocityMetersPerSecond,
|
||||
MimirVector3Snapshot angularVelocityRadiansPerSecond,
|
||||
double confidence,
|
||||
string calibrationId,
|
||||
string trackingSpaceId = "nightwing-move-space",
|
||||
string producerId = "muninn:nightwing:move",
|
||||
string hostId = "nightwing",
|
||||
string discoveryProviderId = "odin",
|
||||
double latencyMilliseconds = 0.0,
|
||||
double battery01 = double.NaN,
|
||||
MimirTrackingButtonSnapshot[]? buttons = null) =>
|
||||
new(
|
||||
$"{streamId}:{sequence}",
|
||||
streamId,
|
||||
deviceId,
|
||||
MimirTrackingObservationKind.PsMoveController,
|
||||
producerId,
|
||||
hostId,
|
||||
discoveryProviderId,
|
||||
trackingSpaceId,
|
||||
calibrationId,
|
||||
sourceTimestampNs,
|
||||
arrivalTimestampNs,
|
||||
sequence,
|
||||
positionMeters,
|
||||
orientation,
|
||||
linearVelocityMetersPerSecond,
|
||||
angularVelocityRadiansPerSecond,
|
||||
Math.Clamp(confidence, 0.0, 1.0),
|
||||
Math.Max(0.0, latencyMilliseconds),
|
||||
double.IsFinite(battery01) ? Math.Clamp(battery01, 0.0, 1.0) : double.NaN,
|
||||
buttons ?? []);
|
||||
}
|
||||
Loading…
Reference in a new issue