-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGTrimAxis.h
Author: Tony Peden
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
-
-
-********************************************************************************
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGTRIMAXIS_H
#define FGTRIMAXIS_H
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include <string>
#include "FGFDMExec.h"
-#include "FGRotation.h"
-#include "FGAtmosphere.h"
-#include "FGState.h"
-#include "FGFCS.h"
-#include "FGAircraft.h"
-#include "FGTranslation.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
-
-#define ID_TRIMAXIS "$Header"
-
-const string AccelNames[6]= { "udot","vdot","wdot","qdot","pdot","rdot" };
-const string ControlNames[13]= { "Throttle","Sideslip","Angle of Attack",
+#include "FGJSBBase.h"
+#include "FGInitialCondition.h"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#define ID_TRIMAXIS "$Id$"
+
+#define DEFAULT_TOLERANCE 0.001
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+namespace JSBSim {
+
+const string StateNames[10]= { "all","udot","vdot","wdot","qdot","pdot","rdot",
+ "hmgt","nlf"
+ };
+const string ControlNames[14]= { "Throttle","Sideslip","Angle of Attack",
"Elevator","Ailerons","Rudder",
"Altitude AGL", "Pitch Angle",
"Roll Angle", "Flight Path Angle",
- "Pitch Trim", "Roll Trim", "Yaw Trim"
+ "Pitch Trim", "Roll Trim", "Yaw Trim",
+ "Heading"
};
-/*******************************************************************************
+
+class FGInitialCondition;
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Models an aircraft axis for purposes of trimming.
+ */
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-enum Accel { tUdot,tVdot,tWdot,tQdot,tPdot,tRdot };
+enum State { tAll,tUdot,tVdot,tWdot,tQdot,tPdot,tRdot,tHmgt,tNlf };
enum Control { tThrottle, tBeta, tAlpha, tElevator, tAileron, tRudder, tAltAGL,
- tTheta, tPhi, tGamma, tPitchTrim, tRollTrim, tYawTrim };
+ tTheta, tPhi, tGamma, tPitchTrim, tRollTrim, tYawTrim, tHeading };
-class FGTrimAxis {
+class FGTrimAxis : public FGJSBBase
+{
public:
- FGTrimAxis(FGFDMExec* fdmex, FGInitialCondition *ic, Accel acc,
- Control ctrl, float tolerance);
+ FGTrimAxis(FGFDMExec* fdmex,
+ FGInitialCondition *ic,
+ State st,
+ Control ctrl );
~FGTrimAxis();
void Run(void);
-
- float GetAccel(void) { getAccel(); return accel_value; }
+
+ double GetState(void) { getState(); return state_value; }
//Accels are not settable
- inline void SetControl(float value ) { control_value=value; }
- inline float GetControl(void) { return control_value; }
+ inline void SetControl(double value ) { control_value=value; }
+ inline double GetControl(void) { return control_value; }
- inline Accel GetAccelType(void) { return accel; }
+ inline State GetStateType(void) { return state; }
inline Control GetControlType(void) { return control; }
- inline string GetAccelName(void) { return AccelNames[accel]; }
+ inline string GetStateName(void) { return StateNames[state]; }
inline string GetControlName(void) { return ControlNames[control]; }
- inline float GetControlMin(void) { return control_min; }
- inline float GetControlMax(void) { return control_max; }
+ inline double GetControlMin(void) { return control_min; }
+ inline double GetControlMax(void) { return control_max; }
inline void SetControlToMin(void) { control_value=control_min; }
inline void SetControlToMax(void) { control_value=control_max; }
+
+ inline void SetControlLimits(double min, double max) {
+ control_min=min;
+ control_max=max;
+ }
- inline void SetTolerance(float ff) { tolerance=ff;}
- inline float GetTolerance(void) { return tolerance; }
+ inline void SetTolerance(double ff) { tolerance=ff;}
+ inline double GetTolerance(void) { return tolerance; }
- inline float GetSolverEps(void) { return solver_eps; }
- inline void SetSolverEps(float ff) { solver_eps=ff; }
+ inline double GetSolverEps(void) { return solver_eps; }
+ inline void SetSolverEps(double ff) { solver_eps=ff; }
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; }
- float GetAvgStability( void );
+ double GetAvgStability( void );
+
+ void SetThetaOnGround(double ff);
+ void SetPhiOnGround(double ff);
+
+ inline void SetStateTarget(float target) { state_target=target; }
+ inline float GetStateTarget(void) { return state_target; }
+
+ bool initTheta(void);
- void SetThetaOnGround(float ff);
- void SetPhiOnGround(float ff);
-
void AxisReport(void);
- bool InTolerance(void) { getAccel(); return (fabs(accel_value) <= tolerance); }
+ bool InTolerance(void) { getState(); return (fabs(state_value) <= tolerance); }
private:
FGFDMExec *fdmex;
FGInitialCondition *fgic;
-
- Accel accel;
+ State state;
Control control;
-
- float accel_value;
+
+ float state_target;
+
+ float state_value;
float control_value;
- float control_min;
- float control_max;
+ double control_min;
+ double control_max;
- float tolerance;
+ double tolerance;
- float solver_eps;
+ double solver_eps;
- float accel_convert;
- float control_convert;
+ double state_convert;
+ double control_convert;
int max_iterations;
int total_stability_iterations;
int total_iterations;
-
void setThrottlesPct(void);
- void getAccel(void);
+ void getState(void);
void getControl(void);
void setControl(void);
-
+
+ double computeHmgt(void);
+
+ void Debug(int from);
};
-
+}
#endif