// Display various parameters to stdout
void fgAircraftOutputCurrent(fgAIRCRAFT *a) {
- FGState *f;
+ FGInterface *f;
f = a->fdm_state;
// $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.
//
// Define a structure containing all the parameters for an aircraft
typedef struct{
- FGState *fdm_state;
+ FGInterface *fdm_state;
FGControls *controls;
} fgAIRCRAFT ;
// $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.
geoRa, geoDec;
fgAIRCRAFT *air;
- FGState *f;
+ FGInterface *f;
air = ¤t_aircraft;
f = air->fdm_state;
// Draw the Sky
void fgSkyRender( void ) {
- FGState *f;
+ FGInterface *f;
fgLIGHT *l;
float inner_color[4];
float middle_color[4];
// $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:
//
// Draw the Stars
void fgStarsRender( void ) {
- FGState *f;
+ FGInterface *f;
fgLIGHT *l;
fgTIME *t;
int i;
// $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:
//
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 );
}
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;
-
- 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);
-}
+ double a, d;
+ 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 )
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 )
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;
+ }
}
// $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.
// 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.
// 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.
#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>
// 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
// 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);
// 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 ) {
}
-// 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();
}
-// 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 );
// 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 );
// $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.
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.
//
-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
#include <stdio.h>
#include "flight.hxx"
+#include "JSBsim.hxx"
#include "LaRCsim.hxx"
#include <Debug/logstream.hxx>
// 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;
// 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();
}
// translate FG to LaRCsim structure
- FGState_2_LaRCsim(base_fdm_state);
+ FGInterface_2_LaRCsim(base_fdm_state);
// initialize LaRCsim
fgLaRCsimInit(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,
// 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);
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();
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() );
}
}
// $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.
/* 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 ()'
-
- `FGState::get_Mass ()'
- `FGState::get_I_xx ()'
- `FGState::get_I_yy ()'
- `FGState::get_I_zz ()'
- `FGState::get_I_xz ()'
+ `FGInterface::get_Longitude ()'
+ `FGInterface::get_Latitude ()'
+ `FGInterface::get_Altitude ()'
+ `FGInterface::get_Phi ()'
+ `FGInterface::get_Theta ()'
+ `FGInterface::get_Psi ()'
+ `FGInterface::get_V_equiv_kts ()'
+
+ `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 ()'
*/
// This is based heavily on LaRCsim/ls_generic.h
-class FGState {
+class FGInterface {
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 ==================*/
};
-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);
// $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.
// Handle keyboard events
void GLUTkey(unsigned char k, int x, int y) {
- FGState *f;
+ FGInterface *f;
fgTIME *t;
FGView *v;
FGWeather *w;
// $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.
// 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 = ¤t_view;
// 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;
// Main ...
int main( int argc, char **argv ) {
- FGState *f;
+ FGInterface *f;
f = current_aircraft.fdm_state;
// $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:
//
$(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 \
// Set initial position and orientation
int fgInitPosition( void ) {
string id;
- FGState *f;
+ FGInterface *f;
f = current_aircraft.fdm_state;
// 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 = ¤t_view;
// $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:
//
char dir;
int deg;
double min;
- FGState *f;
+ FGInterface *f;
fgTIME *t;
// run once every two seconds
char dir;
int deg;
double min;
- FGState *f;
+ FGInterface *f;
fgTIME *t;
// run once per second
// $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.
sound(1),
// Flight Model options
- flight_model(FGState::FG_LARCSIM),
+ flight_model(FGInterface::FG_LARCSIM),
// Rendering options
fog(FG_FOG_NICEST), // nicest
}
-// 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);
}
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" ) {
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");
// $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.
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 );
};
// $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:
//
// 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
// 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);
// 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;
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]
// 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;
// $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.
//
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 );
// $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:
//
// 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;
// Render the local tiles
void fgTileMgrRender( void ) {
- FGState *f;
+ FGInterface *f;
fgTILECACHE *c;
fgTILE *t;
FGView *v;
// $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.
//
// 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;
// update position based on inputs, positions, velocities, etc.
void fgSlewUpdate( void ) {
- FGState *f;
+ FGInterface *f;
FGControls *c;
f = current_aircraft.fdm_state;
// $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.
// 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" );
// $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.
// 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.
// 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 };
// 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;
// $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.
//
// Update the weather parameters for the current position
void FGWeather::Update( void ) {
- FGState *f;
+ FGInterface *f;
f = current_aircraft.fdm_state;
// $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".
//