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

FGTrimAnalysis Class Reference

Inheritance diagram for FGTrimAnalysis:
Collaboration diagram for FGTrimAnalysis:

List of all members.

Public Member Functions

 FGTrimAnalysis (FGFDMExec *FDMExec, TrimAnalysisMode tam=taFull)
 Initializes the trimming class.
 ~FGTrimAnalysis (void)
 Destructor.
bool AddControl (TaControl control)
 Add a control to the current configuration.
void CalculatePhiWFromTargetNlfTurn (double nlf)
 Calculate the wind axis bank angle from a given Nlf (sets also the target Nlf)
void ClearControls (void)
 Clear all controls from the current configuration.
void ClearDebug (void)
bool DoTrim (void)
 Execute the trim.
bool EditState (TaControl new_control, double new_initvalue, double new_step, double new_min, double new_max)
 Change the control settings previously configured.
vector< FGTrimAnalysisControl * > * GetControls ()
double GetCostFunctionValue () const
double GetGamma ()
 Return the current flight path angle in TrimAnalysis object.
bool GetGammaFallback (void)
 query the fallback state
double GetGammaRad ()
 Gets flight path angle.
TrimAnalysisMode GetMode () const
double GetPhiRad ()
 Gets Euler angle phi.
double GetPhiWRad ()
 Gets Euler angle phiW (wind axes)
double GetPsiRad ()
 Gets Euler angle psi.
ofstream * GetResultsFile () const
 Get the pointer to the file where trim analysis results are written,.
double GetTargetNlf (void)
 Gets target normal load factor in steady turn.
double GetThetaRad ()
 Gets Euler angle theta.
double GetTolerance (void)
 Get the tolerance for declaring a state trimmed.
bool GetTrimFailed (void)
 Gets trim result status.
double GetVtFps ()
 Gets true speed [fps] from IC.
bool Load (string fname, bool useStoredPath=true)
 Loads the trim configuration from file.
bool RemoveControl (TaControl control)
 Remove a specific control from the current configuration.
void Report (void)
 Print the results of the trim.
void SetCostFunctionValue (double value)
 Set the value of the cost function.
void SetDebug (int level)
 Debug level 1 shows results of each top-level iteration Debug level 2 shows level 1 & results of each per-axis iteration.
void SetDottedValues (double udot, double vdot, double wdot, double pdot, double qdot, double rdot)
 Sets Dotted values.
void SetEulerAngles (double phi0, double theta0, double psi0)
 Sets Euler angles.
void SetGammaFallback (bool bb)
 automatically switch to trimming longitudinal acceleration with flight path angle (gamma) once it becomes apparent that there is not enough/too much thrust.
void SetMaxCycles (int ii)
 Set the iteration limit.
void SetMode (TrimAnalysisMode tam)
 Clear all controls and set a predefined trim mode (Note: controls are intended here as those variables to be adjusted for attaining convergence of the trimming algorithm)
bool SetResultsFile (string name)
 Set the file where trim analysis results are written, open and get ready.
void SetState (double u0, double v0, double w0, double p0, double q0, double r0, double alpha0, double beta0, double phi0, double theta0, double psi0, double gamma0)
 Sets state variables.
void SetTargetNlf (double nlf)
 Sets target normal load factor in steady turn.
void SetTolerance (double tt)
 Set the tolerance for declaring a state trimmed.
void SetTrimFailed (bool tf)
 Sets trim result status.
void SetTrimSuccessfull ()
void TrimStats ()
 Iteration statistics.
FGColumnVector3 UpdateRatesPullup (void)
 Updates angular rates for pull-up trim.
FGColumnVector3 UpdateRatesTurn (double psi, double theta, double phi, double phiW)
 Updates angular rates for turn trim according to turning trim constraints.

Friends

class Objective

Detailed Description

Definition at line 330 of file FGTrimAnalysis.h.


Constructor & Destructor Documentation

FGTrimAnalysis ( FGFDMExec FDMExec,
TrimAnalysisMode  tam = taFull 
)
Parameters:
FDMExecpointer to a JSBSim executive object.
tamtrim mode

