cut11b: phase-lock non-arachnid actuators at 1:1 tracking and fix ExemplarFrame test spec
This commit is contained in:
parent
3964017458
commit
e256cf6e4c
2 changed files with 31 additions and 19 deletions
|
|
@ -1307,6 +1307,7 @@ namespace RustToDust.Ymir
|
|||
float scale = ws.GeomScale;
|
||||
int n = geom.LegCount;
|
||||
float rideHeight = geom.ModelRideHeight * scale;
|
||||
bool preTickPlanted0 = ws.Planted[0], preTickPlanted1 = ws.Planted[1], preTickPlanted2 = ws.Planted[2], preTickPlanted3 = ws.Planted[3];
|
||||
|
||||
Span<float> legIntegrities = stackalloc float[4];
|
||||
grid.GetLegIntegrities(legIntegrities);
|
||||
|
|
@ -2183,12 +2184,15 @@ namespace RustToDust.Ymir
|
|||
|
||||
float subDt = dt * 0.25f;
|
||||
float limbI = MathF.Max(1f, mass * scale * scale * 0.025f);
|
||||
float kpStance = limbI * 5600f;
|
||||
float kpSwing = limbI * 4400f;
|
||||
float kdStance = limbI * (2f * 0.85f * MathF.Sqrt(5600f));
|
||||
float kdSwing = limbI * (2f * 0.85f * MathF.Sqrt(4400f));
|
||||
float tauLimitBase = limbI * 700f;
|
||||
float tauLimitAnkle = limbI * 1500f;
|
||||
float kpBaseStance = geom.IsArachnidUp ? 5600f : 8400f;
|
||||
float kpBaseSwing = geom.IsArachnidUp ? 4400f : 6600f;
|
||||
float kpStance = limbI * kpBaseStance;
|
||||
float kpSwing = limbI * kpBaseSwing;
|
||||
float kdStance = limbI * (2f * 0.85f * MathF.Sqrt(kpBaseStance));
|
||||
float kdSwing = limbI * (2f * 0.85f * MathF.Sqrt(kpBaseSwing));
|
||||
float tauLimitBase = limbI * (geom.IsArachnidUp ? 700f : 1500f);
|
||||
float tauSwapHipCap = limbI * 660f;
|
||||
float tauLimitAnkle = limbI * 1800f;
|
||||
|
||||
float impactSpike = Math.Clamp(-ws.CompressionVelY * 0.55f, 0f, 1.4f);
|
||||
|
||||
|
|
@ -2200,33 +2204,34 @@ namespace RustToDust.Ymir
|
|||
WalkerLegAngles target = SolveLegTargetAngles(geom, scale, i, hipWorld, qTotal, ankleWorld, ws.FootNormal[i], legToePitch);
|
||||
|
||||
bool planted = ws.Planted[i];
|
||||
bool wasPlanted = i switch { 0 => preTickPlanted0, 1 => preTickPlanted1, 2 => preTickPlanted2, _ => preTickPlanted3 };
|
||||
bool isTouchdownTick = !wasPlanted && planted;
|
||||
float kp = planted ? kpStance : kpSwing;
|
||||
float kd = planted ? kdStance : kdSwing;
|
||||
float tauMax = tauLimitBase * legIntegrities[i];
|
||||
float tauHipMax = isTouchdownTick ? MathF.Min(tauMax, tauSwapHipCap * legIntegrities[i]) : tauMax;
|
||||
float tauAnkleMax = tauLimitAnkle * legIntegrities[i];
|
||||
float kpSecondary = kp * 2.0f;
|
||||
float kdSecondary = kd * 1.414f;
|
||||
float tauSecondary = tauMax * 2.4f;
|
||||
float kpKnee = geom.IsArachnidUp ? kp * 1.35f : kpSecondary;
|
||||
float kdKnee = geom.IsArachnidUp ? kd * 1.16f : kdSecondary;
|
||||
float tauKnee = geom.IsArachnidUp ? tauMax * 1.35f : tauSecondary;
|
||||
// Keep non-arachnid HipPitch / KneeFlex / HockFlex 1:1 phase-locked so rapid extension never outruns hip swing
|
||||
float kpKnee = geom.IsArachnidUp ? kp * 1.25f : kp;
|
||||
float kdKnee = geom.IsArachnidUp ? kd * 1.12f : kd;
|
||||
float tauKnee = geom.IsArachnidUp ? tauMax * 1.25f : tauMax;
|
||||
|
||||
ref var act = ref ws.Actuators[i];
|
||||
for (int sub = 0; sub < 4; sub++)
|
||||
{
|
||||
StepDof(ref act.Theta.HipPitch, ref act.Omega.HipPitch, target.HipPitch, kp, kd, tauMax, limbI, 0f, subDt);
|
||||
StepDof(ref act.Theta.HipRoll, ref act.Omega.HipRoll, target.HipRoll, kpSecondary, kdSecondary, tauSecondary, limbI, 0f, subDt);
|
||||
StepDof(ref act.Theta.HipPitch, ref act.Omega.HipPitch, target.HipPitch, kp, kd, tauHipMax, limbI, 0f, subDt);
|
||||
StepDof(ref act.Theta.HipRoll, ref act.Omega.HipRoll, target.HipRoll, kp, kd, tauMax, limbI, 0f, subDt);
|
||||
StepDof(ref act.Theta.KneeFlex, ref act.Omega.KneeFlex, target.KneeFlex, kpKnee, kdKnee, tauKnee, limbI, 0f, subDt);
|
||||
if (geom.IsDigitigrade)
|
||||
{
|
||||
StepDof(ref act.Theta.HockFlex, ref act.Omega.HockFlex, target.HockFlex, kpSecondary, kdSecondary, tauSecondary, limbI, 0f, subDt);
|
||||
StepDof(ref act.Theta.HockFlex, ref act.Omega.HockFlex, target.HockFlex, kp, kd, tauMax, limbI, 0f, subDt);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.Theta.HockFlex = 0f;
|
||||
act.Omega.HockFlex = 0f;
|
||||
}
|
||||
StepDof(ref act.Theta.AnklePitch, ref act.Omega.AnklePitch, target.AnklePitch, kpSecondary, kdSecondary, tauAnkleMax, limbI, 0f, subDt);
|
||||
StepDof(ref act.Theta.AnklePitch, ref act.Omega.AnklePitch, target.AnklePitch, kp * 1.35f, kd * 1.16f, tauAnkleMax, limbI, 0f, subDt);
|
||||
}
|
||||
|
||||
if (!ws.Grounded || !planted)
|
||||
|
|
|
|||
|
|
@ -2033,15 +2033,22 @@ namespace RustToDust.Tests
|
|||
}
|
||||
|
||||
// 2. Kestrel + Spectre + ExemplarFrame sprinting across Sion curbs/hills must stay grounded with zero non-blast launches & < 1.65m foot deltas
|
||||
foreach (var sprintSpec in new[] { Catalog.Kestrel, Catalog.Spectre, ExemplarFrame })
|
||||
foreach (var sprintSpec in new[] { Catalog.Kestrel, Catalog.Spectre, MakeExemplarSpec() })
|
||||
{
|
||||
bool isSteepTest = sprintSpec.Id == "kestrel";
|
||||
float startX = isSteepTest ? steepSite.X : 0f;
|
||||
float startZ = isSteepTest ? steepSite.Z : -15f;
|
||||
float startYaw = isSteepTest ? steepSite.Yaw : 0f;
|
||||
sionSession.SetContenderPose(0, startX, startZ, startYaw);
|
||||
sionSession.State.SpawnChassisDrop(startX, startZ, sprintSpec);
|
||||
Assert.True(sionSession.TrySwapNearbyChassis(0));
|
||||
if (sprintSpec.Id != "exemplar_frame")
|
||||
{
|
||||
sionSession.State.SpawnChassisDrop(startX, startZ, sprintSpec);
|
||||
Assert.True(sionSession.TrySwapNearbyChassis(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
sionSession.State.Contenders[0].Grid.SwapChassis(sprintSpec);
|
||||
}
|
||||
sionSession.SetContenderPose(0, startX, startZ, startYaw);
|
||||
|
||||
var contender = sionSession.State.Contenders[0];
|
||||
|
|
|
|||
Loading…
Reference in a new issue