All Classes Functions
PIDAP.hpp
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 - Szymon "Enjo" Ender
17 //
18 // This module calculates the appropriate launch azimuth given
19 // desired orbital inclination and desired orbit altitude. This
20 // MFD takes the planets rotation into account, which provides a
21 // much more accurate azimuth. The calculations are performed
22 // 'on the fly' (technically and methaphorically), meaning that
23 // you get info about necessary course corrections.
24 //
25 // This file is part of LaunchMFD.
26 //
27 // LaunchMFD is free software: you can redistribute it and/or modify
28 // it under the terms of the GNU General Public License as published by
29 // the Free Software Foundation, either version 3 of the License, or
30 // (at your option) any later version.
31 //
32 // LaunchMFD is distributed in the hope that it will be useful,
33 // but WITHOUT ANY WARRANTY; without even the implied warranty of
34 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 // GNU General Public License for more details.
36 //
37 // You should have received a copy of the GNU General Public License
38 // along with LaunchMFD. If not, see <http://www.gnu.org/licenses/>.
39 // ==============================================================
40 
41 #ifndef PIDAP_HPP_INCLUDED
42 #define PIDAP_HPP_INCLUDED
43 
44 #include <orbitersdk.h>
45 #include "../../lib/PID/PID.hpp"
46 #include "../../lib/Systems/Vect3.hpp"
47 
48 class PIDAP
49 {
50 public:
51  PIDAP( const VESSEL * vessel );
52  virtual ~PIDAP();
53  void Reset();
54  VECTOR3 GetVesselAngularAccelerationRatio( const VESSEL * vessel );
55 
56  EnjoLib::PID m_pidAPSpaceX;
57  EnjoLib::PID m_pidAPSpaceY;
58  EnjoLib::PID m_pidAPSpaceBank;
59 
60  EnjoLib::PID m_pidAPAtmX;
61  EnjoLib::PID m_pidAPAtmY;
62  EnjoLib::PID m_pidAPAtmBankTarget;
63  EnjoLib::PID m_pidAPAtmBankWingsLevel;
64 
65  EnjoLib::PID m_pidEngDA; // Engine PID
66 
67  void SetSpaceXY( const EnjoLib::PID & pid );
68  void SetSpaceBank( const EnjoLib::PID & pid );
69  void SetAtmoXY( const EnjoLib::PID & pid );
70  void SetAtmoBank( const EnjoLib::PID & pid );
71 
72  double GetReferenceKdForAtmo() const;
73  const double GetAtmXYContinuousControlSwitch() const;
74  const double GetAtmBankTargetWindsLevelSwitch() const;
75  double GetRollAlt() const;
76  bool IsUpsideDown() const;
77  bool IsRollNeeded() const;
78  void SaveConfig( FILEHANDLE fhVar ) const;
79 
80  bool m_prevNeededPitch;
81  // For direct ascent
82  double prevDeltaT;
83  double timeOfSynchroBurn;
84  double dvReallyUsedSynchro;
85 
86 private:
87  void ReadVesselPIDConfig( const VESSEL * vessel );
88  EnjoLib::PID CreatePID( const VECTOR3 & vect ) const;
89  VECTOR3 PID2Vector( const EnjoLib::PID & pid ) const;
90 
91  double m_refKdAtmo; // maximal Kd in thin atmosphere
92  bool m_rotationRatioNeeded;
93  double m_atmXYContinuousControlSwitch;
94  double m_atmBankTargetWindsLevelSwitch;
95  double m_rollAlt;
96  bool m_upsideDown; // Implies roll
97  bool m_rollNeeded;
98 
99 
100 
101  const static EnjoLib::Vect3 m_statDeltaGliderRefRotAcc; // reference pitch, yaw and bank angular accelerations
102 };
103 
104 #endif // PIDAP_HPP_INCLUDED