Definition at line 321 of file FGTrimAnalysis.cpp.

References FGFDMExec::GetAerodynamics(), FGInitialCondition::GetAlphaRadIC(), FGFDMExec::GetAuxiliary(), FGInitialCondition::GetBetaRadIC(), FGFDMExec::GetFCS(), FGInitialCondition::GetFlightPathAngleRadIC(), FGFDMExec::GetIC(), FGInitialCondition::GetPhiRadIC(), FGInitialCondition::GetPRadpsIC(), FGFDMExec::GetPropulsion(), FGInitialCondition::GetPsiRadIC(), FGInitialCondition::GetQRadpsIC(), FGInitialCondition::GetRRadpsIC(), FGInitialCondition::GetTargetNlfIC(), FGInitialCondition::GetThetaRadIC(), FGInitialCondition::GetUBodyFpsIC(), FGInitialCondition::GetVBodyFpsIC(), FGInitialCondition::GetVtrueFpsIC(), FGInitialCondition::GetWBodyFpsIC(), FGTrimAnalysis::SetDebug(), and FGTrimAnalysis::SetMode().

{
  SetDebug(2);

  N=0;

  trim_failed = true;

  max_iterations=2500;
  stop_criterion="Stop-On-Delta";

  Debug=0;DebugLevel=0;

  fdmex=FDMExec;

  fgic=fdmex->GetIC();
  total_its=0;
  trimudot=true;
  gamma_fallback=true;
  ctrl_count=0;
  mode=tt;
  _targetNlf=1.0;
  _targetNlf=fgic->GetTargetNlfIC();

  _vtIC  = fgic->GetVtrueFpsIC();
  _hIC   = fgic->GetAltitudeFtIC();
  _gamma = fgic->GetFlightPathAngleRadIC();
  _rocIC = _vtIC*cos(_gamma);
  _vdownIC = _rocIC;

  // state variables
  _u       = fgic->GetUBodyFpsIC();
  _v       = fgic->GetVBodyFpsIC();
  _w       = fgic->GetWBodyFpsIC();
  _p       = fgic->GetPRadpsIC();
  _q       = fgic->GetQRadpsIC();
  _r       = fgic->GetRRadpsIC();
  _alpha   = fgic->GetAlphaRadIC();
  _beta    = fgic->GetBetaRadIC();
  _theta   = fgic->GetThetaRadIC();
  _phi     = fgic->GetPhiRadIC();
  _psiIC   = fgic->GetPsiRadIC();
  _psi     = _psiIC;
  _psigtIC = _psi;

  _phiW = _psiW = 0.0;

  _vgIC = _vtIC*cos(_gamma);
  _vnorthIC = _vgIC * cos(_psigtIC);
  _veastIC  = _vgIC * sin(_psigtIC);
  wnorthIC = _weastIC = _wdownIC = 0.;

  _udot=_vdot=_wdot=_pdot=_qdot=_rdot=0.;
  _psidot=_thetadot=0.;
  _psiWdot = _phiWdot = _gammadot = 0.;

  C1 = C2 = C3 = 1.0;
  _cbeta = cos(_beta);
  _sbeta = sin(_beta);
  _sphi = sin(_phi);

  SetMode(tt); // creates vTrimAnalysisControls
  fdmex->SetTrimMode( (int)tt );

  trim_id = "default-trim";

  // direct search stuff
  search_type = "Nelder-Mead";
  sigma_nm = 0.5; alpha_nm = 1.0; beta_nm = 0.5; gamma_nm = 2.0;
  initial_step = 0.01;
  tolerance = 1.0E-10; // 0.0000000001
  cost_function_value = 9999.0;

  rf_name = "";
  if (rf.is_open()) rf.close();

  Auxiliary    = fdmex->GetAuxiliary();
  Aerodynamics = fdmex->GetAerodynamics();
  Propulsion   = fdmex->GetPropulsion();
  FCS          = fdmex->GetFCS();
}

Here is the call graph for this function:


Member Function Documentation

bool AddControl ( TaControl  control)

See the enums TaControl in FGTrimAnalysisControl.h for the available options. (Note: controls are intended here as those variables to be adjusted for attaining convergence of the trimming algorithm) Will fail if the given state is already configured.

