1
0
Fork 0

Updates by Tony working on the FDM interface bus.

This commit is contained in:
curt 2000-10-28 16:30:30 +00:00
parent 81bb2f00d1
commit 11a68e55d4
15 changed files with 488 additions and 322 deletions

View file

@ -2280,6 +2280,51 @@ SOURCE=.\src\Main\viewer.cxx
!ENDIF !ENDIF
# End Source File
# Begin Source File
SOURCE=.\src\Main\viewer_lookat.cxx
!IF "$(CFG)" == "FlightGear - Win32 Release"
# PROP Intermediate_Dir "Release\main"
!ELSEIF "$(CFG)" == "FlightGear - Win32 Debug"
# PROP Intermediate_Dir "Debug\main"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\src\Main\viewer_rph.cxx
!IF "$(CFG)" == "FlightGear - Win32 Release"
# PROP Intermediate_Dir "Release\main"
!ELSEIF "$(CFG)" == "FlightGear - Win32 Debug"
# PROP Intermediate_Dir "Debug\main"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\src\Main\viewmgr.cxx
!IF "$(CFG)" == "FlightGear - Win32 Release"
# PROP Intermediate_Dir "Release\main"
!ELSEIF "$(CFG)" == "FlightGear - Win32 Debug"
# PROP Intermediate_Dir "Debug\main"
!ENDIF
# End Source File # End Source File
# End Group # End Group
# Begin Group "Lib_Navaids" # Begin Group "Lib_Navaids"

View file

@ -176,37 +176,14 @@ bool FGBalloonSim::copy_from_BalloonSim() {
// Positions // Positions
current_balloon.getPosition( temp ); current_balloon.getPosition( temp );
double lat_geoc = temp[0]; //temp[0]: geocentric latitude
double lon = temp[1]; //temp[1]: longitude
double alt = temp[2] * METER_TO_FEET; //temp[2]: altitude (meters)
double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc; _updatePosition( temp[0], temp[1], temp[2] * METER_TO_FEET );
sgGeocToGeod( lat_geoc, EQUATORIAL_RADIUS_M + alt * FEET_TO_METER,
&lat_geod, &tmp_alt, &sl_radius1 );
sgGeodToGeoc( lat_geod, alt * FEET_TO_METER, &sl_radius2, &tmp_lat_geoc );
FG_LOG( FG_FLIGHT, FG_DEBUG, "lon = " << lon << " lat_geod = " << lat_geod
<< " lat_geoc = " << lat_geoc
<< " alt = " << alt << " tmp_alt = " << tmp_alt * METER_TO_FEET
<< " sl_radius1 = " << sl_radius1 * METER_TO_FEET
<< " sl_radius2 = " << sl_radius2 * METER_TO_FEET
<< " Equator = " << EQUATORIAL_RADIUS_FT );
_set_Geocentric_Position( lat_geoc, lon,
sl_radius2 * METER_TO_FEET + alt );
_set_Geodetic_Position( lat_geod, lon, alt );
current_balloon.getHPR( temp ); current_balloon.getHPR( temp );
/* **FIXME*** */ _set_Sea_level_radius( sl_radius2 * METER_TO_FEET ); set_Euler_Angles( temp[0], temp[1], temp[2] );
/* **FIXME*** */ _set_Earth_position_angle( 0.0 );
/* ***FIXME*** */ _set_Runway_altitude( 0.0 );
_set_sin_lat_geocentric( lat_geoc );
_set_cos_lat_geocentric( lat_geoc );
_set_sin_cos_longitude( lon );
_set_sin_cos_latitude( lat_geod );
return true; return true;
} }

View file

