All Classes Functions
PEG.h
1 /* This pitch calculation program is derived from the work of NASA (PEG method) and kwan3217 (PEG autopilot)
2 Rewriting and integration into LaunchMFD was done by Steve Arch (agentgonzo) */
3 
4 // ==============================================================
5 // ORBITER MODULE: LaunchMFD
6 // Part of the ORBITER SDK
7 //
8 // Copyright (C) 2004 rjcroy - robust time based pitch autopilot (borrowed code)
9 // Copyright (C) 2004 Dave "Daver" Rowbotham - conversion of rjcroy's autopolot to C++ (borrowed code)
10 // Copyright (C) 2004 Erik H. "Sputnik" Anderson - conversion of the autopilot to energy based (borrowed code)
11 // Copyright (C) 2007 "Vanguard" - dressing up azimuth calcualtions into an MFD (author)
12 // Copyright (C) 2007 Pawel "She'da'Lier" Stiasny - yaw error visual representation (contributor)
13 // Copyright (C) 2008 Mohd "Computerex" Ali - borrowed his code (multiple vessels support) (borrowed code)
14 // Copyright (C) 2008 Chris "Kwan" Jeppesen - borrowed his code (peg guidance) (borrowed code)
15 // Copyright (C) 2008 Steve "agentgonzo" Arch - peg integration, offplane correction, compass, hud display (co-developer)
16 // Copyright (C) 2007-2012 Szymon "Enjo" Ender - everything else ;> (author and maintainer)
17 // All rights reserved
18 //
19 // peg.h - Main MFD class
20 // Authors - NASA (PEG method), Chris "Kwan" Jeppesen (PEG autopilot),
21 // Steve "agentgonzo" Arch (integration into LaunchMFD)
22 //
23 // This module calculates the appropriate launch azimuth given
24 // desired orbital inclination and desired orbit altitude. This
25 // MFD takes the planets rotation into account, which provides a
26 // much more accurate azimuth. The calculations are performed
27 // 'on the fly' (technically and methaphorically), meaning that
28 // you get info about necessary course corrections.
29 //
30 // This file is part of LaunchMFD.
31 //
32 // LaunchMFD is free software: you can redistribute it and/or modify
33 // it under the terms of the GNU General Public License as published by
34 // the Free Software Foundation, either version 3 of the License, or
35 // (at your option) any later version.
36 //
37 // LaunchMFD is distributed in the hope that it will be useful,
38 // but WITHOUT ANY WARRANTY; without even the implied warranty of
39 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 // GNU General Public License for more details.
41 //
42 // You should have received a copy of the GNU General Public License
43 // along with LaunchMFD. If not, see <http://www.gnu.org/licenses/>.
44 // ==============================================================
45 
46 #pragma once
47 
48 #include "Orbitersdk.h"
49 #include "../PitchGuidance.h"
50 #include "../Utils/Engine.hpp"
51 
52 struct TGTPARAM;
53 
54 class PEG : public PitchGuidance
55 {
56 public:
57  PEG( const VESSEL * v);
58  virtual ~PEG();
59  bool IsValid()
60  {
61  return valid;
62  };
63  virtual double GetTargetPitch();
64  void SetApses(double PeAlt, double ApAlt);
65  double GetTMECO() const;
66  double GetDeltaTheta() const;
67 
68 protected:
69  virtual Engine GetEngineCapabilities(const VESSEL * v) const = 0;
70  const VESSEL * vessel;
71 
72 private:
73  bool valid;
74 
75  // From PEGAutopilot
76  double a(double t);
77  double b0(double T);
78  double bn(double T, int n);
79  double c0(double T);
80  double cn(double T, int n);
81 
82  void Navigate();
83  void Estimate();
84  void Guide();
85  void Init();
86 
87  //Targeting variables
88  double raTarget,rpTarget,eTarget,hpTarget,haTarget,taTarget;
89  //Navigation variables
90  double r,h,omega;
91  double vr,vh;
92 
93  double mu,g;
94  double met;
95  double a0,tau;
96  Engine eng;
97 
98  //Estimation variables
99  double rT,vrT,T,p,aOrbit,metCutoff;
100  double A,B;
101  double CmdPDot, CmdP;
102  double target_pitch,last_target_pitch;
103  double TMajorCycle;
104  double deltatheta;
105  double t0; // reference time: designated liftoff time
106 };