JSBSim Flight Dynamics Model 1.0 (23 February 2013)
An Open Source Flight Dynamics and Control Software Library in C++

FGTrimAnalysisControl.h

00001 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00002 
00003  Header:       FGTrimAnalysisControl.h
00004  Author:       Agostino De Marco
00005  Date started: Dec/14/2006
00006 
00007  ------------- Copyright (C) 2006  Agostino De Marco (agodemar@unina.it) -------
00008 
00009  This program is free software; you can redistribute it and/or modify it under
00010  the terms of the GNU Lesser General Public License as published by the Free Software
00011  Foundation; either version 2 of the License, or (at your option) any later
00012  version.
00013 
00014  This program is distributed in the hope that it will be useful, but WITHOUT
00015  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00016  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00017  details.
00018 
00019  You should have received a copy of the GNU Lesser General Public License along with
00020  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021  Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023  Further information about the GNU Lesser General Public License can also be found on
00024  the world wide web at http://www.gnu.org.
00025 
00026 
00027  HISTORY
00028 --------------------------------------------------------------------------------
00029 12/14/06   ADM   Created
00030 
00031 
00032 FUNCTIONAL DESCRIPTION
00033 --------------------------------------------------------------------------------
00034 
00035 
00036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00037 SENTRY
00038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00039 
00040 #ifndef FGTRIMANALYSISCONTROL_H
00041 #define FGTRIMANALYSISCONTROL_H
00042 
00043 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00044 INCLUDES
00045 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00046 
00047 #include <string>
00048 
00049 #include "FGFDMExec.h"
00050 #include "FGJSBBase.h"
00051 #include "initialization/FGInitialCondition.h"
00052 
00053 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00054 DEFINITIONS
00055 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00056 
00057 #define ID_TRIMANALYSISCONTROL "$Id: FGTrimAnalysisControl.h,v 1.2 2009/10/02 10:30:09 jberndt Exp $"
00058 
00059 #define DEFAULT_TRIM_ANALYSIS_TOLERANCE 0.00000001
00060 
00061 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00062 FORWARD DECLARATIONS
00063 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00064 
00065 namespace JSBSim {
00066 
00067 class FGInitialCondition;
00068 
00072 enum TaState { taAll,taUdot,taVdot,taWdot,taQdot,taPdot,taRdot,taHmgt,taNlf };
00076 enum TaControl { taThrottle = 0,
00077                  taPitchTrim, taRollTrim, taYawTrim,
00078                  taElevator,  taAileron,  taRudder,
00079                  taPhi, taTheta, taHeading,
00080                  taGamma, taAltAGL, taBeta, taAlpha};
00081 
00082 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00083 CLASS DOCUMENTATION
00084 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00085 
00089 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00090 CLASS DECLARATION
00091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00092 
00093 class FGTrimAnalysisControl : public FGJSBBase
00094 {
00095 public:
00100   FGTrimAnalysisControl(FGFDMExec* fdmex,
00101                         FGInitialCondition *IC,
00102                         //State state,
00103                         TaControl control );
00105   ~FGTrimAnalysisControl();
00106 
00109   void Run(void);
00110 
00111   //double GetState(void) { getState(); return state_value; }
00112   //Accels are not settable
00113 
00117   inline void SetControl(double value ) { control_value=value; }
00118 
00122   inline double GetControl(void) { return control_value; }
00123 
00124   //inline State GetStateType(void) { return state; }
00128   inline TaControl GetControlType(void) { return control; }
00129 
00130   //inline string GetStateName(void) { return StateNames[state]; }
00131 
00135   inline string GetControlName(void) { return control_name; }
00136 
00140   inline double GetControlMin(void) { return control_min; }
00141 inline double GetControlMax(void) { return control_max; }
00145 
00149   inline void SetControlStep(double value) { control_step = value; }
00153   inline double GetControlStep(void) { return control_step; }
00154 
00158   inline void SetControlInitialValue(double value) { control_initial_value = value; }
00159 
00163   inline double GetControlInitialValue(void) { return control_initial_value; }
00164 
00167   inline void SetControlToMin(void) { control_value=control_min; }
00168 
00171   inline void SetControlToMax(void) { control_value=control_max; }
00172 
00177   inline void SetControlLimits(double min, double max) {
00178       control_min=min;
00179       control_max=max;
00180   }
00181 
00185   inline void  SetTolerance(double ff) { control_tolerance=ff;}
00186 
00190   inline double GetTolerance(void) { return control_tolerance; }
00191 
00195   void SetThetaOnGround(double ff);
00196 
00200   void SetPhiOnGround(double ff);
00201 
00205   inline void SetStateTarget(double target) { state_target=target; }
00206 
00210   inline double GetStateTarget(void) { return state_target; }
00211 
00215   bool initTheta(void);
00216 
00217 private:
00218   FGFDMExec *fdmex;
00219   FGInitialCondition *fgic;
00220 
00221   TaState   state;
00222   TaControl control;
00223 
00224   string control_name;
00225 
00226   double state_target;
00227 
00228   double state_value;
00229   double control_value;
00230 
00231   double control_min;
00232   double control_max;
00233 
00234   double control_initial_value;
00235   double control_step;
00236   double control_tolerance;
00237 
00238   double state_convert;
00239   double control_convert;
00240 
00241   void setThrottlesPct(void);
00242 
00243   void getState(void);
00244   void getControl(void);
00245   void setControl(void);
00246 
00247   double computeHmgt(void);
00248 
00249   void Debug(int from);
00250 };
00251 }
00252 #endif