Parameters:
controlthe control to be adjusted in the trimming algorithm
Returns:
true if add is successful

Definition at line 674 of file FGTrimAnalysis.cpp.

References FGTrimAnalysisControl::GetControlType().

                                                   {
      tac=*iControls;
      if( tac->GetControlType() == control )
        result=false;
      iControls++;
  }
  if(result) {
    vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,control));
  }
  return result;
}

Here is the call graph for this function:

void CalculatePhiWFromTargetNlfTurn ( double  nlf)
Parameters:
nlf

Definition at line 753 of file FGTrimAnalysis.cpp.

Referenced by FGTrimAnalysis::Load().

                                                      {
     // target Nlf is given
     // set _phiW according to given Nlf
     _targetNlf = nlf;
     _phiW = atan2( sqrt(_targetNlf*_targetNlf-cos(_gamma)*cos(_gamma)), cos(_gamma) );
  }
}

Here is the caller graph for this function:

void ClearControls ( void  )

The trimming routine must have at least one control configured to be useful (Note: controls are intended here as those variables to be adjusted for attaining convergence of the trimming algorithm)

Definition at line 654 of file FGTrimAnalysis.cpp.

                                                     {
      tac=*iControls;
      delete tac;

      iControls++;
    }

    vTrimAnalysisControls.clear();

}

bool EditState ( TaControl  new_control,
double  new_initvalue,
double  new_step,
double  new_min,
double  new_max 
)
Parameters:
new_controlthe control used to zero the state
new_initvaluea new initial value
new_stepa new adjusting step
new_min,new_maxa new range
Returns:
true if editing is successful

Definition at line 718 of file FGTrimAnalysis.cpp.

References FGTrimAnalysisControl::GetControlType().

                                                   {
      tac=*iControls;
      if( tac->GetControlType() == new_control ) {
        vTrimAnalysisControls.insert(iControls,1,new FGTrimAnalysisControl(fdmex,fgic,new_control));
        delete tac;
        vTrimAnalysisControls.erase(iControls+1);
        result=true;
        break;
      }
      iControls++;
  }
  return result;
}

Here is the call graph for this function:

double GetCostFunctionValue ( ) const [inline]
Returns:
The current cost function value

Definition at line 482 of file FGTrimAnalysis.h.

{ return cost_function_value;}
double GetGamma ( void  ) [inline]
Returns:
value of gamma

Definition at line 536 of file FGTrimAnalysis.h.

{ return _gamma; }
bool GetGammaFallback ( void  ) [inline]
Returns:
true if fallback is enabled.

Definition at line 548 of file FGTrimAnalysis.h.

{ return gamma_fallback; }
double GetGammaRad ( ) [inline]
Returns:
gamma [rad]

Definition at line 623 of file FGTrimAnalysis.h.

{ return _gamma;}
TrimAnalysisMode GetMode ( ) const [inline]
Returns:
The Trim Analysis mode taLongitudinal, taFull, taGround, taCustom, or taNone

Definition at line 495 of file FGTrimAnalysis.h.

Referenced by Objective::CostFunctionFull(), Objective::CostFunctionFullCoordinatedTurn(), Objective::CostFunctionFullTurn(), Objective::CostFunctionFullWingsLevel(), Objective::CostFunctionLongitudinal(), and Objective::CostFunctionPullUp().

{ return mode;};

Here is the caller graph for this function:

double GetPhiRad ( ) [inline]
Returns:
phi [rad]

Definition at line 606 of file FGTrimAnalysis.h.

{ return _phi;}
double GetPhiWRad ( ) [inline]
Returns:
phiW [rad]

Definition at line 619 of file FGTrimAnalysis.h.

{ return _phiW;}
double GetPsiRad ( ) [inline]
Returns:
phi [rad]

Definition at line 614 of file FGTrimAnalysis.h.

{ return _psi;}
ofstream* GetResultsFile ( ) const [inline]
Returns:
non null pointer if file is open

Definition at line 473 of file FGTrimAnalysis.h.

