1#pragma once
2#include "VcpsEntryFixture.h"
3
4void EntryInterruptionTests()
5{
6
7
8 for(bool entry:{false,true}) {
9 AttitudeController controller;RotationState rotation;
10 rotation.effort=1;rotation.acceleration={.1,.1,.1};
11 Guidance g;
12 auto command=[&] {g={};g.valid=g.thrust=true;g.entryControl=entry;
13 g.phase=Phase::Depart;g.pointing={0,0,1};g.remainingDeltaV=1;};
14 for(int i=0;i<6;++i) {command();controller.Step(g,rotation,{0,1,0},.133);}
15 Check(g.thrust,"entry and orbital burn initially capture attitude");
16 rotation.rates={-.033231537789,.014751114883,-.000207252233};
17 command();g.pointing=
Rotate({0,0,1},{1,0,0},2.59871916*
Pi/180);
18 controller.Step(g,rotation,{0,1,0},.133);
19 Check(g.thrust==entry,"captured entry keeps braking through the recorded small correcting rotation");
20 command();rotation.rates={.1,0,0};controller.Step(g,rotation,{0,1,0},.133);
21 Check(!g.thrust&&g.phase==Phase::Align,"excessive entry rotation still inhibits translation");
22 command();rotation.rates={};g.pointing={1,0,0};controller.Step(g,rotation,{0,1,0},.133);
23 Check(!g.thrust,"large entry attitude errors still require realignment");
24 }
25
26
27 double output=.4,reverser=1;
bool reverseCommand=
true;
28 for(int i=0;i<70;++i) {
29 const bool paused=i<20;
30 const auto c=EntryControl::MainEngine(paused?0:-.008,.02,.02,output,reverser,reverseCommand);
31 reverseCommand=c.reverse;
32 const double before=
output;
33 output+=(std::clamp)(c.lever-output,-.1/5.8,.1/5.8);
34 reverser=(std::clamp)(reverser+(reverseCommand?.05:-.05),0.0,1.0);
35 Check(reverser==1&&(1-2*reverser)*output<=0,"interrupted braking never produces a forward-thrust pulse");
36 Check(std::abs(output-before)<=.1/5.8+1e-12,"braking restart respects engine spool rate");
37 }
38 Check(std::abs(output-.4)<1e-10,"braking resumes without an unnecessary bucket cycle");
39 Check(EntryControl::MainEngine(-.02,.02,.02,0,1,true).lever==1,"entry engine mapping permits full reverse thrust when requested");
40 const auto recorded=VcpsEntryFixture();const auto frozen=VcpsEntryPlan();
42 "wall-time propagation detects the recorded clamped-physics gap as a displacement");
44 "active entry does not misclassify a clamped long frame as a teleport");
45 State jumped=recorded.own;jumped.r.x+=10;
47 "real position discontinuity under normal timing still resets entry");
48 FlyEntry(frozen.end,1,1,0,false,&recorded,&frozen,true);
49
50 auto in=BillEntryFixture();Request r;r.entryOrigin=true;r.arrivalEpoch=in.now+2400;
51 const auto snapshot=
Solve(in,r);Executor ex;
52 Check(ex.Begin(in,r,snapshot).valid&&ex.EntryActive(),"entry plan accepted before descent");
53 const double time=snapshot.plan.end-100;
54 in.own=EntryControl::InCurrentFrame(snapshot.plan,time,in.spin,in.gm).state;in.now+=time;
55 in.entryVehicle.airVelocity=in.own.v-
Cross({0,0,in.spin},in.own.r);
56 Check(
Norm(in.own.r)-in.radius<100,
"recovery regression lies below ordinary new-entry start gate");
57 in.entryVehicle.airAge=2.564;
58 auto waiting=ex.Step(in,r);
59 Check(waiting.valid&&!waiting.thrust&&ex.EntryActive(),"stale input below 100 km retains mission");
60 in.entryVehicle.airAge=0;in.now+=.133;
61 auto resumed=ex.Step(in,r);
62 Check(resumed.valid&&resumed.thrust&&ex.EntryActive(),"fresh input resumes the retained entry below 100 km");
63 auto dirty=in;dirty.entryVehicle.clean=false;dirty.entryVehicle.airAge=2.564;
64 Executor config=ex;
65 Check(!config.Step(dirty,r).valid&&!config.Active(),"stale air cannot mask a known entry configuration failure");
66 ex.Cancel();
67 Check(!ex.Step(in,r).valid&&!ex.EntryActive(),"manual disengagement never automatically reengages entry");
68 Check(!ex.Begin(in,r,snapshot).valid,"retained-entry recovery does not bypass checks for a new low-altitude plan");
69}
Plan Solve(const Input &in, const Request &r, bool geometry)
bool FlightStateDiscontinuous(State previous, State current, double elapsed, double gm, double spin, double maxFrameSeconds, bool activeEntry)
Vec Rotate(Vec v, Vec axis, double angle)