@ -344,6 +344,8 @@ bool FGJSBsim::copy_from_JSBsim() {
fdmex->GetTranslation()->GetUVW()(2), fdmex->GetTranslation()->GetUVW()(2),
fdmex->GetTranslation()->GetUVW()(3) ); fdmex->GetTranslation()->GetUVW()(3) );
_set_V_rel_wind( fdmex->GetTranslation()->GetVt() );
_set_V_equiv_kts( fdmex->GetAuxiliary()->GetVequivalentKTS() ); _set_V_equiv_kts( fdmex->GetAuxiliary()->GetVequivalentKTS() );
// _set_V_calibrated( fdmex->GetAuxiliary()->GetVcalibratedFPS() ); // _set_V_calibrated( fdmex->GetAuxiliary()->GetVcalibratedFPS() );
@ -367,26 +369,9 @@ bool FGJSBsim::copy_from_JSBsim() {
_set_Mach_number( fdmex->GetTranslation()->GetMach() ); _set_Mach_number( fdmex->GetTranslation()->GetMach() );
// Positions // Positions
_updatePosition( fdmex->GetPosition()->GetLatitude(),
double lat_geoc = fdmex->GetPosition()->GetLatitude(); fdmex->GetPosition()->GetLongitude(),
double lon = fdmex->GetPosition()->GetLongitude(); fdmex->GetPosition()->Geth() );
double alt = fdmex->GetPosition()->Geth();
double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc;
sgGeocToGeod( lat_geoc, EQUATORIAL_RADIUS_M + alt * FEET_TO_METER,
&lat_geod, &tmp_alt, &sl_radius1 );
sgGeodToGeoc( lat_geod, alt * FEET_TO_METER, &sl_radius2, &tmp_lat_geoc );
FG_LOG( FG_FLIGHT, FG_DEBUG, "lon = " << lon << " lat_geod = " << lat_geod
<< " lat_geoc = " << lat_geoc
<< " alt = " << alt << " tmp_alt = " << tmp_alt * METER_TO_FEET
<< " sl_radius1 = " << sl_radius1 * METER_TO_FEET
<< " sl_radius2 = " << sl_radius2 * METER_TO_FEET
<< " Equator = " << EQUATORIAL_RADIUS_FT );
_set_Geocentric_Position( lat_geoc, lon, sl_radius2 * METER_TO_FEET + alt );
_set_Geodetic_Position( lat_geod, lon, alt );
_set_Euler_Angles( fdmex->GetRotation()->Getphi(), _set_Euler_Angles( fdmex->GetRotation()->Getphi(),
fdmex->GetRotation()->Gettht(), fdmex->GetRotation()->Gettht(),
@ -398,41 +383,51 @@ bool FGJSBsim::copy_from_JSBsim() {
_set_Gamma_vert_rad( fdmex->GetPosition()->GetGamma() ); _set_Gamma_vert_rad( fdmex->GetPosition()->GetGamma() );
// set_Gamma_horiz_rad( Gamma_horiz_rad ); // set_Gamma_horiz_rad( Gamma_horiz_rad );
/* **FIXME*** */ _set_Sea_level_radius( sl_radius2 * METER_TO_FEET ); _set_Earth_position_angle( fdmex->GetAuxiliary()->GetEarthPositionAngle() );
/* **FIXME*** */ _set_Earth_position_angle( fdmex->GetAuxiliary()->
GetEarthPositionAngle() );
/* ***FIXME*** */ _set_Runway_altitude( scenery.cur_radius * METERS_TO_FEET -
get_Sea_level_radius() );
_set_sin_lat_geocentric( lat_geoc );
_set_cos_lat_geocentric( lat_geoc );
_set_sin_cos_longitude( lon );
_set_sin_cos_latitude( lat_geod );
_set_Climb_Rate( fdmex->GetPosition()->Gethdot() ); _set_Climb_Rate( fdmex->GetPosition()->Gethdot() );
for ( i = 0; i < 3; i++ ) { for ( i = 1; i <= 3; i++ ) {
for ( j = 0; j < 3; j++ ) { for ( j = 1; j <= 3; j++ ) {
_set_T_Local_to_Body( i, j, fdmex->GetState()->GetTl2b()(i,j) ); _set_T_Local_to_Body( i, j, fdmex->GetState()->GetTl2b()(i,j) );
} }
} }
return true; return true;
} }
void FGJSBsim::snap_shot(void) {
fgic->SetLatitudeRadIC(get_Lat_geocentric() );
fgic->SetLongitudeRadIC( get_Longitude() );
fgic->SetAltitudeFtIC( get_Altitude() );
fgic->SetTerrainAltitudeFtIC( get_Runway_altitude() );
fgic->SetVtrueFpsIC( get_V_rel_wind() );
fgic->SetPitchAngleRadIC( get_Theta() );
fgic->SetRollAngleRadIC( get_Phi() );
fgic->SetTrueHeadingRadIC( get_Psi() );
fgic->SetClimbRateFpsIC( get_Climb_Rate() );
}
//Positions //Positions
void FGJSBsim::set_Latitude(double lat) { void FGJSBsim::set_Latitude(double lat) {
FG_LOG(FG_FLIGHT,FG_INFO,"FGJSBsim::set_Latitude: " << lat); double sea_level_radius_meters,lat_geoc;
fgic->SetLatitudeRadIC(lat);
FG_LOG(FG_FLIGHT,FG_INFO,"FGJSBsim::set_Latitude: " << lat );
snap_shot();
sgGeodToGeoc( lat, get_Altitude() , &sea_level_radius_meters, &lat_geoc);
fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * METER_TO_FEET );
fgic->SetLatitudeRadIC( lat_geoc );
fdmex->RunIC(fgic); //loop JSBSim once fdmex->RunIC(fgic); //loop JSBSim once
copy_from_JSBsim(); //update the bus copy_from_JSBsim(); //update the bus
needTrim=true; needTrim=true;
} }
void FGJSBsim::set_Longitude(double lon) { void FGJSBsim::set_Longitude(double lon) {
FG_LOG(FG_FLIGHT,FG_INFO,"FGJSBsim::set_Longitude: " << lon);
FG_LOG(FG_FLIGHT,FG_INFO,"FGJSBsim::set_Longitude: " << lon );
snap_shot();
fgic->SetLongitudeRadIC(lon); fgic->SetLongitudeRadIC(lon);
fdmex->RunIC(fgic); //loop JSBSim once fdmex->RunIC(fgic); //loop JSBSim once
copy_from_JSBsim(); //update the bus copy_from_JSBsim(); //update the bus
@ -440,7 +435,14 @@ void FGJSBsim::set_Longitude(double lon) {
} }
void FGJSBsim::set_Altitude(double alt) { void FGJSBsim::set_Altitude(double alt) {
double sea_level_radius_meters,lat_geoc;
FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Altitude: " << alt ); FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Altitude: " << alt );
snap_shot();
sgGeodToGeoc( get_Latitude(), alt , &sea_level_radius_meters, &lat_geoc);
fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * METER_TO_FEET );
fgic->SetLatitudeRadIC( lat_geoc );
fgic->SetAltitudeFtIC(alt); fgic->SetAltitudeFtIC(alt);
fdmex->RunIC(fgic); //loop JSBSim once fdmex->RunIC(fgic); //loop JSBSim once
copy_from_JSBsim(); //update the bus copy_from_JSBsim(); //update the bus
@ -449,6 +451,8 @@ void FGJSBsim::set_Altitude(double alt) {
void FGJSBsim::set_V_calibrated_kts(double vc) { void FGJSBsim::set_V_calibrated_kts(double vc) {
FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_V_calibrated_kts: " << vc ); FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_V_calibrated_kts: " << vc );
snap_shot();
fgic->SetVcalibratedKtsIC(vc); fgic->SetVcalibratedKtsIC(vc);
fdmex->RunIC(fgic); //loop JSBSim once fdmex->RunIC(fgic); //loop JSBSim once
copy_from_JSBsim(); //update the bus copy_from_JSBsim(); //update the bus
@ -457,6 +461,8 @@ void FGJSBsim::set_V_calibrated_kts(double vc) {
void FGJSBsim::set_Mach_number(double mach) { void FGJSBsim::set_Mach_number(double mach) {
FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Mach_number: " << mach ); FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Mach_number: " << mach );
snap_shot();
fgic->SetMachIC(mach); fgic->SetMachIC(mach);
fdmex->RunIC(fgic); //loop JSBSim once fdmex->RunIC(fgic); //loop JSBSim once
copy_from_JSBsim(); //update the bus copy_from_JSBsim(); //update the bus
@ -466,15 +472,13 @@ void FGJSBsim::set_Mach_number(double mach) {
void FGJSBsim::set_Velocities_Local( double north, double east, double down ){ void FGJSBsim::set_Velocities_Local( double north, double east, double down ){
FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Velocities_Local: " FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Velocities_Local: "
<< north << ", " << east << ", " << down ); << north << ", " << east << ", " << down );
snap_shot();
fgic->SetVnorthFpsIC(north); fgic->SetVnorthFpsIC(north);
fgic->SetVeastFpsIC(east); fgic->SetVeastFpsIC(east);
fgic->SetVdownFpsIC(down); fgic->SetVdownFpsIC(down);
fdmex->RunIC(fgic); //loop JSBSim once fdmex->RunIC(fgic); //loop JSBSim once
cout << "fdmex->GetTranslation()->GetVt(): " << fdmex->GetTranslation()->GetVt() << endl;
cout << "fdmex->GetPosition()->GetVn(): " << fdmex->GetPosition()->GetVn() << endl;
copy_from_JSBsim(); //update the bus copy_from_JSBsim(); //update the bus
busdump();
needTrim=true; needTrim=true;
} }
@ -482,6 +486,7 @@ void FGJSBsim::set_Velocities_Wind_Body( double u, double v, double w){
FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Velocities_Wind_Body: " FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Velocities_Wind_Body: "
<< u << ", " << v << ", " << w ); << u << ", " << v << ", " << w );
snap_shot();
fgic->SetUBodyFpsIC(u); fgic->SetUBodyFpsIC(u);
fgic->SetVBodyFpsIC(v); fgic->SetVBodyFpsIC(v);
fgic->SetWBodyFpsIC(w); fgic->SetWBodyFpsIC(w);
@ -494,6 +499,8 @@ void FGJSBsim::set_Velocities_Wind_Body( double u, double v, double w){
void FGJSBsim::set_Euler_Angles( double phi, double theta, double psi ) { void FGJSBsim::set_Euler_Angles( double phi, double theta, double psi ) {
FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Euler_Angles: " FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Euler_Angles: "
<< phi << ", " << theta << ", " << psi ); << phi << ", " << theta << ", " << psi );
snap_shot();
fgic->SetPitchAngleRadIC(theta); fgic->SetPitchAngleRadIC(theta);
fgic->SetRollAngleRadIC(phi); fgic->SetRollAngleRadIC(phi);
fgic->SetTrueHeadingRadIC(psi); fgic->SetTrueHeadingRadIC(psi);
@ -505,6 +512,8 @@ void FGJSBsim::set_Euler_Angles( double phi, double theta, double psi ) {
//Flight Path //Flight Path
void FGJSBsim::set_Climb_Rate( double roc) { void FGJSBsim::set_Climb_Rate( double roc) {
FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Climb_Rate: " << roc ); FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Climb_Rate: " << roc );
snap_shot();
fgic->SetClimbRateFpsIC(roc); fgic->SetClimbRateFpsIC(roc);
fdmex->RunIC(fgic); //loop JSBSim once fdmex->RunIC(fgic); //loop JSBSim once
copy_from_JSBsim(); //update the bus copy_from_JSBsim(); //update the bus
@ -513,6 +522,8 @@ void FGJSBsim::set_Climb_Rate( double roc) {
void FGJSBsim::set_Gamma_vert_rad( double gamma) { void FGJSBsim::set_Gamma_vert_rad( double gamma) {
FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Gamma_vert_rad: " << gamma ); FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Gamma_vert_rad: " << gamma );
snap_shot();
fgic->SetFlightPathAngleRadIC(gamma); fgic->SetFlightPathAngleRadIC(gamma);
fdmex->RunIC(fgic); //loop JSBSim once fdmex->RunIC(fgic); //loop JSBSim once
copy_from_JSBsim(); //update the bus copy_from_JSBsim(); //update the bus
@ -522,6 +533,8 @@ void FGJSBsim::set_Gamma_vert_rad( double gamma) {
//Earth //Earth
void FGJSBsim::set_Sea_level_radius(double slr) { void FGJSBsim::set_Sea_level_radius(double slr) {
FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Sea_level_radius: " << slr ); FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Sea_level_radius: " << slr );
snap_shot();
fgic->SetSeaLevelRadiusFtIC(slr); fgic->SetSeaLevelRadiusFtIC(slr);
fdmex->RunIC(fgic); //loop JSBSim once fdmex->RunIC(fgic); //loop JSBSim once
copy_from_JSBsim(); //update the bus copy_from_JSBsim(); //update the bus
@ -530,6 +543,8 @@ void FGJSBsim::set_Sea_level_radius(double slr) {
void FGJSBsim::set_Runway_altitude(double ralt) { void FGJSBsim::set_Runway_altitude(double ralt) {
FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Runway_altitude: " << ralt ); FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Runway_altitude: " << ralt );
snap_shot();
_set_Runway_altitude( ralt ); _set_Runway_altitude( ralt );
fdmex->RunIC(fgic); //loop JSBSim once fdmex->RunIC(fgic); //loop JSBSim once
copy_from_JSBsim(); //update the bus copy_from_JSBsim(); //update the bus
@ -538,6 +553,8 @@ void FGJSBsim::set_Runway_altitude(double ralt) {
void FGJSBsim::set_Static_pressure(double p) { void FGJSBsim::set_Static_pressure(double p) {
FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Static_pressure: " << p ); FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Static_pressure: " << p );
snap_shot();
fdmex->GetAtmosphere()->SetExPressure(p); fdmex->GetAtmosphere()->SetExPressure(p);
if(fdmex->GetAtmosphere()->External() == true) if(fdmex->GetAtmosphere()->External() == true)
needTrim=true; needTrim=true;
@ -545,6 +562,8 @@ void FGJSBsim::set_Static_pressure(double p) {
void FGJSBsim::set_Static_temperature(double T) { void FGJSBsim::set_Static_temperature(double T) {
FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Static_temperature: " << T ); FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Static_temperature: " << T );
snap_shot();
fdmex->GetAtmosphere()->SetExTemperature(T); fdmex->GetAtmosphere()->SetExTemperature(T);
if(fdmex->GetAtmosphere()->External() == true) if(fdmex->GetAtmosphere()->External() == true)
needTrim=true; needTrim=true;
@ -553,6 +572,8 @@ void FGJSBsim::set_Static_temperature(double T) {
void FGJSBsim::set_Density(double rho) { void FGJSBsim::set_Density(double rho) {
FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Density: " << rho ); FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Density: " << rho );
snap_shot();
fdmex->GetAtmosphere()->SetExDensity(rho); fdmex->GetAtmosphere()->SetExDensity(rho);
if(fdmex->GetAtmosphere()->External() == true) if(fdmex->GetAtmosphere()->External() == true)
needTrim=true; needTrim=true;
@ -564,6 +585,8 @@ void FGJSBsim::set_Velocities_Local_Airmass (double wnorth,
double wdown ) { double wdown ) {
FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Velocities_Local_Airmass: " FG_LOG(FG_FLIGHT,FG_INFO, "FGJSBsim::set_Velocities_Local_Airmass: "
<< wnorth << ", " << weast << ", " << wdown ); << wnorth << ", " << weast << ", " << wdown );
snap_shot();
fdmex->GetAtmosphere()->SetWindNED(wnorth, weast, wdown ); fdmex->GetAtmosphere()->SetWindNED(wnorth, weast, wdown );
if(fdmex->GetAtmosphere()->External() == true) if(fdmex->GetAtmosphere()->External() == true)
needTrim=true; needTrim=true;

View file

@ -21,6 +21,9 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Further information about the GNU General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY HISTORY
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
02/01/1999 CLO Created 02/01/1999 CLO Created
@ -77,15 +80,6 @@ CLASS DECLARATION
class FGJSBsim: public FGInterface { class FGJSBsim: public FGInterface {
// The aircraft for this instance
FGFDMExec *fdmex;
FGInitialCondition *fgic;
bool needTrim;
bool trimmed;
float trim_elev;
float trim_throttle;
public: public:
/// Constructor /// Constructor
FGJSBsim::FGJSBsim(void); FGJSBsim::FGJSBsim(void);
@ -101,39 +95,119 @@ public:
/// Reset flight params to a specific position /// Reset flight params to a specific position
bool init( double dt ); bool init( double dt );
// Positions /// Position Parameters
//@{
/** Set geocentric latitude
@param lat latitude in radians measured from the 0 meridian where
the westerly direction is positive and east is negative */
void set_Latitude(double lat); // geocentric void set_Latitude(double lat); // geocentric
/** Set longitude
@param lon longitude in radians measured from the equator where
the northerly direction is positive and south is negative */
void set_Longitude(double lon); void set_Longitude(double lon);
/** Set altitude
Note: this triggers a recalculation of AGL altitude
@param alt altitude in feet */
void set_Altitude(double alt); // triggers re-calc of AGL altitude void set_Altitude(double alt); // triggers re-calc of AGL altitude
//@}
//void set_AltitudeAGL(double altagl); // and vice-versa //void set_AltitudeAGL(double altagl); // and vice-versa
// Speeds -- setting any of these will trigger a re-calc of the rest /// Velocity Parameters
//@{
/** Sets calibrated airspeed
Setting this will trigger a recalc of the other velocity terms.
@param vc Calibrated airspeed in ft/sec */
void set_V_calibrated_kts(double vc); void set_V_calibrated_kts(double vc);
void set_Mach_number(double mach);
void set_Velocities_Local( double north, double east, double down );
void set_Velocities_Wind_Body( double u, double v, double w);
// Euler angles /** Sets Mach number.
Setting this will trigger a recalc of the other velocity terms.
@param mach Mach number */
void set_Mach_number(double mach);
/** Sets velocity in N-E-D coordinates.
Setting this will trigger a recalc of the other velocity terms.
@param north velocity northward in ft/sec
@param east velocity eastward in ft/sec
@param down velocity downward in ft/sec */
void set_Velocities_Local( double north, double east, double down );
/** Sets aircraft velocity in stability frame.
Setting this will trigger a recalc of the other velocity terms.
@param u X velocity in ft/sec
@param v Y velocity in ft/sec
@param w Z velocity in ft/sec */
void set_Velocities_Wind_Body( double u, double v, double w);
//@}
/** Euler angle parameters
@param phi roll angle in radians
@param theta pitch angle in radians
@param psi heading angle in radians */
void set_Euler_Angles( double phi, double theta, double psi ); void set_Euler_Angles( double phi, double theta, double psi );
// Flight Path /// Flight Path Parameters
//@{
/** Sets rate of climb
@param roc Rate of climb in ft/sec */
void set_Climb_Rate( double roc); void set_Climb_Rate( double roc);
/** Sets the flight path angle in radians
@param gamma flight path angle in radians. */
void set_Gamma_vert_rad( double gamma); void set_Gamma_vert_rad( double gamma);
//@}
// Earth /// Earth Parameters
//@{
/** Sets the sea level radius in feet.
@param slr Sea Level Radius in feet */
void set_Sea_level_radius(double slr); void set_Sea_level_radius(double slr);
void set_Runway_altitude(double ralt);
// Atmosphere /** Sets the runway altitude in feet above sea level.
@param ralt Runway altitude in feet above sea level. */
void set_Runway_altitude(double ralt);
//@}
/// Atmospheric Parameters
//@{
/** Sets the atmospheric static pressure
@param p pressure in psf */
void set_Static_pressure(double p); void set_Static_pressure(double p);
/** Sets the atmospheric temperature
@param T temperature in degrees rankine */
void set_Static_temperature(double T); void set_Static_temperature(double T);
/** Sets the atmospheric density.
@param rho air density slugs/cubic foot */
void set_Density(double rho); void set_Density(double rho);
/** Sets the velocity of the local airmass for wind modeling.
@param wnorth velocity north in fps
@param weast velocity east in fps
@param wdown velocity down in fps*/
void set_Velocities_Local_Airmass (double wnorth, void set_Velocities_Local_Airmass (double wnorth,
double weast, double weast,
double wdown ); double wdown );
//@}
// update position based on inputs, positions, velocities, etc. /** Update the position based on inputs, positions, velocities, etc.
@param multiloop number of times to loop through the FDM
@return true if successful */
bool update( int multiloop ); bool update( int multiloop );
private:
FGFDMExec *fdmex;
FGInitialCondition *fgic;
bool needTrim;
bool trimmed;
float trim_elev;
float trim_throttle;
void snap_shot(void);
}; };

View file

@ -110,8 +110,8 @@ void FGInitialCondition::SetVequivalentKtsIC(float tt) {
vc=calcVcas(mach); vc=calcVcas(mach);
} }
void FGInitialCondition::SetVtrueKtsIC(float tt) { void FGInitialCondition::SetVtrueFpsIC(float tt) {
vt=tt*jsbKTSTOFPS; vt=tt;
lastSpeedSet=setvt; lastSpeedSet=setvt;
mach=vt/fdmex->GetAtmosphere()->GetSoundSpeed(); mach=vt/fdmex->GetAtmosphere()->GetSoundSpeed();
vc=calcVcas(mach); vc=calcVcas(mach);

View file

@ -118,7 +118,8 @@ public:
void SetVcalibratedKtsIC(float tt); void SetVcalibratedKtsIC(float tt);
void SetVequivalentKtsIC(float tt); void SetVequivalentKtsIC(float tt);
void SetVtrueKtsIC(float tt); inline void SetVtrueKtsIC(float tt) { SetVtrueFpsIC(tt*jsbKTSTOFPS); }
void SetVtrueFpsIC(float tt);
void SetMachIC(float tt); void SetMachIC(float tt);
void SetUBodyFpsIC(float tt); void SetUBodyFpsIC(float tt);
@ -207,6 +208,9 @@ public:
inline float GetPhiRadIC(void) { return phi; } inline float GetPhiRadIC(void) { return phi; }
inline float GetPsiRadIC(void) { return psi; } inline float GetPsiRadIC(void) { return psi; }
inline float GetSeaLevelRadiusFtIC(void) { return sea_level_radius; }
inline float GetTerrainAltitudeFtIC(void) { return terrain_altitude; }
private: private:

View file

@ -360,6 +360,10 @@ void FGState::Initialize(FGInitialCondition *FGIC) {
psi = FGIC->GetPsiRadIC(); psi = FGIC->GetPsiRadIC();
Initialize(U, V, W, phi, tht, psi, latitude, longitude, h); Initialize(U, V, W, phi, tht, psi, latitude, longitude, h);
FDMExec->GetPosition()->SetSeaLevelRadius( FGIC->GetSeaLevelRadiusFtIC() );
FDMExec->GetPosition()->SetRunwayRadius( FGIC->GetSeaLevelRadiusFtIC() +
FGIC->GetTerrainAltitudeFtIC() );
} }
/******************************************************************************/ /******************************************************************************/

View file

@ -38,24 +38,22 @@
#include "LaRCsim.hxx" #include "LaRCsim.hxx"
FGLaRCsim::FGLaRCsim(void) { FGLaRCsim::FGLaRCsim(void) {
ls_toplevel_init( 0.0, (char *)globals->get_options()->get_aircraft().c_str() ); ls_toplevel_init( 0.0,
lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is (char *)globals->get_options()->get_aircraft().c_str() );
copy_to_LaRCsim(); // initialize all of LaRCsim's vars lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
//this should go away someday -- formerly done in fg_init.cxx copy_to_LaRCsim(); // initialize all of LaRCsim's vars
Mass = 8.547270E+01; //this should go away someday -- formerly done in fg_init.cxx
I_xx = 1.048000E+03; Mass = 8.547270E+01;
I_yy = 3.000000E+03; I_xx = 1.048000E+03;
I_zz = 3.530000E+03; I_yy = 3.000000E+03;
I_xz = 0.000000E+00; I_zz = 3.530000E+03;
I_xz = 0.000000E+00;
} }
FGLaRCsim::~FGLaRCsim(void) { FGLaRCsim::~FGLaRCsim(void) {
if(lsic != NULL) { if(lsic != NULL) {
delete lsic; delete lsic;
} }
} }
// Initialize the LaRCsim flight model, dt is the time increment for // Initialize the LaRCsim flight model, dt is the time increment for
@ -88,7 +86,6 @@ bool FGLaRCsim::init( double dt ) {
// actual LaRCsim top level init // actual LaRCsim top level init
// ls_toplevel_init( dt, (char *)globals->get_options()->get_aircraft().c_str() ); // ls_toplevel_init( dt, (char *)globals->get_options()->get_aircraft().c_str() );
FG_LOG( FG_FLIGHT, FG_INFO, "FG pos = " << FG_LOG( FG_FLIGHT, FG_INFO, "FG pos = " <<
get_Latitude() ); get_Latitude() );
@ -116,9 +113,9 @@ bool FGLaRCsim::update( int multiloop ) {
eng.set_Throttle_Lever_Pos( controls.get_throttle( 0 ) * 100.0 ); eng.set_Throttle_Lever_Pos( controls.get_throttle( 0 ) * 100.0 );
eng.set_Propeller_Lever_Pos( 100 ); eng.set_Propeller_Lever_Pos( 100 );
if ( controls.get_mixture( 0 ) > 0.60 ) { if ( controls.get_mixture( 0 ) > 0.60 ) {
eng.set_Mixture_Lever_Pos( controls.get_mixture( 0 ) * 100.0 ); eng.set_Mixture_Lever_Pos( controls.get_mixture( 0 ) * 100.0 );
} else { } else {
eng.set_Mixture_Lever_Pos( 60.0 ); eng.set_Mixture_Lever_Pos( 60.0 );
} }
// update engine model // update engine model
@ -138,13 +135,16 @@ bool FGLaRCsim::update( int multiloop ) {
e->set_prop_thrust( eng.get_prop_thrust_SI() ); e->set_prop_thrust( eng.get_prop_thrust_SI() );
#if 0 #if 0
FG_LOG( FG_FLIGHT, FG_INFO, "Throttle = " << controls.get_throttle( 0 ) * 100.0); FG_LOG( FG_FLIGHT, FG_INFO, "Throttle = "
<< controls.get_throttle( 0 ) * 100.0);
FG_LOG( FG_FLIGHT, FG_INFO, " Mixture = " << 80); FG_LOG( FG_FLIGHT, FG_INFO, " Mixture = " << 80);
FG_LOG( FG_FLIGHT, FG_INFO, " RPM = " << eng.get_RPM()); FG_LOG( FG_FLIGHT, FG_INFO, " RPM = " << eng.get_RPM());
FG_LOG( FG_FLIGHT, FG_INFO, " MP = " << eng.get_Manifold_Pressure()); FG_LOG( FG_FLIGHT, FG_INFO, " MP = " << eng.get_Manifold_Pressure());
FG_LOG( FG_FLIGHT, FG_INFO, " HP = " << ( eng.get_MaxHP() * eng.get_Percentage_Power()/ 100.0) ); FG_LOG( FG_FLIGHT, FG_INFO, " HP = "
<< ( eng.get_MaxHP() * eng.get_Percentage_Power()/ 100.0) );
FG_LOG( FG_FLIGHT, FG_INFO, " EGT = " << eng.get_EGT()); FG_LOG( FG_FLIGHT, FG_INFO, " EGT = " << eng.get_EGT());
FG_LOG( FG_FLIGHT, FG_INFO, " Thrust (N) " << eng.get_prop_thrust_SI()); // Thrust in Newtons FG_LOG( FG_FLIGHT, FG_INFO, " Thrust (N) "
<< eng.get_prop_thrust_SI()); // Thrust in Newtons
FG_LOG( FG_FLIGHT, FG_INFO, '\n'); FG_LOG( FG_FLIGHT, FG_INFO, '\n');
#endif #endif
// Hmm .. Newtons to lbs is 0.2248 ... // Hmm .. Newtons to lbs is 0.2248 ...
@ -185,8 +185,8 @@ bool FGLaRCsim::update( int multiloop ) {
// Weather // Weather
/* V_north_airmass = get_V_north_airmass(); /* V_north_airmass = get_V_north_airmass();
V_east_airmass = get_V_east_airmass(); V_east_airmass = get_V_east_airmass();
V_down_airmass = get_V_down_airmass(); */ V_down_airmass = get_V_down_airmass(); */
// old -- FGInterface_2_LaRCsim() not needed except for Init() // old -- FGInterface_2_LaRCsim() not needed except for Init()
@ -198,11 +198,6 @@ bool FGLaRCsim::update( int multiloop ) {
ls_update(multiloop); ls_update(multiloop);
if(isnan(Phi)) {
busdump();
exit(1);
}
// printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048); // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
// printf("%d Altitude = %.2f\n", i, Altitude * 0.3048); // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
@ -438,7 +433,7 @@ bool FGLaRCsim::copy_from_LaRCsim() {
// set_Velocities_Gust( U_gust, V_gust, W_gust ); // set_Velocities_Gust( U_gust, V_gust, W_gust );
_set_Velocities_Wind_Body( U_body, V_body, W_body ); _set_Velocities_Wind_Body( U_body, V_body, W_body );
// set_V_rel_wind( V_rel_wind ); _set_V_rel_wind( V_rel_wind );
// set_V_true_kts( V_true_kts ); // set_V_true_kts( V_true_kts );
// set_V_rel_ground( V_rel_ground ); // set_V_rel_ground( V_rel_ground );
// set_V_inertial( V_inertial ); // set_V_inertial( V_inertial );
@ -472,7 +467,7 @@ bool FGLaRCsim::copy_from_LaRCsim() {
// Positions // Positions
_set_Geocentric_Position( Lat_geocentric, tmp_lon_geoc, _set_Geocentric_Position( Lat_geocentric, tmp_lon_geoc,
Radius_to_vehicle ); Radius_to_vehicle );
_set_Geodetic_Position( Latitude, tmp_lon, Altitude ); _set_Geodetic_Position( Latitude, tmp_lon, Altitude );
_set_Euler_Angles( Phi, Theta, Psi ); _set_Euler_Angles( Phi, Theta, Psi );
@ -549,159 +544,188 @@ bool FGLaRCsim::copy_from_LaRCsim() {
void FGLaRCsim::set_ls(void) { void FGLaRCsim::set_ls(void) {
Phi=lsic->GetRollAngleRadIC(); Phi=lsic->GetRollAngleRadIC();
Theta=lsic->GetPitchAngleRadIC(); Theta=lsic->GetPitchAngleRadIC();
Psi=lsic->GetHeadingRadIC(); Psi=lsic->GetHeadingRadIC();
V_north=lsic->GetVnorthFpsIC(); V_north=lsic->GetVnorthFpsIC();
V_east=lsic->GetVeastFpsIC(); V_east=lsic->GetVeastFpsIC();
V_down=lsic->GetVdownFpsIC(); V_down=lsic->GetVdownFpsIC();
Altitude=lsic->GetAltitudeFtIC(); Altitude=lsic->GetAltitudeFtIC();
Latitude=lsic->GetLatitudeGDRadIC(); Latitude=lsic->GetLatitudeGDRadIC();
Longitude=lsic->GetLongitudeRadIC(); Longitude=lsic->GetLongitudeRadIC();
Runway_altitude=lsic->GetRunwayAltitudeFtIC(); Runway_altitude=lsic->GetRunwayAltitudeFtIC();
V_north_airmass = lsic->GetVnorthAirmassFpsIC(); V_north_airmass = lsic->GetVnorthAirmassFpsIC();
V_east_airmass = lsic->GetVeastAirmassFpsIC(); V_east_airmass = lsic->GetVeastAirmassFpsIC();
V_down_airmass = lsic->GetVdownAirmassFpsIC(); V_down_airmass = lsic->GetVdownAirmassFpsIC();
ls_loop(0.0,-1); ls_loop(0.0,-1);
copy_from_LaRCsim(); copy_from_LaRCsim();
FG_LOG( FG_FLIGHT, FG_INFO, " FGLaRCsim::set_ls(): " ); FG_LOG( FG_FLIGHT, FG_INFO, " FGLaRCsim::set_ls(): " );
FG_LOG( FG_FLIGHT, FG_INFO, " Phi: " << Phi ); FG_LOG( FG_FLIGHT, FG_INFO, " Phi: " << Phi );
FG_LOG( FG_FLIGHT, FG_INFO, " Theta: " << Theta ); FG_LOG( FG_FLIGHT, FG_INFO, " Theta: " << Theta );
FG_LOG( FG_FLIGHT, FG_INFO, " Psi: " << Psi ); FG_LOG( FG_FLIGHT, FG_INFO, " Psi: " << Psi );
FG_LOG( FG_FLIGHT, FG_INFO, " V_north: " << V_north ); FG_LOG( FG_FLIGHT, FG_INFO, " V_north: " << V_north );
FG_LOG( FG_FLIGHT, FG_INFO, " V_east: " << V_east ); FG_LOG( FG_FLIGHT, FG_INFO, " V_east: " << V_east );
FG_LOG( FG_FLIGHT, FG_INFO, " V_down: " << V_down ); FG_LOG( FG_FLIGHT, FG_INFO, " V_down: " << V_down );
FG_LOG( FG_FLIGHT, FG_INFO, " Altitude: " << Altitude ); FG_LOG( FG_FLIGHT, FG_INFO, " Altitude: " << Altitude );
FG_LOG( FG_FLIGHT, FG_INFO, " Latitude: " << Latitude ); FG_LOG( FG_FLIGHT, FG_INFO, " Latitude: " << Latitude );
FG_LOG( FG_FLIGHT, FG_INFO, " Longitude: " << Longitude ); FG_LOG( FG_FLIGHT, FG_INFO, " Longitude: " << Longitude );
FG_LOG( FG_FLIGHT, FG_INFO, " Runway_altitude: " << Runway_altitude ); FG_LOG( FG_FLIGHT, FG_INFO, " Runway_altitude: " << Runway_altitude );
FG_LOG( FG_FLIGHT, FG_INFO, " V_north_airmass: " << V_north_airmass ); FG_LOG( FG_FLIGHT, FG_INFO, " V_north_airmass: " << V_north_airmass );
FG_LOG( FG_FLIGHT, FG_INFO, " V_east_airmass: " << V_east_airmass ); FG_LOG( FG_FLIGHT, FG_INFO, " V_east_airmass: " << V_east_airmass );
FG_LOG( FG_FLIGHT, FG_INFO, " V_down_airmass: " << V_down_airmass ); FG_LOG( FG_FLIGHT, FG_INFO, " V_down_airmass: " << V_down_airmass );
} }
//Positions void FGLaRCsim::snap_shot(void) {
lsic->SetLatitudeGDRadIC( get_Latitude() );
lsic->SetLongitudeRadIC( get_Longitude() );
lsic->SetAltitudeFtIC( get_Altitude() );
lsic->SetRunwayAltitudeFtIC( get_Runway_altitude() );
lsic->SetVtrueFpsIC( get_V_rel_wind() );
lsic->SetPitchAngleRadIC( get_Theta() );
lsic->SetRollAngleRadIC( get_Phi() );
lsic->SetHeadingRadIC( get_Psi() );
lsic->SetClimbRateFpsIC( get_Climb_Rate() );
lsic->SetVNEDAirmassFpsIC( get_V_north_airmass(),
get_V_east_airmass(),
get_V_down_airmass() );
}
//Positions
void FGLaRCsim::set_Latitude(double lat) { void FGLaRCsim::set_Latitude(double lat) {
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Latitude: " << lat ); FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Latitude: " << lat );
lsic->SetLatitudeGDRadIC(lat); snap_shot();
set_ls(); lsic->SetLatitudeGDRadIC(lat);
copy_from_LaRCsim(); //update the bus set_ls();
copy_from_LaRCsim(); //update the bus
} }
void FGLaRCsim::set_Longitude(double lon) { void FGLaRCsim::set_Longitude(double lon) {
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Longitude: " << lon ); FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Longitude: " << lon );
lsic->SetLongitudeRadIC(lon); snap_shot();
set_ls(); lsic->SetLongitudeRadIC(lon);
copy_from_LaRCsim(); //update the bus set_ls();
copy_from_LaRCsim(); //update the bus
} }
void FGLaRCsim::set_Altitude(double alt) { void FGLaRCsim::set_Altitude(double alt) {
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Altitude: " << alt ); FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Altitude: " << alt );
lsic->SetAltitudeFtIC(alt); snap_shot();
set_ls(); lsic->SetAltitudeFtIC(alt);
copy_from_LaRCsim(); //update the bus set_ls();
copy_from_LaRCsim(); //update the bus
} }
void FGLaRCsim::set_V_calibrated_kts(double vc) { void FGLaRCsim::set_V_calibrated_kts(double vc) {
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_V_calibrated_kts: " << vc ); FG_LOG( FG_FLIGHT, FG_INFO,
lsic->SetVcalibratedKtsIC(vc); "FGLaRCsim::set_V_calibrated_kts: " << vc );
set_ls(); snap_shot();
copy_from_LaRCsim(); //update the bus lsic->SetVcalibratedKtsIC(vc);
set_ls();
copy_from_LaRCsim(); //update the bus
} }
void FGLaRCsim::set_Mach_number(double mach) { void FGLaRCsim::set_Mach_number(double mach) {
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Mach_number: " << mach ); FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Mach_number: " << mach );
lsic->SetMachIC(mach); snap_shot();
set_ls(); lsic->SetMachIC(mach);
copy_from_LaRCsim(); //update the bus set_ls();
copy_from_LaRCsim(); //update the bus
} }
void FGLaRCsim::set_Velocities_Local( double north, double east, double down ){ void FGLaRCsim::set_Velocities_Local( double north, double east, double down ){
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Velocities_local: " FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Velocities_local: "
<< north << " " << east << " " << down ); << north << " " << east << " " << down );
lsic->SetVnorthFpsIC(north); snap_shot();
lsic->SetVeastFpsIC(east); lsic->SetVNEDFpsIC(north, east, down);
lsic->SetVdownFpsIC(down); set_ls();
set_ls(); copy_from_LaRCsim(); //update the bus
copy_from_LaRCsim(); //update the bus
} }
void FGLaRCsim::set_Velocities_Wind_Body( double u, double v, double w){ void FGLaRCsim::set_Velocities_Wind_Body( double u, double v, double w){
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Velocities_Wind_Body: " FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Velocities_Wind_Body: "
<< u << " " << v << " " << w ); << u << " " << v << " " << w );
snap_shot();
lsic->SetUBodyFpsIC(u); lsic->SetUVWFpsIC(u,v,w);
lsic->SetVBodyFpsIC(v); set_ls();
lsic->SetWBodyFpsIC(w); copy_from_LaRCsim(); //update the bus
set_ls();
copy_from_LaRCsim(); //update the bus
} }
//Euler angles //Euler angles
void FGLaRCsim::set_Euler_Angles( double phi, double theta, double psi ) { void FGLaRCsim::set_Euler_Angles( double phi, double theta, double psi ) {
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Euler_angles: " FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Euler_angles: "
<< phi << " " << theta << " " << psi ); << phi << " " << theta << " " << psi );
lsic->SetPitchAngleRadIC(theta); snap_shot();
lsic->SetRollAngleRadIC(phi); lsic->SetPitchAngleRadIC(theta);
lsic->SetHeadingRadIC(psi); lsic->SetRollAngleRadIC(phi);
set_ls(); lsic->SetHeadingRadIC(psi);
copy_from_LaRCsim(); //update the bus set_ls();
copy_from_LaRCsim(); //update the bus
} }
//Flight Path //Flight Path
void FGLaRCsim::set_Climb_Rate( double roc) { void FGLaRCsim::set_Climb_Rate( double roc) {
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Climb_rate: " << roc ); FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Climb_rate: " << roc );
lsic->SetClimbRateFpsIC(roc); snap_shot();
set_ls(); lsic->SetClimbRateFpsIC(roc);
copy_from_LaRCsim(); //update the bus set_ls();
copy_from_LaRCsim(); //update the bus
} }
void FGLaRCsim::set_Gamma_vert_rad( double gamma) { void FGLaRCsim::set_Gamma_vert_rad( double gamma) {
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Gamma_vert_rad: " << gamma ); FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Gamma_vert_rad: " << gamma );
lsic->SetFlightPathAngleRadIC(gamma); snap_shot();
set_ls(); lsic->SetFlightPathAngleRadIC(gamma);
copy_from_LaRCsim(); //update the bus set_ls();
copy_from_LaRCsim(); //update the bus
} }
void FGLaRCsim::set_Runway_altitude(double ralt) { void FGLaRCsim::set_Runway_altitude(double ralt) {
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Runway_altitude: " << ralt ); FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Runway_altitude: " << ralt );
lsic->SetRunwayAltitudeFtIC(ralt); snap_shot();
set_ls(); lsic->SetRunwayAltitudeFtIC(ralt);
copy_from_LaRCsim(); //update the bus set_ls();
copy_from_LaRCsim(); //update the bus
} }
void FGLaRCsim::set_AltitudeAGL(double altagl) { void FGLaRCsim::set_AltitudeAGL(double altagl) {
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_AltitudeAGL: " << altagl ); FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_AltitudeAGL: " << altagl );
lsic->SetAltitudeAGLFtIC(altagl); snap_shot();
set_ls(); lsic->SetAltitudeAGLFtIC(altagl);
copy_from_LaRCsim(); set_ls();
copy_from_LaRCsim();
} }
void FGLaRCsim::set_Velocities_Local_Airmass (double wnorth, void FGLaRCsim::set_Velocities_Local_Airmass (double wnorth,
double weast, double weast,
double wdown ) { double wdown ) {
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Velocities_Local_Airmass: " FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Velocities_Local_Airmass: "
<< wnorth << " " << weast << " " << wdown ); << wnorth << " " << weast << " " << wdown );
_set_Velocities_Local_Airmass( wnorth, weast, wdown ); snap_shot();
set_ls(); lsic->SetVNEDAirmassFpsIC( wnorth, weast, wdown );
copy_from_LaRCsim(); set_ls();
copy_from_LaRCsim();
} }
void FGLaRCsim::set_Static_pressure(double p) { void FGLaRCsim::set_Static_pressure(double p) {
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Static_pressure: " << p ); FG_LOG( FG_FLIGHT, FG_INFO,
FG_LOG( FG_FLIGHT, FG_INFO, "LaRCsim does not support externally supplied atmospheric data" ); "FGLaRCsim::set_Static_pressure: " << p );
FG_LOG( FG_FLIGHT, FG_INFO,
"LaRCsim does not support externally supplied atmospheric data" );
} }
void FGLaRCsim::set_Static_temperature(double T) { void FGLaRCsim::set_Static_temperature(double T) {
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Static_temperature: " << T ); FG_LOG( FG_FLIGHT, FG_INFO,
FG_LOG( FG_FLIGHT, FG_INFO, "LaRCsim does not support externally supplied atmospheric data" ); "FGLaRCsim::set_Static_temperature: " << T );
FG_LOG( FG_FLIGHT, FG_INFO,
"LaRCsim does not support externally supplied atmospheric data" );
} }
void FGLaRCsim::set_Density(double rho) { void FGLaRCsim::set_Density(double rho) {
FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Density: " << rho ); FG_LOG( FG_FLIGHT, FG_INFO, "FGLaRCsim::set_Density: " << rho );
FG_LOG( FG_FLIGHT, FG_INFO, "LaRCsim does not support externally supplied atmospheric data" ); FG_LOG( FG_FLIGHT, FG_INFO,
"LaRCsim does not support externally supplied atmospheric data" );
} }

View file

@ -36,6 +36,7 @@ class FGLaRCsim: public FGInterface {
FGNewEngine eng; FGNewEngine eng;
LaRCsimIC* lsic; LaRCsimIC* lsic;
void set_ls(void); void set_ls(void);
void snap_shot(void);
double time_step; double time_step;
public: public:

View file

@ -37,6 +37,9 @@
CURRENT RCS HEADER INFO: CURRENT RCS HEADER INFO:
$Header$ $Header$
$Log$ $Log$
Revision 1.3 2000/10/28 14:30:33 curt
Updates by Tony working on the FDM interface bus.
Revision 1.2 2000/04/10 18:09:41 curt Revision 1.2 2000/04/10 18:09:41 curt
David Megginson made a few (mostly minor) mods to the LaRCsim files, and David Megginson made a few (mostly minor) mods to the LaRCsim files, and
it's now possible to choose the LaRCsim model at runtime, as in it's now possible to choose the LaRCsim model at runtime, as in
@ -119,6 +122,7 @@ void ls_model( SCALAR dt, int Initialize ) {
navion_gear( dt, Initialize ); navion_gear( dt, Initialize );
break; break;
case C172: case C172:
if(Initialize < 0) c172_init();
inertias( dt, Initialize ); inertias( dt, Initialize );
subsystems( dt, Initialize ); subsystems( dt, Initialize );
c172_aero( dt, Initialize ); c172_aero( dt, Initialize );

View file

@ -119,40 +119,18 @@ void LaRCsimIC::SetPitchAngleRadIC(SCALAR tt) {
getAlpha(); getAlpha();
} }
void LaRCsimIC::SetUBodyFpsIC( SCALAR tt) { void LaRCsimIC::SetUVWFpsIC(SCALAR vu, SCALAR vv, SCALAR vw) {
u=tt; u=vu; v=vv; w=vw;
vt=sqrt(u*u+v*v+w*w); vt=sqrt(u*u+v*v+w*w);
lastSpeedSet=lssetuvw; lastSpeedSet=lssetuvw;
} }
void LaRCsimIC::SetVBodyFpsIC( SCALAR tt) { void LaRCsimIC::SetVNEDAirmassFpsIC(SCALAR north, SCALAR east, SCALAR down ) {
v=tt; vnorthwind=north; veastwind=east; vdownwind=down;
vt=sqrt(u*u+v*v+w*w);
lastSpeedSet=lssetuvw;
}
void LaRCsimIC::SetWBodyFpsIC( SCALAR tt) {
w=tt;
vt=sqrt(u*u+v*v+w*w);
lastSpeedSet=lssetuvw;
}
void LaRCsimIC::SetVNorthAirmassFpsIC(SCALAR tt) {
vnorthwind=tt;
vw=sqrt(vnorthwind*vnorthwind + veastwind*veastwind + vdownwind*vdownwind);
}
void LaRCsimIC::SetVEastAirmassFpsIC(SCALAR tt) {
veastwind=tt;
vw=sqrt(vnorthwind*vnorthwind + veastwind*veastwind + vdownwind*vdownwind);
}
void LaRCsimIC::SetVDownAirmassFpsIC(SCALAR tt){
vdownwind=tt;
vw=sqrt(vnorthwind*vnorthwind + veastwind*veastwind + vdownwind*vdownwind); vw=sqrt(vnorthwind*vnorthwind + veastwind*veastwind + vdownwind*vdownwind);
vtg=vt+vw; vtg=vt+vw;
hdot=-vtg*sin(gamma); SetClimbRateFpsIC(-1*(vdown+vdownwind));
} }
void LaRCsimIC::SetAltitudeFtIC( SCALAR tt) { void LaRCsimIC::SetAltitudeFtIC( SCALAR tt) {
@ -243,23 +221,13 @@ void LaRCsimIC::calcNEDfromVt(void) {
vdownwind; vdownwind;
} }
void LaRCsimIC::SetVnorthFpsIC( SCALAR tt) { void LaRCsimIC::SetVNEDFpsIC( SCALAR north, SCALAR east, SCALAR down) {
vnorth=tt; vnorth=north;
lastSpeedSet=lssetned; veast=east;
calcVtfromNED(); vdown=down;
}
void LaRCsimIC::SetVeastFpsIC( SCALAR tt) {
veast=tt;
lastSpeedSet=lssetned;
calcVtfromNED();
}
void LaRCsimIC::SetVdownFpsIC( SCALAR tt) {
vdown=tt;
calcVtfromNED();
SetClimbRateFpsIC(-1*vdown); SetClimbRateFpsIC(-1*vdown);
lastSpeedSet=lssetned; lastSpeedSet=lssetned;
calcVtfromNED();
} }
void LaRCsimIC::SetLatitudeGDRadIC(SCALAR tt) { void LaRCsimIC::SetLatitudeGDRadIC(SCALAR tt) {

View file

@ -59,17 +59,11 @@ public:
void SetVequivalentKtsIC(SCALAR tt); void SetVequivalentKtsIC(SCALAR tt);
void SetUBodyFpsIC(SCALAR tt); void SetUVWFpsIC(SCALAR vu, SCALAR vv, SCALAR vw);
void SetVBodyFpsIC(SCALAR tt);
void SetWBodyFpsIC(SCALAR tt);
void SetVnorthFpsIC(SCALAR tt); void SetVNEDFpsIC(SCALAR north, SCALAR east, SCALAR down);
void SetVeastFpsIC(SCALAR tt);
void SetVdownFpsIC(SCALAR tt);
void SetVNorthAirmassFpsIC(SCALAR tt); void SetVNEDAirmassFpsIC(SCALAR north, SCALAR east, SCALAR down );
void SetVEastAirmassFpsIC(SCALAR tt);
void SetVDownAirmassFpsIC(SCALAR tt);
void SetAltitudeFtIC(SCALAR tt); void SetAltitudeFtIC(SCALAR tt);
void SetAltitudeAGLFtIC(SCALAR tt); void SetAltitudeAGLFtIC(SCALAR tt);

View file

@ -27,6 +27,7 @@
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/math/sg_geodesy.hxx> #include <simgear/math/sg_geodesy.hxx>
#include <Scenery/scenery.hxx>
#include <FDM/LaRCsim/ls_interface.h> #include <FDM/LaRCsim/ls_interface.h>
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Time/timestamp.hxx> #include <Time/timestamp.hxx>
@ -137,8 +138,6 @@ FGInterface::FGInterface(void) {
sin_latitude=cos_latitude=0; sin_latitude=cos_latitude=0;
sin_longitude=cos_longitude=0; sin_longitude=cos_longitude=0;
altitude_agl=0; altitude_agl=0;
resetNeeded=false;
} }
@ -159,6 +158,58 @@ bool FGInterface::update( int multi_loop ) {
} }
void FGInterface::_updatePosition( double lat_geoc, double lon, double alt ) {
double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc;
sgGeocToGeod( lat_geoc, EQUATORIAL_RADIUS_M + alt * FEET_TO_METER,
&lat_geod, &tmp_alt, &sl_radius1 );
sgGeodToGeoc( lat_geod, alt * FEET_TO_METER, &sl_radius2, &tmp_lat_geoc );
FG_LOG( FG_FLIGHT, FG_DEBUG, "lon = " << lon
<< " lat_geod = " << lat_geod
<< " lat_geoc = " << lat_geoc
<< " alt = " << alt
<< " tmp_alt = " << tmp_alt * METER_TO_FEET
<< " sl_radius1 = " << sl_radius1 * METER_TO_FEET
<< " sl_radius2 = " << sl_radius2 * METER_TO_FEET
<< " Equator = " << EQUATORIAL_RADIUS_FT );
_set_Geocentric_Position( lat_geoc, lon,
sl_radius2 * METER_TO_FEET + alt );
_set_Geodetic_Position( lat_geod, lon, alt );
_set_Sea_level_radius( sl_radius2 * METER_TO_FEET );
_set_Runway_altitude( scenery.cur_elev*METERS_TO_FEET );
_set_sin_lat_geocentric( lat_geoc );
_set_cos_lat_geocentric( lat_geoc );
_set_sin_cos_longitude( lon );
_set_sin_cos_latitude( lat_geod );
/* Norman's code for slope of the terrain */
/* needs to be tested -- get it on the HUD and taxi around */
/* double *tnorm = scenery.cur_normal;
double sy = sin ( -get_Psi() ) ;
double cy = cos ( -get_Psi() ) ;
double phitb, thetatb, psitb;
if(tnorm[1] != 0.0) {
psitb = -atan2 ( tnorm[0], tnorm[1] );
}
if(tnorm[2] != 0.0) {
thetatb = atan2 ( tnorm[0] * cy - tnorm[1] * sy, tnorm[2] );
phitb = -atan2 ( tnorm[1] * cy + tnorm[0] * sy, tnorm[2] );
}
_set_terrain_slope(phitb, thetatb, psitb)
*/
}
// Extrapolate fdm based on time_offset (in usec) // Extrapolate fdm based on time_offset (in usec)
void FGInterface::extrapolate( int time_offset ) { void FGInterface::extrapolate( int time_offset ) {
double dt = time_offset / 1000000.0; double dt = time_offset / 1000000.0;
@ -301,7 +352,7 @@ void FGInterface::set_Velocities_Local_Airmass (double wnorth,
} }
void FGInterface::busdump(void) { void FGInterface::_busdump(void) {
FG_LOG(FG_FLIGHT,FG_INFO,"d_pilot_rp_body_v[3]: " << d_pilot_rp_body_v[0] << ", " << d_pilot_rp_body_v[1] << ", " << d_pilot_rp_body_v[2]); FG_LOG(FG_FLIGHT,FG_INFO,"d_pilot_rp_body_v[3]: " << d_pilot_rp_body_v[0] << ", " << d_pilot_rp_body_v[1] << ", " << d_pilot_rp_body_v[2]);
FG_LOG(FG_FLIGHT,FG_INFO,"d_cg_rp_body_v[3]: " << d_cg_rp_body_v[0] << ", " << d_cg_rp_body_v[1] << ", " << d_cg_rp_body_v[2]); FG_LOG(FG_FLIGHT,FG_INFO,"d_cg_rp_body_v[3]: " << d_cg_rp_body_v[0] << ", " << d_cg_rp_body_v[1] << ", " << d_cg_rp_body_v[2]);

View file

@ -160,10 +160,6 @@ typedef vector < FGEngInterface > engine_list;
// This is based heavily on LaRCsim/ls_generic.h // This is based heavily on LaRCsim/ls_generic.h
class FGInterface { class FGInterface {
protected:
void busdump(void);
private: private:
// Pilot location rel to ref pt // Pilot location rel to ref pt
@ -253,9 +249,6 @@ private:
double sin_latitude, cos_latitude; double sin_latitude, cos_latitude;
double altitude_agl; double altitude_agl;
//change flag
bool resetNeeded;
// Engine list // Engine list
engine_list engines; engine_list engines;
@ -263,6 +256,9 @@ private:
FGTimeStamp next_stamp; // time this record is valid FGTimeStamp next_stamp; // time this record is valid
protected: protected:
void _busdump(void);
void _updatePosition( double lat_geoc, double lon, double alt );
void _updateWeather( void );
inline void _set_Inertias( double m, double xx, double yy, inline void _set_Inertias( double m, double xx, double yy,
double zz, double xz) double zz, double xz)
@ -326,6 +322,7 @@ protected:
v_wind_body_v[1] = v; v_wind_body_v[1] = v;
v_wind_body_v[2] = w; v_wind_body_v[2] = w;
} }
inline void _set_V_rel_wind(double vt) { v_rel_wind = vt; }
inline void _set_V_ground_speed( double v) { v_ground_speed = v; } inline void _set_V_ground_speed( double v) { v_ground_speed = v; }
inline void _set_V_equiv_kts( double kts ) { v_equiv_kts = kts; } inline void _set_V_equiv_kts( double kts ) { v_equiv_kts = kts; }
inline void _set_V_calibrated_kts( double kts ) { v_calibrated_kts = kts; } inline void _set_V_calibrated_kts( double kts ) { v_calibrated_kts = kts; }
@ -726,7 +723,7 @@ public:
inline double get_V_body() const { return v_wind_body_v[1]; } inline double get_V_body() const { return v_wind_body_v[1]; }
inline double get_W_body() const { return v_wind_body_v[2]; } inline double get_W_body() const { return v_wind_body_v[2]; }
// inline double get_V_rel_wind() const { return v_rel_wind; } inline double get_V_rel_wind() const { return v_rel_wind; }
// inline void set_V_rel_wind(double wind) { v_rel_wind = wind; } // inline void set_V_rel_wind(double wind) { v_rel_wind = wind; }
// inline double get_V_true_kts() const { return v_true_kts; } // inline double get_V_true_kts() const { return v_true_kts; }

View file

@ -407,21 +407,21 @@ bool fgInitGeneral( void ) {
// set initial aircraft speed // set initial aircraft speed
bool fgVelocityInit( void ) { bool fgVelocityInit( void ) {
switch(globals->get_options()->get_speedset()) { switch(globals->get_options()->get_speedset()) {
case 1: //FG_VC case FGOptions::FG_VC:
current_aircraft.fdm_state->set_V_calibrated_kts( current_aircraft.fdm_state->set_V_calibrated_kts(
globals->get_options()->get_vc() ); globals->get_options()->get_vc() );
break; break;
case 2: //FG_MACH case FGOptions::FG_MACH:
current_aircraft.fdm_state->set_Mach_number( current_aircraft.fdm_state->set_Mach_number(
globals->get_options()->get_mach() ); globals->get_options()->get_mach() );
break; break;
case 3: //FG_VTUVW case FGOptions::FG_VTUVW:
current_aircraft.fdm_state->set_Velocities_Wind_Body( current_aircraft.fdm_state->set_Velocities_Wind_Body(
globals->get_options()->get_uBody(), globals->get_options()->get_uBody(),
globals->get_options()->get_vBody(), globals->get_options()->get_vBody(),
globals->get_options()->get_wBody() ); globals->get_options()->get_wBody() );
break; break;
case 4: //FG_VTNED case FGOptions::FG_VTNED:
current_aircraft.fdm_state->set_Velocities_Local( current_aircraft.fdm_state->set_Velocities_Local(
globals->get_options()->get_vNorth(), globals->get_options()->get_vNorth(),
globals->get_options()->get_vEast(), globals->get_options()->get_vEast(),