{ if (rf.is_open()) return &rf; else return 0; } // const_cast<ofstream*>(&rf) (if rf is not mutable)
double GetTargetNlf ( void  ) [inline]
Returns:
_targetNlf

Definition at line 663 of file FGTrimAnalysis.h.

{ return _targetNlf; }
double GetThetaRad ( ) [inline]
Returns:
phi [rad]

Definition at line 610 of file FGTrimAnalysis.h.

{ return _theta;}
double GetTolerance ( void  ) [inline]
Returns:
tolerance.

Definition at line 569 of file FGTrimAnalysis.h.

{return tolerance; }
bool GetTrimFailed ( void  ) [inline]
Returns:
trim_failed (boolean)

Definition at line 578 of file FGTrimAnalysis.h.

{ return trim_failed; }
double GetVtFps ( ) [inline]
Returns:
Vt [fps]

Definition at line 627 of file FGTrimAnalysis.h.

{ return _vtIC;}
bool Load ( string  fname,
bool  useStoredPath = true 
)
Parameters:
fnameThe name of a trim configuration file
useStoredPathtrue if the stored path to the trim config file should be used
Returns:
true if successful

Definition at line 451 of file FGTrimAnalysis.cpp.

References FGTrimAnalysis::CalculatePhiWFromTargetNlfTurn(), Element::FindElement(), Element::GetAttributeValue(), FGInitialCondition::GetFlightPathAngleRadIC(), FGFDMExec::GetFullAircraftPath(), FGInitialCondition::GetPhiRadIC(), FGInitialCondition::GetPsiRadIC(), FGInitialCondition::GetThetaRadIC(), and FGTrimAnalysis::SetResultsFile().

{
    string name="", type="";
    string trimDef;
    Element *element=0, *trimCfg=0, *search_element=0, *output_element=0;

    string sep = "/";
# ifdef macintosh
    sep = ";";
# endif

    if( useStoredPath ) {
        trimDef = fdmex->GetFullAircraftPath() + sep + fname + ".xml";
    } else {
        trimDef = fname;
    }

    document = this->LoadXMLDocument(trimDef);

    trimCfg = document->FindElement("trim_config");
    if (!trimCfg) {
        cerr << "File: " << trimDef << " does not contain a trim configuration tag" << endl;
        return false;
    }

    name = trimCfg->GetAttributeValue("name");
    trim_id = name;

    // First, find "search" element that specifies the type of cost function minimum search

    search_element = trimCfg->FindElement("search");
    if (!search_element) {
        cerr << "Using the Nelder-Mead search algorithm (default)." << endl;
    } else {
        type = search_element->GetAttributeValue("type");
        if (type.size() > 0) search_type = type; // if search type is not set, default is already Nelder-Mead
        if (search_type == "Nelder-Mead") {
            // Read settings from search
            // Note: all of these have defaults set above
            if ( search_element->FindElement("sigma_nm") )
                sigma_nm = search_element->FindElementValueAsNumber("sigma_nm");
            if ( search_element->FindElement("alpha_nm") )
                alpha_nm = search_element->FindElementValueAsNumber("alpha_nm");
            if ( search_element->FindElement("beta_nm") )
                beta_nm = search_element->FindElementValueAsNumber("beta_nm");
            if ( search_element->FindElement("gamma_nm") )
                gamma_nm = search_element->FindElementValueAsNumber("gamma_nm");
        }
        // ToDo: manage all the other possible choices here
        // if (search_type == "Sequential-Multiple-Nelder-Mead") { }
        // if (search_type == "Multicompass") { }
        // etc ...
        if ( search_element->FindElement("tolerance") ) {
            tolerance = search_element->FindElement("tolerance")->GetAttributeValueAsNumber("value");
        }
        if ( search_element->FindElement("max_iterations") ) {
            max_iterations = (unsigned int)search_element->FindElement("max_iterations")->GetAttributeValueAsNumber("value");
        }
        if ( search_element->FindElement("stop_criterion") ) {
            stop_criterion = search_element->FindElement("stop_criterion")->GetAttributeValue("type");
        }
    }

    // Initialize trim controls based on what is in the trim config file. This
    // includes initial trim values (or defaults from the IC file) and step
    // size values.

    element = trimCfg->FindElement("phi");
    InitializeTrimControl(fgic->GetPhiRadIC(), element, "RAD", JSBSim::taPhi);
    if ( ( fabs(_phi) < 89.5*(FGJSBBase::degtorad ) ) && ( mode == taTurn ))
                _targetNlf = 1./cos(_phi);

    element = trimCfg->FindElement("theta");
    InitializeTrimControl(fgic->GetThetaRadIC(), element, "RAD", JSBSim::taTheta);
    
    element = trimCfg->FindElement("psi");
    InitializeTrimControl(fgic->GetPsiRadIC(), element, "RAD", JSBSim::taHeading);

    element = trimCfg->FindElement("gamma");
    _gamma = fgic->GetFlightPathAngleRadIC();
    if (element)
      if (element->GetNumDataLines() > 0) _gamma = element->GetDataAsNumber();

    element = trimCfg->FindElement("nlf");
    if (element) {
      if (element->GetNumDataLines() > 0) _targetNlf = element->GetDataAsNumber();
      CalculatePhiWFromTargetNlfTurn(_targetNlf);
    }

    element = trimCfg->FindElement("throttle_cmd");
    if (element) InitializeTrimControl(0, element, "", JSBSim::taThrottle);

    element = trimCfg->FindElement("elevator_cmd");
    if (element) InitializeTrimControl(0, element, "", JSBSim::taElevator);

    element = trimCfg->FindElement("rudder_cmd");
    if (element) InitializeTrimControl(0, element, "", JSBSim::taRudder);

    element = trimCfg->FindElement("aileron_cmd");
    if (element) InitializeTrimControl(0, element, "", JSBSim::taAileron);

    output_element = trimCfg->FindElement("output_file");
    if (output_element) {
        rf_name = output_element->GetAttributeValue("name");
        if (rf_name.empty()) {
            cerr << "name must be specified in output_file \"name\" attribute."<< endl;
        } else {
            if ( !SetResultsFile(rf_name) )
                cerr << "Unable to use output file "<< rf_name << endl;
        }
    }
    return true;
}

