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

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

1#pragma once
2#include "../Modules/OrbitAscentProfile.h"
3
4void AscentProfileTests() {
5 AscentHistory history;constexpr double radius=2939.6;
6 history.Begin({radius,0,0},radius,100);
7 for(int j=1;j<=100;++j)history.Add({radius+j*.01,0,0},radius,100+j*.2);
8 auto path=history.Path();
9 Check(path.size()>=5&&path.back().distanceKm==0&&std::abs(path.back().altitudeKm-1)<1e-8,
10 "VTOL records vertical progress at zero ground distance without REC");
11 history.Add({0,radius+1,0},radius,121);
12 Check(std::abs(history.Distance()-radius*Pi/2)<1e-8,"distance uses surface arc rather than slant distance at altitude");
13 const double distance=history.Distance();history.Add({0,0,radius},radius,120);
14 Check(history.Distance()==distance,"reversed time cannot append a false profile segment");
15 history.Begin({radius,0,0},radius,0);
16 for(int j=1;j<=30000;++j)history.Add(Rotate({radius,0,0},{0,0,1},j/radius),radius,j);
17 path=history.Path();
18 Check(path.size()<=4096&&path.front().distanceKm==0&&std::abs(path.back().distanceKm-30000)<1e-6,
19 "bounded history preserves departure and live endpoint across multiple laps");
20
21 auto in=LaunchFixture();Request request;request.ascent=true;request.ascentOrbitSteering=true;request.ascentWait=false;
22 {
23 auto weak=in;weak.onGround=false;weak.freeFlight=true;weak.aglKm=66;
24 weak.own.r={0,weak.radius+66.574,0};weak.own.v=Cross({0,0,weak.spin},weak.own.r)+Vec{0,.34,2.54};
25 weak.entryVehicle.airVelocity=weak.own.v-Cross({0,0,weak.spin},weak.own.r);
26 weak.entryVehicle.aeroAcceleration={};weak.entryVehicle.aeroValid=true;
27 Ascent::Controller control;const auto command=control.Step(weak,200,{0,0,1},.2);
28 Check(command.valid&&command.aircraft&&command.bankLimit==0&&
29 std::wstring(command.status)==L"HDG LIMITED / RCS PIT",
30 "thin-air climb exposes unavailable banked heading authority while retaining pitch assistance");
31 }
32 request.arrivalEpoch=in.now+7200;in.targetKind=TargetKind::None;
33 AscentProfileDisplay display;Snapshot snapshot=Solve(in,request);
34 for(int n=0;n<300;++n) {
35 display.Update(in,request,{},true);display.Publish(snapshot,in.now,true);
36 if(!snapshot.ascentProfile.pending)break;
37 }
38 const auto plan=snapshot.ascentProfile.plan;
39 Check(plan.size()>100&&plan.front().distanceKm==0&&plan.back().distanceKm>100&&plan.back().altitudeKm>190,
40 "parking orbit without target has a complete powered ascent plan");
41 Check(plan.size()<=4096&&!snapshot.ascentProfile.pending,"powered profile computation terminates within bounded work");
42 const auto launch=in;
43 in.onGround=false;in.freeFlight=true;in.now+=1;in.own.r=Unit(in.own.r)*(in.radius+1);
44 display.Update(in,request,{},true);display.Publish(snapshot,in.now,true);
45 Check(snapshot.ascentProfile.actual.size()==2&&snapshot.ascentProfile.actual.back().distanceKm<1e-8,
46 "vertical liftoff retains departure origin");
47 in.now+=10;in.own.r=Rotate(Unit(in.own.r)*(in.radius+10),{0,0,1},.01);
48 display.Update(in,request,{},true);display.Publish(snapshot,in.now,true);
49 Check(snapshot.ascentProfile.actual.back().distanceKm>25&&snapshot.ascentProfile.plan.back().distanceKm==plan.back().distanceKm,
50 "airborne history grows while the departure forecast stays fixed");
51 auto picture=Plot(snapshot,View::Orbit);
52 auto has=[&](const wchar_t* text) {return std::any_of(picture.labels.begin(),picture.labels.end(),[&](const Label& a){return a.text==text;});};
53 Check(has(L"GROUND DISTANCE (km)")&&has(L"ALT km MSL")&&has(L"ACTUAL")&&has(L"PLAN EST"),
54 "ascent explicitly labels both axes and distinguishes measured history from forecast");
55 Check(AscentView(snapshot,View::Orbit)&&!AscentView(snapshot,View::Track),"full ascent profile retains selectable orbital/track views");
56 Preview(in,request,"ascent-profile",nullptr,nullptr,&snapshot.ascentProfile);
57 display.Update(in,request,{},true,true);display.Publish(snapshot,in.now,true);
58 Check(snapshot.ascentProfile.pickup&&snapshot.ascentProfile.actual.front().distanceKm==0&&snapshot.ascentProfile.actual.size()==1,
59 "vehicle/simulator/teleport reset starts clearly labeled airborne pickup");
60 in=launch;in.now+=100;display.Update(in,request,{},true);display.Publish(snapshot,in.now,true);
61 Check(!snapshot.ascentProfile.pickup&&snapshot.ascentProfile.actual.size()==1&&snapshot.ascentProfile.actual.front().distanceKm==0,
62 "landing resets history for the next departure and discards airborne baseline");
63 in.own.r=Rotate(in.own.r,{0,0,1},.01);in.now+=5;
64 display.Update(in,request,{},true);display.Publish(snapshot,in.now,true);
65 Check(snapshot.ascentProfile.actual.size()==1&&snapshot.ascentProfile.actual.front().distanceKm==0,"taxi is excluded from departure distance");
66 std::cout<<"Ascent altitude/distance profile: "<<plan.size()<<" planned points, insertion at "<<plan.back().distanceKm<<" km\n";
67}
bool Unit(Vector3 &v)
ArrivalPreview Preview(const Input &in, const Request &r)
Plan Solve(const Input &in, const Request &r, bool geometry)
Definition OrbitEntry.h:332
Vec Rotate(Vec v, Vec axis, double angle)
Definition OrbitMath.h:22
bool AscentView(const Snapshot &s, View view)
Picture Plot(const Snapshot &s, View view)
Vec Cross(Vec a, Vec b)
Definition OrbitMath.h:17
path
Definition erin.py:153