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