Here is the call graph for this function:

bool RemoveControl ( TaControl  control)
Parameters:
controlthe state to remove
Returns:
true if removal is successful

Definition at line 695 of file FGTrimAnalysis.cpp.

References FGTrimAnalysisControl::GetControlType().

                                                   {
      tac=*iControls;
      if( tac->GetControlType() == control ) {
        delete tac;
        vTrimAnalysisControls.erase(iControls);
        result=true;
        continue;
      }
      iControls++;
  }

  return result;
}

Here is the call graph for this function:

void Report ( void  )

For each axis trimmed, this includes the final state value, control value, and tolerance used.

Returns:
true if trim succeeds

Definition at line 611 of file FGTrimAnalysis.cpp.

                        : " << endl;
      cout << "\tTrim algorithm terminated with the following values:" << endl;
      cout << "\tu, v, w        (ft/s): " << _u <<", "<< _v <<", "<< _w << endl
           << "\tp, q, r       (rad/s): " << _p <<", "<< _q <<", "<< _r << endl
           << "\talpha, beta     (deg): " << _alpha*57.3 <<", "<< _beta*57.3 << endl
           << "\tphi, theta, psi (deg): " << _phi*57.3 <<", "<< _theta*57.3 << ", " << _psi*57.3 << endl
           << "\tCost function value  : " << cost_function_value << endl
           << "\tCycles executed      : " << total_its << endl << endl;

      cout << "\tTrim variables adjusted:" << endl;
      for (unsigned int i=0; i<vTrimAnalysisControls.size();i++){
          cout << "\t\t" << vTrimAnalysisControls[i]->GetControlName() <<": ";
          cout << vTrimAnalysisControls[i]->GetControl() << endl;
      }
      //...

      cout << endl;

      cout << "\t** Initial -> Final Conditions **" << endl;
      cout << "\tAlpha IC: " << fgic->GetAlphaDegIC() << " Degrees" << endl;
      cout << "\t   Final: " << Auxiliary->Getalpha()*57.3 << " Degrees" << endl;
      cout << "\tBeta  IC: " << fgic->GetBetaDegIC() << " Degrees" << endl;
      cout << "\t   Final: " << Auxiliary->Getbeta()*57.3 << " Degrees" << endl;
      cout << "\tGamma IC: " << fgic->GetFlightPathAngleDegIC() << " Degrees" << endl;
      cout << "\t   Final: " << Auxiliary->GetGamma()*57.3 << " Degrees" << endl;
      cout << "\tPhi IC  : " << fgic->GetPhiDegIC() << " Degrees" << endl;
      cout << "\t   Final: " << fdmex->GetPropagate()->GetEuler(1)*57.3 << " Degrees" << endl;
      cout << "\tTheta IC: " << fgic->GetThetaDegIC() << " Degrees" << endl;
      cout << "\t   Final: " << fdmex->GetPropagate()->GetEuler(2)*57.3 << " Degrees" << endl;
      cout << "\tPsi IC  : " << fgic->GetPsiDegIC() << " Degrees" << endl;
      cout << "\t   Final: " << fdmex->GetPropagate()->GetEuler(3)*57.3 << " Degrees" << endl;
      cout << endl;
      cout << "--------------------------------------------------------------------- \n\n";

      fdmex->EnableOutput();
}

