1
0
Fork 0

Modifications to incorporate Jon S. Berndts flight model code.

This commit is contained in:
curt 1999-02-05 21:28:09 +00:00
parent bef268a4cd
commit b8d59efa71
29 changed files with 276 additions and 252 deletions

View file

@ -44,7 +44,7 @@ void fgAircraftInit( void ) {
// Display various parameters to stdout
void fgAircraftOutputCurrent(fgAIRCRAFT *a) {
FGState *f;
FGInterface *f;
f = a->fdm_state;
@ -68,6 +68,9 @@ void fgAircraftOutputCurrent(fgAIRCRAFT *a) {
// $Log$
// Revision 1.7 1999/02/05 21:28:09 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.6 1998/12/05 15:53:59 curt
// Renamed class fgFLIGHT to class FGState as per request by JSB.
//

View file

@ -39,7 +39,7 @@
// Define a structure containing all the parameters for an aircraft
typedef struct{
FGState *fdm_state;
FGInterface *fdm_state;
FGControls *controls;
} fgAIRCRAFT ;
@ -61,6 +61,9 @@ void fgAircraftOutputCurrent(fgAIRCRAFT *a);
// $Log$
// Revision 1.6 1999/02/05 21:28:10 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.5 1999/02/01 21:33:24 curt
// Renamed FlightGear/Simulator/Flight to FlightGear/Simulator/FDM since
// Jon accepted my offer to do this and thought it was a good idea.

View file

@ -113,7 +113,7 @@ void Moon::updatePosition(fgTIME *t, Star *ourSun)
geoRa, geoDec;
fgAIRCRAFT *air;
FGState *f;
FGInterface *f;
air = &current_aircraft;
f = air->fdm_state;

View file

@ -255,7 +255,7 @@ void fgSkyInit( void ) {
// Draw the Sky
void fgSkyRender( void ) {
FGState *f;
FGInterface *f;
fgLIGHT *l;
float inner_color[4];
float middle_color[4];
@ -362,6 +362,9 @@ void fgSkyRender( void ) {
// $Log$
// Revision 1.21 1999/02/05 21:28:50 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.20 1999/02/02 20:13:29 curt
// MSVC++ portability changes by Bernie Bright:
//

View file

@ -220,7 +220,7 @@ int fgStarsInit( void ) {
// Draw the Stars
void fgStarsRender( void ) {
FGState *f;
FGInterface *f;
fgLIGHT *l;
fgTIME *t;
int i;
@ -264,6 +264,9 @@ void fgStarsRender( void ) {
// $Log$
// Revision 1.27 1999/02/05 21:28:52 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.26 1999/02/02 20:13:30 curt
// MSVC++ portability changes by Bernie Bright:
//

View file

@ -50,79 +50,51 @@
static double get_speed( void )
{
FGState *f;
f = current_aircraft.fdm_state;
return( f->get_V_equiv_kts() ); // Make an explicit function call.
return( current_aircraft.fdm_state->get_V_equiv_kts() );
}
static double get_aoa( void )
{
FGState *f;
f = current_aircraft.fdm_state;
return( f->get_Gamma_vert_rad() * RAD_TO_DEG );
return( current_aircraft.fdm_state->get_Gamma_vert_rad() * RAD_TO_DEG );
}
static double fgAPget_roll( void )
{
FGState *f;
f = current_aircraft.fdm_state;
return( f->get_Phi() * RAD_TO_DEG );
return( current_aircraft.fdm_state->get_Phi() * RAD_TO_DEG );
}
static double get_pitch( void )
{
FGState *f;
f = current_aircraft.fdm_state;
return( f->get_Theta() );
return( current_aircraft.fdm_state->get_Theta() );
}
double fgAPget_heading( void )
{
FGState *f;
f = current_aircraft.fdm_state;
return( f->get_Psi() * RAD_TO_DEG );
return( current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG );
}
static double fgAPget_altitude( void )
{
FGState *f;
f = current_aircraft.fdm_state;
return( f->get_Altitude() * FEET_TO_METER /* -rough_elev */ );
return( current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER );
}
static double fgAPget_climb( void )
{
FGState *f;
f = current_aircraft.fdm_state;
// return in meters per minute
return( f->get_Climb_Rate() * FEET_TO_METER * 60 );
// return in meters per minute
return( current_aircraft.fdm_state->get_Climb_Rate() * FEET_TO_METER * 60 );
}
static double get_sideslip( void )
{
FGState *f;
f = current_aircraft.fdm_state;
return( f->get_Beta() );
return( current_aircraft.fdm_state->get_Beta() );
}
static double fgAPget_agl( void )
{
FGState *f;
double agl;
f = current_aircraft.fdm_state;
agl = f->get_Altitude() * FEET_TO_METER - scenery.cur_elev;
agl = current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER
- scenery.cur_elev;
return( agl );
}

View file

@ -66,50 +66,38 @@ static pCockpit ac_cockpit;
double get_latitude( void )
{
FGState *f;
f = current_aircraft.fdm_state;
// return( toDM(FG_Latitude * RAD_TO_DEG) );
return((double)((int)( f->get_Latitude() * RAD_TO_DEG)) );
return((double)((int)( current_aircraft.fdm_state->get_Latitude()
* RAD_TO_DEG)) );
}
double get_lat_min( void )
{
FGState *f;
double a, d;
double a, d;
f = current_aircraft.fdm_state;
a = f->get_Latitude() * RAD_TO_DEG;
if (a < 0.0) {
a = -a;
}
d = (double) ( (int) a);
return( (a - d) * 60.0);
a = current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
if (a < 0.0) {
a = -a;
}
d = (double) ( (int) a);
return( (a - d) * 60.0);
}
double get_longitude( void )
{
FGState *f;
f = current_aircraft.fdm_state;
// return( toDM(FG_Longitude * RAD_TO_DEG) );
return((double)((int) (f->get_Longitude() * RAD_TO_DEG)) );
return( (double)((int) (current_aircraft.fdm_state->get_Longitude()
* RAD_TO_DEG)) );
}
double get_long_min( void )
{
FGState *f;
double a, d;
f = current_aircraft.fdm_state;
a = f->get_Longitude() * RAD_TO_DEG;
if (a < 0.0) {
a = -a;
}
d = (double) ( (int) a);
return( (a - d) * 60.0);
double a, d;
a = current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
if (a < 0.0) {
a = -a;
}
d = (double) ( (int) a);
return( (a - d) * 60.0);
}
double get_throttleval( void )
@ -139,80 +127,52 @@ double get_rudderval( void )
double get_speed( void )
{
FGState *f;
f = current_aircraft.fdm_state;
return( f->get_V_equiv_kts() ); // Make an explicit function call.
return( current_aircraft.fdm_state->get_V_equiv_kts() );
}
double get_aoa( void )
{
FGState *f;
f = current_aircraft.fdm_state;
return( f->get_Alpha() * RAD_TO_DEG );
return( current_aircraft.fdm_state->get_Alpha() * RAD_TO_DEG );
}
double get_roll( void )
{
FGState *f;
f = current_aircraft.fdm_state;
return( f->get_Phi() );
return( current_aircraft.fdm_state->get_Phi() );
}
double get_pitch( void )
{
FGState *f;
f = current_aircraft.fdm_state;
return( f->get_Theta() );
return( current_aircraft.fdm_state->get_Theta() );
}
double get_heading( void )
{
FGState *f;
f = current_aircraft.fdm_state;
return( f->get_Psi() * RAD_TO_DEG );
return( current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG );
}
double get_altitude( void )
{
FGState *f;
// double rough_elev;
f = current_aircraft.fdm_state;
// rough_elev = mesh_altitude(f->get_Longitude() * RAD_TO_ARCSEC,
// f->get_Latitude() * RAD_TO_ARCSEC);
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
return f->get_Altitude();
} else {
return f->get_Altitude() * FEET_TO_METER;
}
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
return current_aircraft.fdm_state->get_Altitude();
} else {
return current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER;
}
}
double get_agl( void )
{
FGState *f;
f = current_aircraft.fdm_state;
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
return f->get_Altitude() - scenery.cur_elev * METER_TO_FEET;
} else {
return f->get_Altitude() * FEET_TO_METER - scenery.cur_elev;
}
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
return current_aircraft.fdm_state->get_Altitude()
- scenery.cur_elev * METER_TO_FEET;
} else {
return current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER
- scenery.cur_elev;
}
}
double get_sideslip( void )
{
FGState *f;
f = current_aircraft.fdm_state;
return( f->get_Beta() );
return( current_aircraft.fdm_state->get_Beta() );
}
double get_frame_rate( void )
@ -237,15 +197,12 @@ double get_vfc_tris_drawn ( void )
double get_climb_rate( void )
{
FGState *f;
f = current_aircraft.fdm_state;
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
return f->get_Climb_Rate() * 60.0;
} else {
return f->get_Climb_Rate() * FEET_TO_METER * 60.0;
}
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
return current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
} else {
return current_aircraft.fdm_state->get_Climb_Rate()
* FEET_TO_METER * 60.0;
}
}
@ -303,6 +260,9 @@ void fgCockpitUpdate( void ) {
// $Log$
// Revision 1.30 1999/02/05 21:28:57 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.29 1999/01/08 19:27:34 curt
// Fixed AOA reading on HUD.
// Continued work on time jitter compensation.

View file

@ -31,17 +31,20 @@
// reset flight params to a specific position
void fgExternalInit( FGState &f ) {
void fgExternalInit( FGInterface &f ) {
}
// update position based on inputs, positions, velocities, etc.
void fgExternalUpdate( FGState& f, int multiloop ) {
void fgExternalUpdate( FGInterface& f, int multiloop ) {
}
// $Log$
// Revision 1.5 1999/02/05 21:29:03 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.4 1999/02/01 21:33:32 curt
// Renamed FlightGear/Simulator/Flight to FlightGear/Simulator/FDM since
// Jon accepted my offer to do this and thought it was a good idea.

View file

@ -76,13 +76,16 @@ public:
// reset flight params to a specific position
void fgExternalInit( FGState& f );
void fgExternalInit( FGInterface& f );
#endif // _EXTERNAL_HXX
// $Log$
// Revision 1.6 1999/02/05 21:29:04 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.5 1999/01/19 17:52:12 curt
// Working on being able to extrapolate a new position and orientation
// based on a position, orientation, and time offset.

View file

@ -26,6 +26,7 @@
#include <Aircraft/aircraft.hxx>
#include <Controls/controls.hxx>
#include <Debug/logstream.hxx>
#include <FDM/flight.hxx>
#include <FDM/LaRCsim/ls_cockpit.h>
#include <FDM/LaRCsim/ls_generic.h>
@ -42,7 +43,7 @@ int fgLaRCsimInit(double dt) {
// Run an iteration of the EOM (equations of motion)
int fgLaRCsimUpdate(FGState& f, int multiloop) {
int fgLaRCsimUpdate(FGInterface& f, int multiloop) {
double save_alt = 0.0;
// lets try to avoid really screwing up the LaRCsim model
@ -62,9 +63,9 @@ int fgLaRCsimUpdate(FGState& f, int multiloop) {
// Inform LaRCsim of the local terrain altitude
Runway_altitude = f.get_Runway_altitude();
// old -- FGstate_2_LaRCsim() not needed except for Init()
// old -- FGInterface_2_LaRCsim() not needed except for Init()
// translate FG to LaRCsim structure
// FGState_2_LaRCsim(f);
// FGInterface_2_LaRCsim(f);
// printf("FG_Altitude = %.2f\n", FG_Altitude * 0.3048);
// printf("Altitude = %.2f\n", Altitude * 0.3048);
// printf("Radius to Vehicle = %.2f\n", Radius_to_vehicle * 0.3048);
@ -77,7 +78,7 @@ int fgLaRCsimUpdate(FGState& f, int multiloop) {
// translate LaRCsim back to FG structure so that the
// autopilot (and the rest of the sim can use the updated
// values
fgLaRCsim_2_FGState(f);
fgLaRCsim_2_FGInterface(f);
// but lets restore our original bogus altitude when we are done
if ( save_alt < -9000.0 ) {
@ -88,8 +89,8 @@ int fgLaRCsimUpdate(FGState& f, int multiloop) {
}
// Convert from the FGState struct to the LaRCsim generic_ struct
int FGState_2_LaRCsim (FGState& f) {
// Convert from the FGInterface struct to the LaRCsim generic_ struct
int FGInterface_2_LaRCsim (FGInterface& f) {
Mass = f.get_Mass();
I_xx = f.get_I_xx();
@ -265,8 +266,8 @@ int FGState_2_LaRCsim (FGState& f) {
}
// Convert from the LaRCsim generic_ struct to the FGState struct
int fgLaRCsim_2_FGState (FGState& f) {
// Convert from the LaRCsim generic_ struct to the FGInterface struct
int fgLaRCsim_2_FGInterface (FGInterface& f) {
// Mass properties and geometry values
f.set_Inertias( Mass, I_xx, I_yy, I_zz, I_xz );
@ -324,6 +325,11 @@ int fgLaRCsim_2_FGState (FGState& f) {
// f.set_Euler_Rates( Phi_dot, Theta_dot, Psi_dot );
f.set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
FG_LOG( FG_FLIGHT, FG_DEBUG, "lon = " << Longitude
<< " lat_geoc = " << Lat_geocentric << " lat_geod = " << Latitude
<< " alt = " << Altitude << " sl_radius = " << Sea_level_radius
<< " radius_to_vehicle = " << Radius_to_vehicle );
// Positions
f.set_Geocentric_Position( Lat_geocentric, Lon_geocentric,
Radius_to_vehicle );
@ -389,6 +395,9 @@ int fgLaRCsim_2_FGState (FGState& f) {
// $Log$
// Revision 1.11 1999/02/05 21:28:58 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.10 1999/02/01 21:33:30 curt
// Renamed FlightGear/Simulator/Flight to FlightGear/Simulator/FDM since
// Jon accepted my offer to do this and thought it was a good idea.

View file

@ -35,19 +35,22 @@
int fgLaRCsimInit(double dt);
// update position based on inputs, positions, velocities, etc.
int fgLaRCsimUpdate(FGState& f, int multiloop);
int fgLaRCsimUpdate(FGInterface& f, int multiloop);
// Convert from the FGState struct to the LaRCsim generic_ struct
int FGState_2_LaRCsim (FGState& f);
// Convert from the FGInterface struct to the LaRCsim generic_ struct
int FGInterface_2_LaRCsim (FGInterface& f);
// Convert from the LaRCsim generic_ struct to the FGState struct
int fgLaRCsim_2_FGState (FGState& f);
// Convert from the LaRCsim generic_ struct to the FGInterface struct
int fgLaRCsim_2_FGInterface (FGInterface& f);
#endif // _LARCSIM_HXX
// $Log$
// Revision 1.5 1999/02/05 21:28:59 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.4 1998/12/05 15:54:09 curt
// Renamed class fgFLIGHT to class FGState as per request by JSB.
//

View file

@ -1,7 +1,9 @@
SUBDIRS = External LaRCsim Slew
SUBDIRS = External JSBsim LaRCsim Slew
noinst_LIBRARIES = libFlight.a
libFlight_a_SOURCES = flight.cxx flight.hxx LaRCsim.cxx LaRCsim.hxx
libFlight_a_SOURCES = flight.cxx flight.hxx \
JSBsim.cxx JSBsim.hxx \
LaRCsim.cxx LaRCsim.hxx
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator

View file

@ -25,6 +25,7 @@
#include <stdio.h>
#include "flight.hxx"
#include "JSBsim.hxx"
#include "LaRCsim.hxx"
#include <Debug/logstream.hxx>
@ -40,12 +41,12 @@
// world time, so we introduce cur_fdm_state which is extrapolated by
// the difference between sim time and real world time
FGState cur_fdm_state;
FGState base_fdm_state;
FGInterface cur_fdm_state;
FGInterface base_fdm_state;
// Extrapolate fdm based on time_offset (in usec)
void FGState::extrapolate( int time_offset ) {
void FGInterface::extrapolate( int time_offset ) {
double dt = time_offset / 1000000.0;
cout << "extrapolating FDM by dt = " << dt << endl;
@ -70,17 +71,19 @@ void FGState::extrapolate( int time_offset ) {
// Initialize the flight model parameters
int fgFDMInit(int model, FGState& f, double dt) {
int fgFDMInit(int model, FGInterface& f, double dt) {
double save_alt = 0.0;
FG_LOG( FG_FLIGHT ,FG_INFO, "Initializing flight model" );
base_fdm_state = f;
if ( model == FGState::FG_SLEW ) {
if ( model == FGInterface::FG_SLEW ) {
// fgSlewInit(dt);
} else if ( model == FGState::FG_LARCSIM ) {
} else if ( model == FGInterface::FG_JSBSIM ) {
fgJSBsimInit(dt);
fgJSBsim_2_FGInterface(base_fdm_state);
} else if ( model == FGInterface::FG_LARCSIM ) {
// lets try to avoid really screwing up the LaRCsim model
if ( base_fdm_state.get_Altitude() < -9000.0 ) {
save_alt = base_fdm_state.get_Altitude();
@ -88,7 +91,7 @@ int fgFDMInit(int model, FGState& f, double dt) {
}
// translate FG to LaRCsim structure
FGState_2_LaRCsim(base_fdm_state);
FGInterface_2_LaRCsim(base_fdm_state);
// initialize LaRCsim
fgLaRCsimInit(dt);
@ -97,13 +100,13 @@ int fgFDMInit(int model, FGState& f, double dt) {
base_fdm_state.get_Latitude() );
// translate LaRCsim back to FG structure
fgLaRCsim_2_FGState(base_fdm_state);
fgLaRCsim_2_FGInterface(base_fdm_state);
// but lets restore our original bogus altitude when we are done
if ( save_alt < -9000.0 ) {
base_fdm_state.set_Altitude( save_alt );
}
} else if ( model == FGState::FG_EXTERNAL ) {
} else if ( model == FGInterface::FG_EXTERNAL ) {
fgExternalInit(base_fdm_state);
} else {
FG_LOG( FG_FLIGHT, FG_WARN,
@ -120,7 +123,7 @@ int fgFDMInit(int model, FGState& f, double dt) {
// Run multiloop iterations of the flight model
int fgFDMUpdate(int model, FGState& f, int multiloop, int time_offset) {
int fgFDMUpdate(int model, FGInterface& f, int multiloop, int time_offset) {
double time_step, start_elev, end_elev;
// printf("Altitude = %.2f\n", FG_Altitude * 0.3048);
@ -131,14 +134,17 @@ int fgFDMUpdate(int model, FGState& f, int multiloop, int time_offset) {
time_step = (1.0 / DEFAULT_MODEL_HZ) * multiloop;
start_elev = base_fdm_state.get_Altitude();
if ( model == FGState::FG_SLEW ) {
if ( model == FGInterface::FG_SLEW ) {
// fgSlewUpdate(f, multiloop);
} else if ( model == FGState::FG_LARCSIM ) {
} else if ( model == FGInterface::FG_JSBSIM ) {
fgJSBsimUpdate(base_fdm_state, multiloop);
f = base_fdm_state;
} else if ( model == FGInterface::FG_LARCSIM ) {
fgLaRCsimUpdate(base_fdm_state, multiloop);
// extrapolate position based on actual time
// f = extrapolate_fdm( base_fdm_state, time_offset );
f = base_fdm_state;
} else if ( model == FGState::FG_EXTERNAL ) {
} else if ( model == FGInterface::FG_EXTERNAL ) {
// fgExternalUpdate(f, multiloop);
FGTimeStamp current;
current.stamp();
@ -175,7 +181,7 @@ void fgFDMForceAltitude(int model, double alt_meters) {
METER_TO_FEET) );
// additional work needed for some flight models
if ( model == FGState::FG_LARCSIM ) {
if ( model == FGInterface::FG_LARCSIM ) {
ls_ForceAltitude( base_fdm_state.get_Altitude() );
}
}
@ -189,6 +195,9 @@ void fgFDMSetGroundElevation(int model, double ground_meters) {
// $Log$
// Revision 1.15 1999/02/05 21:29:01 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.14 1999/02/01 21:33:31 curt
// Renamed FlightGear/Simulator/Flight to FlightGear/Simulator/FDM since
// Jon accepted my offer to do this and thought it was a good idea.

View file

@ -33,51 +33,51 @@
/* Required get_()
`FGState::get_Longitude ()'
`FGState::get_Latitude ()'
`FGState::get_Altitude ()'
`FGState::get_Phi ()'
`FGState::get_Theta ()'
`FGState::get_Psi ()'
`FGState::get_V_equiv_kts ()'
`FGInterface::get_Longitude ()'
`FGInterface::get_Latitude ()'
`FGInterface::get_Altitude ()'
`FGInterface::get_Phi ()'
`FGInterface::get_Theta ()'
`FGInterface::get_Psi ()'
`FGInterface::get_V_equiv_kts ()'
`FGState::get_Mass ()'
`FGState::get_I_xx ()'
`FGState::get_I_yy ()'
`FGState::get_I_zz ()'
`FGState::get_I_xz ()'
`FGInterface::get_Mass ()'
`FGInterface::get_I_xx ()'
`FGInterface::get_I_yy ()'
`FGInterface::get_I_zz ()'
`FGInterface::get_I_xz ()'
`FGState::get_V_north ()'
`FGState::get_V_east ()'
`FGState::get_V_down ()'
`FGInterface::get_V_north ()'
`FGInterface::get_V_east ()'
`FGInterface::get_V_down ()'
`FGState::get_P_Body ()'
`FGState::get_Q_Body ()'
`FGState::get_R_Body ()'
`FGInterface::get_P_Body ()'
`FGInterface::get_Q_Body ()'
`FGInterface::get_R_Body ()'
`FGState::get_Gamma_vert_rad ()'
`FGState::get_Climb_Rate ()'
`FGState::get_Alpha ()'
`FGState::get_Beta ()'
`FGInterface::get_Gamma_vert_rad ()'
`FGInterface::get_Climb_Rate ()'
`FGInterface::get_Alpha ()'
`FGInterface::get_Beta ()'
`FGState::get_Runway_altitude ()'
`FGInterface::get_Runway_altitude ()'
`FGState::get_Lon_geocentric ()'
`FGState::get_Lat_geocentric ()'
`FGState::get_Sea_level_radius ()'
`FGState::get_Earth_position_angle ()'
`FGInterface::get_Lon_geocentric ()'
`FGInterface::get_Lat_geocentric ()'
`FGInterface::get_Sea_level_radius ()'
`FGInterface::get_Earth_position_angle ()'
`FGState::get_Latitude_dot()'
`FGState::get_Longitude_dot()'
`FGState::get_Radius_dot()'
`FGInterface::get_Latitude_dot()'
`FGInterface::get_Longitude_dot()'
`FGInterface::get_Radius_dot()'
`FGState::get_Dx_cg ()'
`FGState::get_Dy_cg ()'
`FGState::get_Dz_cg ()'
`FGInterface::get_Dx_cg ()'
`FGInterface::get_Dy_cg ()'
`FGInterface::get_Dz_cg ()'
`FGState::get_T_local_to_body_11 ()' ... `FGState::get_T_local_to_body_33 ()'
`FGInterface::get_T_local_to_body_11 ()' ... `FGInterface::get_T_local_to_body_33 ()'
`FGState::get_Radius_to_vehicle ()'
`FGInterface::get_Radius_to_vehicle ()'
*/
@ -93,7 +93,7 @@ typedef double FG_VECTOR_3[3];
// This is based heavily on LaRCsim/ls_generic.h
class FGState {
class FGInterface {
public:
@ -102,18 +102,23 @@ public:
// Slew (in MS terminology)
FG_SLEW = 0,
// The only "real" model that is currently implemented
// The NASA LaRCsim (Navion) flight model
FG_LARCSIM = 1,
FG_ACM = 2,
FG_SUPER_SONIC = 3,
FG_HELICOPTER = 4,
FG_AUTOGYRO = 5,
FG_BALLOON = 6,
FG_PARACHUTE = 7,
// Jon S. Berndt's new FDM written from the ground up in C++
FG_JSBSIM = 2,
// The following aren't implemented but are here to spark
// thoughts and discussions, and maybe even action.
FG_ACM = 3,
FG_SUPER_SONIC = 4,
FG_HELICOPTER = 5,
FG_AUTOGYRO = 6,
FG_BALLOON = 7,
FG_PARACHUTE = 8,
// Driven externally via a serial port, net, file, etc.
FG_EXTERNAL = 8
FG_EXTERNAL = 9
};
/*================== Mass properties and geometry values ==================*/
@ -792,16 +797,16 @@ public:
};
extern FGState cur_fdm_state;
extern FGInterface cur_fdm_state;
// General interface to the flight model routines
// Initialize the flight model parameters
int fgFDMInit(int model, FGState& f, double dt);
int fgFDMInit(int model, FGInterface& f, double dt);
// Run multiloop iterations of the flight model
int fgFDMUpdate(int model, FGState& f, int multiloop, int jitter);
int fgFDMUpdate(int model, FGInterface& f, int multiloop, int jitter);
// Set the altitude (force)
void fgFDMForceAltitude(int model, double alt_meters);
@ -814,6 +819,9 @@ void fgFDMSetGroundElevation(int model, double alt_meters);
// $Log$
// Revision 1.13 1999/02/05 21:29:02 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.12 1999/01/20 13:42:23 curt
// Tweaked FDM interface.
// Testing check sum support for NMEA serial output.

View file

@ -69,7 +69,7 @@ static void local_update_sky_and_lighting_params( void ) {
// Handle keyboard events
void GLUTkey(unsigned char k, int x, int y) {
FGState *f;
FGInterface *f;
fgTIME *t;
FGView *v;
FGWeather *w;
@ -386,6 +386,9 @@ void GLUTspecialkey(int k, int x, int y) {
// $Log$
// Revision 1.39 1999/02/05 21:29:07 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.38 1998/12/11 20:26:25 curt
// Fixed view frustum culling accuracy bug so we can look out the sides and
// back without tri-stripes dropping out.

View file

@ -371,7 +371,7 @@ static void fgRenderFrame( void ) {
// Update internal time dependent calculations (i.e. flight model)
void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
FGState *f = current_aircraft.fdm_state;
FGInterface *f = current_aircraft.fdm_state;
fgLIGHT *l = &cur_light_params;
fgTIME *t = &cur_time_params;
FGView *v = &current_view;
@ -451,7 +451,7 @@ static const double alt_adjust_m = alt_adjust_ft * FEET_TO_METER;
// What should we do when we have nothing else to do? Let's get ready
// for the next move and update the display?
static void fgMainLoop( void ) {
FGState *f;
FGInterface *f;
fgTIME *t;
static long remainder = 0;
long elapsed, multi_loop;
@ -927,7 +927,7 @@ int fgGlutInitEvents( void ) {
// Main ...
int main( int argc, char **argv ) {
FGState *f;
FGInterface *f;
f = current_aircraft.fdm_state;
@ -1007,6 +1007,9 @@ int main( int argc, char **argv ) {
// $Log$
// Revision 1.85 1999/02/05 21:29:08 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.84 1999/02/02 20:13:34 curt
// MSVC++ portability changes by Bernie Bright:
//

View file

@ -52,6 +52,7 @@ fgfs_LDADD = \
$(top_builddir)/Simulator/Controls/libControls.a \
$(top_builddir)/Simulator/FDM/libFlight.a \
$(top_builddir)/Simulator/FDM/External/libExternal.a \
$(top_builddir)/Simulator/FDM/JSBsim/libJSBsim.a \
$(top_builddir)/Simulator/FDM/LaRCsim/libLaRCsim.a \
$(top_builddir)/Simulator/FDM/Slew/libSlew.a \
$(top_builddir)/Simulator/GUI/libGUI.a \

View file

@ -74,7 +74,7 @@ extern const char *default_root;
// Set initial position and orientation
int fgInitPosition( void ) {
string id;
FGState *f;
FGInterface *f;
f = current_aircraft.fdm_state;
@ -154,7 +154,7 @@ int fgInitGeneral( void ) {
// Returns non-zero if a problem encountered.
int fgInitSubsystems( void )
{
FGState *f; // assigned later
FGInterface *f; // assigned later
fgLIGHT *l = &cur_light_params;
fgTIME *t = &cur_time_params;
FGView *v = &current_view;
@ -392,6 +392,9 @@ int fgInitSubsystems( void )
// $Log$
// Revision 1.66 1999/02/05 21:29:10 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.65 1999/02/02 20:13:36 curt
// MSVC++ portability changes by Bernie Bright:
//

View file

@ -232,7 +232,7 @@ static void send_nmea_out( fgIOCHANNEL *p ) {
char dir;
int deg;
double min;
FGState *f;
FGInterface *f;
fgTIME *t;
// run once every two seconds
@ -331,7 +331,7 @@ static void send_garmin_out( fgIOCHANNEL *p ) {
char dir;
int deg;
double min;
FGState *f;
FGInterface *f;
fgTIME *t;
// run once per second
@ -468,6 +468,9 @@ void fgSerialProcess() {
// $Log$
// Revision 1.11 1999/02/05 21:29:11 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.10 1999/01/21 00:55:01 curt
// Fixed some problems with timing of output strings.
// Added checksum support for nmea and garmin output.

View file

@ -128,7 +128,7 @@ fgOPTIONS::fgOPTIONS() :
sound(1),
// Flight Model options
flight_model(FGState::FG_LARCSIM),
flight_model(FGInterface::FG_LARCSIM),
// Rendering options
fog(FG_FOG_NICEST), // nicest
@ -303,19 +303,21 @@ fgOPTIONS::parse_tile_radius( const string& arg ) {
}
// Parse --flightmode=abcdefg type option
// Parse --fdm=abcdefg type option
int
fgOPTIONS::parse_flight_model( const string& fm ) {
// printf("flight model = %s\n", fm);
fgOPTIONS::parse_fdm( const string& fm ) {
// printf("fdm = %s\n", fm);
if ( fm == "slew" ) {
return FGState::FG_SLEW;
return FGInterface::FG_SLEW;
} else if ( fm == "jsb" ) {
return FGInterface::FG_JSBSIM;
} else if ( (fm == "larcsim") || (fm == "LaRCsim") ) {
return FGState::FG_LARCSIM;
return FGInterface::FG_LARCSIM;
} else if ( fm == "external" ) {
return FGState::FG_EXTERNAL;
return FGInterface::FG_EXTERNAL;
} else {
FG_LOG( FG_GENERAL, FG_ALERT, "Unknown flight model = " << fm );
FG_LOG( FG_GENERAL, FG_ALERT, "Unknown fdm = " << fm );
exit(-1);
}
@ -426,8 +428,8 @@ int fgOPTIONS::parse_option( const string& arg ) {
pitch = atof( arg.substr(8) );
} else if ( arg.find( "--fg-root=" ) != string::npos ) {
fg_root = arg.substr( 10 );
} else if ( arg.find( "--flight-model=" ) != string::npos ) {
flight_model = parse_flight_model( arg.substr(15) );
} else if ( arg.find( "--fdm=" ) != string::npos ) {
flight_model = parse_fdm( arg.substr(6) );
} else if ( arg == "--fog-disable" ) {
fog = FG_FOG_DISABLED;
} else if ( arg == "--fog-fastest" ) {
@ -575,7 +577,7 @@ void fgOPTIONS::usage ( void ) {
printf("\n");
printf("Flight Model:\n");
printf("\t--flight-mode=abcd: one of slew, larcsim, or external\n");
printf("\t--fdm=abcd: one of slew, jsb, larcsim, or external\n");
printf("\n");
printf("Initial Position and Orientation:\n");
@ -629,6 +631,9 @@ fgOPTIONS::~fgOPTIONS( void ) {
// $Log$
// Revision 1.39 1999/02/05 21:29:12 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.38 1999/02/01 21:33:35 curt
// Renamed FlightGear/Simulator/Flight to FlightGear/Simulator/FDM since
// Jon accepted my offer to do this and thought it was a good idea.

View file

@ -232,7 +232,7 @@ private:
double parse_degree( const string& degree_str );
int parse_time_offset( const string& time_str );
int parse_tile_radius( const string& arg );
int parse_flight_model( const string& fm );
int parse_fdm( const string& fm );
double parse_fov( const string& arg );
bool parse_serial( const string& serial_str );
};
@ -245,6 +245,9 @@ extern fgOPTIONS current_options;
// $Log$
// Revision 1.27 1999/02/05 21:29:13 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.26 1999/02/02 20:13:37 curt
// MSVC++ portability changes by Bernie Bright:
//

View file

@ -52,7 +52,7 @@ static int panel_hist = 0;
// and external modes wouldn't need to recreate the LaRCsim matrices
// themselves.
static const bool use_larcsim_local_to_body = true;
static const bool use_larcsim_local_to_body = false;
// This is a record containing current view parameters
@ -198,7 +198,7 @@ void FGView::LookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
// Update the view volume, position, and orientation
void FGView::UpdateViewParams( void ) {
FGState *f = current_aircraft.fdm_state;
FGInterface *f = current_aircraft.fdm_state;
UpdateViewMath(f);
UpdateWorldToEye(f);
@ -262,7 +262,7 @@ void FGView::UpdateViewParams( void ) {
// Update the view parameters
void FGView::UpdateViewMath( FGState *f ) {
void FGView::UpdateViewMath( FGInterface *f ) {
Point3D p;
MAT3vec vec, forward, v0, minus_z;
MAT3mat R, TMP, UP, LOCAL, VIEW;
@ -296,15 +296,13 @@ void FGView::UpdateViewMath( FGState *f ) {
p.setz( p.radius() + scenery.cur_elev + 0.5 * METER_TO_FEET );
}
abs_view_pos = fgPolarToCart3d(p);
view_pos = abs_view_pos - scenery.center;
FG_LOG( FG_VIEW, FG_DEBUG, "Absolute view pos = "
<< abs_view_pos.x() << ", "
<< abs_view_pos.y() << ", "
<< abs_view_pos.z() );
FG_LOG( FG_VIEW, FG_DEBUG, "Relative view pos = "
<< view_pos.x() << ", " << view_pos.y() << ", " << view_pos.z() );
FG_LOG( FG_VIEW, FG_DEBUG, "Polar view pos = " << p );
FG_LOG( FG_VIEW, FG_DEBUG, "Absolute view pos = " << abs_view_pos );
FG_LOG( FG_VIEW, FG_DEBUG, "Relative view pos = " << view_pos );
// Derive the LOCAL aircraft rotation matrix (roll, pitch, yaw)
// from FG_T_local_to_body[3][3]
@ -435,7 +433,7 @@ void FGView::UpdateViewMath( FGState *f ) {
// Update the "World to Eye" transformation matrix
// This is most useful for view frustum culling
void FGView::UpdateWorldToEye( FGState *f ) {
void FGView::UpdateWorldToEye( FGInterface *f ) {
MAT3mat R_Phi, R_Theta, R_Psi, R_Lat, R_Lon, T_view;
MAT3mat TMP;
MAT3hvec vec;
@ -603,6 +601,9 @@ FGView::~FGView( void ) {
// $Log$
// Revision 1.33 1999/02/05 21:29:14 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.32 1999/01/07 20:25:12 curt
// Updated struct fgGENERAL to class FGGeneral.
//

View file

@ -172,10 +172,10 @@ public:
inline void force_update_fov_math() { update_fov = true; }
// Update the view parameters
void UpdateViewMath( FGState *f );
void UpdateViewMath( FGInterface *f );
// Update the "World to Eye" transformation matrix
void UpdateWorldToEye( FGState *f );
void UpdateWorldToEye( FGInterface *f );
// Update the field of view coefficients
void UpdateFOV( const fgOPTIONS& o );
@ -232,6 +232,9 @@ extern FGView current_view;
// $Log$
// Revision 1.21 1999/02/05 21:29:15 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.20 1999/02/02 20:13:38 curt
// MSVC++ portability changes by Bernie Bright:
//

View file

@ -333,7 +333,7 @@ fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos ) {
// the chunk isn't already in the cache, then read it from disk.
int fgTileMgrUpdate( void ) {
fgTILECACHE *c;
FGState *f;
FGInterface *f;
fgBUCKET p1, p2;
static fgBUCKET p_last = {-1000, 0, 0, 0};
int tile_diameter;
@ -651,7 +651,7 @@ update_tile_geometry( fgTILE *t, GLdouble *MODEL_VIEW)
// Render the local tiles
void fgTileMgrRender( void ) {
FGState *f;
FGInterface *f;
fgTILECACHE *c;
fgTILE *t;
FGView *v;
@ -758,6 +758,9 @@ void fgTileMgrRender( void ) {
// $Log$
// Revision 1.53 1999/02/05 21:29:16 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.52 1999/01/27 04:49:48 curt
// Fixes so that the sim can start out at an airport below sea level.
//

View file

@ -34,7 +34,7 @@
// reset flight params to a specific position
void fgSlewInit(double pos_x, double pos_y, double pos_z, double heading) {
FGState *f;
FGInterface *f;
f = current_aircraft.fdm_state;
@ -62,7 +62,7 @@ void fgSlewInit(double pos_x, double pos_y, double pos_z, double heading) {
// update position based on inputs, positions, velocities, etc.
void fgSlewUpdate( void ) {
FGState *f;
FGInterface *f;
FGControls *c;
f = current_aircraft.fdm_state;
@ -83,6 +83,9 @@ void fgSlewUpdate( void ) {
// $Log$
// Revision 1.6 1999/02/05 21:29:05 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.5 1999/02/01 21:33:33 curt
// Renamed FlightGear/Simulator/Flight to FlightGear/Simulator/FDM since
// Jon accepted my offer to do this and thought it was a good idea.

View file

@ -333,7 +333,7 @@ double sidereal_course(fgTIME *t, double lng) {
// Update time variables such as gmt, julian date, and sidereal time
void fgTimeUpdate(FGState *f, fgTIME *t) {
void fgTimeUpdate(FGInterface *f, fgTIME *t) {
double gst_precise, gst_course;
FG_LOG( FG_EVENT, FG_DEBUG, "Updating time" );
@ -399,6 +399,9 @@ void fgTimeUpdate(FGState *f, fgTIME *t) {
// $Log$
// Revision 1.31 1999/02/05 21:29:18 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.30 1999/02/01 21:33:37 curt
// Renamed FlightGear/Simulator/Flight to FlightGear/Simulator/FDM since
// Jon accepted my offer to do this and thought it was a good idea.

View file

@ -98,13 +98,16 @@ void fgTimeInit(fgTIME *t);
// Update the time dependent variables
void fgTimeUpdate(FGState *f, fgTIME *t);
void fgTimeUpdate(FGInterface *f, fgTIME *t);
#endif // _FG_TIME_HXX
// $Log$
// Revision 1.14 1999/02/05 21:29:19 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.13 1999/02/01 21:33:39 curt
// Renamed FlightGear/Simulator/Flight to FlightGear/Simulator/FDM since
// Jon accepted my offer to do this and thought it was a good idea.

View file

@ -95,7 +95,7 @@ void fgLIGHT::Init( void ) {
// update lighting parameters based on current sun position
void fgLIGHT::Update( void ) {
FGState *f;
FGInterface *f;
fgTIME *t;
// if the 4th field is 0.0, this specifies a direction ...
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
@ -154,7 +154,7 @@ void fgLIGHT::Update( void ) {
// calculate fog color adjusted for sunrise/sunset effects
void fgLIGHT::UpdateAdjFog( void ) {
FGState *f;
FGInterface *f;
double sun_angle_deg, rotation, param1[3], param2[3];
f = current_aircraft.fdm_state;
@ -220,6 +220,9 @@ fgLIGHT::~fgLIGHT( void ) {
// $Log$
// Revision 1.26 1999/02/05 21:29:20 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.25 1999/01/07 20:25:36 curt
// Portability changes and updates from Bernie Bright.
//

View file

@ -67,7 +67,7 @@ void FGWeather::Init( ) {
// Update the weather parameters for the current position
void FGWeather::Update( void ) {
FGState *f;
FGInterface *f;
f = current_aircraft.fdm_state;
@ -79,6 +79,9 @@ void FGWeather::Update( void ) {
// $Log$
// Revision 1.6 1999/02/05 21:29:21 curt
// Modifications to incorporate Jon S. Berndts flight model code.
//
// Revision 1.5 1998/12/06 13:51:26 curt
// Turned "struct fgWEATHER" into "class FGWeather".
//