1
0
Fork 0
flightgear/src/FDM/ADA.cxx

332 lines
10 KiB
C++
Raw Normal View History

// ADA.cxx -- interface to the "External"-ly driven ADA flight model
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// $Id$
// Modified by Cdr. VS Renganthan <vsranga@ada.ernet.in>, 12 Oct 2K
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/io/iochannel.hxx>
#include <simgear/io/sg_socket.hxx>
#include <simgear/constants.h>
#include <Controls/controls.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx> //to get ID of window (left/right or center)
#include <Scenery/scenery.hxx> //to pass ground elevation to FDM
#include "ADA.hxx"
#define numberofbytes 472 // from FDM to visuals
#define nbytes 8 //from visuals to FDM
struct {
double number_of_bytes;
double lat_geoc;
double lon_geoc;
double altitude;
double psirad;
double thetrad;
double phirad;
double earth_posn_angle;
double radius_to_vehicle;
double sea_level_radius;
double latitude;
double longitude;
double Vnorth;
double Veast;
double Vdown;
double Vcas_kts;
double prad;
double qrad;
double rrad;
double alpharad;
double betarad;
double latitude_dot;
double longitude_dot;
double radius_dot;
double Gamma_vert_rad;
double Runway_altitude;
double throttle;
double pstick;
double rstick;
double rpedal;
double U_local;
double V_local;
double W_local;
double U_dot_local;
double V_dot_local;
double W_dot_local;
double Machno;
double anxg;
double anyg;
double anzg;
double aux1;
double aux2;
double aux3;
double aux4;
double aux5;
double aux6;
double aux7;
double aux8;
int iaux1;
int iaux2;
int iaux3;
int iaux4;
int iaux5;
int iaux6;
int iaux7;
int iaux8;
int iaux9;
int iaux10;
int iaux11;
int iaux12;
float aux9;
float aux10;
float aux11;
float aux12;
float aux13;
float aux14;
float aux15;
float aux16;
float aux17;
float aux18;
} sixdof_to_visuals;
double view_offset; //if this zero, means center window
struct {
double ground_elevation;
} visuals_to_sixdof;
#define ground_elevation visuals_to_sixdof.ground_elevation
#define number_of_bytes sixdof_to_visuals.number_of_bytes
#define U_dot_local sixdof_to_visuals.U_dot_local
#define V_dot_local sixdof_to_visuals.V_dot_local
#define W_dot_local sixdof_to_visuals.W_dot_local
#define U_local sixdof_to_visuals.U_local
#define V_local sixdof_to_visuals.V_local
#define W_local sixdof_to_visuals.W_local
#define throttle sixdof_to_visuals.throttle
#define pstick sixdof_to_visuals.pstick
#define rstick sixdof_to_visuals.rstick
#define rpedal sixdof_to_visuals.rpedal
#define V_north sixdof_to_visuals.Vnorth
#define V_east sixdof_to_visuals.Veast
#define V_down sixdof_to_visuals.Vdown
#define V_calibrated_kts sixdof_to_visuals.Vcas_kts
#define P_body sixdof_to_visuals.prad
#define Q_body sixdof_to_visuals.qrad
#define R_body sixdof_to_visuals.rrad
#define Latitude_dot sixdof_to_visuals.latitude_dot
#define Longitude_dot sixdof_to_visuals.longitude_dot
#define Radius_dot sixdof_to_visuals.radius_dot
#define Latitude sixdof_to_visuals.latitude
#define Longitude sixdof_to_visuals.longitude
#define Lat_geocentric sixdof_to_visuals.lat_geoc
#define Lon_geocentric sixdof_to_visuals.lon_geoc
#define Radius_to_vehicle sixdof_to_visuals.radius_to_vehicle
#define Altitude sixdof_to_visuals.altitude
#define Phi sixdof_to_visuals.phirad
#define Theta sixdof_to_visuals.thetrad
#define Psi sixdof_to_visuals.psirad
#define Alpha sixdof_to_visuals.alpharad
#define Beta sixdof_to_visuals.betarad
#define Sea_level_radius sixdof_to_visuals.sea_level_radius
#define Earth_position_angle sixdof_to_visuals.earth_posn_angle
#define Runway_altitude sixdof_to_visuals.Runway_altitude
#define Gamma_vert_rad sixdof_to_visuals.Gamma_vert_rad
#define Machno sixdof_to_visuals.Machno
#define anxg sixdof_to_visuals.anxg
#define anyg sixdof_to_visuals.anyg
#define anzg sixdof_to_visuals.anzg
FGADA::FGADA( double dt ) {
// set_delta_t( dt );
}
FGADA::~FGADA() {
}
// Initialize the ADA flight model, dt is the time increment
// for each subsequent iteration through the EOM
void FGADA::init() {
From David Megginson: The files in the attached tarball make the following changes to FlightGear: - rename the existing FGInterface::init() method to FGInterface::_setup to get it out of the way - move *all* FDM initialization code out of src/Main/fg_init.cxx and into FGInterface::init(), and clean up fg_init.cxx a little (especially by removing the zillions of attempts to place the plane on the ground at various locations in the code) - modify FGInterface::bind() so that no values are picked up automatically at bind time (they are set previously by init() instead) - modify the init() methods of the classes derived from FGInterface (i.e. larcsim, jsbsim, balloon, magic, and ada) to invoke FGInterface::init() explicitly before doing their own setup I don't claim that the code in FGInterface::init() is optimal (or even correct), but it seems to work for on-ground starts with both LaRCSim and JSBSim on runways pointing various directions from near sea level to about 700' ASL (the range I happened to test). I expect that Jon and Tony will want to look at the code and refactor and correct it now that they can see what's going on in one place. Here's a quick outline of what is invoked: cur_fdm_state = new <whatever>(dt); cur_fdm_state->init(); cur_fdm_state->bind(); The constructor allocates memory and sets default values only (with the help of the FGInterface::_setup() method). The init() method pull any required properties out of the property tree and sets up the initial state of the FDM. The bind() method takes ownership of FDM-related properties so that the FDM can publish them to the rest of the sim. Note that bind() and init() are virtual, so any implementation in a subclass will hide the implementation in FGInterface; that's why subclass implementations of init() and bind() have to invoke FGInterface::init() and FGInterface::bind() explicitly, probably at the start, so that they get the basic initialization.
2001-04-05 20:20:44 +00:00
2001-11-06 22:33:05 +00:00
//do init common to all FDM"s
common_init();
//now do ADA-specific init.
From David Megginson: The files in the attached tarball make the following changes to FlightGear: - rename the existing FGInterface::init() method to FGInterface::_setup to get it out of the way - move *all* FDM initialization code out of src/Main/fg_init.cxx and into FGInterface::init(), and clean up fg_init.cxx a little (especially by removing the zillions of attempts to place the plane on the ground at various locations in the code) - modify FGInterface::bind() so that no values are picked up automatically at bind time (they are set previously by init() instead) - modify the init() methods of the classes derived from FGInterface (i.e. larcsim, jsbsim, balloon, magic, and ada) to invoke FGInterface::init() explicitly before doing their own setup I don't claim that the code in FGInterface::init() is optimal (or even correct), but it seems to work for on-ground starts with both LaRCSim and JSBSim on runways pointing various directions from near sea level to about 700' ASL (the range I happened to test). I expect that Jon and Tony will want to look at the code and refactor and correct it now that they can see what's going on in one place. Here's a quick outline of what is invoked: cur_fdm_state = new <whatever>(dt); cur_fdm_state->init(); cur_fdm_state->bind(); The constructor allocates memory and sets default values only (with the help of the FGInterface::_setup() method). The init() method pull any required properties out of the property tree and sets up the initial state of the FDM. The bind() method takes ownership of FDM-related properties so that the FDM can publish them to the rest of the sim. Note that bind() and init() are virtual, so any implementation in a subclass will hide the implementation in FGInterface; that's why subclass implementations of init() and bind() have to invoke FGInterface::init() and FGInterface::bind() explicitly, probably at the start, so that they get the basic initialization.
2001-04-05 20:20:44 +00:00
// cout << "FGADA::init()" << endl;
char OutBuffer[nbytes];
copy_to_FGADA();
printf("\nInitialising UDP sockets\n");
// initialise a "udp" socket
fdmsock = new SGSocket( "fdm_pc", "5001", "udp" );
// open as a client
bool result = fdmsock->open(SG_IO_OUT);
if (result == false) {
printf ("Socket Open Error\n");
} else {
copy_to_FGADA();
// Write FGExternal structure from socket to establish connection
int result = fdmsock->write(OutBuffer, nbytes);
printf("Connection established = %d.\n", result);
}
}
// Run an iteration of the EOM. This is essentially a NOP here
// because these values are getting filled in elsewhere based on
// external input.
void FGADA::update( double dt ) {
// cout << "FGADA::update()" << endl;
if (is_suspended())
return;
char Buffer[numberofbytes];
char OutBuffer[nbytes];
// Read FGExternal structure from socket
while (1) {
int result = fdmsock->read(Buffer, numberofbytes);
if (result == numberofbytes) {
// Copy buffer into FGExternal structure
memcpy (&sixdof_to_visuals, &Buffer, sizeof (Buffer));
// Convert from the FGExternal struct to the FGInterface struct (input)
copy_from_FGADA();
} else {
break;
}
}
copy_to_FGADA();
fgGetDouble("/sim/view/offset",view_offset);
if ( view_offset == 0.0) {
memcpy (&OutBuffer, &visuals_to_sixdof, sizeof (OutBuffer));
fdmsock->write(OutBuffer, nbytes);
}
}
// Convert from the FGInterface struct to the FGADA struct (output)
bool FGADA::copy_to_FGADA () {
ground_elevation = globals->get_scenery()->get_cur_elev();
return true;
}
// Convert from the FGADA struct to the FGInterface struct (input)
bool FGADA::copy_from_FGADA() {
//Positions and attitudes for The Rendering engine
I tested: LaRCsim c172 on-ground and in-air starts, reset: all work UIUC Cessna172 on-ground and in-air starts work as expected, reset results in an aircraft that is upside down but does not crash FG. I don't know what it was like before, so it may well be no change. JSBSim c172 and X15 in-air starts work fine, resets now work (and are trimmed), on-ground starts do not -- the c172 ends up on its back. I suspect this is no worse than before. I did not test: Balloon (the weather code returns nan's for the atmosphere data --this is in the weather module and apparently is a linux only bug) ADA (don't know how) MagicCarpet (needs work yet) External (don't know how) known to be broken: LaRCsim c172 on-ground starts with a negative terrain altitude (this happens at KPAO when the scenery is not present). The FDM inits to about 50 feet AGL and the model falls to the ground. It does stay upright, however, and seems to be fine once it settles out, FWIW. To do: --implement set_Model on the bus --bring Christian's weather data into JSBSim -- add default method to bus for updating things like the sin and cos of latitude (for Balloon, MagicCarpet) -- lots of cleanup The files: src/FDM/flight.cxx src/FDM/flight.hxx -- all data members now declared protected instead of private. -- eliminated all but a small set of 'setters', no change to getters. -- that small set is declared virtual, the default implementation provided preserves the old behavior -- all of the vector data members are now initialized. -- added busdump() method -- FG_LOG's all the bus data when called, useful for diagnostics. src/FDM/ADA.cxx -- bus data members now directly assigned to src/FDM/Balloon.cxx -- bus data members now directly assigned to -- changed V_equiv_kts to V_calibrated_kts src/FDM/JSBSim.cxx src/FDM/JSBSim.hxx -- bus data members now directly assigned to -- implemented the FGInterface virtual setters with JSBSim specific logic -- changed the static FDMExec to a dynamic fdmex (needed so that the JSBSim object can be deleted when a model change is called for) -- implemented constructor and destructor, moved some of the logic formerly in init() to constructor -- added logic to bring up FGEngInterface objects and set the RPM and throttle values. src/FDM/LaRCsim.cxx src/FDM/LaRCsim.hxx -- bus data members now directly assigned to -- implemented the FGInterface virtual setters with LaRCsim specific logic, uses LaRCsimIC -- implemented constructor and destructor, moved some of the logic formerly in init() to constructor -- moved default inertias to here from fg_init.cxx -- eliminated the climb rate calculation. The equivalent, climb_rate = -1*vdown, is now in copy_from_LaRCsim(). src/FDM/LaRCsimIC.cxx src/FDM/LaRCsimIC.hxx -- similar to FGInitialCondition, this class has all the logic needed to turn data like Vc and Mach into the more fundamental quantities LaRCsim needs to initialize. -- put it in src/FDM since it is a class src/FDM/MagicCarpet.cxx -- bus data members now directly assigned to src/FDM/Makefile.am -- adds LaRCsimIC.hxx and cxx src/FDM/JSBSim/FGAtmosphere.h src/FDM/JSBSim/FGDefs.h src/FDM/JSBSim/FGInitialCondition.cpp src/FDM/JSBSim/FGInitialCondition.h src/FDM/JSBSim/JSBSim.cpp -- changes to accomodate the new bus src/FDM/LaRCsim/atmos_62.h src/FDM/LaRCsim/ls_geodesy.h -- surrounded prototypes with #ifdef __cplusplus ... #endif , functions here are needed in LaRCsimIC src/FDM/LaRCsim/c172_main.c src/FDM/LaRCsim/cherokee_aero.c src/FDM/LaRCsim/ls_aux.c src/FDM/LaRCsim/ls_constants.h src/FDM/LaRCsim/ls_geodesy.c src/FDM/LaRCsim/ls_geodesy.h src/FDM/LaRCsim/ls_step.c src/FDM/UIUCModel/uiuc_betaprobe.cpp -- changed PI to LS_PI, eliminates preprocessor naming conflict with weather module src/FDM/LaRCsim/ls_interface.c src/FDM/LaRCsim/ls_interface.h -- added function ls_set_model_dt() src/Main/bfi.cxx -- eliminated calls that set the NED speeds to body components. They are no longer needed and confuse the new bus. src/Main/fg_init.cxx -- eliminated calls that just brought the bus data up-to-date (e.g. set_sin_cos_latitude). or set default values. The bus now handles the defaults and updates itself when the setters are called (for LaRCsim and JSBSim). A default method for doing this needs to be added to the bus. -- added fgVelocityInit() to set the speed the user asked for. Both JSBSim and LaRCsim can now be initialized using any of: vc,mach, NED components, UVW components. src/Main/main.cxx --eliminated call to fgFDMSetGroundElevation, this data is now 'pulled' onto the bus every update() src/Main/options.cxx src/Main/options.hxx -- added enum to keep track of the speed requested by the user -- eliminated calls to set NED velocity properties to body speeds, they are no longer needed. -- added options for the NED components. src/Network/garmin.cxx src/Network/nmea.cxx --eliminated calls that just brought the bus data up-to-date (e.g. set_sin_cos_latitude). The bus now updates itself when the setters are called (for LaRCsim and JSBSim). A default method for doing this needs to be added to the bus. -- changed set_V_equiv_kts to set_V_calibrated_kts. set_V_equiv_kts no longer exists ( get_V_equiv_kts still does, though) src/WeatherCM/FGLocalWeatherDatabase.cpp -- commented out the code to put the weather data on the bus, a different scheme for this is needed.
2000-10-24 00:34:50 +00:00
_set_Geodetic_Position( Latitude, Longitude, Altitude );
_set_Euler_Angles( Phi, Theta, Psi );
_set_Geocentric_Position( Lat_geocentric, Lon_geocentric,
Radius_to_vehicle );
I tested: LaRCsim c172 on-ground and in-air starts, reset: all work UIUC Cessna172 on-ground and in-air starts work as expected, reset results in an aircraft that is upside down but does not crash FG. I don't know what it was like before, so it may well be no change. JSBSim c172 and X15 in-air starts work fine, resets now work (and are trimmed), on-ground starts do not -- the c172 ends up on its back. I suspect this is no worse than before. I did not test: Balloon (the weather code returns nan's for the atmosphere data --this is in the weather module and apparently is a linux only bug) ADA (don't know how) MagicCarpet (needs work yet) External (don't know how) known to be broken: LaRCsim c172 on-ground starts with a negative terrain altitude (this happens at KPAO when the scenery is not present). The FDM inits to about 50 feet AGL and the model falls to the ground. It does stay upright, however, and seems to be fine once it settles out, FWIW. To do: --implement set_Model on the bus --bring Christian's weather data into JSBSim -- add default method to bus for updating things like the sin and cos of latitude (for Balloon, MagicCarpet) -- lots of cleanup The files: src/FDM/flight.cxx src/FDM/flight.hxx -- all data members now declared protected instead of private. -- eliminated all but a small set of 'setters', no change to getters. -- that small set is declared virtual, the default implementation provided preserves the old behavior -- all of the vector data members are now initialized. -- added busdump() method -- FG_LOG's all the bus data when called, useful for diagnostics. src/FDM/ADA.cxx -- bus data members now directly assigned to src/FDM/Balloon.cxx -- bus data members now directly assigned to -- changed V_equiv_kts to V_calibrated_kts src/FDM/JSBSim.cxx src/FDM/JSBSim.hxx -- bus data members now directly assigned to -- implemented the FGInterface virtual setters with JSBSim specific logic -- changed the static FDMExec to a dynamic fdmex (needed so that the JSBSim object can be deleted when a model change is called for) -- implemented constructor and destructor, moved some of the logic formerly in init() to constructor -- added logic to bring up FGEngInterface objects and set the RPM and throttle values. src/FDM/LaRCsim.cxx src/FDM/LaRCsim.hxx -- bus data members now directly assigned to -- implemented the FGInterface virtual setters with LaRCsim specific logic, uses LaRCsimIC -- implemented constructor and destructor, moved some of the logic formerly in init() to constructor -- moved default inertias to here from fg_init.cxx -- eliminated the climb rate calculation. The equivalent, climb_rate = -1*vdown, is now in copy_from_LaRCsim(). src/FDM/LaRCsimIC.cxx src/FDM/LaRCsimIC.hxx -- similar to FGInitialCondition, this class has all the logic needed to turn data like Vc and Mach into the more fundamental quantities LaRCsim needs to initialize. -- put it in src/FDM since it is a class src/FDM/MagicCarpet.cxx -- bus data members now directly assigned to src/FDM/Makefile.am -- adds LaRCsimIC.hxx and cxx src/FDM/JSBSim/FGAtmosphere.h src/FDM/JSBSim/FGDefs.h src/FDM/JSBSim/FGInitialCondition.cpp src/FDM/JSBSim/FGInitialCondition.h src/FDM/JSBSim/JSBSim.cpp -- changes to accomodate the new bus src/FDM/LaRCsim/atmos_62.h src/FDM/LaRCsim/ls_geodesy.h -- surrounded prototypes with #ifdef __cplusplus ... #endif , functions here are needed in LaRCsimIC src/FDM/LaRCsim/c172_main.c src/FDM/LaRCsim/cherokee_aero.c src/FDM/LaRCsim/ls_aux.c src/FDM/LaRCsim/ls_constants.h src/FDM/LaRCsim/ls_geodesy.c src/FDM/LaRCsim/ls_geodesy.h src/FDM/LaRCsim/ls_step.c src/FDM/UIUCModel/uiuc_betaprobe.cpp -- changed PI to LS_PI, eliminates preprocessor naming conflict with weather module src/FDM/LaRCsim/ls_interface.c src/FDM/LaRCsim/ls_interface.h -- added function ls_set_model_dt() src/Main/bfi.cxx -- eliminated calls that set the NED speeds to body components. They are no longer needed and confuse the new bus. src/Main/fg_init.cxx -- eliminated calls that just brought the bus data up-to-date (e.g. set_sin_cos_latitude). or set default values. The bus now handles the defaults and updates itself when the setters are called (for LaRCsim and JSBSim). A default method for doing this needs to be added to the bus. -- added fgVelocityInit() to set the speed the user asked for. Both JSBSim and LaRCsim can now be initialized using any of: vc,mach, NED components, UVW components. src/Main/main.cxx --eliminated call to fgFDMSetGroundElevation, this data is now 'pulled' onto the bus every update() src/Main/options.cxx src/Main/options.hxx -- added enum to keep track of the speed requested by the user -- eliminated calls to set NED velocity properties to body speeds, they are no longer needed. -- added options for the NED components. src/Network/garmin.cxx src/Network/nmea.cxx --eliminated calls that just brought the bus data up-to-date (e.g. set_sin_cos_latitude). The bus now updates itself when the setters are called (for LaRCsim and JSBSim). A default method for doing this needs to be added to the bus. -- changed set_V_equiv_kts to set_V_calibrated_kts. set_V_equiv_kts no longer exists ( get_V_equiv_kts still does, though) src/WeatherCM/FGLocalWeatherDatabase.cpp -- commented out the code to put the weather data on the bus, a different scheme for this is needed.
2000-10-24 00:34:50 +00:00
_set_Sea_level_radius( Sea_level_radius );
_set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
I tested: LaRCsim c172 on-ground and in-air starts, reset: all work UIUC Cessna172 on-ground and in-air starts work as expected, reset results in an aircraft that is upside down but does not crash FG. I don't know what it was like before, so it may well be no change. JSBSim c172 and X15 in-air starts work fine, resets now work (and are trimmed), on-ground starts do not -- the c172 ends up on its back. I suspect this is no worse than before. I did not test: Balloon (the weather code returns nan's for the atmosphere data --this is in the weather module and apparently is a linux only bug) ADA (don't know how) MagicCarpet (needs work yet) External (don't know how) known to be broken: LaRCsim c172 on-ground starts with a negative terrain altitude (this happens at KPAO when the scenery is not present). The FDM inits to about 50 feet AGL and the model falls to the ground. It does stay upright, however, and seems to be fine once it settles out, FWIW. To do: --implement set_Model on the bus --bring Christian's weather data into JSBSim -- add default method to bus for updating things like the sin and cos of latitude (for Balloon, MagicCarpet) -- lots of cleanup The files: src/FDM/flight.cxx src/FDM/flight.hxx -- all data members now declared protected instead of private. -- eliminated all but a small set of 'setters', no change to getters. -- that small set is declared virtual, the default implementation provided preserves the old behavior -- all of the vector data members are now initialized. -- added busdump() method -- FG_LOG's all the bus data when called, useful for diagnostics. src/FDM/ADA.cxx -- bus data members now directly assigned to src/FDM/Balloon.cxx -- bus data members now directly assigned to -- changed V_equiv_kts to V_calibrated_kts src/FDM/JSBSim.cxx src/FDM/JSBSim.hxx -- bus data members now directly assigned to -- implemented the FGInterface virtual setters with JSBSim specific logic -- changed the static FDMExec to a dynamic fdmex (needed so that the JSBSim object can be deleted when a model change is called for) -- implemented constructor and destructor, moved some of the logic formerly in init() to constructor -- added logic to bring up FGEngInterface objects and set the RPM and throttle values. src/FDM/LaRCsim.cxx src/FDM/LaRCsim.hxx -- bus data members now directly assigned to -- implemented the FGInterface virtual setters with LaRCsim specific logic, uses LaRCsimIC -- implemented constructor and destructor, moved some of the logic formerly in init() to constructor -- moved default inertias to here from fg_init.cxx -- eliminated the climb rate calculation. The equivalent, climb_rate = -1*vdown, is now in copy_from_LaRCsim(). src/FDM/LaRCsimIC.cxx src/FDM/LaRCsimIC.hxx -- similar to FGInitialCondition, this class has all the logic needed to turn data like Vc and Mach into the more fundamental quantities LaRCsim needs to initialize. -- put it in src/FDM since it is a class src/FDM/MagicCarpet.cxx -- bus data members now directly assigned to src/FDM/Makefile.am -- adds LaRCsimIC.hxx and cxx src/FDM/JSBSim/FGAtmosphere.h src/FDM/JSBSim/FGDefs.h src/FDM/JSBSim/FGInitialCondition.cpp src/FDM/JSBSim/FGInitialCondition.h src/FDM/JSBSim/JSBSim.cpp -- changes to accomodate the new bus src/FDM/LaRCsim/atmos_62.h src/FDM/LaRCsim/ls_geodesy.h -- surrounded prototypes with #ifdef __cplusplus ... #endif , functions here are needed in LaRCsimIC src/FDM/LaRCsim/c172_main.c src/FDM/LaRCsim/cherokee_aero.c src/FDM/LaRCsim/ls_aux.c src/FDM/LaRCsim/ls_constants.h src/FDM/LaRCsim/ls_geodesy.c src/FDM/LaRCsim/ls_geodesy.h src/FDM/LaRCsim/ls_step.c src/FDM/UIUCModel/uiuc_betaprobe.cpp -- changed PI to LS_PI, eliminates preprocessor naming conflict with weather module src/FDM/LaRCsim/ls_interface.c src/FDM/LaRCsim/ls_interface.h -- added function ls_set_model_dt() src/Main/bfi.cxx -- eliminated calls that set the NED speeds to body components. They are no longer needed and confuse the new bus. src/Main/fg_init.cxx -- eliminated calls that just brought the bus data up-to-date (e.g. set_sin_cos_latitude). or set default values. The bus now handles the defaults and updates itself when the setters are called (for LaRCsim and JSBSim). A default method for doing this needs to be added to the bus. -- added fgVelocityInit() to set the speed the user asked for. Both JSBSim and LaRCsim can now be initialized using any of: vc,mach, NED components, UVW components. src/Main/main.cxx --eliminated call to fgFDMSetGroundElevation, this data is now 'pulled' onto the bus every update() src/Main/options.cxx src/Main/options.hxx -- added enum to keep track of the speed requested by the user -- eliminated calls to set NED velocity properties to body speeds, they are no longer needed. -- added options for the NED components. src/Network/garmin.cxx src/Network/nmea.cxx --eliminated calls that just brought the bus data up-to-date (e.g. set_sin_cos_latitude). The bus now updates itself when the setters are called (for LaRCsim and JSBSim). A default method for doing this needs to be added to the bus. -- changed set_V_equiv_kts to set_V_calibrated_kts. set_V_equiv_kts no longer exists ( get_V_equiv_kts still does, though) src/WeatherCM/FGLocalWeatherDatabase.cpp -- commented out the code to put the weather data on the bus, a different scheme for this is needed.
2000-10-24 00:34:50 +00:00
_set_Earth_position_angle( Earth_position_angle );
_set_sin_lat_geocentric(Lat_geocentric);
_set_cos_lat_geocentric(Lat_geocentric);
_set_sin_cos_longitude(Longitude);
_set_sin_cos_latitude(Latitude);
// Velocities and accelerations for the pitch ladder and velocity vector
I tested: LaRCsim c172 on-ground and in-air starts, reset: all work UIUC Cessna172 on-ground and in-air starts work as expected, reset results in an aircraft that is upside down but does not crash FG. I don't know what it was like before, so it may well be no change. JSBSim c172 and X15 in-air starts work fine, resets now work (and are trimmed), on-ground starts do not -- the c172 ends up on its back. I suspect this is no worse than before. I did not test: Balloon (the weather code returns nan's for the atmosphere data --this is in the weather module and apparently is a linux only bug) ADA (don't know how) MagicCarpet (needs work yet) External (don't know how) known to be broken: LaRCsim c172 on-ground starts with a negative terrain altitude (this happens at KPAO when the scenery is not present). The FDM inits to about 50 feet AGL and the model falls to the ground. It does stay upright, however, and seems to be fine once it settles out, FWIW. To do: --implement set_Model on the bus --bring Christian's weather data into JSBSim -- add default method to bus for updating things like the sin and cos of latitude (for Balloon, MagicCarpet) -- lots of cleanup The files: src/FDM/flight.cxx src/FDM/flight.hxx -- all data members now declared protected instead of private. -- eliminated all but a small set of 'setters', no change to getters. -- that small set is declared virtual, the default implementation provided preserves the old behavior -- all of the vector data members are now initialized. -- added busdump() method -- FG_LOG's all the bus data when called, useful for diagnostics. src/FDM/ADA.cxx -- bus data members now directly assigned to src/FDM/Balloon.cxx -- bus data members now directly assigned to -- changed V_equiv_kts to V_calibrated_kts src/FDM/JSBSim.cxx src/FDM/JSBSim.hxx -- bus data members now directly assigned to -- implemented the FGInterface virtual setters with JSBSim specific logic -- changed the static FDMExec to a dynamic fdmex (needed so that the JSBSim object can be deleted when a model change is called for) -- implemented constructor and destructor, moved some of the logic formerly in init() to constructor -- added logic to bring up FGEngInterface objects and set the RPM and throttle values. src/FDM/LaRCsim.cxx src/FDM/LaRCsim.hxx -- bus data members now directly assigned to -- implemented the FGInterface virtual setters with LaRCsim specific logic, uses LaRCsimIC -- implemented constructor and destructor, moved some of the logic formerly in init() to constructor -- moved default inertias to here from fg_init.cxx -- eliminated the climb rate calculation. The equivalent, climb_rate = -1*vdown, is now in copy_from_LaRCsim(). src/FDM/LaRCsimIC.cxx src/FDM/LaRCsimIC.hxx -- similar to FGInitialCondition, this class has all the logic needed to turn data like Vc and Mach into the more fundamental quantities LaRCsim needs to initialize. -- put it in src/FDM since it is a class src/FDM/MagicCarpet.cxx -- bus data members now directly assigned to src/FDM/Makefile.am -- adds LaRCsimIC.hxx and cxx src/FDM/JSBSim/FGAtmosphere.h src/FDM/JSBSim/FGDefs.h src/FDM/JSBSim/FGInitialCondition.cpp src/FDM/JSBSim/FGInitialCondition.h src/FDM/JSBSim/JSBSim.cpp -- changes to accomodate the new bus src/FDM/LaRCsim/atmos_62.h src/FDM/LaRCsim/ls_geodesy.h -- surrounded prototypes with #ifdef __cplusplus ... #endif , functions here are needed in LaRCsimIC src/FDM/LaRCsim/c172_main.c src/FDM/LaRCsim/cherokee_aero.c src/FDM/LaRCsim/ls_aux.c src/FDM/LaRCsim/ls_constants.h src/FDM/LaRCsim/ls_geodesy.c src/FDM/LaRCsim/ls_geodesy.h src/FDM/LaRCsim/ls_step.c src/FDM/UIUCModel/uiuc_betaprobe.cpp -- changed PI to LS_PI, eliminates preprocessor naming conflict with weather module src/FDM/LaRCsim/ls_interface.c src/FDM/LaRCsim/ls_interface.h -- added function ls_set_model_dt() src/Main/bfi.cxx -- eliminated calls that set the NED speeds to body components. They are no longer needed and confuse the new bus. src/Main/fg_init.cxx -- eliminated calls that just brought the bus data up-to-date (e.g. set_sin_cos_latitude). or set default values. The bus now handles the defaults and updates itself when the setters are called (for LaRCsim and JSBSim). A default method for doing this needs to be added to the bus. -- added fgVelocityInit() to set the speed the user asked for. Both JSBSim and LaRCsim can now be initialized using any of: vc,mach, NED components, UVW components. src/Main/main.cxx --eliminated call to fgFDMSetGroundElevation, this data is now 'pulled' onto the bus every update() src/Main/options.cxx src/Main/options.hxx -- added enum to keep track of the speed requested by the user -- eliminated calls to set NED velocity properties to body speeds, they are no longer needed. -- added options for the NED components. src/Network/garmin.cxx src/Network/nmea.cxx --eliminated calls that just brought the bus data up-to-date (e.g. set_sin_cos_latitude). The bus now updates itself when the setters are called (for LaRCsim and JSBSim). A default method for doing this needs to be added to the bus. -- changed set_V_equiv_kts to set_V_calibrated_kts. set_V_equiv_kts no longer exists ( get_V_equiv_kts still does, though) src/WeatherCM/FGLocalWeatherDatabase.cpp -- commented out the code to put the weather data on the bus, a different scheme for this is needed.
2000-10-24 00:34:50 +00:00
_set_Accels_Local( U_dot_local, V_dot_local, W_dot_local );
_set_Velocities_Ground( U_local, V_local, W_local );//same as V_NED in mps
_set_Velocities_Local( V_north, V_east, V_down ); //same as UVW_local in fps
//Positions and attitude for ship
_set_daux(1,sixdof_to_visuals.aux1);//ship lat
_set_daux(2,sixdof_to_visuals.aux2);//ship lon
_set_daux(3,sixdof_to_visuals.aux3);//ship alt+heave
_set_daux(4,sixdof_to_visuals.aux4);//distance of a/c from ski-jump exit
_set_faux(1,sixdof_to_visuals.aux9);//ship pitch
_set_faux(2,sixdof_to_visuals.aux10);//ship roll
_set_faux(3,sixdof_to_visuals.aux11);//ship yaw
_set_iaux(1,sixdof_to_visuals.iaux1);//flag for drawing ship
// controls
globals->get_controls()->set_throttle(0,throttle/131.0);
globals->get_controls()->set_elevator(pstick);
globals->get_controls()->set_aileron(rstick);
globals->get_controls()->set_rudder(rpedal);
// auxilliary parameters for HUD
_set_V_calibrated_kts( V_calibrated_kts );
_set_Alpha( Alpha );
_set_Beta( Beta );
_set_Accels_CG_Body_N( anxg,anyg,anzg);
_set_Mach_number( Machno);
_set_Climb_Rate( W_local*SG_METER_TO_FEET ); //pressure alt in feet for lca(navy)
_set_iaux(2,sixdof_to_visuals.iaux2);//control law mode switch posn
_set_iaux(3,sixdof_to_visuals.iaux3);//ldg gear posn
_set_iaux(4,sixdof_to_visuals.iaux4);// wow nose status
_set_iaux(5,sixdof_to_visuals.iaux5);// wow main status
_set_iaux(6,sixdof_to_visuals.iaux6);// arrester hook posn
_set_iaux(7,sixdof_to_visuals.iaux7);
_set_iaux(8,sixdof_to_visuals.iaux8);
_set_iaux(9,sixdof_to_visuals.iaux9);
_set_iaux(10,sixdof_to_visuals.iaux10);
_set_iaux(11,sixdof_to_visuals.iaux11);
_set_iaux(12,sixdof_to_visuals.iaux12);
_set_daux(5,sixdof_to_visuals.aux5);
_set_daux(6,sixdof_to_visuals.aux6);
_set_daux(7,sixdof_to_visuals.aux7);
_set_daux(8,sixdof_to_visuals.aux8);
_set_faux(4,sixdof_to_visuals.aux12);
_set_faux(5,sixdof_to_visuals.aux13);
_set_faux(6,sixdof_to_visuals.aux14);
_set_faux(7,sixdof_to_visuals.aux15);
_set_faux(8,sixdof_to_visuals.aux16);
_set_faux(9,sixdof_to_visuals.aux17);
_set_faux(10,sixdof_to_visuals.aux18);
// Angular rates
_set_Omega_Body( P_body, Q_body, R_body );
// Miscellaneous quantities
_set_Gamma_vert_rad( Gamma_vert_rad );
_set_Runway_altitude( Runway_altitude );
// SG_LOG( SG_FLIGHT, SG_DEBUG, "lon = " << Longitude
// << " lat_geoc = " << Lat_geocentric << " lat_geod = " << Latitude
// << " alt = " << Altitude << " sl_radius = " << Sea_level_radius
// << " radius_to_vehicle = " << Radius_to_vehicle );
// printf("sr=%f\n",Sea_level_radius);
// printf("psi = %f %f\n",Psi,Psi*SGD_RADIANS_TO_DEGREES);
return true;
}