void SetCostFunctionValue ( double  value) [inline]
Parameters:
valuethe cost function value

Definition at line 478 of file FGTrimAnalysis.h.

{cost_function_value = value;}
void SetDottedValues ( double  udot,
double  vdot,
double  wdot,
double  pdot,
double  qdot,
double  rdot 
)
Parameters:
udot,vdot,wdot,pdot,qdot,rdot

Definition at line 444 of file FGTrimAnalysis.cpp.

{
    _udot=udot; _vdot=vdot; _wdot=wdot; _pdot=pdot; _qdot=qdot; _rdot=rdot;
}

void SetEulerAngles ( double  phi0,
double  theta0,
double  psi0 
)
Parameters:
phi0,theta0,psi0

Definition at line 433 of file FGTrimAnalysis.cpp.

{
    // feed into private variables
    _phi = phi; _cphi = cos(_phi); _sphi = sin(_phi);
    _theta = theta; _ctheta = cos(_theta); _stheta = sin(_theta);
    _psi = psi; _cpsi = cos(_psi); _spsi = sin(_psi);

}

void SetGammaFallback ( bool  bb) [inline]
Parameters:
bbtrue to enable fallback

Definition at line 543 of file FGTrimAnalysis.h.

{ gamma_fallback=bb; }
void SetMaxCycles ( int  ii) [inline]

DoTrim() will return false if limit iterations are reached before trim is achieved. The default is 60. This does not ordinarily need to be changed.

Parameters:
iiinteger iteration limit

Definition at line 555 of file FGTrimAnalysis.h.

{ max_iterations = ii; }
void SetMode ( TrimAnalysisMode  tam)
Parameters:
tamthe set of axes to trim. Can be: taLongitudinal, taFull, taGround, taCustom, or taNone

Definition at line 996 of file FGTrimAnalysis.cpp.

