1
0
Fork 0

JSBSim updates.

Updates to put more internal JSBSim values on the "bus".
This commit is contained in:
curt 2000-07-25 21:41:59 +00:00
parent 273efc8729
commit 6a98486375
8 changed files with 84 additions and 26 deletions

View file

@ -89,7 +89,7 @@ int FGJSBsim::init( double dt ) {
FDMExec.GetAtmosphere()->UseInternal();
FG_LOG( FG_FLIGHT, FG_INFO, " Initializing JSBsim with:" );
FG_LOG( FG_FLIGHT, FG_INFO, " Initializing JSBSim with:" );
FGInitialCondition *fgic = new FGInitialCondition(&FDMExec);
fgic->SetAltitudeFtIC(get_Altitude());
@ -157,7 +157,7 @@ int FGJSBsim::init( double dt ) {
FG_LOG( FG_FLIGHT, FG_INFO, " set dt" );
FG_LOG( FG_FLIGHT, FG_INFO, "Finished initializing JSBsim" );
FG_LOG( FG_FLIGHT, FG_INFO, "Finished initializing JSBSim" );
copy_from_JSBsim();
@ -186,8 +186,8 @@ int FGJSBsim::update( int multiloop ) {
FDMExec.GetFCS()->SetPitchTrimCmd(controls.get_elevator_trim());
FDMExec.GetFCS()->SetDrCmd( controls.get_rudder());
FDMExec.GetFCS()->SetDfCmd( controls.get_flaps() );
FDMExec.GetFCS()->SetDsbCmd( 0.0 );
FDMExec.GetFCS()->SetDspCmd( 0.0 );
FDMExec.GetFCS()->SetDsbCmd( 0.0 ); //speedbrakes
FDMExec.GetFCS()->SetDspCmd( 0.0 ); //spoilers
FDMExec.GetFCS()->SetThrottleCmd( FGControls::ALL_ENGINES,
controls.get_throttle( 0 ) * 100.0 );
@ -246,23 +246,65 @@ int FGJSBsim::copy_to_JSBsim() {
int FGJSBsim::copy_from_JSBsim() {
set_Inertias( FDMExec.GetAircraft()->GetMass(),
FDMExec.GetAircraft()->GetIxx(),
FDMExec.GetAircraft()->GetIyy(),
FDMExec.GetAircraft()->GetIzz(),
FDMExec.GetAircraft()->GetIxz() );
set_CG_Position ( FDMExec.GetAircraft()->GetXYZcg()(1),
FDMExec.GetAircraft()->GetXYZcg()(2),
FDMExec.GetAircraft()->GetXYZcg()(3) );
set_Accels_Body ( FDMExec.GetTranslation()->GetUVWdot()(1),
FDMExec.GetTranslation()->GetUVWdot()(2),
FDMExec.GetTranslation()->GetUVWdot()(3) );
set_Accels_CG_Body ( FDMExec.GetTranslation()->GetUVWdot()(1),
FDMExec.GetTranslation()->GetUVWdot()(2),
FDMExec.GetTranslation()->GetUVWdot()(3) );
set_Accels_CG_Body_N ( FDMExec.GetTranslation()->GetNcg()(1),
FDMExec.GetTranslation()->GetNcg()(2),
FDMExec.GetTranslation()->GetNcg()(3) );
set_Accels_Pilot_Body( FDMExec.GetAuxiliary()->GetPilotAccel()(1),
FDMExec.GetAuxiliary()->GetPilotAccel()(2),
FDMExec.GetAuxiliary()->GetPilotAccel()(3) );
set_Accels_Pilot_Body_N( FDMExec.GetAuxiliary()->GetNpilot()(1),
FDMExec.GetAuxiliary()->GetNpilot()(2),
FDMExec.GetAuxiliary()->GetNpilot()(3) );
set_Nlf( FDMExec.GetAircraft()->GetNlf());
// Velocities
set_Velocities_Local( FDMExec.GetPosition()->GetVn(),
FDMExec.GetPosition()->GetVe(),
FDMExec.GetPosition()->GetVd() );
set_Velocities_Wind_Body( FDMExec.GetTranslation()->GetUVW()(1),
FDMExec.GetTranslation()->GetUVW()(2),
FDMExec.GetTranslation()->GetUVW()(3) );
set_V_equiv_kts( FDMExec.GetAuxiliary()->GetVequivalentKTS() );
//set_V_calibrated( FDMExec.GetAuxiliary()->GetVcalibratedFPS() );
set_V_calibrated_kts( FDMExec.GetAuxiliary()->GetVcalibratedKTS() );
set_V_ground_speed ( FDMExec.GetPosition()->GetVground() );
set_Omega_Body( FDMExec.GetState()->GetParameter(FG_ROLLRATE),
FDMExec.GetState()->GetParameter(FG_PITCHRATE),
FDMExec.GetState()->GetParameter(FG_YAWRATE) );
set_Euler_Rates( FDMExec.GetRotation()->Getphi(),
/* HUH!?! */ set_Euler_Rates( FDMExec.GetRotation()->Getphi(),
FDMExec.GetRotation()->Gettht(),
FDMExec.GetRotation()->Getpsi() );

View file

@ -158,6 +158,7 @@ public:
inline unsigned int GetNumEngines(void) { return numEngines; }
inline FGColumnVector GetXYZcg(void) { return vXYZcg; }
inline FGColumnVector GetXYZrp(void) { return vXYZrp; }
inline FGColumnVector GetXYZep(void) { return vXYZep; }
inline float GetNlf(void) { return nlf; }
inline float GetAlphaCLMax(void) { return alphaclmax; }
inline float GetAlphaCLMin(void) { return alphaclmin; }

View file

@ -50,6 +50,7 @@ INCLUDES
#include "FGAircraft.h"
#include "FGPosition.h"
#include "FGOutput.h"
#include "FGMatrix.h"
/*******************************************************************************
************************************ CODE **************************************
@ -90,6 +91,8 @@ bool FGAuxiliary::Run() {
A = pow(((pt-p)/psl+1),0.28571);
vcas = sqrt(7*psl/rhosl*(A-1));
veas = sqrt(2*qbar/rhosl);
vPilotAccel = Translation->GetUVWdot() + Aircraft->GetXYZep() * Rotation->GetPQRdot();

View file

@ -39,6 +39,7 @@ SENTRY
INCLUDES
*******************************************************************************/
#include "FGModel.h"
#include "FGMatrix.h"
/*******************************************************************************
DEFINES
@ -60,9 +61,11 @@ public:
inline float GetVcalibratedKTS(void) { return vcas*FPSTOKTS; }
inline float GetVequivalentFPS(void) { return veas; }
inline float GetVequivalentKTS(void) { return veas*FPSTOKTS; }
inline FGColumnVector GetPilotAccel(void) { return vPilotAccel; }
inline FGColumnVector GetNpilot(void) { return vPilotAccel*INVGRAVITY; }
protected:
private:
@ -76,6 +79,10 @@ private:
//if a general freestream total is needed, e-mail Tony Peden
// (apeden@earthlink.net) or you can add it your self using the
// isentropic flow equations
FGColumnVector vPilotAccel;
void GetState(void);
};

View file

@ -94,7 +94,7 @@ FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex),
LongitudeDot = LatitudeDot = RadiusDot = 0.0;
lastLongitudeDot = lastLatitudeDot = lastRadiusDot = 0.0;
Longitude = Latitude = 0.0;
gamma = Vt = 0.0;
gamma = Vt = Vground = 0.0;
h = 3.0; // Est. height of aircraft cg off runway
SeaLevelRadius = EARTHRAD; // For initialization ONLY
Radius = SeaLevelRadius + h;
@ -121,6 +121,8 @@ bool FGPosition:: Run(void) {
if (!FGModel::Run()) {
GetState();
Vground = sqrt( vVel(eNorth)*vVel(eNorth) + vVel(eEast)*vVel(eEast) );
invMass = 1.0 / Aircraft->GetMass();
Radius = h + SeaLevelRadius;
invRadius = 1.0 / Radius;

View file

@ -63,7 +63,7 @@ class FGPosition : public FGModel {
double DistanceAGL;
double SeaLevelRadius;
double gamma;
double Vt;
double Vt, Vground;
double hoverb,b;
void GetState(void);
@ -77,6 +77,7 @@ public:
inline double GetVn(void) { return vVel(eX); }
inline double GetVe(void) { return vVel(eY); }
inline double GetVd(void) { return vVel(eZ); }
inline double GetVground(void) { return Vground; }
inline double Geth(void) { return h; }
inline double Gethdot(void) { return RadiusDot; }
inline double GetLatitude(void) { return Latitude; }

View file

@ -341,26 +341,30 @@ public:
}
FG_VECTOR_3 n_cg_body_v;
// inline double * get_N_cg_body_v() { return n_cg_body_v; }
// inline double get_N_X_cg() const { return n_cg_body_v[0]; }
// inline double get_N_Y_cg() const { return n_cg_body_v[1]; }
// inline double get_N_Z_cg() const { return n_cg_body_v[2]; }
/* inline void set_Accels_CG_Body_N( double x, double y, double z ) {
inline double * get_N_cg_body_v() { return n_cg_body_v; }
inline double get_N_X_cg() const { return n_cg_body_v[0]; }
inline double get_N_Y_cg() const { return n_cg_body_v[1]; }
inline double get_N_Z_cg() const { return n_cg_body_v[2]; }
inline void set_Accels_CG_Body_N( double x, double y, double z ) {
n_cg_body_v[0] = x;
n_cg_body_v[1] = y;
n_cg_body_v[2] = z;
} */
}
FG_VECTOR_3 n_pilot_body_v;
// inline double * get_N_pilot_body_v() { return n_pilot_body_v; }
// inline double get_N_X_pilot() const { return n_pilot_body_v[0]; }
// inline double get_N_Y_pilot() const { return n_pilot_body_v[1]; }
// inline double get_N_Z_pilot() const { return n_pilot_body_v[2]; }
/* inline void set_Accels_Pilot_Body_N( double x, double y, double z ) {
inline double get_N_X_pilot() const { return n_pilot_body_v[0]; }
inline double get_N_Y_pilot() const { return n_pilot_body_v[1]; }
inline double get_N_Z_pilot() const { return n_pilot_body_v[2]; }
inline void set_Accels_Pilot_Body_N( double x, double y, double z ) {
n_pilot_body_v[0] = x;
n_pilot_body_v[1] = y;
n_pilot_body_v[2] = z;
} */
}
double nlf; //Normal Load Factor
double get_Nlf(void) { return nlf; }
void set_Nlf(double n) { nlf=n; }
FG_VECTOR_3 omega_dot_body_v;
// inline double * get_Omega_dot_body_v() { return omega_dot_body_v; }
@ -876,5 +880,3 @@ void fgFDMSetGroundElevation(int model, double alt_meters);
#endif // _FLIGHT_HXX

View file

@ -192,8 +192,8 @@ bool fgInitPosition( void ) {
f->set_Longitude( current_options.get_lon() * DEG_TO_RAD );
f->set_Latitude( current_options.get_lat() * DEG_TO_RAD );
if ( scenery.cur_elev > current_options.get_altitude() - 2 ) {
current_options.set_altitude( scenery.cur_elev + 2 );
if ( scenery.cur_elev > current_options.get_altitude() - 1) {
current_options.set_altitude( scenery.cur_elev + 1 );
}
FG_LOG( FG_GENERAL, FG_INFO,
@ -201,7 +201,7 @@ bool fgInitPosition( void ) {
f->set_Altitude( current_options.get_altitude() * METER_TO_FEET );
fgFDMSetGroundElevation( current_options.get_flight_model(),
(f->get_Altitude() - 3.758099) * FEET_TO_METER );
f->get_Altitude() * FEET_TO_METER );
FG_LOG( FG_GENERAL, FG_INFO,
"Initial position is: ("