1#pragma once
2void OrbitBurnTests()
3{
4
5 const Vec recorded{-.000203428,.004329055,3.265791419};
6 const auto trim=OrbitalRcsRequest(recorded,.01316,true);
7 Check(Norm(trim)<.00002,"small pointing lag no longer commands near-full lateral RCS");
8 Check(std::abs(trim.y/.01316-recorded.y/recorded.z)<1e-12,"translation follows the main thrust vector proportionally");
9 Check(Norm(OrbitalRcsRequest(recorded,0,true))==0,"unspooled mains cannot demand large transverse corrections");
10 Check(Norm(OrbitalRcsRequest(recorded,-.01,true))==0,"reverser transition cannot drive transverse thrust the wrong way");
11 Check(Norm(OrbitalRcsRequest({1,1,0},.01,true))==0,"large off-axis burn waits for alignment");
12 const Vec fine{.0003,-.0002,.001};
13 Check(Norm(OrbitalRcsRequest(fine,.01,true)-Vec{fine.x,fine.y,0})<1e-12,"terminal trims retain existing authority");
17 Check(reverse.x>0&&reverse.y>0&&reverse.z==0,"aligned reverse thrust retains correct trim direction");
18
19 BurnCountdown timer;Guidance g;g.valid=g.thrust=true;g.phase=Phase::Depart;
20 for(int i=0;i<=100;++i) {
21 g.remainingDeltaV=1-i*.002;timer.Update(g,i*.1,.02,5.8);
22 }
23 Check(std::abs(g.mecoSeconds-(.8-.0005)/.02)<.4,"live bulk countdown follows measured convergence");
24 timer.Reset();
25 for(int i=0;i<=50;++i) {
26 g.remainingDeltaV=.02*std::exp(-i*.1/.7);timer.Update(g,i*.1,.02,5.8);
27 if(i==25) Check(std::abs(g.mecoSeconds-.7*std::log(g.remainingDeltaV/.0005))<.15,
28 "taper estimate accounts for exponential throttle-down");
29 }
30 g.remainingDeltaV=.01;timer.Update(g,5.1,.02,5.8);
31 Check(g.mecoSeconds<0,"new correction demand invalidates old countdown");
32 for(auto phase:{Phase::Align,Phase::Wait,Phase::Coast,Phase::Abort,Phase::Complete,Phase::Off}) {
33 g.phase=phase;g.mecoSeconds=12;timer.Update(g,6,.02,5.8);
34 Check(g.mecoSeconds<0,"non-burn phases never show stale MECO");
35 }
36 g.phase=Phase::Arrive;g.entryControl=true;timer.Update(g,7,.02,5.8);
37 Check(g.mecoSeconds<0,"continuous reentry is not assigned an impulsive cutoff");
38 g.entryControl=false;g.ascentControl=true;timer.Update(g,8,.02,5.8);
39 Check(g.mecoSeconds<0,"ascent retains its own guidance presentation");
40 g.ascentControl=false;g.remainingDeltaV=.2;timer.Update(g,9,.02,5.8);timer.Update(g,11,.02,5.8);
41 Check(g.mecoSeconds<0,"interrupted samples cannot extrapolate stale convergence");
42
43 auto in=Fixture();auto r=Settings(in);BusState data;
44 data.request=r;data.snapshot=
Solve(in,r);data.snapshot.actualCoast={
true,-1959,100};
45 data.snapshot.lowAtmosphere=true;data.snapshot.plan.clearance={true,118,6.3};
46 data.guidance.valid=data.guidance.thrust=true;data.guidance.phase=Phase::Depart;
47 data.guidance.status=L"DOR BURN";data.guidance.mecoSeconds=12.1;
48 data.guidance.correctionClearance={true,1214,0};
49 for(double time:{0.,1.5}) for(auto view:{View::Orbit,View::Plane,View::Edge,View::Track}) {
50 data.clock=time;data.request.view=view;bool warning=false,burn=false,minimum=false;
51 for(
const auto& label:
Plot(data.snapshot,view).
labels)
52 minimum=minimum||(label.text==L"PLAN MIN ALT 118.0km MSL");
53 for(
const auto& label:
Readouts(data,
Rows(r,data.snapshot.mode),0,
true)) {
54 warning=warning||(label.text==L
"COAST MIN -1959.0km"&&label.color==
Red);
55 burn=burn||(label.text==L
"BURN MECO ~00:13"&&label.color==
Green);
56 Check(label.x+label.text.size()*5<=420&&label.y+13<=320,"burn presentation fits native MFD");
57 }
58 Check(warning&&minimum,"planned minimum and unsafe unpowered coast remain distinct across all views");
59 Check(burn==(time==0),"normal burn and MECO share the EXEC blink without inheriting red");
60 }
61 data.guidance.phase=Phase::Abort;data.guidance.status=L"DOR: CORRECTION MARGIN LOST";
62 bool red=false;
63 for(
const auto& label:
Readouts(data,
Rows(r,data.snapshot.mode),0,
false))
64 red=red||(label.y==278&&label.color==
Red&&label.text==data.guidance.status);
65 Check(red,"actual execution failures remain red independently of phase colors");
66}
Plan Solve(const Input &in, const Request &r, bool geometry)
constexpr std::uint32_t Red
Vec OrbitalRcsRequest(Vec deltaBody, double mainGrossAcceleration, bool hasMains)
constexpr std::uint32_t Green
std::vector< Row > Rows(const Request &r, Mode mode, bool entry=false, bool ascent=false, bool recordingAllowed=false)
std::vector< Label > Readouts(const BusState &data, const std::vector< Row > &rows, int uiRow, bool dorActive, bool showKeys=true)
Picture Plot(const Snapshot &s, View view)
std::vector< Label > labels