Referenced by FGTrimAnalysis::FGTrimAnalysis().

                                    : ";
    mode=tt;
    switch(tt) {
      case taLongitudinal:
        if (debug_lvl > 0)
          cout << "  Longitudinal Trim" << endl;
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taThrottle ));
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taElevator )); // TODO: taPitchTrim
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taTheta ));
        break;
      case taFull:
        if (debug_lvl > 0)
          cout << "  Full Trim" << endl;
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taThrottle ));
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taElevator )); // TODO: taPitchTrim
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taAileron ));  // TODO: taRollTrim
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taRudder ));   // TODO: taYawTrim
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taPhi ));
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taTheta ));
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taHeading ));
        break;
      case taFullWingsLevel:
        if (debug_lvl > 0)
          cout << "  Full Trim, Wings-Level" << endl;
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taThrottle ));
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taElevator )); // TODO: taPitchTrim
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taAileron ));  // TODO: taRollTrim
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taRudder ));   // TODO: taYawTrim
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taTheta ));
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taHeading ));
        break;
      case taTurn:
          // ToDo: set target NLF here !!!
          // ToDo: assign psiDot here !!
        if (debug_lvl > 0)
          cout << "  Full Trim, Coordinated turn" << endl;
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taThrottle ));
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taElevator )); // TODO: taPitchTrim
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taAileron ));  // TODO: taRollTrim
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taRudder ));   // TODO: taYawTrim
        //vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taPhi ));
        //vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taTheta ));
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taHeading ));
        break;
      case taTurnFull:
        if (debug_lvl > 0)
          cout << "  Non-coordinated Turn Trim" << endl;
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taThrottle ));
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taElevator )); // TODO: taPitchTrim
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taAileron ));  // TODO: taRollTrim
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taRudder ));   // TODO: taYawTrim
        //vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taPhi ));
        // calculate this from target nlf
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taTheta ));
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taHeading ));
        break;
      case taPullup:
          // ToDo: set target NLF here !!!
          // ToDo: assign qDot here !!
        if (debug_lvl > 0)
          cout << "  Full Trim, Pullup" << endl;
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taThrottle ));
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taElevator )); // TODO: taPitchTrim
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taAileron ));
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taRudder ));
        //vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taPhi ));
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taTheta ));
        //vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taHeading ));
        break;
      case taGround:
        if (debug_lvl > 0)
          cout << "  Ground Trim" << endl;
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taAltAGL ));
        vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taTheta ));
        //vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taPhi ));
        break;
      case taCustom:
        // agodemar...
        // ...agodemar
      case taNone:
        break;
    }

    current_ctrl=0;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Here is the caller graph for this function:

bool SetResultsFile ( string  name)
Parameters:
namethe file name
Returns:
true if file open is successful

Definition at line 1088 of file FGTrimAnalysis.cpp.

Referenced by FGTrimAnalysis::Load().

{
    if ( rf.is_open() ) return false;

    rf_name = name;
    rf.open(rf_name.c_str(), ios::out);
    if ( !rf.is_open() ) {
       cerr << "Unable to open " << rf_name << endl;
       return false;
    }
    //rf << "# ... complete this " << endl;
    //rf << "# iteration, CostFunc, size, dT, dE, dA, dR, Psi (rad), Theta (rad), Phi (rad)\n";
    return true;
}

Here is the caller graph for this function:

void SetState ( double  u0,
double  v0,
double  w0,
double  p0,
double  q0,
double  r0,
double  alpha0,
double  beta0,
double  phi0,
double  theta0,
double  psi0,
double  gamma0 
)
Parameters:
u0
v0
w0
p0
q0
r0
alpha0
beta0
phi0
psi0
theta0
gamma0

Definition at line 422 of file FGTrimAnalysis.cpp.

{
  _u=u0; _v=v0; _w=w0;
  _p=p0; _q=q0; _r=r0;
  _alpha=alpha0; _beta=beta0; _gamma=gamma0;
  _theta=theta0; _phi=phi0; _psi=psi0;
}

void SetTargetNlf ( double  nlf) [inline]
Parameters:
nlftarget normal load factor

Definition at line 658 of file FGTrimAnalysis.h.

{ _targetNlf=nlf; }
void SetTolerance ( double  tt) [inline]

(In the evaluation of the cost function, squares of angular accels are devided by 100) The default is 1e-8.

Parameters:
ttuser defined tolerance

Definition at line 563 of file FGTrimAnalysis.h.

                                      {
    tolerance = tt;
  }
void SetTrimFailed ( bool  tf) [inline]
Parameters:
tf(boolean)

Definition at line 574 of file FGTrimAnalysis.h.

{ trim_failed = tf; }
FGColumnVector3 UpdateRatesPullup ( void  )
Returns:
p, q, r

Definition at line 921 of file FGTrimAnalysis.cpp.

FGColumnVector3 UpdateRatesTurn ( double  psi,
double  theta,
double  phi,
double  phiW 
)
Parameters:
psi,theta,phi
Returns:
p, q, r

Definition at line 915 of file FGTrimAnalysis.cpp.


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