%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGFDMExec.h"
+#include "FGJSBBase.h"
#include "FGRotation.h"
#include "FGAtmosphere.h"
#include "FGState.h"
#define ID_TRIM "$Id$"
+typedef enum { tLongitudinal, tFull, tGround, tPullup,
+ tCustom, tNone, tTurn
+ } TrimMode;
+
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#endif
+
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-typedef enum { tLongitudinal, tFull, tGround, tCustom, tNone } TrimMode;
-
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-class FGTrim {
+class FGTrim : public FGJSBBase
+{
private:
vector<FGTrimAxis*> TrimAxes;
- int current_axis;
+ unsigned int current_axis;
int N, Nsub;
TrimMode mode;
- int Debug;
- float Tolerance, A_Tolerance;
- float wdot,udot,qdot;
- float dth;
- float *sub_iterations;
- float *successful;
+ int DebugLevel, Debug;
+ double Tolerance, A_Tolerance;
+ double wdot,udot,qdot;
+ double dth;
+ double *sub_iterations;
+ double *successful;
bool *solution;
int max_sub_iterations;
int max_iterations;
bool trimudot;
bool gamma_fallback;
bool trim_failed;
- int axis_count;
+ unsigned int axis_count;
int solutionDomain;
- float xlo,xhi,alo,ahi;
+ double xlo,xhi,alo,ahi;
+ double targetNlf;
+ int debug_axis;
+
+ double psidot,thetadot;
FGFDMExec* fdmex;
FGInitialCondition* fgic;
bool findInterval(void);
bool checkLimits(void);
+
+ void setupPullup(void);
+ void setupTurn(void);
+
+ void updateRates(void);
+
+ void setDebug(void);
public:
/** Initializes the trimming class
*/
void Report(void);
- /** Prints a summary of simulator state (speed, altitude,
- configuration, etc.)
- */
- void ReportState(void);
-
/** Iteration statistics
*/
void TrimStats();
held to a tolerance of 1/10th of the given. The default is
0.001 for the recti-linear accelerations and 0.0001 for the angular.
*/
- inline void SetTolerance(float tt) {
+ inline void SetTolerance(double tt) {
Tolerance = tt;
A_Tolerance = tt / 10;
}
- //Debug level 1 shows results of each top-level iteration
- //Debug level 2 shows level 1 & results of each per-axis iteration
- inline void SetDebug(int level) { Debug = level; }
- inline void ClearDebug(void) { Debug = 0; }
+ /**
+ Debug level 1 shows results of each top-level iteration
+ Debug level 2 shows level 1 & results of each per-axis iteration
+ */
+ inline void SetDebug(int level) { DebugLevel = level; }
+ inline void ClearDebug(void) { DebugLevel = 0; }
+
+ /**
+ Output debug data for one of the axes
+ The State enum is defined in FGTrimAxis.h
+ */
+ inline void DebugState(State state) { debug_axis=state; }
+
+ inline void SetTargetNlf(float nlf) { targetNlf=nlf; }
+ inline double GetTargetNlf(void) { return targetNlf; }
};