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

FGTrimAxis Class Reference

Inheritance diagram for FGTrimAxis:
Collaboration diagram for FGTrimAxis:

List of all members.

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)
string GetControlName (void)
Control GetControlType (void)
int GetIterationLimit (void)
int GetRunCount (void)
double GetSolverEps (void)
int GetStability (void)
double GetState (void)
string GetStateName (void)
double GetStateTarget (void)
State GetStateType (void)
double GetTolerance (void)
bool initTheta (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 SetPhiOnGround (double ff)
void SetSolverEps (double ff)
void SetStateTarget (double target)
void SetThetaOnGround (double ff)
void SetTolerance (double ff)

Detailed Description

Definition at line 89 of file FGTrimAxis.h.


Constructor & Destructor Documentation

FGTrimAxis ( FGFDMExec fdmex,
FGInitialCondition IC,
State  state,
Control  control 
)
Parameters:
fdmexFGFDMExec pointer
ICpointer to initial conditions instance
statea State type (enum)
controla Control type (enum)

Definition at line 64 of file FGTrimAxis.cpp.

                                     {

  fdmex=fdex;
  fgic=ic;
  state=st;
  control=ctrl;
  max_iterations=10;
  control_value=0;
  its_to_stable_value=0;
  total_iterations=0;
  total_stability_iterations=0;
  state_convert=1.0;
  control_convert=1.0;
  state_value=0;
  state_target=0;
  switch(state) {
    case tUdot: tolerance = DEFAULT_TOLERANCE; break;
    case tVdot: tolerance = DEFAULT_TOLERANCE; break;
    case tWdot: tolerance = DEFAULT_TOLERANCE; break;
    case tQdot: tolerance = DEFAULT_TOLERANCE / 10; break;
    case tPdot: tolerance = DEFAULT_TOLERANCE / 10; break;
    case tRdot: tolerance = DEFAULT_TOLERANCE / 10; break;
    case tHmgt: tolerance = 0.01; break;
    case  tNlf: state_target=1.0; tolerance = 1E-5; break;
    case tAll: break;
  }

  solver_eps=tolerance;
  switch(control) {
  case tThrottle:
    control_min=0;
    control_max=1;
    control_value=0.5;
    break;
  case tBeta:
    control_min=-30*degtorad;
    control_max=30*degtorad;
    control_convert=radtodeg;
    break;
  case tAlpha:
    control_min=fdmex->GetAerodynamics()->GetAlphaCLMin();
    control_max=fdmex->GetAerodynamics()->GetAlphaCLMax();
    if(control_max <= control_min) {
      control_max=20*degtorad;
      control_min=-5*degtorad;
    }
    control_value= (control_min+control_max)/2;
    control_convert=radtodeg;
    solver_eps=tolerance/100;
    break;
  case tPitchTrim:
  case tElevator:
  case tRollTrim:
  case tAileron:
  case tYawTrim:
  case tRudder:
    control_min=-1;
    control_max=1;
    state_convert=radtodeg;
    solver_eps=tolerance/100;
    break;
  case tAltAGL:
    control_min=0;
    control_max=30;
    control_value=fdmex->GetPropagate()->GetDistanceAGL();
    solver_eps=tolerance/100;
    break;
  case tTheta:
    control_min=fdmex->GetPropagate()->GetEuler(eTht) - 5*degtorad;
    control_max=fdmex->GetPropagate()->GetEuler(eTht) + 5*degtorad;
    state_convert=radtodeg;
    break;
  case tPhi:
    control_min=fdmex->GetPropagate()->GetEuler(ePhi) - 30*degtorad;
    control_max=fdmex->GetPropagate()->GetEuler(ePhi) + 30*degtorad;
    state_convert=radtodeg;
    control_convert=radtodeg;
    break;
  case tGamma:
    solver_eps=tolerance/100;
    control_min=-80*degtorad;
    control_max=80*degtorad;
    control_convert=radtodeg;
    break;
  case tHeading:
    control_min=fdmex->GetPropagate()->GetEuler(ePsi) - 30*degtorad;
    control_max=fdmex->GetPropagate()->GetEuler(ePsi) + 30*degtorad;
    state_convert=radtodeg;
    break;
  }


  Debug(0);
}

Member Function Documentation

void Run ( void  )

Definition at line 397 of file FGTrimAxis.cpp.

                         {

  double last_state_value;
  int i;
  setControl();
  //cout << "FGTrimAxis::Run: " << control_value << endl;
  i=0;
  bool stable=false;
  while(!stable) {
    i++;
    last_state_value=state_value;
    fdmex->Initialize(fgic);
    fdmex->Run();
    getState();
    if(i > 1) {
      if((fabs(last_state_value - state_value) < tolerance) || (i >= 100) )
        stable=true;
    }
  }

  its_to_stable_value=i;
  total_stability_iterations+=its_to_stable_value;
  total_iterations++;
}

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