Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add frame-based assembly joints and pose-aware mesh export

Yuechen Li18905d282a17
diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.cs
index c2dd10a5..d04d3213 100644
--- a/Aetheris.CLI/CliRunner.cs
+++ b/Aetheris.CLI/CliRunner.cs
@@ -3935,8 +3935,10 @@ Model CanonicalPanel {
{
var definition = ir.Interfaces.Single(item => item.StableId == mate.InterfaceStableId);
stdout.WriteLine($"- {mate.Name}: Interface<{definition.Family}> {mate.InterfaceStableId} ({string.Join(", ", mate.Roles.Select(x => x.Role + "=" + x.ParticipantPath))}); status={mate.ValidationStatus}");
- foreach (var constraint in definition.Requirements)
- stdout.WriteLine($" Expanded Mate {constraint.Kind}: {constraint.FirstRole}.{constraint.FirstMember} -> {constraint.SecondRole}.{constraint.SecondMember}");
+ foreach (var constraint in ir.PlacementConstraints.Concat((ir.AssemblyDefinitions ?? [])
+ .SelectMany(item => item.LocalPlacementConstraints ?? []))
+ .Where(constraint => constraint.MateStableId == mate.StableId))
+ stdout.WriteLine($" Expanded Mate {constraint.Kind}: {constraint.FirstSemanticValueId} -> {constraint.SecondSemanticValueId}");
foreach (var requirement in mate.RequirementResults ?? [])
stdout.WriteLine($" Require {requirement.Name}: {requirement.Expression} ({requirement.Status})");
if (mate.GearResult is { } gear)
@@ -3946,6 +3948,8 @@ Model CanonicalPanel {
stdout.WriteLine($" Derived: ratio={gear.Ratio:G6}; rotation-sign={gear.RotationSign}; center expected={gear.ExpectedCenterDistanceMm:G6}mm actual={gear.ActualCenterDistanceMm:G6}mm; {gear.CompatibilityStatus}");
}
}
+ foreach (var joint in ir.Joints ?? [])
+ stdout.WriteLine($" Joint {joint.Name}: {joint.Family}; parent={joint.ParentOccurrenceId}; child={joint.ChildOccurrenceId}; DOF={joint.DegreesOfFreedom}; default={joint.DefaultState:G6}{(joint.Family == MechanicalInterfaceFamily.Revolute ? "deg" : joint.Family == MechanicalInterfaceFamily.Prismatic ? "mm" : "")}");
var definitions = ir.AssemblyDefinitions ?? [];
if (definitions.Count > 0)
{
diff --git a/Aetheris.Firmament.SchemaGenerator/SemanticSchemaGenerator.cs b/Aetheris.Firmament.SchemaGenerator/SemanticSchemaGenerator.cs
index e82a47be..c8b61b20 100644
--- a/Aetheris.Firmament.SchemaGenerator/SemanticSchemaGenerator.cs
+++ b/Aetheris.Firmament.SchemaGenerator/SemanticSchemaGenerator.cs
@@ -33,7 +33,7 @@ public sealed class SemanticSchemaGenerator : IIncrementalGenerator
{
var construct = symbol.GetAttributes().Single(a => a.AttributeClass?.Name == "FirmamentConstructAttribute");
var id = Arg(construct, 0); var name = Arg(construct, 1);
- if (!ValidId(id) || !ValidId(name) || !constructIds.Add(id) || !names.Add(name))
+ if (!ValidId(id) || !ValidName(name) || !constructIds.Add(id) || !names.Add(name))
{ Error(output, symbol, $"construct '{name}' needs a unique, nonempty stable ID and name"); continue; }
var fields = new List<Field>();
var outputs = new List<Output>();
@@ -111,6 +111,9 @@ public sealed class SemanticSchemaGenerator : IIncrementalGenerator
private static string? Str(AttributeData attribute, string name) => Named(attribute, name).Value?.ToString();
private static bool Bool(AttributeData attribute, string name) => Named(attribute, name).Value is true;
private static bool ValidId(string value) => !string.IsNullOrWhiteSpace(value) && value.All(c => char.IsLetterOrDigit(c) || c == '_');
+ private static bool ValidName(string value) => ValidId(value) ||
+ value.StartsWith("Interface<", StringComparison.Ordinal) && value.EndsWith(">", StringComparison.Ordinal)
+ && ValidId(value.Substring("Interface<".Length, value.Length - "Interface<".Length - 1));
private static string Q(string? value) => value is null ? "null" : SymbolDisplay.FormatLiteral(value, true);
private static void Error(SourceProductionContext output, INamedTypeSymbol symbol, string message) => output.ReportDiagnostic(Diagnostic.Create(Invalid, symbol.Locations.FirstOrDefault(), message));
diff --git a/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyKinematicsX0Tests.cs b/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyKinematicsX0Tests.cs
new file mode 100644
index 00000000..b96cd15b
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyKinematicsX0Tests.cs
@@ -0,0 +1,205 @@
+using Aetheris.Kernel.Firmament.Assembly;
+using Aetheris.Kernel.Firmament.FirmamentV2;
+
+namespace Aetheris.Kernel.Firmament.Tests.Assembly;
+
+public sealed class AssemblyKinematicsX0Tests
+{
+ [Fact]
+ public void TwoLinkArm_ComposesPureRevolutePosesAndReusesDefinitions()
+ {
+ var path = FirmamentCorpusHarness.ResolveFixtureFullPath("fixtures/Canonical/AssemblyInterfaces/two-link-arm.firmament");
+ var compiled = new AssemblyM0Pipeline().CompileFile(path);
+ Assert.True(compiled.IsSuccess, Evidence(compiled));
+ var ir = compiled.Ir!;
+ Assert.Equal(2, ir.Joints!.Count);
+ Assert.All(ir.Joints, joint => Assert.Equal(MechanicalInterfaceFamily.Revolute, joint.Family));
+ Assert.All(ir.Joints, joint => Assert.Equal(1, joint.DegreesOfFreedom));
+ var zero = AssemblyKinematics.Evaluate(ir, new Dictionary<string, double>());
+ Assert.True(zero.IsSuccess, Evidence(zero));
+ Assert.Equal(0, zero.State["Shoulder"]);
+ Assert.Equal(0, zero.State["Elbow"]);
+ Assert.Equal(20, X(zero, "TwoLinkArm.Link2"), 6);
+ Assert.Equal(0, Y(zero, "TwoLinkArm.Link2"), 6);
+ var fortyFive = AssemblyKinematics.Evaluate(ir, new Dictionary<string, double> { ["Shoulder"] = 45 });
+ Assert.Equal(20 / Math.Sqrt(2), X(fortyFive, "TwoLinkArm.Link2"), 5);
+ Assert.Equal(20 / Math.Sqrt(2), Y(fortyFive, "TwoLinkArm.Link2"), 5);
+ var plus = AssemblyKinematics.Evaluate(ir, new Dictionary<string, double> { ["Shoulder"] = 90, ["Elbow"] = 45 });
+ Assert.True(plus.IsSuccess, Evidence(plus));
+ Assert.Equal(0, X(plus, "TwoLinkArm.Link2"), 5);
+ Assert.Equal(20, Y(plus, "TwoLinkArm.Link2"), 5);
+ Assert.Equal(Math.Cos(135 * Math.PI / 180),
+ plus.Instances.Single(instance => instance.Path.ToString() == "TwoLinkArm.Link2").ResolvedTransform!.Matrix[0], 5);
+ var minus = AssemblyKinematics.Evaluate(ir, new Dictionary<string, double> { ["Shoulder"] = -45 });
+ Assert.Equal(20 / Math.Sqrt(2), X(minus, "TwoLinkArm.Link2"), 5);
+ Assert.Equal(-20 / Math.Sqrt(2), Y(minus, "TwoLinkArm.Link2"), 5);
+ Assert.Equal(plus.Instances.Select(instance => instance.ResolvedTransform?.Matrix),
+ AssemblyKinematics.Evaluate(ir, new Dictionary<string, double> { ["Elbow"] = 45, ["Shoulder"] = 90 })
+ .Instances.Select(instance => instance.ResolvedTransform?.Matrix), new MatrixComparer());
+ Assert.Equal(ir.Instances.Where(instance => instance.DefinitionIdentity == "ArmLink").Select(instance => instance.DefinitionIdentity),
+ plus.Instances.Where(instance => instance.DefinitionIdentity == "ArmLink").Select(instance => instance.DefinitionIdentity));
+ Assert.Same(ir.Instances.Single(instance => instance.Path.ToString() == "TwoLinkArm.Link1").SemanticRoot,
+ plus.Instances.Single(instance => instance.Path.ToString() == "TwoLinkArm.Link1").SemanticRoot);
+ }
+
+ [Theory]
+ [InlineData("Fixed", 0, 10)]
+ [InlineData("Prismatic", 15, 25)]
+ public void FrameContract_UsesExactZeroAndDirectState(string family, double state, double expectedZ)
+ {
+ var source = $$"""
+ Assembly Pair {
+ <Assembly Pair>
+ <Part Base = Block> Semantic Port { DatumFrame Frame = [0,0,10] x [1,0,0] y [0,1,0] z [0,0,1]; } </Part>
+ <Part Child = Block> Semantic Port { DatumFrame Frame = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1]; } </Part>
+ </Assembly>
+ Anchor: Pair.Base.Port;
+ Interface<{{family}}> Joint { A: Pair.Base.Port; B: Pair.Child.Port; }
+ }
+ """;
+ var parsed = new AssemblyM0Parser().Parse(source);
+ Assert.True(parsed.IsSuccess, string.Join("\n", parsed.Diagnostics.Select(diagnostic => diagnostic.Message)));
+ var compiled = new AssemblyM0Compiler().Compile(parsed.Source!);
+ Assert.True(compiled.IsSuccess, Evidence(compiled));
+ var joint = Assert.Single(compiled.Ir!.Joints!);
+ Assert.Equal(family == "Fixed" ? 0 : 1, joint.DegreesOfFreedom);
+ var zero = AssemblyKinematics.Evaluate(compiled.Ir, new Dictionary<string, double>());
+ Assert.Equal(10, Z(zero, "Pair.Child"), 6);
+ var pose = AssemblyKinematics.Evaluate(compiled.Ir, family == "Fixed" ? new Dictionary<string, double>() : new Dictionary<string, double> { ["Joint"] = state });
+ Assert.True(pose.IsSuccess, Evidence(pose));
+ Assert.Equal(expectedZ, Z(pose, "Pair.Child"), 6);
+ }
+
+ [Fact]
+ public void OpposedFixedFramePoseMatchesCompiledZeroTransform()
+ {
+ const string source = """
+ Assembly Pair {
+ <Assembly Pair>
+ <Part Base = Block> Semantic Port { DatumFrame Frame = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1]; } </Part>
+ <Part Child = Block> Semantic Port { DatumFrame Frame = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1]; } </Part>
+ </Assembly>
+ Anchor: Pair.Base.Port;
+ Interface<Fixed> Mount { A: Pair.Base.Port; B: Pair.Child.Port; Lower FrameCoincident A B OpposedDirection; }
+ }
+ """;
+ var compiled = new AssemblyM0Compiler().Compile(new AssemblyM0Parser().Parse(source).Source!);
+ Assert.True(compiled.IsSuccess, Evidence(compiled));
+ var child = compiled.Ir!.Instances.Single(instance => instance.Path.ToString() == "Pair.Child");
+ var poseChild = AssemblyKinematics.Evaluate(compiled.Ir, new Dictionary<string, double>()).Instances
+ .Single(instance => instance.StableId == child.StableId);
+ Assert.Equal(child.ResolvedTransform!.Matrix, poseChild.ResolvedTransform!.Matrix);
+ }
+
+ [Fact]
+ public void AuthoredRevoluteFrameMemberSelectsSourceAddressableDatum()
+ {
+ const string source = """
+ Assembly Pair {
+ <Assembly Pair>
+ <Part Base = Block> Semantic Port {
+ DatumFrame Other = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1];
+ DatumFrame Pivot = [0,0,5] x [1,0,0] y [0,1,0] z [0,0,1];
+ } </Part>
+ <Part Child = Block> Semantic Port {
+ DatumFrame Other = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1];
+ DatumFrame Pivot = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1];
+ } </Part>
+ </Assembly>
+ Anchor: Pair.Base.Port;
+ Interface<Revolute> Joint { A: Pair.Base.Port; B: Pair.Child.Port; Lower FrameCoincident A.Pivot B.Pivot; }
+ }
+ """;
+ var compiled = new AssemblyM0Compiler().Compile(new AssemblyM0Parser().Parse(source).Source!);
+ Assert.True(compiled.IsSuccess, Evidence(compiled));
+ Assert.Equal(5, Z(AssemblyKinematics.Evaluate(compiled.Ir!, new Dictionary<string, double>()), "Pair.Child"), 6);
+ Assert.EndsWith(".Pivot", Assert.Single(compiled.Ir!.Joints!).ParentFrameSemanticId, StringComparison.Ordinal);
+ }
+
+ [Fact]
+ public void MissingFrameAndInvalidState_AreDiagnosed()
+ {
+ const string source = """
+ Assembly Pair {
+ <Assembly Pair>
+ <Part Base = Block> Semantic Port { DatumFrame Frame = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1]; } </Part>
+ <Part Child = Block> Semantic Port { Point Origin = [0,0,0]; } </Part>
+ </Assembly>
+ Anchor: Pair.Base.Port;
+ Interface<Prismatic> Joint { A: Pair.Base.Port; B: Pair.Child.Port; }
+ }
+ """;
+ var compiled = new AssemblyM0Compiler().Compile(new AssemblyM0Parser().Parse(source).Source!);
+ Assert.False(compiled.IsSuccess);
+ Assert.Contains(compiled.Diagnostics, diagnostic => diagnostic.Code == AssemblyM0Compiler.CapabilityMismatch);
+ Assert.Contains(compiled.Diagnostics, diagnostic => diagnostic.Code == "assembly-interface-missing-frame");
+ var invalidLower = source.Replace("B: Pair.Child.Port; }", "B: Pair.Child.Port; Lower AxisCoincident A.Axis B.Axis; }", StringComparison.Ordinal);
+ Assert.Contains(new AssemblyM0Parser().Parse(invalidLower).Diagnostics,
+ diagnostic => diagnostic.Code == "assembly-interface-invalid-contract-lowering");
+ var valid = new AssemblyM0Pipeline().CompileFile(FirmamentCorpusHarness.ResolveFixtureFullPath("fixtures/Canonical/AssemblyInterfaces/two-link-arm.firmament"));
+ var invalidState = AssemblyKinematics.Evaluate(valid.Ir!, new Dictionary<string, double> { ["Shoulder"] = double.NaN });
+ Assert.False(invalidState.IsSuccess);
+ Assert.Contains(invalidState.Diagnostics, diagnostic => diagnostic.Code == "assembly-kinematic-invalid-state");
+ }
+
+ [Fact]
+ public void ExternalStepDefinitionsStaySharedWhenPoseChanges()
+ {
+ var path = FirmamentCorpusHarness.ResolveFixtureFullPath("fixtures/Canonical/AssemblyInterfaces/external-step-slider.firmament");
+ var compiled = new AssemblyM1Pipeline().CompileFile(path);
+ Assert.True(compiled.IsSuccess, string.Join("\n", compiled.Diagnostics.Select(diagnostic => diagnostic.Code + ": " + diagnostic.Message)));
+ Assert.Single(compiled.Geometry!.Artifact.Definitions);
+ var pose = AssemblyKinematics.Evaluate(compiled.Ir!, new Dictionary<string, double> { ["Travel"] = 12 });
+ Assert.True(pose.IsSuccess, Evidence(pose));
+ Assert.Equal(12, Z(pose, "ExternalSlider.Carriage"), 6);
+ Assert.Equal(0, Z(pose, "ExternalSlider.Rail"), 6);
+ var restDisplay = AssemblyDisplayMeshExporter.Export(compiled);
+ var display = AssemblyDisplayMeshExporter.WithPose(restDisplay, pose);
+ Assert.Same(restDisplay.Definitions, display.Definitions);
+ Assert.Single(display.Definitions);
+ Assert.Equal(2, display.Occurrences.Count(occurrence => occurrence.DefinitionId == display.Definitions[0].Id));
+ Assert.Equal(12, display.Occurrences.Single(occurrence => occurrence.Path == "ExternalSlider.Carriage").Transform[14], 6);
+ }
+
+ [Fact]
+ public void DuplicateDriverAndKinematicLoop_FailAtCompileTime()
+ {
+ var source = File.ReadAllText(FirmamentCorpusHarness.ResolveFixtureFullPath("fixtures/Canonical/AssemblyInterfaces/two-link-arm.firmament"));
+ var insertion = source.LastIndexOf('}');
+ var duplicate = source.Insert(insertion, " Interface<Revolute> Other { A: TwoLinkArm.Base.Hinge; B: TwoLinkArm.Link1.Input; }\n");
+ var duplicateResult = new AssemblyM0Compiler().Compile(new AssemblyM0Parser().Parse(duplicate).Source!);
+ Assert.Contains(duplicateResult.Diagnostics, diagnostic => diagnostic.Code == "assembly-kinematic-duplicate-child");
+ var loop = source.Insert(insertion, " Interface<Revolute> Return { A: TwoLinkArm.Link2.Input; B: TwoLinkArm.Base.Hinge; }\n");
+ var loopResult = new AssemblyM0Compiler().Compile(new AssemblyM0Parser().Parse(loop).Source!);
+ Assert.Contains(loopResult.Diagnostics, diagnostic => diagnostic.Code == "assembly-kinematic-loop-unsupported");
+ }
+
+ [Fact]
+ public void SchemaListsThreeFrameContractsAndRequiredParticipants()
+ {
+ foreach (var family in new[] { "Fixed", "Revolute", "Prismatic" })
+ {
+ var schema = FirmamentSemanticSchemas.Get($"Interface<{family}>");
+ Assert.NotNull(schema);
+ Assert.Equal(["A", "B"], schema.Fields.Select(field => field.Name));
+ Assert.All(schema.Fields, field => Assert.True(field.Required));
+ }
+ const string source = "Assembly A { Interface<Revolute> Joint { ";
+ var completion = FirmamentLanguageService.Complete(source, "arm.firmament", "1", source.Length);
+ Assert.Equal("Interface<Revolute>", completion.Context);
+ Assert.Equal(["A", "B"], completion.MissingRequiredFields);
+ }
+
+ private static double X(AssemblyPoseResult pose, string path) => Component(pose, path, 12);
+ private static double Y(AssemblyPoseResult pose, string path) => Component(pose, path, 13);
+ private static double Z(AssemblyPoseResult pose, string path) => Component(pose, path, 14);
+ private static double Component(AssemblyPoseResult pose, string path, int index) =>
+ pose.Instances.Single(instance => instance.Path.ToString() == path).ResolvedTransform!.Matrix[index];
+ private static string Evidence(AssemblyCompilationResult result) => string.Join("\n", result.Diagnostics.Select(diagnostic => diagnostic.Code + ": " + diagnostic.Message));
+ private static string Evidence(AssemblyPoseResult result) => string.Join("\n", result.Diagnostics.Select(diagnostic => diagnostic.Code + ": " + diagnostic.Message));
+ private sealed class MatrixComparer : IEqualityComparer<double[]?>
+ {
+ public bool Equals(double[]? x, double[]? y) => x is null ? y is null : y is not null && x.SequenceEqual(y);
+ public int GetHashCode(double[]? obj) => 0;
+ }
+}
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs
index 7b9fcc70..3cff578b 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs
@@ -8,7 +8,7 @@ public sealed class FirmamentSemanticSchemaTests
public void GeneratedRegistry_IsStableOptInAndCoversFirstConstructs()
{
Assert.Equal("firmament-semantic-schema/1", FirmamentSemanticSchemas.Version);
- Assert.Equal(["Box", "Concept", "Helix", "Hole", "Loft", "Perforation", "Thread"], FirmamentSemanticSchemas.All.Select(s => s.Name));
+ Assert.Equal(["Box", "Concept", "Helix", "Hole", "Interface<Fixed>", "Interface<Prismatic>", "Interface<Revolute>", "Loft", "Perforation", "Thread"], FirmamentSemanticSchemas.All.Select(s => s.Name));
var hole = Assert.IsType<FirmamentConstructSchema>(FirmamentSemanticSchemas.Get("Hole"));
var diameter = Assert.Single(hole.Fields, f => f.Name == "Diameter");
Assert.Equal("Hole.Diameter", diameter.Id.Value);
diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyDisplayMeshExporter.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyDisplayMeshExporter.cs
index 73e9120d..1f9c3eb8 100644
--- a/Aetheris.Kernel.Firmament/Assembly/AssemblyDisplayMeshExporter.cs
+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyDisplayMeshExporter.cs
@@ -15,10 +15,34 @@ public sealed record AssemblyDisplayMeshDocument(string Schema, string Name, str
/// <summary>Deterministic local-definition meshes plus world occurrence frames. Never drops failed geometry.</summary>
public static class AssemblyDisplayMeshExporter
{
- public static AssemblyDisplayMeshDocument Export(AssemblyM1CompilationResult compilation, DisplayTessellationOptions? options = null)
+ /// <summary>Apply a new pure pose to an existing display document without tessellating
+ /// or rebuilding any shared part definition.</summary>
+ public static AssemblyDisplayMeshDocument WithPose(AssemblyDisplayMeshDocument document, AssemblyPoseResult pose)
+ {
+ if (!pose.IsSuccess) throw new InvalidOperationException("assembly-mesh-invalid-pose");
+ var transforms = pose.Instances.ToDictionary(instance => instance.StableId, instance => instance.ResolvedTransform, StringComparer.Ordinal);
+ if (transforms.Count != document.Occurrences.Count || document.Occurrences.Any(occurrence =>
+ !transforms.TryGetValue(occurrence.Id, out var transform) || transform is null))
+ throw new InvalidOperationException("assembly-mesh-pose-occurrence-mismatch");
+ return document with
+ {
+ Occurrences = document.Occurrences.Select(occurrence => occurrence with
+ {
+ Transform = transforms[occurrence.Id]!.Matrix.ToArray()
+ }).ToArray()
+ };
+ }
+
+ public static AssemblyDisplayMeshDocument Export(AssemblyM1CompilationResult compilation, DisplayTessellationOptions? options = null,
+ AssemblyPoseResult? pose = null)
{
if (!compilation.IsSuccess || compilation.Ir is null || compilation.Geometry is null)
throw new InvalidOperationException("assembly-mesh-invalid-compilation");
+ if (pose is { IsSuccess: false }) throw new InvalidOperationException("assembly-mesh-invalid-pose");
+ if (pose is not null && (pose.Instances.Count != compilation.Ir.Instances.Count
+ || pose.Instances.Any(instance => !compilation.Ir.Instances.Any(original => original.StableId == instance.StableId
+ && original.DefinitionIdentity == instance.DefinitionIdentity))))
+ throw new InvalidOperationException("assembly-mesh-pose-occurrence-mismatch");
var geometry = compilation.Geometry;
var ids = geometry.Artifact.Definitions.ToDictionary(d => d.DefinitionIdentity, d => d.StableId, StringComparer.Ordinal);
var definitions = new List<AssemblyDisplayMeshDefinition>();
@@ -58,7 +82,7 @@ public static class AssemblyDisplayMeshExporter
definitions.Add(new(ids[identity], identity, positions.ToArray(), normals.ToArray(), indices.ToArray(),
tessellation.Value.MeshPipeline.ToString(), ranges));
}
- var occurrences = compilation.Ir.Instances.OrderBy(i => i.Path.ToString(), StringComparer.Ordinal).Select(instance =>
+ var occurrences = (pose?.Instances ?? compilation.Ir.Instances).OrderBy(i => i.Path.ToString(), StringComparer.Ordinal).Select(instance =>
{
var id = instance.Kind == AssemblyInstanceKind.Part
? ids.GetValueOrDefault(instance.DefinitionIdentity) ?? throw new InvalidOperationException($"assembly-mesh-missing-definition:{instance.Path}") : null;
diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyKinematics.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyKinematics.cs
new file mode 100644
index 00000000..bd9948b4
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyKinematics.cs
@@ -0,0 +1,83 @@
+using Aetheris.Kernel.Core.Math;
+
+namespace Aetheris.Kernel.Firmament.Assembly;
+
+/// <summary>Pure occurrence pose evaluation. State keys are Interface names; values are
+/// degrees for Revolute and millimetres for Prismatic. Geometry definitions are reused.</summary>
+public static class AssemblyKinematics
+{
+ public static AssemblyPoseResult Evaluate(AssemblyIr assembly, IReadOnlyDictionary<string, double> state)
+ {
+ var joints = assembly.Joints ?? [];
+ var diagnostics = new List<AssemblyDiagnostic>();
+ var movable = joints.Where(joint => joint.DegreesOfFreedom == 1)
+ .ToDictionary(joint => joint.Name, StringComparer.Ordinal);
+ foreach (var (name, value) in state)
+ if (!movable.ContainsKey(name) || !double.IsFinite(value))
+ diagnostics.Add(new("assembly-kinematic-invalid-state", $"State '{name}' must name a movable Interface and have a finite value."));
+ if (diagnostics.Count > 0) return new([], diagnostics, new System.Collections.ObjectModel.ReadOnlyDictionary<string, double>(
+ state.ToDictionary(pair => pair.Key, pair => pair.Value, StringComparer.Ordinal)));
+ var snapshot = new System.Collections.ObjectModel.ReadOnlyDictionary<string, double>(
+ movable.Values.ToDictionary(joint => joint.Name, joint => state.GetValueOrDefault(joint.Name, joint.DefaultState), StringComparer.Ordinal));
+
+ var baseline = assembly.Instances.Where(instance => instance.ResolvedTransform is not null)
+ .ToDictionary(instance => instance.StableId, instance => instance.ResolvedTransform!, StringComparer.Ordinal);
+ var world = new Dictionary<string, AssemblyTransform>(baseline, StringComparer.Ordinal);
+ var driven = joints.Select(joint => joint.ChildOccurrenceId).ToHashSet(StringComparer.Ordinal);
+ var pending = joints.ToList();
+ var resolved = new HashSet<string>(StringComparer.Ordinal);
+ while (pending.Count > 0)
+ {
+ var progress = false;
+ foreach (var joint in pending.ToArray())
+ {
+ if (driven.Contains(joint.ParentOccurrenceId) && !resolved.Contains(joint.ParentOccurrenceId)) continue;
+ if (!world.TryGetValue(joint.ParentOccurrenceId, out var parentWorld))
+ {
+ diagnostics.Add(new("assembly-kinematic-unresolved-parent", $"Interface '{joint.Name}' parent occurrence has no compiled zero pose."));
+ pending.Remove(joint); progress = true; continue;
+ }
+ var value = snapshot.GetValueOrDefault(joint.Name, joint.DefaultState);
+ var motion = Motion(joint.Family, value);
+ var child = Transform3D.FromRowMajor(joint.ChildLocalFrame.Matrix).Inverse()
+ * motion * Transform3D.FromRowMajor(joint.ParentLocalFrame.Matrix)
+ * Transform3D.FromRowMajor(parentWorld.Matrix);
+ world[joint.ChildOccurrenceId] = new(child.ToRowMajor());
+ resolved.Add(joint.ChildOccurrenceId);
+ pending.Remove(joint); progress = true;
+ }
+ if (progress) continue;
+ diagnostics.Add(new("assembly-kinematic-loop-unsupported", "Kinematic relationships contain an unresolved cycle."));
+ break;
+ }
+ // Descendants without a joint retain their immutable local placement.
+ foreach (var instance in assembly.Instances.OrderBy(instance => instance.Path.Segments.Count))
+ {
+ if (instance.ParentStableId is null || driven.Contains(instance.StableId)
+ || !baseline.TryGetValue(instance.StableId, out var zero)
+ || !baseline.TryGetValue(instance.ParentStableId, out var zeroParent)
+ || !world.TryGetValue(instance.ParentStableId, out var currentParent)) continue;
+ var relative = Transform3D.FromRowMajor(zero.Matrix) * Transform3D.FromRowMajor(zeroParent.Matrix).Inverse();
+ world[instance.StableId] = new((relative * Transform3D.FromRowMajor(currentParent.Matrix)).ToRowMajor());
+ }
+ return new(assembly.Instances.Select(instance => instance with
+ {
+ ResolvedTransform = world.GetValueOrDefault(instance.StableId)
+ }).ToArray(), diagnostics, snapshot);
+ }
+
+ private static Transform3D Motion(MechanicalInterfaceFamily family, double state)
+ {
+ var angle = family == MechanicalInterfaceFamily.Revolute ? state * Math.PI / 180d : 0;
+ var cosine = Math.Cos(angle); var sine = Math.Sin(angle);
+ return Transform3D.FromRowMajor([
+ cosine, sine, 0, 0, -sine, cosine, 0, 0, 0, 0, 1, 0,
+ 0, 0, family == MechanicalInterfaceFamily.Prismatic ? state : 0, 1]);
+ }
+}
+
+public sealed record AssemblyPoseResult(IReadOnlyList<AssemblyInstanceIr> Instances, IReadOnlyList<AssemblyDiagnostic> Diagnostics,
+ IReadOnlyDictionary<string, double> State)
+{
+ public bool IsSuccess => Diagnostics.Count == 0;
+}
diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Compiler.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Compiler.cs
index db1c0d2f..b985e0dc 100644
--- a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Compiler.cs
+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Compiler.cs
@@ -46,6 +46,7 @@ public sealed class AssemblyM0Compiler
ResolvedTransform = placements.First(x => x.InstanceStableId == instance.StableId).Transform
}).ToArray();
mates = ValidateGearInterfaces(mates, interfaces, instances, diagnostics);
+ var joints = BindJoints(source.Anchor, mates, interfaces, instances, constraints, diagnostics);
placementWatch.Stop();
var graphWatch = Stopwatch.StartNew();
@@ -78,7 +79,7 @@ public sealed class AssemblyM0Compiler
.OrderBy(solution => solution.MateStableId, StringComparer.Ordinal).ToArray();
var ir = new AssemblyIr("aetheris/assembly-ir/m0", $"assembly:{source.Name}", source.Name,
instances.Single(x => x.ParentStableId is null).StableId, instances, source.Interfaces, mates,
- constraints, placements, relations, stackups, fits, diagnostics, assemblyDefinitions, panelMateEvidence, datums, datumSolutions, source.SourceDependencies);
+ constraints, placements, relations, stackups, fits, diagnostics, assemblyDefinitions, panelMateEvidence, datums, datumSolutions, source.SourceDependencies, joints);
return new(ir, diagnostics, perf);
static string SemanticPath(AssemblyInstanceIr instance, SemanticValue value)
@@ -172,7 +173,10 @@ public sealed class AssemblyM0Compiler
valid = false;
continue;
}
- var missing = role.RequiredCapabilities.Where(c => !HasCapability(reference!.Value, c)).ToArray();
+ var frameRevolute = definition.Family == MechanicalInterfaceFamily.Revolute
+ && reference!.Value.TryBinding<ExactDatumFrameBinding>(out _);
+ var requiredCapabilities = frameRevolute ? ["DatumFrameCapable"] : role.RequiredCapabilities;
+ var missing = requiredCapabilities.Where(c => !HasCapability(reference!.Value, c)).ToArray();
if (reference!.Value.Type.Name == "Gear" && definition.Family != MechanicalInterfaceFamily.Gear)
missing = [.. missing, $"endpoint type {definition.Family} (Gear is not implicitly coerced)"];
if (missing.Length > 0)
@@ -180,7 +184,7 @@ public sealed class AssemblyM0Compiler
valid = false;
diagnostics.Add(new(CapabilityMismatch, $"Mate '{mate.Name}' Role '{role.Name}' participant '{assignment.Participant}' lacks: {string.Join(", ", missing)}."));
}
- endpoints.Add(new(role.Name, assignment.Participant, reference!.Value.StableIdentity, role.RequiredCapabilities));
+ endpoints.Add(new(role.Name, assignment.Participant, reference!.Value.StableIdentity, requiredCapabilities));
}
result.Add(new($"mate:{source.Name}:{mate.Name}", mate.Name, definition.StableId, endpoints, [],
valid && endpoints.Count == definition.Roles.Count ? "valid" : "invalid"));
@@ -303,7 +307,26 @@ public sealed class AssemblyM0Compiler
foreach (var mate in mates)
{
var definition = interfaces.Values.Single(x => x.StableId == mate.InterfaceStableId);
- foreach (var (requirement, index) in definition.Requirements.Select((x, i) => (x, i)))
+ var frameRevolute = definition.Family == MechanicalInterfaceFamily.Revolute && mate.Roles.Count == 2
+ && mate.Roles.All(role => Flatten(instances.Select(instance => instance.SemanticRoot))
+ .FirstOrDefault(value => value.StableIdentity == role.ParticipantSemanticValueId)?
+ .TryBinding<ExactDatumFrameBinding>(out _) == true);
+ var authoredFrame = definition.Requirements.Count == 1
+ && definition.Requirements[0].Kind == PlacementConstraintKind.FrameCoincident;
+ var defaultLegacyRevolute = definition.Requirements.Count == 2
+ && definition.Requirements[0] is { Kind: PlacementConstraintKind.AxisCoincident, FirstRole: "A", FirstMember: "Axis", SecondRole: "B", SecondMember: "Axis" }
+ && definition.Requirements[1] is { Kind: PlacementConstraintKind.PlaneCoincident, FirstRole: "A", FirstMember: "Seat", SecondRole: "B", SecondMember: "Seat" };
+ if (frameRevolute && !authoredFrame && !defaultLegacyRevolute)
+ {
+ diagnostics.Add(new("assembly-interface-invalid-contract-lowering",
+ $"Interface<Revolute> '{definition.Name}' Mate '{mate.Name}' has frame-capable participants; use their DatumFrames directly or one authored FrameCoincident relation."));
+ continue;
+ }
+ var requirements = frameRevolute
+ ? authoredFrame ? definition.Requirements
+ : [new InterfaceRequirementDefinition(PlacementConstraintKind.FrameCoincident, "A", ".", "B", ".")]
+ : definition.Requirements;
+ foreach (var (requirement, index) in requirements.Select((x, i) => (x, i)))
{
var first = mate.Roles.FirstOrDefault(x => x.Role == requirement.FirstRole);
var second = mate.Roles.FirstOrDefault(x => x.Role == requirement.SecondRole);
@@ -312,12 +335,41 @@ public sealed class AssemblyM0Compiler
var secondId = ResolveRelativeSemantic(second.ParticipantSemanticValueId, requirement.SecondMember, instances);
if (firstId is null || secondId is null)
{ diagnostics.Add(new(InvalidParticipant, $"Interface '{definition.Name}' requirement '{requirement.Kind}' cannot resolve exposed members '{requirement.FirstMember}'/'{requirement.SecondMember}'.")); continue; }
+ if (requirement.Kind == PlacementConstraintKind.FrameCoincident)
+ {
+ var values = Flatten(instances.Select(instance => instance.SemanticRoot)).ToDictionary(value => value.StableIdentity, StringComparer.Ordinal);
+ if (!values[firstId].TryBinding<ExactDatumFrameBinding>(out var firstFrame) || !values[secondId].TryBinding<ExactDatumFrameBinding>(out var secondFrame))
+ {
+ diagnostics.Add(new("assembly-interface-missing-frame", $"Interface '{definition.Name}' Mate '{mate.Name}' requires an exact DatumFrame on both participants."));
+ continue;
+ }
+ if (!ValidJointFrame(firstFrame) || !ValidJointFrame(secondFrame))
+ {
+ diagnostics.Add(new("assembly-interface-invalid-frame", $"Interface '{definition.Name}' Mate '{mate.Name}' requires finite, orthonormal, right-handed participant frames."));
+ continue;
+ }
+ }
result.Add(new($"constraint:{mate.StableId}:{index:D2}", requirement.Kind, mate.StableId, firstId, secondId, requirement.OffsetMm, 0, "admitted", requirement.Orientation));
}
}
return result;
}
+ private static bool ValidJointFrame(ExactDatumFrameBinding frame)
+ {
+ var x = new[] { frame.XAxisX, frame.XAxisY, frame.XAxisZ };
+ var y = new[] { frame.YAxisX, frame.YAxisY, frame.YAxisZ };
+ var z = new[] { frame.ZAxisX, frame.ZAxisY, frame.ZAxisZ };
+ if (x.Concat(y).Concat(z).Append(frame.OriginX).Append(frame.OriginY).Append(frame.OriginZ)
+ .Any(value => !double.IsFinite(value))) return false;
+ static double Dot(double[] a, double[] b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
+ if (Math.Abs(Dot(x, x) - 1) > 1e-6 || Math.Abs(Dot(y, y) - 1) > 1e-6
+ || Math.Abs(Dot(z, z) - 1) > 1e-6 || Math.Abs(Dot(x, y)) > 1e-6
+ || Math.Abs(Dot(x, z)) > 1e-6 || Math.Abs(Dot(y, z)) > 1e-6) return false;
+ var cross = new[] { x[1] * y[2] - x[2] * y[1], x[2] * y[0] - x[0] * y[2], x[0] * y[1] - x[1] * y[0] };
+ return Dot(cross, z) > 1 - 1e-6;
+ }
+
private static string? ResolveRelativeSemantic(string rootId, string member, IReadOnlyList<AssemblyInstanceIr> instances)
{
var root = Flatten(instances.Select(x => x.SemanticRoot)).FirstOrDefault(x => x.StableIdentity == rootId);
@@ -329,6 +381,80 @@ public sealed class AssemblyM0Compiler
return current.StableIdentity;
}
+ private static IReadOnlyList<AssemblyJointIr> BindJoints(AssemblyPath anchorPath, IReadOnlyList<MateIr> mates,
+ IReadOnlyDictionary<string, InterfaceDefinition> interfaces, IReadOnlyList<AssemblyInstanceIr> instances,
+ IReadOnlyList<PlacementConstraintIr> constraints, List<AssemblyDiagnostic> diagnostics)
+ {
+ var values = Flatten(instances.Select(instance => instance.SemanticRoot))
+ .ToDictionary(value => value.StableIdentity, StringComparer.Ordinal);
+ var anchor = instances.Where(instance => anchorPath.ToString() == instance.Path.ToString()
+ || anchorPath.ToString().StartsWith(instance.Path + ".", StringComparison.Ordinal))
+ .OrderByDescending(instance => instance.Path.Segments.Count).FirstOrDefault();
+ var result = new List<AssemblyJointIr>();
+ foreach (var mate in mates.Where(mate => mate.ValidationStatus == "valid"))
+ {
+ var family = interfaces.Values.Single(definition => definition.StableId == mate.InterfaceStableId).Family;
+ if (family is not (MechanicalInterfaceFamily.Fixed or MechanicalInterfaceFamily.Revolute or MechanicalInterfaceFamily.Prismatic)) continue;
+ var frame = constraints.SingleOrDefault(constraint => constraint.MateStableId == mate.StableId
+ && constraint.Kind == PlacementConstraintKind.FrameCoincident);
+ if (frame is null) continue; // Legacy axis/seat Revolute retains its existing placement semantics.
+ var a = mate.Roles.SingleOrDefault(role => role.Role == "A");
+ var b = mate.Roles.SingleOrDefault(role => role.Role == "B");
+ if (a is null || b is null) continue;
+ var parent = OwnerInstance(a.ParticipantSemanticValueId, instances);
+ var child = OwnerInstance(b.ParticipantSemanticValueId, instances);
+ if (parent is null || child is null || parent.StableId == child.StableId)
+ {
+ diagnostics.Add(new("assembly-interface-invalid-occurrences", $"Interface '{mate.Name}' requires distinct occurrence participants."));
+ continue;
+ }
+ if (!values[frame.FirstSemanticValueId].TryBinding<ExactDatumFrameBinding>(out var aFrame)
+ || !values[frame.SecondSemanticValueId].TryBinding<ExactDatumFrameBinding>(out var bFrame)) continue;
+ var parentSemanticId = frame.FirstSemanticValueId;
+ var childSemanticId = frame.SecondSemanticValueId;
+ if (OwnerInstance(parentSemanticId, instances)?.StableId == child.StableId
+ && OwnerInstance(childSemanticId, instances)?.StableId == parent.StableId)
+ {
+ (aFrame, bFrame) = (bFrame, aFrame);
+ (parentSemanticId, childSemanticId) = (childSemanticId, parentSemanticId);
+ }
+ // Historical Fixed declarations often placed the moving endpoint in A.
+ // Preserve their anchored direction while new A-parent/B-child joints stay direct.
+ var reverseFixed = family == MechanicalInterfaceFamily.Fixed && anchor?.StableId == child.StableId;
+ if (reverseFixed)
+ {
+ (parent, child) = (child, parent);
+ (aFrame, bFrame) = (bFrame, aFrame);
+ (parentSemanticId, childSemanticId) = (childSemanticId, parentSemanticId);
+ }
+ result.Add(new(mate.StableId, mate.Name, family, parent.StableId, child.StableId,
+ parentSemanticId, childSemanticId,
+ new(FrameMatrix(aFrame, frame.Orientation).ToRowMajor()),
+ new(FrameMatrix(bFrame, DatumOrientationRelation.SameDirection).ToRowMajor()),
+ family == MechanicalInterfaceFamily.Fixed ? 0 : 1));
+ }
+ foreach (var group in result.Where(joint => joint.DegreesOfFreedom == 1)
+ .GroupBy(joint => joint.ChildOccurrenceId).Where(group => group.Count() > 1))
+ diagnostics.Add(new("assembly-kinematic-duplicate-child", $"Occurrence '{group.Key}' is driven by multiple kinematic Interfaces: {string.Join(", ", group.Select(joint => joint.Name))}."));
+ var parentByChild = result.Where(joint => joint.DegreesOfFreedom == 1)
+ .GroupBy(joint => joint.ChildOccurrenceId).ToDictionary(group => group.Key, group => group.First().ParentOccurrenceId);
+ foreach (var child in parentByChild.Keys)
+ {
+ var seen = new HashSet<string>(StringComparer.Ordinal);
+ var current = child;
+ while (parentByChild.TryGetValue(current, out var parent))
+ {
+ if (!seen.Add(current))
+ {
+ diagnostics.Add(new("assembly-kinematic-loop-unsupported", $"Kinematic loop through occurrence '{current}' requires loop closure, which X0 does not support."));
+ break;
+ }
+ current = parent;
+ }
+ }
+ return result;
+ }
+
private static IReadOnlyList<PlacementResultIr> ResolvePlacements(AssemblySource source, IReadOnlyList<AssemblyInstanceIr> instances,
IReadOnlyList<MateIr> mates, IReadOnlyDictionary<string, InterfaceDefinition> interfaces,
IReadOnlyList<PlacementConstraintIr> constraints, List<AssemblyDiagnostic> diagnostics)
diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Models.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Models.cs
index a49613f1..08e039fe 100644
--- a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Models.cs
+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Models.cs
@@ -9,7 +9,7 @@ public enum PlacementConstraintKind { AxisCoincident, AxisAligned, PlaneCoincide
public enum DatumOrientationRelation { SameDirection, OpposedDirection }
public enum PlacementStatus { Anchored, Resolved, Underconstrained, Overconstrained, Unresolved }
public enum PlacementAuthority { MateDerived, ImportedOccurrence, LegacyExplicit }
-public enum MechanicalInterfaceFamily { Custom, Fixed, Axial, Revolute, Gear }
+public enum MechanicalInterfaceFamily { Custom, Fixed, Axial, Revolute, Prismatic, Gear }
public sealed record AssemblyDiagnostic(string Code, string Message, AssemblyDiagnosticSeverity Severity = AssemblyDiagnosticSeverity.Error);
public sealed record AssemblyPath(IReadOnlyList<string> Segments)
@@ -155,6 +155,12 @@ public sealed record AssemblyDatumIr(string SemanticValueId, string SemanticPath
public sealed record DatumMateSolutionIr(string MateStableId, string FirstDatumSemanticValueId, string SecondDatumSemanticValueId,
DatumOrientationRelation Orientation, int ConstrainedDegreesOfFreedom, string Status, AssemblyTransform? DerivedTransform);
+/// <summary>One occurrence relationship. Local frames are source-addressable semantic datums;
+/// Z is the motion axis and X fixes the angular zero. State is degrees or millimetres.</summary>
+public sealed record AssemblyJointIr(string MateStableId, string Name, MechanicalInterfaceFamily Family,
+ string ParentOccurrenceId, string ChildOccurrenceId, string ParentFrameSemanticId, string ChildFrameSemanticId,
+ AssemblyTransform ParentLocalFrame, AssemblyTransform ChildLocalFrame, int DegreesOfFreedom, double DefaultState = 0);
+
public sealed record AssemblyDefinitionIr(
string StableId, string DefinitionIdentity, string TemplateName, string SpecializationIdentity,
IReadOnlyList<SemanticProvenance> Provenance, IReadOnlyList<AssemblyInstanceIr> LocalInstances,
@@ -185,7 +191,8 @@ public sealed record AssemblyIr(
IReadOnlyList<PanelMateEvidenceIr>? PanelMateEvidence = null,
IReadOnlyList<AssemblyDatumIr>? Datums = null,
IReadOnlyList<DatumMateSolutionIr>? DatumMateSolutions = null,
- IReadOnlyList<AssemblySourceDependencyIr>? SourceDependencies = null);
+ IReadOnlyList<AssemblySourceDependencyIr>? SourceDependencies = null,
+ IReadOnlyList<AssemblyJointIr>? Joints = null);
public sealed record AssemblyCompilationResult(AssemblyIr? Ir, IReadOnlyList<AssemblyDiagnostic> Diagnostics, AssemblyPerformanceIr? Performance = null)
{
diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Parser.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Parser.cs
index ffd9b671..a2b453a1 100644
--- a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Parser.cs
+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Parser.cs
@@ -199,7 +199,7 @@ public sealed class AssemblyM0Parser
private static IReadOnlyList<InterfaceDefinition> ParseInterfaces(string source, string sourceIdentity, List<AssemblyDiagnostic> diagnostics)
{
var result = new List<InterfaceDefinition>();
- foreach (Match header in Regex.Matches(source, @"\bInterface(?:\s*<\s*(?<family>Custom|Fixed|Axial|Revolute|Gear)\s*>)?\s+(?<name>[A-Za-z_]\w*)\s*\{", RegexOptions.CultureInvariant))
+ foreach (Match header in Regex.Matches(source, @"\bInterface(?:\s*<\s*(?<family>Custom|Fixed|Axial|Revolute|Prismatic|Gear)\s*>)?\s+(?<name>[A-Za-z_]\w*)\s*\{", RegexOptions.CultureInvariant))
{
var body = BalancedBody(source, header.Index + header.Length - 1, diagnostics, "Interface");
if (body is null) continue;
@@ -223,6 +223,11 @@ public sealed class AssemblyM0Parser
m.Groups["a"].Value, m.Groups["am"].Value, m.Groups["b"].Value, m.Groups["bm"].Value,
m.Groups["offset"].Success ? Number(m.Groups["offset"].Value) : 0)).ToArray();
requirements = requirements.Concat(atomicRequirements).ToArray();
+ if (family is MechanicalInterfaceFamily.Fixed or MechanicalInterfaceFamily.Prismatic
+ && requirements.Length > 0
+ && (requirements.Length != 1 || requirements[0].Kind != PlacementConstraintKind.FrameCoincident))
+ diagnostics.Add(new("assembly-interface-invalid-contract-lowering",
+ $"Interface<{family}> '{name}' requires one frame relationship; authored geometric Lower/Mate relations cannot replace its typed contract."));
var fitMatch = Regex.Match(body, @"\bFit\s+(?<a>[A-Za-z_]\w*)\.(?<am>[A-Za-z_]\w*)\s+inside\s+(?<b>[A-Za-z_]\w*)\.(?<bm>[A-Za-z_]\w*)(?:\s+(?<perSide>per-side))?\s*;", RegexOptions.CultureInvariant);
var policyMatch = Regex.Match(body, @"\bClearancePolicy\s+Minimum\s+(?<min>[-+]?\d+(?:\.\d+)?)mm\s+Maximum\s+(?<max>[-+]?\d+(?:\.\d+)?)mm\s*;", RegexOptions.CultureInvariant);
var variationMatch = Regex.Match(body, @"\bVariation\s+Linear\s+(?<linear>\d+(?:\.\d+)?)mm\s+Thickness\s+(?<thickness>\d+(?:\.\d+)?)mm\s+BendAngle\s+(?<angle>\d+(?:\.\d+)?)deg\s+BendLocation\s+(?<location>\d+(?:\.\d+)?)mm\s+Coating\s+(?<coating>\d+(?:\.\d+)?)mm\s+CoatingTolerance\s+(?<coatingTol>\d+(?:\.\d+)?)mm\s+Engagement\s+(?<engagement>\d+(?:\.\d+)?)mm\s*;", RegexOptions.CultureInvariant);
@@ -240,6 +245,7 @@ public sealed class AssemblyM0Parser
{
MechanicalInterfaceFamily.Fixed => new[] { "DatumFrameCapable" },
MechanicalInterfaceFamily.Revolute => new[] { "AxisCapable", "PlaneCapable" },
+ MechanicalInterfaceFamily.Prismatic => new[] { "DatumFrameCapable" },
MechanicalInterfaceFamily.Axial => new[] { "AxisCapable" },
MechanicalInterfaceFamily.Gear => new[] { "GearCapable" },
_ => Array.Empty<string>()
@@ -253,6 +259,7 @@ public sealed class AssemblyM0Parser
MechanicalInterfaceFamily.Fixed => [new(PlacementConstraintKind.FrameCoincident, "A", ".", "B", ".")],
MechanicalInterfaceFamily.Axial => [new(PlacementConstraintKind.AxisCoincident, "A", "Axis", "B", "Axis")],
MechanicalInterfaceFamily.Revolute => [new(PlacementConstraintKind.AxisCoincident, "A", "Axis", "B", "Axis"), new(PlacementConstraintKind.PlaneCoincident, "A", "Seat", "B", "Seat")],
+ MechanicalInterfaceFamily.Prismatic => [new(PlacementConstraintKind.FrameCoincident, "A", ".", "B", ".")],
_ => []
};
}
@@ -261,6 +268,7 @@ public sealed class AssemblyM0Parser
{
MechanicalInterfaceFamily.Axial => ["translation:along-axis", "rotation:about-axis"],
MechanicalInterfaceFamily.Revolute => ["rotation:about-axis"],
+ MechanicalInterfaceFamily.Prismatic => ["translation:along-axis"],
_ => []
};
var predicates = Regex.Matches(body, @"\bRequire\s+(?<name>[A-Za-z_]\w*)\s*=>\s*(?<left>[-+]?\d+(?:\.\d+)?)mm\s*(?<op>>=|<=|>|<|==)\s*(?<right>[-+]?\d+(?:\.\d+)?)mm\s*;", RegexOptions.CultureInvariant)
@@ -742,7 +750,7 @@ public sealed class AssemblyM0Parser
.Select(m => new MateRoleAssignment(m.Groups["role"].Value, AssemblyPath.Parse(m.Groups["path"].Value))).ToArray();
result.Add(new(header.Groups["name"].Value, header.Groups["interface"].Value, roles, SemanticSourceSpan.Generated(sourceIdentity)));
}
- foreach (Match header in Regex.Matches(body, @"\bInterface\s*<\s*(?<family>Custom|Fixed|Axial|Revolute|Gear)\s*>\s+(?<name>[A-Za-z_]\w*)\s*\{", RegexOptions.CultureInvariant))
+ foreach (Match header in Regex.Matches(body, @"\bInterface\s*<\s*(?<family>Custom|Fixed|Axial|Revolute|Prismatic|Gear)\s*>\s+(?<name>[A-Za-z_]\w*)\s*\{", RegexOptions.CultureInvariant))
{
var block = BalancedBody(body, header.Index + header.Length - 1, diagnostics, "typed Interface"); if (block is null || Regex.IsMatch(block, @"\bRole\s+", RegexOptions.CultureInvariant)) continue;
var roles = Regex.Matches(block, @"\b(?<role>A|B)\s*:\s*(?<path>[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)\s*;", RegexOptions.CultureInvariant)
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.cs
index 0149dc11..b2dd0f45 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.cs
@@ -25,7 +25,13 @@ public static class FirmamentLanguageService
var beforePrefix = source[lineStart..prefixStart];
IReadOnlyList<FirmamentAuthoringField> fields;
string context;
- if (IsInsideThread(source, offset))
+ var interfaceFamily = ActiveFrameInterface(source, offset);
+ if (interfaceFamily is not null)
+ {
+ fields = FirmamentSchemaAuthoringFields.For($"Interface<{interfaceFamily}>");
+ context = $"Interface<{interfaceFamily}>";
+ }
+ else if (IsInsideThread(source, offset))
{
fields = FirmamentSchemaAuthoringFields.For("Thread");
context = "Thread";
@@ -48,7 +54,10 @@ public static class FirmamentLanguageService
if (beforePrefix.Contains(':')) return new(document, revision, "Value", prefixStart, prefix.Length, [], []);
var inModify = IsInsideConstruct(source, offset, "Modify");
var entries = FirmamentSemanticSchemas.All
- .Where(item => item.Entry is not null && item.Name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) &&
+ .Where(item => item.Entry is not null &&
+ (item.Name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)
+ || beforePrefix.EndsWith("Interface<", StringComparison.Ordinal)
+ && item.Name.StartsWith("Interface<" + prefix, StringComparison.OrdinalIgnoreCase)) &&
(!inModify || item.Context?.StartsWith("Modify", StringComparison.Ordinal) == true))
.Select(item => new FirmamentLanguageEntry(item.Id.Value, item.Name, item.Context ?? string.Empty, item.Entry!)).ToArray();
return new(document, revision, entries.Length > 0 ? "ConstructEntry" : "Unsupported",
@@ -81,6 +90,15 @@ public static class FirmamentLanguageService
return header is not null && !prefix[(header.Index + header.Length)..].Contains('}');
}
+ private static string? ActiveFrameInterface(string source, int offset)
+ {
+ var prefix = source[..offset];
+ var header = Regex.Matches(prefix, @"\bInterface\s*<\s*(Fixed|Revolute|Prismatic)\s*>\s+[A-Za-z_]\w*\s*\{", RegexOptions.CultureInvariant)
+ .Cast<Match>().LastOrDefault();
+ return header is not null && !prefix[(header.Index + header.Length)..].Contains('}')
+ ? header.Groups[1].Value : null;
+ }
+
private static bool IsInsideThread(string source, int offset)
{
var prefix = source[..offset];
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs
index 156d9fb4..7e23bc8e 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs
@@ -72,4 +72,19 @@ public static class LoftSemanticDeclaration { }
[FirmamentConstruct("Concept", "Concept", Context = "Document", Entry = "Concept MountingFrame { Bounds: Box3; TopPlane: Plane }", Description = "Named semantic requirements; member names and types are authored per Concept.")]
public static class ConceptSemanticDeclaration { }
+[FirmamentConstruct("InterfaceFixed", "Interface<Fixed>", Context = "Assembly", Entry = "Interface<Fixed> Mount { A: Assembly.Base.Mount; B: Assembly.Link.Socket; }", Description = "Two semantic datum frames define one zero-DOF rigid relationship.")]
+[FirmamentField("A", "A", FirmamentSchemaValueKind.ConstructReference, Required = true, Description = "Parent occurrence's source-addressable DatumFrame-capable semantic port.")]
+[FirmamentField("B", "B", FirmamentSchemaValueKind.ConstructReference, Required = true, Description = "Child occurrence's source-addressable DatumFrame-capable semantic port.")]
+public static class FixedInterfaceSemanticDeclaration { }
+
+[FirmamentConstruct("InterfaceRevolute", "Interface<Revolute>", Context = "Assembly", Entry = "Interface<Revolute> Hinge { A: Assembly.Base.Hinge; B: Assembly.Link.Hinge; }", Description = "One angular DOF about frame Z; frame X defines the zero angle.")]
+[FirmamentField("A", "A", FirmamentSchemaValueKind.ConstructReference, Required = true, Description = "Parent occurrence's source-addressable DatumFrame-capable semantic port.")]
+[FirmamentField("B", "B", FirmamentSchemaValueKind.ConstructReference, Required = true, Description = "Child occurrence's source-addressable DatumFrame-capable semantic port.")]
+public static class RevoluteInterfaceSemanticDeclaration { }
+
+[FirmamentConstruct("InterfacePrismatic", "Interface<Prismatic>", Context = "Assembly", Entry = "Interface<Prismatic> Slide { A: Assembly.Rail.Slide; B: Assembly.Carriage.Slide; }", Description = "One translational DOF along frame Z; coincident frames define zero displacement.")]
+[FirmamentField("A", "A", FirmamentSchemaValueKind.ConstructReference, Required = true, Description = "Parent occurrence's source-addressable DatumFrame-capable semantic port.")]
+[FirmamentField("B", "B", FirmamentSchemaValueKind.ConstructReference, Required = true, Description = "Child occurrence's source-addressable DatumFrame-capable semantic port.")]
+public static class PrismaticInterfaceSemanticDeclaration { }
+
diff --git a/docs/public/firmament/assemblies.md b/docs/public/firmament/assemblies.md
index 70ef5512..f38626ab 100644
--- a/docs/public/firmament/assemblies.md
+++ b/docs/public/firmament/assemblies.md
@@ -12,12 +12,28 @@ The Assembly profile admits this bounded matrix:
|---|---|---|---|
| `Interface<Fixed>` | `FrameCoincident` | none | qualified |
| `Interface<Axial>` | `AxisCoincident` | translation along and rotation about the axis | qualified |
-| `Interface<Revolute>` | `AxisCoincident` + `PlaneCoincident` | rotation about the axis | qualified |
+| `Interface<Revolute>` | two semantic datum frames | rotation about frame Z | qualified for state-driven poses; legacy axis/seat form remains accepted |
+| `Interface<Prismatic>` | two semantic datum frames | translation along frame Z | qualified for state-driven poses |
| `Interface<Custom>` | authored atomic `Mate` lines and bounded numeric `Require` checks | explicitly authored | qualified escape hatch |
| `Interface<Gear>` | the existing Gear evaluator plus occurrence-space axis and center-distance evidence | ideal ratio/sign metadata | qualified for direct and exposed hierarchical Gear endpoints |
These are compiler-owned families, not user-defined generics. Atomic assembly relations remain the existing `AxisCoincident`, `AxisAligned`, `PlaneCoincident`, `PointCoincident`, `OffsetAlongAxis`, and `FrameCoincident` kinds. A typed family expands into those relations before the ordinary Assembly compiler runs.
+For `Fixed`, `Revolute`, and `Prismatic`, the preferred port is one `Semantic` value with a `DatumFrame`. `A` names the parent occurrence and `B` names the child. The two frame origins coincide at state zero; Z is the rotation or translation axis, and X fixes the angular reference. The compiler derives the zero transform directly. `Revolute` accepts angle state in degrees, `Prismatic` accepts position state in millimetres, and omitted state means zero. The compiled `AssemblyIr.Joints` and pure `AssemblyKinematics.Evaluate(ir, state)` expose the relationship, DOF, frames, and posed occurrence transforms. Changing state keeps part definitions and BReps shared. A cycle or multiple movable interfaces driving the same child is rejected.
+
+```firmament
+Assembly Arm {
+ <Assembly Arm>
+ <Part Base = BasePart> Semantic Hinge { DatumFrame Frame = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1]; } </Part>
+ <Part Link = LinkPart> Semantic Socket { DatumFrame Frame = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1]; } </Part>
+ </Assembly>
+ Anchor: Arm.Base.Hinge;
+ Interface<Revolute> Shoulder { A: Arm.Base.Hinge; B: Arm.Link.Socket; }
+}
+```
+
+The older `Revolute` axis/seat port continues to compile through the atomic relation path. It does not produce a state-driven joint because the axis/seat pair does not define a unique angular zero. For a deterministic movable interface, provide datum frames. Imported STEP part occurrences can declare these ports in Firmament; the STEP geometry need not contain mating metadata.
+
```firmament
Interface<Revolute> ShaftBearing {
A: Module.Shaft.Joint;
diff --git a/docs/release/ASSEMBLY-INTERFACE-X0.md b/docs/release/ASSEMBLY-INTERFACE-X0.md
new file mode 100644
index 00000000..9e553e57
--- /dev/null
+++ b/docs/release/ASSEMBLY-INTERFACE-X0.md
@@ -0,0 +1,42 @@
+# ASSEMBLY-INTERFACE-X0: audit and design
+
+## Audit before changes
+
+Assembly `Interface<T>` is currently a compiler-owned shorthand over the older `Mate` graph. `Fixed` expands to `FrameCoincident`; `Revolute` expands to `AxisCoincident` plus `PlaneCoincident`; `Axial` admits rotation and translation; `Custom` accepts authored atomic geometric relations. Inline `Interface<T> Name { A: path; B: path; }` also defines the participant assignment. Separate interface definitions declare `Role ... requires ...`, `Lower ...`, and `Mate Name: InterfaceName`. Bind resolves semantic source paths through occurrence-scoped `SemanticValue`s, checks role capabilities, then lowers atomic relations. Placement walks anchored instances and applies a direct candidate transform, with residual checks for conflicts. It stores admitted free motions but has no state-to-pose function.
+
+The awkwardness is that `Revolute` requires a separate axis and seat plane and leaves its angular zero chosen by the axis alignment fallback. `Axial` is deliberately two-DOF and cannot stand in for `Prismatic`. The generic atomic relation machinery remains useful for old fixtures and manufacturing/tolerance checks, but it is a poor authoring surface for deterministic joints. A missing member can also survive role capability validation until lowering. Multiple relationships to one moving occurrence are discovered as transform conflicts, rather than diagnosed as duplicate kinematic ownership.
+
+Firmament Concept IR already models named, typed member requirements, materialized structs, semantic references, and compile-time values for one object. The Assembly profile uses a narrower `Concept` declaration to check required `Part`, `Assembly`, `Mate`, or `Semantic` members of one template. Neither places instances. `Interface<T>` remains the relation between occurrence-qualified participants and does not duplicate Concept's single-object conformance machinery. The STEP AP242 graph owns shared part definitions, occurrence identity, and imported source transforms; it has no native Firmament joint authority. `ExternalStep` provides reusable geometry and a Firmament-authored `Semantic` datum can provide its interface port without editing the STEP file.
+
+## Chosen refinement
+
+Keep the concise inline `A`/`B` participant paths and existing `DatumFrame` syntax. For new `Fixed`, `Revolute`, and `Prismatic` contracts, each participant supplies one right-handed datum frame. Its origin defines the joint origin, Z the motion axis, and X the zero-angle direction. `A` is the parent and `B` the child for a movable contract. At state zero, the frames coincide exactly. Motion is a rotation about or translation along the coincident Z axis. This is one semantic frame per side and one scalar state per movable interface; authors need no explicit transform, seat plane, or geometric constraint list. Legacy `Revolute` axis/seat forms stay accepted for compatibility, with the new frame form selected by frame-capable endpoints.
+
+The assembly binder validates both participant frame bindings. Lowering derives one exact zero transform, records the occurrence-qualified parent/child and DOF, and rejects duplicate child ownership or loops. The pose evaluator composes immutable transforms along the tree; it never modifies or clones a BRep definition. `0deg` and `0mm` are default states. Gear, Axial, Custom, and existing Concept behavior remain unchanged.
+
+This maps directly to a future USD/robotics joint: the two local frames, joint family, axis, zero pose, state, and parent/child occurrence identities are already explicit. No USD or robotics serialization is part of X0.
+
+## Source, lowering, and pose
+
+The new source form keeps the existing inline syntax. The type selects the contract, while `A` and `B` bind source-addressable semantic ports on concrete assembly occurrences:
+
+```firmament
+Interface<Revolute> Shoulder { A: TwoLinkArm.Base.Hinge; B: TwoLinkArm.Link1.Input; }
+Interface<Revolute> Elbow { A: TwoLinkArm.Link1.Output; B: TwoLinkArm.Link2.Input; }
+```
+
+Each referenced `Semantic` port contains a `DatumFrame Frame = [origin] x [unit X] y [unit Y] z [unit Z]`. The binder rejects a missing frame or a non-finite, non-orthonormal, or left-handed frame. A malformed participant never falls through to runtime pose evaluation. The existing `Concept<T>` assembly-template satisfaction check remains separate: it validates required members of one reusable definition, not the relation between occurrences.
+
+The compiler lowers a frame contract to one direct frame alignment for its zero pose. `AssemblyJointIr` then carries the occurrence identities, semantic frame identities, two local frames, family, DOF, and default state. `AssemblyKinematics.Evaluate` accepts a finite state map by Interface name and computes a new set of world occurrence transforms. State zero is `0deg` or `0mm`. A read-only state snapshot is part of the pose result. The arm's parent/child transforms compose in joint order. Multiple movable drivers for one child and loops receive compile diagnostics. Bounds are intentionally deferred; unbounded finite state is valid in X0.
+
+The display path can apply the new pose with `AssemblyDisplayMeshExporter.WithPose` to an existing mesh document. It returns new occurrence transforms while retaining the exact same shared definition meshes. BReps, imported STEP definitions, and mesh data are neither mutated nor rebuilt by this operation. The AP242 definition/occurrence graph retains its separate imported source transforms and shared definition identities; Firmament's Interface declaration supplies the semantic mating authority. The external STEP slider witness uses one imported STEP definition twice and attaches its two authored datum ports at the occurrence sites.
+
+`Interface<Fixed>`, `Interface<Revolute>`, and `Interface<Prismatic>` plus their required `A`/`B` ports are generated into the static semantic schema. Firmament language completion reads that schema. CLI Assembly inspection reports the actual lowered frame relation and compiled joint; JSON inspection serializes `AssemblyIr.Joints`. No handwritten Helios table, constraint solver, USD emitter, physics, or loop closure was added.
+
+## Qualification
+
+The canonical arm is `fixtures/Canonical/AssemblyInterfaces/two-link-arm.firmament`. The imported-part witness is `fixtures/Canonical/AssemblyInterfaces/external-step-slider.firmament`. `AssemblyKinematicsX0Tests` checks Fixed zero placement, Revolute zero/+45/-45 and two-joint composition, Prismatic zero/positive displacement, immutable display-definition reuse, external STEP geometry sharing, deterministic repeat, missing frame, invalid state, duplicate driver, loop rejection, schema, and LX field discovery. Existing Assembly, Gear, Concept, STEP import/export, and Cadmata display tests remain in the serial solution test gate.
+
+The only intentional compatibility distinction is that the historical axis/seat `Revolute` form remains accepted for its old placement behavior but does not acquire state-driven kinematics: it lacks a fully specified angular zero. New frame-based declarations use the same concise `Interface<Revolute> { A: ...; B: ...; }` syntax. The compiler distinguishes them by the bound semantic port capabilities. `Axial`, `Custom`, `Gear`, and atomic manufacturing/tolerance relations retain their existing ownership. No general constraint solver was introduced; the new state path uses matrix composition from exact authored frames.
+
+Validation on the final checkout: `dotnet build Aetheris.slnx -c Release --no-restore -m:1` passed with existing WebAssembly warnings; the required fast lane passed 1,005 tests; `dotnet test Aetheris.slnx -c Release --no-build -m:1 -- RunConfiguration.MaxCpuCount=1` passed all 4,005 discovered tests across the serial project suites (the FrictionLab test assembly exposes no tests). `aetheris asm inspect fixtures/Canonical/AssemblyInterfaces/two-link-arm.firmament` reported two valid `FrameCoincident` relationships and two one-DOF Revolute joints. The external STEP witness uses the bounded cylinder evidence file under `fixtures/Regression/Chamfer/evidence/`; the larger G2 STEP part exceeded the display tessellation time budget under full-suite load, so it was removed from this timing-sensitive witness. `git diff --check` passed. These commands reproduce the compact evidence; generated test output remains local and untracked.
diff --git a/fixtures/Canonical/AssemblyInterfaces/external-step-slider.firmament b/fixtures/Canonical/AssemblyInterfaces/external-step-slider.firmament
new file mode 100644
index 00000000..b334ccac
--- /dev/null
+++ b/fixtures/Canonical/AssemblyInterfaces/external-step-slider.firmament
@@ -0,0 +1,14 @@
+// One external STEP definition is reused by both occurrence identities.
+// Firmament owns the authored interface ports; the STEP part needs no mate metadata.
+Assembly ExternalSlider {
+ <Assembly ExternalSlider>
+ <Part Rail = ExternalStep<"../../Regression/Chamfer/evidence/cylinder-top-rim.step">>
+ Semantic Slide { DatumFrame Frame = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1]; }
+ </Part>
+ <Part Carriage = ExternalStep<"../../Regression/Chamfer/evidence/cylinder-top-rim.step">>
+ Semantic Slide { DatumFrame Frame = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1]; }
+ </Part>
+ </Assembly>
+ Anchor: ExternalSlider.Rail.Slide;
+ Interface<Prismatic> Travel { A: ExternalSlider.Rail.Slide; B: ExternalSlider.Carriage.Slide; }
+}
diff --git a/fixtures/Canonical/AssemblyInterfaces/two-link-arm.firmament b/fixtures/Canonical/AssemblyInterfaces/two-link-arm.firmament
new file mode 100644
index 00000000..6d76edea
--- /dev/null
+++ b/fixtures/Canonical/AssemblyInterfaces/two-link-arm.firmament
@@ -0,0 +1,17 @@
+Assembly TwoLinkArm {
+ <Assembly TwoLinkArm>
+ <Part Base = ArmBase>
+ Semantic Hinge { DatumFrame Frame = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1]; }
+ </Part>
+ <Part Link1 = ArmLink>
+ Semantic Input { DatumFrame Frame = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1]; }
+ Semantic Output { DatumFrame Frame = [20,0,0] x [1,0,0] y [0,1,0] z [0,0,1]; }
+ </Part>
+ <Part Link2 = ArmLink>
+ Semantic Input { DatumFrame Frame = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1]; }
+ </Part>
+ </Assembly>
+ Anchor: TwoLinkArm.Base.Hinge;
+ Interface<Revolute> Shoulder { A: TwoLinkArm.Base.Hinge; B: TwoLinkArm.Link1.Input; }
+ Interface<Revolute> Elbow { A: TwoLinkArm.Link1.Output; B: TwoLinkArm.Link2.Input; }
+}