Rise
The Vieneo Province
Loading...
Searching...
No Matches
Tests/OrbitEntryBurnCoastTests.h

Source at documentation-generation time. See Test catalog for fixture associations.

1#pragma once
2
3void EntryBurnCoastTests()
4{
5 auto in=BillEntryFixture();Request r;r.entryOrigin=true;r.passTime=PassTime::Manual;
6 r.arrivalEpoch=in.now+1650;
7 const auto early=Solve(in,r);
8 Check(early.plan.valid&&!early.plan.planningOnly&&EntryProfile::HasTransferCoast(early.plan.entry),
9 "earlier handoff finds an executable finite-burn/coast/capture profile");
10 Check(early.plan.end==1650,"planner never silently extends the selected handoff deadline");
11 for(int i=0;i<=25;++i)
12 Check(!EntryPlanning::Candidate(in,r,1620.0*i/25,false,Route::Orbital).valid,
13 "new early case was unavailable to the continuous entry family");
14 const auto lean=Solve(in,r,false);
15 Check(lean.plan.valid&&std::abs(lean.plan.fuel-early.plan.fuel)<1e-8&&lean.plan.entry.samples.empty(),
16 "burn/coast feasibility is independent of drawing geometry");
17 const auto& e=early.plan.entry;
18 for(double join:{e.coastSeconds,e.transferCoastStart,e.transferCoastEnd,early.plan.end}) {
19 const auto before=EntryControl::Reference(early.plan,join-1e-5,in.spin,in.gm);
20 const auto after=EntryControl::Reference(early.plan,join+1e-5,in.spin,in.gm);
21 Check(Norm(before.state.r-after.state.r)<.001&&Norm(before.state.v-after.state.v)<1e-5&&
22 Norm(before.acceleration-after.acceleration)<1e-5,
23 "coast transitions preserve position velocity and acceleration without hidden impulses");
24 }
25 for(const auto& sample:e.samples) if(EntryProfile::Coasting(e,sample.seconds)) {
26 Check(Norm(sample.state.r)-in.radius>=100&&sample.thrustFraction<=.02,
27 "ballistic transfer coast stays above dense-entry region with only small trim demand");
28 }
29 // A rebased display/reference must describe exactly the same trajectory.
30 Executor ex;Check(ex.Begin(in,r,early).valid,"new trajectory can be committed");
31 auto later=in;later.now+=60;const auto rebased=ex.ReferencePlan(later);
32 const double probe=(e.transferCoastStart+e.transferCoastEnd)*.5;
33 const auto original=EntryControl::Reference(early.plan,probe,in.spin,in.gm);
34 const auto shifted=EntryControl::Reference(rebased,probe-60,in.spin,in.gm);
35 Check(Norm(shifted.state.r-Rotate(original.state.r,{0,0,1},-in.spin*60))<1e-7&&
36 Norm(shifted.state.v-Rotate(original.state.v,{0,0,1},-in.spin*60))<1e-8,
37 "committed coast coefficients rotate and age with the displayed reference");
38 auto dry=in;dry.fuelKg=100;
39 Check(!Solve(dry,r,false).plan.valid,"earlier handoff cannot borrow unavailable fuel");
40 auto weak=in;weak.entryReverseKN*=.1;
41 Check(!Solve(weak,r,false).plan.valid,"early trajectory respects reverse authority independently of forward thrust");
42 auto urgent=r;urgent.arrivalEpoch=in.now+300;
43 Check(!Solve(in,urgent,false).plan.valid,"unreachable deadline remains rejected");
44 auto ground=in;ground.onGround=true;ground.freeFlight=false;
45 const auto groundPreview=Solve(ground,r,false);Executor groundExecutor;
46 Check(!groundExecutor.Begin(ground,r,groundPreview).valid,
47 "an entry preview cannot engage the entry controller on the ground or in VTOL");
48 auto slow=r;slow.arrivalEpoch=in.now+2100;
49 const auto economical=Solve(in,slow,false);
50 Check(economical.plan.valid&&early.plan.fuel>economical.plan.fuel+100,
51 "selected earlier handoff trades additional fuel for less time when needed");
52 const auto fast=FlyEntry(1650);
53 Check(fast.seconds<1710&&fast.peakMain>.7&&fast.coastIdleSeconds>20,
54 "finite vehicle flies earlier high-thrust entry and actually idles between burns");
55 FlyEntry(1650,1,1.10,.015);
56 FlyEntry(2400,1.5,.9);
57 // The user's VCPS orbit: earlier than the recorded ~959 s handoff, stronger
58 // reverse burn, real actuator dynamics, and both recorded timing gaps.
59 const auto vcps=VcpsEntryFixture();Request vr;vr.entryOrigin=true;vr.passTime=PassTime::Manual;
60 vr.arrivalEpoch=vcps.now+810;const auto vp=Solve(vcps,vr);
61 Check(vp.plan.valid&&EntryProfile::HasTransferCoast(vp.plan.entry)&&vp.plan.entry.peakReverse>.9,
62 "recorded vehicle has an earlier plan using over 90 percent reverse authority");
63 const auto flown=FlyEntry(810,1,1,0,false,&vcps,&vp.plan,true);
64 Check(flown.seconds<870&&flown.peakMain>.9&&flown.coastIdleSeconds>20,
65 "recorded vehicle reaches earlier handoff with a real coast despite timing gaps");
66 BusState display;display.request=r;display.snapshot=early;display.clock=in.now;
67 bool coastLabel=false;
68 for(const auto& label:Readouts(display,Rows(r,early.mode,true),0,false)) {
69 coastLabel|=label.text.rfind(L"COAST ",0)==0;
70 Check(label.y<=304&&label.x+label.text.size()*5<=420,"burn/coast readout fits the existing instrument");
71 }
72 Check(coastLabel,"entry display identifies the new coast start/end countdowns");
73 auto hot=in;const double mid=(e.transferCoastStart+e.transferCoastEnd)*.5;
74 hot.own=EntryControl::InCurrentFrame(early.plan,mid,in.spin,in.gm).state;
75 hot.entryVehicle.airVelocity=hot.own.v-Cross({0,0,in.spin},hot.own.r);
76 hot.entryVehicle.aftC=210;Vec integral;
77 const auto protectedCoast=EntryControl::Command(hot,early.plan,mid,integral,.2);
78 Check(protectedCoast.entryLimited&&protectedCoast.thrust&&protectedCoast.attitude,
79 "a planned coast never suppresses active thermal protection");
80}
Vec Cross(Vec a, Vec b)
Definition OrbitMath.h:17