Cut 5b-2: Hybrid B centroidal GRF + 2nd-order joint mech locomotion across all 7 walkers

This commit is contained in:
Meta Vens 2026-12-05 06:37:26 +01:00
commit dee2e738d8
9 changed files with 3077 additions and 431 deletions

View file

@ -724,7 +724,7 @@ public partial class Smoke : Node
new VehicleRigDriveInput(new Vector3(0f, 0f, 6f), 0f, 0.70f, 18f, 0f, 0.8f, 0f, 1f, 1f / 60f),
minRotRad: 0.001f);
// Breaker: verify oleo strut slide + scissor torque links + recess ram aiming
// Breaker: verify oleo strut slide + scissor torque links + recess ram aiming driven by Newtonian GRF load
{
var breakerVis = VehicleVisualInstance.Create(cache, "breaker", VehicleVisualRole.Player);
Node3D? oleo = breakerVis.GetNamedNode("LegL.Oleo");
@ -737,10 +737,13 @@ public partial class Smoke : Node
Transform3D oleo0 = oleo.Transform;
Transform3D sc0 = scissorUp.Transform;
Transform3D ramRest = ram0.Transform;
var inp1 = new VehicleRigDriveInput(new Vector3(0f, -6f, 8f), 0f, 0.4f, 10f, 0f, 1f, 0f, 1f, 1f / 60f);
for (int s = 0; s < 10; s++) VehicleRigAnimator.Update(breakerVis, in inp1, Basis.Identity);
var inp2 = new VehicleRigDriveInput(new Vector3(0f, 3f, 8f), 0f, 0.4f, 10f, 0f, 1f, 0f, 1f, 1f / 60f);
for (int s = 0; s < 10; s++) VehicleRigAnimator.Update(breakerVis, in inp2, Basis.Identity);
Node3D? footL = breakerVis.GetNamedNode("LegL.Foot");
if (footL is not null)
{
footL.Transform = new Transform3D(new Basis(Vector3.Right, 0.28f) * footL.Transform.Basis, footL.Transform.Origin);
}
for (int s = 0; s < 10; s++) VehicleRigAnimator.StepBreakerLinkages(breakerVis, leftLoadG: 1.85f, rightLoadG: 0.25f, dt: 1f / 60f);
for (int s = 0; s < 10; s++) VehicleRigAnimator.StepBreakerLinkages(breakerVis, leftLoadG: 0.25f, rightLoadG: 1.85f, dt: 1f / 60f);
float oleoDelta = (oleo.Transform.Origin - oleo0.Origin).Length();
float scDelta = sc0.Basis.GetRotationQuaternion().AngleTo(scissorUp.Transform.Basis.GetRotationQuaternion());
@ -920,39 +923,73 @@ public partial class Smoke : Node
drops.RemoveRange(baseCount, added.Count);
}
// 6. All 7 walkers stay grounded (minVertexY - restMinY >= -0.05m) and swing along +Z/-Z through a full stride cycle
// 6. All 7 walkers (including Kestrel) walk through real ArenaSession + Hybrid B FK snapshot cleanly
{
var walkerChecks = new (string Id, string? FootNode, string? PelvisNode, bool CheckSagittal)[]
using var walkSession = new RustToDust.Ymir.ArenaSession(seed: 42, mapKind: ArenaMapKind.Desert);
for (int cIdx = 1; cIdx < walkSession.State.Contenders.Count; cIdx++)
{
("raptor", "LegL.Cannon", "Pelvis", true),
("spectre", "LegL.Cannon", "Pelvis", true),
("manticore", "FootFL", "Hull", true),
("bastion", "Ankle.fl", "Trunk", true),
("breaker", "LegL.Foot", "Pelvis", true),
("paladin", "LegL.Ankle", "Pelvis", true),
("kestrel", null, null, false),
walkSession.SetContenderPose(cIdx, 450f + cIdx * 18f, 450f);
}
var walkerChecks = new (string Id, string FootNode, string PelvisNode)[]
{
("raptor", "FootL", "Pelvis"),
("spectre", "LegL.Ankle", "Pelvis"),
("manticore", "FootFL", "Hull"),
("bastion", "Ankle.fl", "Trunk"),
("breaker", "LegL.Foot", "Pelvis"),
("paladin", "LegL.Ankle", "Pelvis"),
("kestrel", "LegL.Foot", "Pelvis"),
};
foreach (var (wId, footNodeName, pelvisNodeName, checkSagittal) in walkerChecks)
foreach (var (wId, footNodeName, pelvisNodeName) in walkerChecks)
{
var wSpec = Catalog.ChassisById[wId];
walkSession.SetContenderPose(0, 0f, 0f, 0f);
if (walkSession.State.Player.Grid.Spec.Id != wId)
{
walkSession.State.SpawnChassisDrop(0f, 0f, wSpec);
Check(walkSession.TrySwapNearbyChassis(), $"Failed to swap walkSession player to '{wId}'");
}
var vis = VehicleVisualInstance.Create(cache, wId, VehicleVisualRole.Player);
float restMinY = vis.ComputeMinVertexY(relativeToModelRoot: true);
float worstRelMinY = float.PositiveInfinity;
float minFootZ = float.PositiveInfinity, maxFootZ = float.NegativeInfinity;
float minFootX = float.PositiveInfinity, maxFootX = float.NegativeInfinity;
Node3D? footNode = footNodeName is not null ? vis.GetNamedNode(footNodeName) : null;
Node3D? pelvisNode = pelvisNodeName is not null ? vis.GetNamedNode(pelvisNodeName) : null;
Node3D? footNode = vis.GetNamedNode(footNodeName);
Node3D? pelvisNode = vis.GetNamedNode(pelvisNodeName);
Check(footNode is not null && pelvisNode is not null,
$"Missing FK nodes '{footNodeName}'/'{pelvisNodeName}' on walker '{wId}'");
var walkInp = new VehicleRigDriveInput(
new Vector3(0f, 0f, 8f), 0f, 0f, 0f, 0f, 1f, 0f, 1f, 0.05f);
for (int step = 0; step < 48; step++)
var player = walkSession.State.Player;
for (int step = 0; step < 60; step++)
{
VehicleRigAnimator.Update(vis, in walkInp, Basis.Identity);
float curMinY = vis.ComputeMinVertexY(relativeToModelRoot: true);
float relMinY = curMinY - restMinY;
if (relMinY < worstRelMinY) worstRelMinY = relMinY;
Check(!float.IsNaN(curMinY), $"NaN vertex Y on walker '{wId}' step {step}");
walkSession.Step(new PlayerInput(
Throttle: 1f,
Steer: 0f,
AimWorldX: player.X,
AimWorldZ: player.Z + 50f,
Fire: false,
InteractPickup: false,
Brake: false));
bool hasSnap = walkSession.TrySampleInterpolatedWalkerPose(true, player.Id, 1f, out var walkerSnap);
Check(hasSnap, $"Missing WalkerVisualSnapshot for '{wId}' at step {step}");
if (!hasSnap) break;
var (interpPos, interpRot, interpVel) = walkSession.GetInterpolatedContenderPose(player.Id, 1f);
var q = new Quaternion(interpRot.X, interpRot.Y, interpRot.Z, interpRot.W);
vis.Root.Transform = new Transform3D(new Basis(q), new Vector3(interpPos.X, interpPos.Y, interpPos.Z));
VehicleRigAnimator.Update(
vis,
player,
new Vector3(interpVel.X, interpVel.Y, interpVel.Z),
vis.Root.Basis,
1f / 60f,
in walkerSnap);
float curMinWorldY = vis.ComputeMinVertexY(relativeToModelRoot: false);
Check(!float.IsNaN(curMinWorldY), $"NaN vertex Y on walker '{wId}' step {step}");
if (footNode is not null && pelvisNode is not null)
{
@ -961,20 +998,24 @@ public partial class Smoke : Node
if (fPos.Z > maxFootZ) maxFootZ = fPos.Z;
if (fPos.X < minFootX) minFootX = fPos.X;
if (fPos.X > maxFootX) maxFootX = fPos.X;
Vector3 fInModel = TransformPointToAncestor(footNode, vis.ModelRoot, Vector3.Zero);
Vector3 fWorld = vis.Root.Transform * (vis.ModelRoot.Transform * fInModel);
float groundUnderFoot = walkSession.State.Terrain.SampleHeight(fWorld.X, fWorld.Z);
float relMinY = curMinWorldY - groundUnderFoot;
if (relMinY < worstRelMinY) worstRelMinY = relMinY;
}
}
float zSpan = footNode is not null ? maxFootZ - minFootZ : 0f;
float xSpan = footNode is not null ? maxFootX - minFootX : 0f;
GD.Print($"SMOKE INFO: Walker {wId} stride minFootY={worstRelMinY:F4}m zSpan={zSpan:F3}m xSpan={xSpan:F3}m");
Check(worstRelMinY >= -0.05f,
$"Walker '{wId}' foot plunged below rest floor: minRelY={worstRelMinY:F4}m");
if (checkSagittal && footNode is not null)
GD.Print($"SMOKE INFO: HybridB Walker {wId} minWorldFootRelY={worstRelMinY:F4}m zSpan={zSpan:F3}m xSpan={xSpan:F3}m");
Check(worstRelMinY >= -0.25f,
$"Walker '{wId}' plunged below terrain: minRelY={worstRelMinY:F4}m");
if (footNode is not null)
{
Check(zSpan > 0.12f,
$"Expected walker '{wId}' foot '{footNodeName}' to stride along Z > 0.12m, got {zSpan:F3}m");
Check(xSpan < 0.03f,
$"Expected walker '{wId}' foot '{footNodeName}' to swing cleanly in sagittal plane (xSpan < 0.03m), got {xSpan:F3}m");
$"Expected walker '{wId}' foot '{footNodeName}' to stride along Z > 0.12m through Hybrid B FK, got {zSpan:F3}m");
}
vis.Root.QueueFree();
}