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

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

1#pragma once
2
3void OrbitDockedPlanningTests()
4{
5 // Synthetic TAC-height station to a ground destination roughly as far as
6 // Freedom in the report. No invented launch velocity or changed performance.
7 auto in=SurfaceFixture(5750);
8 in.onGround=false;in.freeFlight=false;in.dockedAtStation=true;
9 const double radius=in.radius+937.5;
10 in.own={{radius,0,0},{0,std::sqrt(in.gm/radius),0}};
11 Request r;r.passTime=PassTime::Manual;r.arrivalEpoch=in.now+7200;
12 for(bool simulator:{false,true}) for(auto route:{Route::Auto,Route::Atmospheric,Route::Suborbital,Route::Orbital}) {
13 in.simulator=simulator;r.route=route;
14 const auto docked=Solve(in,r);
15 auto airborne=in;airborne.dockedAtStation=false;airborne.freeFlight=true;
16 const auto flying=Solve(airborne,r);
17 Check(docked.flightPhase==L"DOCKED"&&docked.plan.planningOnly,"docked origin remains explicitly docked and planning only");
18 Check(docked.plan.valid==flying.plan.valid&&
19 docked.plan.fuel==flying.plan.fuel&&docked.plan.path.size()==flying.plan.path.size(),
20 "station attachment does not change the preview physics or feasibility");
21 Check(docked.plan.alternatives[0].reason==L"ENTRY FIRST","ATM is cruise, not a reentry selector at TAC height");
22 if(route==Route::Atmospheric) Check(!docked.plan.valid&&docked.status==L"SELECT AUTO / SUB / ORB","forced ATM retains its entry-first reason");
23 else {
24 Check(!docked.plan.path.empty(),"docked station offers an inspectable space-to-surface route");
25 Check(Norm((docked.plan.coast.empty()?docked.plan.path.front():docked.plan.coast.front()).r-in.own.r)<1e-8,"docked preview starts at actual station-carried position");
26 Check(std::abs(Norm(docked.plan.path.back().r)-in.radius-r.entryAltitudeKm)<1e-6,
27 "docked preview ends at selected atmospheric handoff altitude");
28 }
29 Executor ex;const auto g=ex.Begin(in,r,docked);
30 Check(!ex.Active()&&!g.valid&&!g.thrust&&!g.attitude,"surface preview never arms or commands thrust while docked");
31 Check(!ex.Begin(airborne,r,flying).valid,"undocking does not make surface preview executable");
32 }
33 r={};SurfacePlanning::InitialPassSearch surfaceSearch;
34 for(int tick=0;tick<200&&r.passTime==PassTime::Pending;++tick) surfaceSearch.Step(in,r,false);
35 Check(r.passTime==PassTime::Seeded&&Solve(in,r).plan.valid,"automatic surface PASS finds a fitting preview while docked");
36 const double deadline=r.arrivalEpoch;
37 in.freeFlight=true;in.dockedAtStation=false;in.now+=1;
38 surfaceSearch.Step(in,r,false);
39 Check(r.arrivalEpoch==deadline,"undocking preserves selected PASS deadline");
40 in.freeFlight=false;in.dockedAtStation=true;r.passTime=PassTime::Pending;++r.revision;
41 surfaceSearch.Step(in,r,true);
42 Check(r.passTime==PassTime::Pending,"execution lock prevents preview search from changing a committed plan");
43 in.powered=false;surfaceSearch.Step(in,r,false);
44 Check(r.passTime==PassTime::Pending&&Solve(in,r).plan.path.empty(),"docked power loss still inhibits preview and search");
45
46 // Executable orbital objectives can also be inspected from the attachment,
47 // including a scheduled departure, but may only be armed after undocking.
48 for(bool adjust:{false,true}) for(auto start:{Start::Now,Start::Time,Start::Auto}) {
49 in=Fixture();in.freeFlight=false;in.dockedAtStation=true;r=Settings(in);
50 r.adjust=adjust;r.start=start;
51 if(adjust) {r.sizeKm=Norm(in.own.r);r.eccentricity=0;}
52 auto s=Solve(in,r);Check(s.plan.valid,"docked orbital preview has a valid solution");
53 Executor ex;auto g=ex.Begin(in,r,s);
54 Check(!g.valid&&!g.thrust&&!g.attitude&&!ex.Active()&&g.status==L"DOR: UNDOCK TO EXECUTE",
55 "NOW AUTO and timed orbital plans cannot arm while docked");
56 in.dockedAtStation=false;in.freeFlight=true;
57 Check(!ex.Step(in,r).valid&&!ex.Active(),"undocking alone never arms the preview");
58 s=Solve(in,r);g=ex.Begin(in,r,s);
59 Check(g.valid&&ex.Active(),"explicit DOR engagement after undocking remains available");
60 in.dockedAtStation=true;in.freeFlight=false;
61 g=ex.Step(in,r);
62 Check(!g.valid&&!g.thrust&&!g.attitude&&!ex.Active(),"redocking cancels an executing orbital plan");
63 }
64 in=Fixture();in.own={{in.radius+905,0,0},{0,std::sqrt(in.gm/(in.radius+905)),0}};
65 in.targetKind=TargetKind::Surface;in.target.r=Rotate({in.radius,0,0},{0,0,1},2.9);
66 in.freeFlight=false;in.dockedAtStation=true;r={};r.returnToSurface=false;r.altitudeKm=200;
67 InitialPassSearch overflySearch;
68 for(int tick=0;tick<100&&r.passTime==PassTime::Pending;++tick) overflySearch.Step(in,r,false);
69 Check(r.passTime==PassTime::Seeded&&SuitableInitialPass(Solve(in,r)),"OVERFLY initial PASS is available while docked");
70 Executor ex;Check(!ex.Begin(in,r,Solve(in,r)).valid,"docked overfly remains non-executable");
71 in.dockedAtStation=false;
72 Check(Solve(in,r).status==L"NO DEPARTURE STATE","contained or invalid frames do not gain docked planning permission");
73}
Plan Solve(const Input &in, const Request &r, bool geometry)
Definition OrbitEntry.h:332
bool SuitableInitialPass(const Snapshot &s)
Definition OrbitModel.h:360
Vec Rotate(Vec v, Vec axis, double angle)
Definition OrbitMath.h:22
double Norm(Vec a)
Definition OrbitMath.h:18
std::vector< Sample > path
Definition OrbitState.h:240