JSBSim Flight Dynamics Model 1.3.0 (09 Apr 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGTrimAxis Class Reference

Detailed Description

Definition at line 86 of file FGTrimAxis.h.

+ Inheritance diagram for FGTrimAxis:
+ Collaboration diagram for FGTrimAxis:

Public Member Functions

 FGTrimAxis (FGFDMExec *fdmex, FGInitialCondition *IC, State state, Control control)
 Constructor for Trim Axis class.
 
 ~FGTrimAxis ()
 Destructor.
 
void AxisReport (void)
 
double GetAvgStability (void)
 
double GetControl (void)
 
double GetControlMax (void)
 
double GetControlMin (void)
 
std::string GetControlName (void)
 
Control GetControlType (void)
 
int GetIterationLimit (void)
 
int GetRunCount (void)
 
double GetSolverEps (void)
 
int GetStability (void)
 
double GetState (void)
 
std::string GetStateName (void)
 
double GetStateTarget (void)
 
State GetStateType (void)
 
double GetTolerance (void)
 
bool InTolerance (void)
 
void Run (void)
 This function iterates through a call to the FGFDMExec::RunIC() function until the desired trimming condition falls inside a tolerance.
 
void SetControl (double value)
 
void SetControlLimits (double min, double max)
 
void SetControlToMax (void)
 
void SetControlToMin (void)
 
void SetIterationLimit (int ii)
 
void SetSolverEps (double ff)
 
void SetStateTarget (double target)
 
void SetTolerance (double ff)
 
- Public Member Functions inherited from FGJSBBase
 FGJSBBase ()
 Constructor for FGJSBBase.
 
virtual ~FGJSBBase ()
 Destructor for FGJSBBase.
 
void disableHighLighting (void)
 Disables highlighting in the console output.
 

Additional Inherited Members

- Public Types inherited from FGJSBBase
enum  { eL = 1 , eM , eN }
 Moments L, M, N. More...
 
enum  { eP = 1 , eQ , eR }
 Rates P, Q, R. More...
 
enum  { eU = 1 , eV , eW }
 Velocities U, V, W. More...
 
enum  { eX = 1 , eY , eZ }
 Positions X, Y, Z. More...
 
enum  { ePhi = 1 , eTht , ePsi }
 Euler angles Phi, Theta, Psi. More...
 
enum  { eDrag = 1 , eSide , eLift }
 Stability axis forces, Drag, Side force, Lift. More...
 
enum  { eRoll = 1 , ePitch , eYaw }
 Local frame orientation Roll, Pitch, Yaw. More...
 
enum  { eNorth = 1 , eEast , eDown }
 Local frame position North, East, Down. More...
 
enum  { eLat = 1 , eLong , eRad }
 Locations Radius, Latitude, Longitude. More...
 
enum  {
  inNone = 0 , inDegrees , inRadians , inMeters ,
  inFeet
}
 Conversion specifiers. More...
 
- Static Public Member Functions inherited from FGJSBBase
static const std::string & GetVersion (void)
 Returns the version number of JSBSim.
 
static constexpr double KelvinToFahrenheit (double kelvin)
 Converts from degrees Kelvin to degrees Fahrenheit.
 
static constexpr double CelsiusToRankine (double celsius)
 Converts from degrees Celsius to degrees Rankine.
 
static constexpr double RankineToCelsius (double rankine)
 Converts from degrees Rankine to degrees Celsius.
 
static constexpr double KelvinToRankine (double kelvin)
 Converts from degrees Kelvin to degrees Rankine.
 
static constexpr double RankineToKelvin (double rankine)
 Converts from degrees Rankine to degrees Kelvin.
 
static constexpr double FahrenheitToCelsius (double fahrenheit)
 Converts from degrees Fahrenheit to degrees Celsius.
 
static constexpr double CelsiusToFahrenheit (double celsius)
 Converts from degrees Celsius to degrees Fahrenheit.
 
static constexpr double CelsiusToKelvin (double celsius)
 Converts from degrees Celsius to degrees Kelvin.
 
static constexpr double KelvinToCelsius (double kelvin)
 Converts from degrees Kelvin to degrees Celsius.
 
static constexpr double FeetToMeters (double measure)
 Converts from feet to meters.
 
static bool EqualToRoundoff (double a, double b)
 Finite precision comparison.
 
static bool EqualToRoundoff (float a, float b)
 Finite precision comparison.
 
static bool EqualToRoundoff (float a, double b)
 Finite precision comparison.
 
static bool EqualToRoundoff (double a, float b)
 Finite precision comparison.
 
static constexpr double Constrain (double min, double value, double max)
 Constrain a value between a minimum and a maximum value.
 
static constexpr double sign (double num)
 
- Static Public Attributes inherited from FGJSBBase
static char highint [5] = {27, '[', '1', 'm', '\0' }
 highlights text
 
static char halfint [5] = {27, '[', '2', 'm', '\0' }
 low intensity text
 
static char normint [6] = {27, '[', '2', '2', 'm', '\0' }
 normal intensity text
 
static char reset [5] = {27, '[', '0', 'm', '\0' }
 resets text properties
 
static char underon [5] = {27, '[', '4', 'm', '\0' }
 underlines text
 
static char underoff [6] = {27, '[', '2', '4', 'm', '\0' }
 underline off
 
static char fgblue [6] = {27, '[', '3', '4', 'm', '\0' }
 blue text
 
static char fgcyan [6] = {27, '[', '3', '6', 'm', '\0' }
 cyan text
 
static char fgred [6] = {27, '[', '3', '1', 'm', '\0' }
 red text
 
static char fggreen [6] = {27, '[', '3', '2', 'm', '\0' }
 green text
 
static char fgdef [6] = {27, '[', '3', '9', 'm', '\0' }
 default text
 
static short debug_lvl = 1
 
- Static Protected Member Functions inherited from FGJSBBase
static std::string CreateIndexedPropertyName (const std::string &Property, int index)
 
- Static Protected Attributes inherited from FGJSBBase
static constexpr double radtodeg = 180. / M_PI
 
static constexpr double degtorad = M_PI / 180.
 
static constexpr double hptoftlbssec = 550.0
 
static constexpr double psftoinhg = 0.014138
 
static constexpr double psftopa = 47.88
 
static constexpr double fttom = 0.3048
 
static constexpr double ktstofps = 1852./(3600*fttom)
 
static constexpr double fpstokts = 1.0 / ktstofps
 
static constexpr double inchtoft = 1.0/12.0
 
static constexpr double m3toft3 = 1.0/(fttom*fttom*fttom)
 
static constexpr double in3tom3 = inchtoft*inchtoft*inchtoft/m3toft3
 
static constexpr double inhgtopa = 3386.38
 
static constexpr double slugtolb = 32.174049
 Note that definition of lbtoslug by the inverse of slugtolb and not to a different constant you can also get from some tables will make lbtoslug*slugtolb == 1 up to the magnitude of roundoff.
 
static constexpr double lbtoslug = 1.0/slugtolb
 
static constexpr double kgtolb = 2.20462
 
static constexpr double kgtoslug = 0.06852168
 
static const std::string needed_cfg_version = "2.0"
 
static const std::string JSBSim_version = JSBSIM_VERSION " " __DATE__ " " __TIME__
 

Constructor & Destructor Documentation

◆ FGTrimAxis()

FGTrimAxis ( FGFDMExec fdmex,
FGInitialCondition IC,
State  state,
Control  control 
)

Constructor for Trim Axis class.

Parameters
fdmexFGFDMExec pointer
ICpointer to initial conditions instance
statea State type (enum)
controla Control type (enum)

Definition at line 63 of file FGTrimAxis.cpp.

64 {
65
66 fdmex=fdex;
67 fgic=ic;
68 state=st;
69 control=ctrl;
70 max_iterations=10;
71 control_value=0;
72 its_to_stable_value=0;
73 total_iterations=0;
74 total_stability_iterations=0;
75 state_convert=1.0;
76 control_convert=1.0;
77 state_value=0;
78 state_target=0;
79 tolerance=DEFAULT_TOLERANCE;
80 switch(state) {
81 case tUdot: tolerance = DEFAULT_TOLERANCE; break;
82 case tVdot: tolerance = DEFAULT_TOLERANCE; break;
83 case tWdot: tolerance = DEFAULT_TOLERANCE; break;
84 case tQdot: tolerance = DEFAULT_TOLERANCE / 10; break;
85 case tPdot: tolerance = DEFAULT_TOLERANCE / 10; break;
86 case tRdot: tolerance = DEFAULT_TOLERANCE / 10; break;
87 case tHmgt: tolerance = 0.01; break;
88 case tNlf: state_target=1.0; tolerance = 1E-5; break;
89 case tAll: break;
90 }
91
92 solver_eps=tolerance;
93 switch(control) {
94 case tThrottle:
95 control_min=0;
96 control_max=1;
97 control_value=0.5;
98 break;
99 case tBeta:
100 control_min=-30*degtorad;
101 control_max=30*degtorad;
102 control_convert=radtodeg;
103 break;
104 case tAlpha:
105 control_min=fdmex->GetAerodynamics()->GetAlphaCLMin();
106 control_max=fdmex->GetAerodynamics()->GetAlphaCLMax();
107 if(control_max <= control_min) {
108 control_max=20*degtorad;
109 control_min=-5*degtorad;
110 }
111 control_value= (control_min+control_max)/2;
112 control_convert=radtodeg;
113 solver_eps=tolerance/100;
114 break;
115 case tPitchTrim:
116 case tElevator:
117 case tRollTrim:
118 case tAileron:
119 case tYawTrim:
120 case tRudder:
121 control_min=-1;
122 control_max=1;
123 state_convert=radtodeg;
124 solver_eps=tolerance/100;
125 break;
126 case tAltAGL:
127 control_min=0;
128 control_max=30;
129 control_value=ic->GetAltitudeAGLFtIC();
130 solver_eps=tolerance/100;
131 break;
132 case tTheta:
133 control_min=ic->GetThetaRadIC() - 5*degtorad;
134 control_max=ic->GetThetaRadIC() + 5*degtorad;
135 state_convert=radtodeg;
136 break;
137 case tPhi:
138 control_min=ic->GetPhiRadIC() - 30*degtorad;
139 control_max=ic->GetPhiRadIC() + 30*degtorad;
140 state_convert=radtodeg;
141 control_convert=radtodeg;
142 break;
143 case tGamma:
144 solver_eps=tolerance/100;
145 control_min=-80*degtorad;
146 control_max=80*degtorad;
147 control_convert=radtodeg;
148 break;
149 case tHeading:
150 control_min=ic->GetPsiRadIC() - 30*degtorad;
151 control_max=ic->GetPsiRadIC() + 30*degtorad;
152 state_convert=radtodeg;
153 break;
154 }
155
156
157 Debug(0);
158}
std::shared_ptr< FGAerodynamics > GetAerodynamics(void) const
Returns the FGAerodynamics pointer.
+ Here is the call graph for this function:

◆ ~FGTrimAxis()

~FGTrimAxis ( void  )

Destructor.

Definition at line 162 of file FGTrimAxis.cpp.

163{
164 Debug(1);
165}

Member Function Documentation

◆ AxisReport()

void AxisReport ( void  )

Definition at line 295 of file FGTrimAxis.cpp.

295 {
296 FGLogging out(LogLevel::STDOUT);
297 out << " " << left << setw(20) << GetControlName() << ": ";
298 out << setw(6) << setprecision(2) << GetControl()*control_convert << ' ';
299 out << setw(5) << GetStateName() << ": ";
300 out << setw(9) << setprecision(2) << scientific << GetState()+state_target;
301 out << " Tolerance: " << setw(3) << setprecision(0) << scientific << GetTolerance();
302
303 if( fabs(GetState()+state_target) < fabs(GetTolerance()) )
304 out << " Passed\n";
305 else
306 out << " Failed\n";
307}

◆ GetAvgStability()

double GetAvgStability ( void  )

Definition at line 311 of file FGTrimAxis.cpp.

311 {
312 if(total_iterations > 0) {
313 return double(total_stability_iterations)/double(total_iterations);
314 }
315 return 0;
316}

◆ GetControl()

double GetControl ( void  )
inline

Definition at line 108 of file FGTrimAxis.h.

108{ return control_value; }

◆ GetControlMax()

double GetControlMax ( void  )
inline

Definition at line 117 of file FGTrimAxis.h.

117{ return control_max; }

◆ GetControlMin()

double GetControlMin ( void  )
inline

Definition at line 116 of file FGTrimAxis.h.

116{ return control_min; }

◆ GetControlName()

std::string GetControlName ( void  )
inline

Definition at line 114 of file FGTrimAxis.h.

114{ return ControlNames[control]; }

◆ GetControlType()

Control GetControlType ( void  )
inline

Definition at line 111 of file FGTrimAxis.h.

111{ return control; }

◆ GetIterationLimit()

int GetIterationLimit ( void  )
inline

Definition at line 133 of file FGTrimAxis.h.

133{ return max_iterations; }

◆ GetRunCount()

int GetRunCount ( void  )
inline

Definition at line 137 of file FGTrimAxis.h.

137{ return total_stability_iterations; }

◆ GetSolverEps()

double GetSolverEps ( void  )
inline

Definition at line 130 of file FGTrimAxis.h.

130{ return solver_eps; }

◆ GetStability()

int GetStability ( void  )
inline

Definition at line 136 of file FGTrimAxis.h.

136{ return its_to_stable_value; }

◆ GetState()

double GetState ( void  )
inline

Definition at line 105 of file FGTrimAxis.h.

105{ getState(); return state_value; }

◆ GetStateName()

std::string GetStateName ( void  )
inline

Definition at line 113 of file FGTrimAxis.h.

113{ return StateNames[state]; }

◆ GetStateTarget()

double GetStateTarget ( void  )
inline

Definition at line 141 of file FGTrimAxis.h.

141{ return state_target; }

◆ GetStateType()

State GetStateType ( void  )
inline

Definition at line 110 of file FGTrimAxis.h.

110{ return state; }

◆ GetTolerance()

double GetTolerance ( void  )
inline

Definition at line 128 of file FGTrimAxis.h.

128{ return tolerance; }

◆ InTolerance()

bool InTolerance ( void  )
inline

Definition at line 145 of file FGTrimAxis.h.

145{ getState(); return (fabs(state_value) <= tolerance); }

◆ Run()

void Run ( void  )

This function iterates through a call to the FGFDMExec::RunIC() function until the desired trimming condition falls inside a tolerance.

Definition at line 248 of file FGTrimAxis.cpp.

248 {
249
250 double last_state_value;
251 int i;
252 setControl();
253 //FGLogging log(LogLevel::INFO);
254 //log << "FGTrimAxis::Run: " << control_value << "\n";
255 i=0;
256 bool stable=false;
257 while(!stable) {
258 i++;
259 last_state_value=state_value;
260 fdmex->Initialize(fgic);
261 fdmex->Run();
262 getState();
263 if(i > 1) {
264 if((fabs(last_state_value - state_value) < tolerance) || (i >= 100) )
265 stable=true;
266 }
267 }
268
269 its_to_stable_value=i;
270 total_stability_iterations+=its_to_stable_value;
271 total_iterations++;
272}
bool Run(void)
This function executes each scheduled model in succession.
void Initialize(const FGInitialCondition *FGIC)
Initializes the simulation with initial conditions.
+ Here is the call graph for this function:

◆ SetControl()

void SetControl ( double  value)
inline

Definition at line 107 of file FGTrimAxis.h.

107{ control_value=value; }

◆ SetControlLimits()

void SetControlLimits ( double  min,
double  max 
)
inline

Definition at line 122 of file FGTrimAxis.h.

122 {
123 control_min=min;
124 control_max=max;
125 }

◆ SetControlToMax()

void SetControlToMax ( void  )
inline

Definition at line 120 of file FGTrimAxis.h.

120{ control_value=control_max; }

◆ SetControlToMin()

void SetControlToMin ( void  )
inline

Definition at line 119 of file FGTrimAxis.h.

119{ control_value=control_min; }

◆ SetIterationLimit()

void SetIterationLimit ( int  ii)
inline

Definition at line 134 of file FGTrimAxis.h.

134{ max_iterations=ii; }

◆ SetSolverEps()

void SetSolverEps ( double  ff)
inline

Definition at line 131 of file FGTrimAxis.h.

131{ solver_eps=ff; }

◆ SetStateTarget()

void SetStateTarget ( double  target)
inline

Definition at line 140 of file FGTrimAxis.h.

140{ state_target=target; }

◆ SetTolerance()

void SetTolerance ( double  ff)
inline

Definition at line 127 of file FGTrimAxis.h.

127{ tolerance=ff;}

The documentation for this class was generated from the following files: