#include <FDM/LaRCsim/ls_generic.h>
#include <FDM/LaRCsim/ls_interface.h>
#include <FDM/LaRCsimIC.hxx>
+#include <FDM/UIUCModel/uiuc_aircraft.h>
#include "IO360.hxx"
#include "LaRCsim.hxx"
ls_toplevel_init( 0.0, (char *)(aircraft->getStringValue().c_str()) );
lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
- copy_to_LaRCsim(); // initialize all of LaRCsim's vars
- //this should go away someday -- formerly done in fg_init.cxx
- Mass = 8.547270E+01;
- I_xx = 1.048000E+03;
- I_yy = 3.000000E+03;
- I_zz = 3.530000E+03;
- I_xz = 0.000000E+00;
- //current_aircraft.fdm_state->set_Tank1Fuel(15.0);
- //current_aircraft.fdm_state->set_Tank2Fuel(15.0);
- //Tank1Fuel = 15.0;
- //Tank2Fuel = 15.0;
-}
-
-FGLaRCsim::~FGLaRCsim(void) {
- if(lsic != NULL) {
- delete lsic;
+ if ( aircraft->getStringValue() == "c172" ) {
+ copy_to_LaRCsim(); // initialize all of LaRCsim's vars
+
+ //this should go away someday -- formerly done in fg_init.cxx
+ Mass = 8.547270E+01;
+ I_xx = 1.048000E+03;
+ I_yy = 3.000000E+03;
+ I_zz = 3.530000E+03;
+ I_xz = 0.000000E+00;
}
-}
-
-// Initialize the LaRCsim flight model, dt is the time increment for
-// each subsequent iteration through the EOM
-void FGLaRCsim::init() {
-
- // Explicitly call the superclass's
- // init method first.
- FGInterface::init();
-
+
ls_set_model_dt( get_delta_t() );
- // Initialize our little engine that hopefully might
+
+ // Initialize our little engine that hopefully might
eng.init( get_delta_t() );
// dcl - in passing dt to init rather than update I am assuming
// that the LaRCsim dt is fixed at one value (yes it is 120hz CLO)
// is slightly less
set_Tank1Fuel(28.0);
set_Tank2Fuel(28.0);
+}
- // SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::init()" );
-
- double save_alt = 0.0;
-
- if ( get_Altitude() < -9000.0 ) {
- save_alt = get_Altitude();
- set_Altitude( 0.0 );
+FGLaRCsim::~FGLaRCsim(void) {
+ if ( lsic != NULL ) {
+ delete lsic;
+ lsic = NULL;
}
+}
- // translate FG to LaRCsim structure
- copy_to_LaRCsim();
-
- // actual LaRCsim top level init
- // ls_toplevel_init( dt, (char *)fgGetString("/sim/aircraft").c_str() );
-
- SG_LOG( SG_FLIGHT, SG_INFO, "FG pos = " <<
- get_Latitude() );
-
- // translate LaRCsim back to FG structure
- copy_from_LaRCsim();
+// Initialize the LaRCsim flight model, dt is the time increment for
+// each subsequent iteration through the EOM
+void FGLaRCsim::init() {
+ //do init common to all FDM's
+ common_init();
- // but lets restore our original bogus altitude when we are done
- if ( save_alt < -9000.0 ) {
- set_Altitude( save_alt );
- }
+ //now do any specific to LaRCsim
}
// set control inputs
// cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
eng.set_IAS( V_calibrated_kts );
- eng.set_Throttle_Lever_Pos( controls.get_throttle( 0 ) * 100.0 );
+ eng.set_Throttle_Lever_Pos( globals->get_controls()->get_throttle( 0 )
+ * 100.0 );
eng.set_Propeller_Lever_Pos( 100 );
- eng.set_Mixture_Lever_Pos( controls.get_mixture( 0 ) * 100.0 );
+ eng.set_Mixture_Lever_Pos( globals->get_controls()->get_mixture( 0 )
+ * 100.0 );
+ eng.set_Magneto_Switch_Pos( globals->get_controls()->get_magnetos(0) );
+ eng.setStarterFlag( globals->get_controls()->get_starter(0) );
eng.set_p_amb( Static_pressure );
eng.set_T_amb( Static_temperature );
// copy engine state values onto "bus"
FGEngInterface *e = get_engine( 0 );
- e->set_Throttle( controls.get_throttle( 0 ) * 100.0 );
- e->set_Mixture( 80 );
+ e->set_Throttle( globals->get_controls()->get_throttle(0) * 100.0 );
+ e->set_Mixture( 80 ); // ???????
e->set_Prop_Advance( 100 );
e->set_RPM( eng.get_RPM() );
e->set_Manifold_Pressure( eng.get_Manifold_Pressure() );
e->set_CHT( eng.get_CHT() );
e->set_prop_thrust( eng.get_prop_thrust_SI() );
e->set_Fuel_Flow( eng.get_fuel_flow_gals_hr() );
+ e->set_Oil_Temp( eng.get_oil_temp() );
+ e->set_Running_Flag( eng.getRunningFlag() );
+ e->set_Cranking_Flag( eng.getCrankingFlag() );
//Assume we are using both tanks equally for now
reduce_Tank1Fuel( (eng.get_fuel_flow_gals_hr() / (2 * 3600))
#if 0
SG_LOG( SG_FLIGHT, SG_INFO, "Throttle = "
- << controls.get_throttle( 0 ) * 100.0);
+ << globals->get_controls()->get_throttle( 0 ) * 100.0);
SG_LOG( SG_FLIGHT, SG_INFO, " Mixture = " << 80);
SG_LOG( SG_FLIGHT, SG_INFO, " RPM = " << eng.get_RPM());
SG_LOG( SG_FLIGHT, SG_INFO, " MP = " << eng.get_Manifold_Pressure());
}
// copy control positions into the LaRCsim structure
- Lat_control = controls.get_aileron() /
+ Lat_control = globals->get_controls()->get_aileron() /
speed_up->getIntValue();
- Long_control = controls.get_elevator();
- Long_trim = controls.get_elevator_trim();
- Rudder_pedal = controls.get_rudder() /
+ Long_control = globals->get_controls()->get_elevator();
+ Long_trim = globals->get_controls()->get_elevator_trim();
+ Rudder_pedal = globals->get_controls()->get_rudder() /
speed_up->getIntValue();
- Flap_handle = 30.0 * controls.get_flaps();
+ Flap_handle = 30.0 * globals->get_controls()->get_flaps();
if ( aircraft->getStringValue() == "c172" ) {
Use_External_Engine = 1;
Use_External_Engine = 0;
}
- Throttle_pct = controls.get_throttle( 0 ) * 1.0;
+ Throttle_pct = globals->get_controls()->get_throttle( 0 ) * 1.0;
- Brake_pct[0] = controls.get_brake( 1 );
- Brake_pct[1] = controls.get_brake( 0 );
+ Brake_pct[0] = globals->get_controls()->get_brake( 1 );
+ Brake_pct[1] = globals->get_controls()->get_brake( 0 );
// Inform LaRCsim of the local terrain altitude
// Runway_altitude = get_Runway_altitude();
- Runway_altitude = scenery.cur_elev * SG_METER_TO_FEET;
+ Runway_altitude = scenery.get_cur_elev() * SG_METER_TO_FEET;
// Weather
/* V_north_airmass = get_V_north_airmass();
_set_Geodetic_Position( Latitude, tmp_lon, Altitude );
_set_Euler_Angles( Phi, Theta, Psi );
- _set_Altitude_AGL( Altitude-Runway_altitude );
+ _set_Altitude_AGL( Altitude - Runway_altitude );
// Miscellaneous quantities
_set_T_Local_to_Body(T_local_to_body_m);
_set_Climb_Rate( -1 * V_down );
// cout << "climb rate = " << -V_down * 60 << endl;
+
+ if ( aircraft->getStringValue() == "uiuc" ) {
+ if (pilot_elev_no) {
+ globals->get_controls()->set_elevator(Long_control);
+ globals->get_controls()->set_elevator_trim(Long_trim);
+ // controls.set_elevator(Long_control);
+ // controls.set_elevator_trim(Long_trim);
+ }
+ if (pilot_ail_no) {
+ globals->get_controls()->set_aileron(Lat_control);
+ // controls.set_aileron(Lat_control);
+ }
+ if (pilot_rud_no) {
+ globals->get_controls()->set_rudder(Rudder_pedal);
+ // controls.set_rudder(Rudder_pedal);
+ }
+ if (Throttle_pct_input) {
+ globals->get_controls()->set_throttle(0,Throttle_pct);
+ // controls.set_throttle(0,Throttle_pct);
+ }
+ }
+
return true;
}