Match Jimmy controller arithmetic and facing to original probes

This commit is contained in:
UnixNight committed 2026-11-05 09:47:28 -05:00
1 parent 42ea2b8cd5
commit 0e2f426d42
60 files changed
+6027 -48

No files matched your search

@@ -0,0 +1,29 @@
using System.Numerics;
using System.Text.Json;
using GamePort.Game;
using var document=JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory,"original-ground-reference.json")));
int inputs=0,applies=0;
foreach(var c in document.RootElement.GetProperty("cases").EnumerateArray())
{
var p=c.GetProperty("input").EnumerateArray().Select(v=>v.GetSingle()).ToArray();
var o=c.GetProperty("observed").EnumerateArray().Select(v=>v.GetSingle()).ToArray();string name=c.GetProperty("name").GetString()!;
if(c.GetProperty("kind").GetString()=="INPUT")
{
var r=JimmyGroundMotion.Input(new(p[0],0,p[6],p[7]!=0),p[5],new(p[1]!=0,p[2]!=0,p[3]!=0,p[4]!=0,false));
Near(r.State.Speed,o[0],name+" scalar");Near(r.Lateral,o[1],name+" side");Near(r.State.TargetYaw,o[2],name+" heading");
Check(r.State.AutoTurning==(o[3]!=0),name+" latch");inputs++;
}
else
{
var r=JimmyGroundMotion.Apply(p[0],new(p[1],p[2],p[3]),new(p[4],p[5],p[6]),p[7],p[8],p[9]!=0,p[10]!=0,p[11]);
Near(r.Velocity.X,o[0],name+" X");Near(r.Velocity.Y,o[1],name+" Y");Near(r.Velocity.Z,o[2],name+" Z");Near(r.Rotation.Y,o[3],name+" yaw");applies++;
}
}
Check(inputs==17&&applies==8,"complete25 native observations");Console.WriteLine("PASS17 original ground-input observations and8 ground-apply observations");
var active=JimmyGroundMotion.Input(new(100,130),90,new(true,false,false,false,false));Check(active.State.TargetYaw==90,"active forward stops previous destination-yaw drift");
var idle=JimmyGroundMotion.Input(new(100,130),90,default);Check(idle.State.TargetYaw==130,"idle retains prior destination yaw");
var fire=JimmyGroundMotion.Input(new(100,90),90,new(false,true,false,false,false,Fire:true),blockBackward:true);
Check(fire.State.Speed==65&&!fire.HeadingUpdated,"source parent fire acceptance gate suppresses backward");
Console.WriteLine("PASS heading publication and caller-owned backward/fire gate");
static void Check(bool condition,string name){if(!condition)throw new Exception(name);}
static void Near(float value,float expected,string name)=>Check(float.IsFinite(value)&&Math.Abs(value-expected)<.02f,$"{name}: {value} != {expected}");