]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/LaRCsim.cxx
Initial revision.
[flightgear.git] / src / FDM / LaRCsim.cxx
index da2ee815992089a813bdf09979957d3912729b07..fedef5a210c2a3823aabab8102e6e7187a7882ce 100644 (file)
@@ -34,6 +34,7 @@
 #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"
@@ -47,14 +48,16 @@ FGLaRCsim::FGLaRCsim( double dt ) {
     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;
+    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;
+    }
     
     ls_set_model_dt( get_delta_t() );
     
@@ -73,8 +76,6 @@ FGLaRCsim::FGLaRCsim( double dt ) {
     // is slightly less
     set_Tank1Fuel(28.0);
     set_Tank2Fuel(28.0);  
-
-
 }
 
 FGLaRCsim::~FGLaRCsim(void) {
@@ -87,10 +88,10 @@ FGLaRCsim::~FGLaRCsim(void) {
 // 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();
 
-               // Explicitly call the superclass's
-                               // init method first.
-    FGInterface::init();
+   //now do any specific to LaRCsim
 }
 
 
@@ -106,6 +107,8 @@ bool FGLaRCsim::update( int multiloop ) {
        eng.set_Propeller_Lever_Pos( 100 );
         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 );
 
@@ -114,8 +117,8 @@ bool FGLaRCsim::update( int multiloop ) {
 
        // copy engine state values onto "bus"
        FGEngInterface *e = get_engine( 0 );
-       e->set_Throttle( globals->get_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() );
@@ -125,6 +128,9 @@ bool FGLaRCsim::update( int multiloop ) {
        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))
@@ -179,7 +185,7 @@ bool FGLaRCsim::update( int multiloop ) {
 
     // 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();
@@ -469,7 +475,7 @@ bool FGLaRCsim::copy_from_LaRCsim() {
     _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);
@@ -537,6 +543,28 @@ bool FGLaRCsim::copy_from_LaRCsim() {
 
     _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;
 }