1
0
Fork 0
flightgear/src/FDM/JSBSim/FGTrimAxis.h

187 lines
5.7 KiB
C
Raw Normal View History

2000-11-03 23:02:47 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2000-10-02 23:07:30 +00:00
Header: FGTrimAxis.h
Author: Tony Peden
Date started: 7/3/00
------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
7/3/00 TP Created
2000-11-03 23:02:47 +00:00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2000-10-02 23:07:30 +00:00
SENTRY
2000-11-03 23:02:47 +00:00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
2000-10-02 23:07:30 +00:00
#ifndef FGTRIMAXIS_H
#define FGTRIMAXIS_H
2000-11-03 23:02:47 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2000-10-02 23:07:30 +00:00
INCLUDES
2000-11-03 23:02:47 +00:00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
2000-10-02 23:07:30 +00:00
#include <string>
#include "FGFDMExec.h"
#include "FGJSBBase.h"
#include "FGInitialCondition.h"
2000-10-02 23:07:30 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
2001-03-30 01:04:50 +00:00
#define ID_TRIMAXIS "$Id$"
#define DEFAULT_TOLERANCE 0.001
2000-10-02 23:07:30 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
namespace JSBSim {
2001-11-30 17:49:37 +00:00
const string StateNames[10]= { "all","udot","vdot","wdot","qdot","pdot","rdot",
"hmgt","nlf"
};
2001-03-30 01:04:50 +00:00
const string ControlNames[14]= { "Throttle","Sideslip","Angle of Attack",
2000-10-02 23:07:30 +00:00
"Elevator","Ailerons","Rudder",
"Altitude AGL", "Pitch Angle",
"Roll Angle", "Flight Path Angle",
2001-03-30 01:04:50 +00:00
"Pitch Trim", "Roll Trim", "Yaw Trim",
"Heading"
2000-10-02 23:07:30 +00:00
};
2001-03-30 01:04:50 +00:00
class FGInitialCondition;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Models an aircraft axis for purposes of trimming.
*/
2000-11-03 23:02:47 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2000-10-02 23:07:30 +00:00
CLASS DECLARATION
2000-11-03 23:02:47 +00:00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
2000-10-02 23:07:30 +00:00
2001-11-30 17:49:37 +00:00
enum State { tAll,tUdot,tVdot,tWdot,tQdot,tPdot,tRdot,tHmgt,tNlf };
2000-10-02 23:07:30 +00:00
enum Control { tThrottle, tBeta, tAlpha, tElevator, tAileron, tRudder, tAltAGL,
2001-03-30 01:04:50 +00:00
tTheta, tPhi, tGamma, tPitchTrim, tRollTrim, tYawTrim, tHeading };
2000-10-02 23:07:30 +00:00
class FGTrimAxis : public FGJSBBase
{
2000-10-02 23:07:30 +00:00
public:
FGTrimAxis(FGFDMExec* fdmex,
FGInitialCondition *ic,
State st,
2001-03-30 01:04:50 +00:00
Control ctrl );
2000-10-02 23:07:30 +00:00
~FGTrimAxis();
void Run(void);
2000-11-03 23:02:47 +00:00
2001-11-20 22:34:24 +00:00
double GetState(void) { getState(); return state_value; }
2000-10-02 23:07:30 +00:00
//Accels are not settable
2001-11-20 22:34:24 +00:00
inline void SetControl(double value ) { control_value=value; }
inline double GetControl(void) { return control_value; }
2000-10-02 23:07:30 +00:00
2001-03-30 01:04:50 +00:00
inline State GetStateType(void) { return state; }
2000-10-02 23:07:30 +00:00
inline Control GetControlType(void) { return control; }
2001-03-30 01:04:50 +00:00
inline string GetStateName(void) { return StateNames[state]; }
2000-10-02 23:07:30 +00:00
inline string GetControlName(void) { return ControlNames[control]; }
2001-11-20 22:34:24 +00:00
inline double GetControlMin(void) { return control_min; }
inline double GetControlMax(void) { return control_max; }
2000-10-02 23:07:30 +00:00
inline void SetControlToMin(void) { control_value=control_min; }
inline void SetControlToMax(void) { control_value=control_max; }
2000-11-03 23:02:47 +00:00
2001-11-20 22:34:24 +00:00
inline void SetControlLimits(double min, double max) {
2000-11-03 23:02:47 +00:00
control_min=min;
control_max=max;
}
2000-10-02 23:07:30 +00:00
2001-11-20 22:34:24 +00:00
inline void SetTolerance(double ff) { tolerance=ff;}
inline double GetTolerance(void) { return tolerance; }
2000-10-02 23:07:30 +00:00
2001-11-20 22:34:24 +00:00
inline double GetSolverEps(void) { return solver_eps; }
inline void SetSolverEps(double ff) { solver_eps=ff; }
2000-10-02 23:07:30 +00:00
inline int GetIterationLimit(void) { return max_iterations; }
inline void SetIterationLimit(int ii) { max_iterations=ii; }
inline int GetStability(void) { return its_to_stable_value; }
inline int GetRunCount(void) { return total_stability_iterations; }
2001-11-20 22:34:24 +00:00
double GetAvgStability( void );
2000-10-02 23:07:30 +00:00
2001-11-20 22:34:24 +00:00
void SetThetaOnGround(double ff);
void SetPhiOnGround(double ff);
2000-11-03 23:02:47 +00:00
2001-11-30 17:49:37 +00:00
inline void SetStateTarget(float target) { state_target=target; }
inline float GetStateTarget(void) { return state_target; }
2000-11-03 23:02:47 +00:00
bool initTheta(void);
2000-10-02 23:07:30 +00:00
void AxisReport(void);
2001-03-30 01:04:50 +00:00
bool InTolerance(void) { getState(); return (fabs(state_value) <= tolerance); }
2000-10-02 23:07:30 +00:00
private:
FGFDMExec *fdmex;
FGInitialCondition *fgic;
2001-03-30 01:04:50 +00:00
State state;
2000-10-02 23:07:30 +00:00
Control control;
2001-11-30 17:49:37 +00:00
float state_target;
float state_value;
float control_value;
2000-10-02 23:07:30 +00:00
2001-11-20 22:34:24 +00:00
double control_min;
double control_max;
2000-10-02 23:07:30 +00:00
2001-11-20 22:34:24 +00:00
double tolerance;
2000-10-02 23:07:30 +00:00
2001-11-20 22:34:24 +00:00
double solver_eps;
2000-10-02 23:07:30 +00:00
2001-11-20 22:34:24 +00:00
double state_convert;
double control_convert;
2000-10-02 23:07:30 +00:00
int max_iterations;
int its_to_stable_value;
int total_stability_iterations;
int total_iterations;
void setThrottlesPct(void);
2001-03-30 01:04:50 +00:00
void getState(void);
2000-10-02 23:07:30 +00:00
void getControl(void);
void setControl(void);
2000-11-03 23:02:47 +00:00
2001-11-20 22:34:24 +00:00
double computeHmgt(void);
2000-11-03 23:02:47 +00:00
2001-12-13 04:48:34 +00:00
void Debug(int from);
2000-10-02 23:07:30 +00:00
};
}
2000-10-02 23:07:30 +00:00
#endif