]> git.mxchange.org Git - flightgear.git/blobdiff - FDM/LaRCsim.cxx
LaRCsim maintains all it's variables internally. I had been copying all of
[flightgear.git] / FDM / LaRCsim.cxx
index bd7570b4d673786cfc208e7d814b03ca608b6ec5..5e206dd24e244f20200e7c5dc5ceb7b11fc413ac 100644 (file)
@@ -42,7 +42,7 @@ int fgLaRCsimInit(double dt) {
 
 
 // Run an iteration of the EOM (equations of motion)
-int fgLaRCsimUpdate(fgFLIGHT& f, int multiloop) {
+int fgLaRCsimUpdate(FGState& f, int multiloop) {
     double save_alt = 0.0;
 
     // lets try to avoid really screwing up the LaRCsim model
@@ -51,8 +51,20 @@ int fgLaRCsimUpdate(fgFLIGHT& f, int multiloop) {
        f.set_Altitude( 0.0 );
     }
 
+    // copy control positions into the LaRCsim structure
+    Lat_control = controls.get_aileron();
+    Long_control = controls.get_elevator();
+    Long_trim = controls.get_elevator_trim();
+    Rudder_pedal = controls.get_rudder();
+    Throttle_pct = controls.get_throttle( 0 );
+    Brake_pct = controls.get_brake( 0 );
+
+    // Inform LaRCsim of the local terrain altitude
+    Runway_altitude =   f.get_Runway_altitude();
+
+    // old -- FGstate_2_LaRCsim() not needed except for Init()
     // translate FG to LaRCsim structure
-    fgFlight_2_LaRCsim(f);
+    // FGState_2_LaRCsim(f);
     // printf("FG_Altitude = %.2f\n", FG_Altitude * 0.3048);
     // printf("Altitude = %.2f\n", Altitude * 0.3048);
     // printf("Radius to Vehicle = %.2f\n", Radius_to_vehicle * 0.3048);
@@ -65,7 +77,7 @@ int fgLaRCsimUpdate(fgFLIGHT& f, int multiloop) {
     // translate LaRCsim back to FG structure so that the
     // autopilot (and the rest of the sim can use the updated
     // values
-    fgLaRCsim_2_Flight(f);
+    fgLaRCsim_2_FGState(f);
 
     // but lets restore our original bogus altitude when we are done
     if ( save_alt < -9000.0 ) {
@@ -76,15 +88,8 @@ int fgLaRCsimUpdate(fgFLIGHT& f, int multiloop) {
 }
 
 
-// Convert from the fgFLIGHT struct to the LaRCsim generic_ struct
-int fgFlight_2_LaRCsim (fgFLIGHT& f) {
-
-    Lat_control = controls.get_aileron();
-    Long_control = controls.get_elevator();
-    Long_trim = controls.get_elevator_trim();
-    Rudder_pedal = controls.get_rudder();
-    Throttle_pct = controls.get_throttle( 0 );
-    Brake_pct = controls.get_brake( 0 );
+// Convert from the FGState struct to the LaRCsim generic_ struct
+int FGState_2_LaRCsim (FGState& f) {
 
     Mass =      f.get_Mass();
     I_xx =      f.get_I_xx();
@@ -260,8 +265,8 @@ int fgFlight_2_LaRCsim (fgFLIGHT& f) {
 }
 
 
-// Convert from the LaRCsim generic_ struct to the fgFLIGHT struct
-int fgLaRCsim_2_Flight (fgFLIGHT& f) {
+// Convert from the LaRCsim generic_ struct to the FGState struct
+int fgLaRCsim_2_FGState (FGState& f) {
     // Mass properties and geometry values
     f.set_Inertias( Mass, I_xx, I_yy, I_zz, I_xz );
     f.set_Pilot_Location( Dx_pilot, Dy_pilot, Dz_pilot );
@@ -382,6 +387,18 @@ int fgLaRCsim_2_Flight (fgFLIGHT& f) {
 
 
 // $Log$
+// Revision 1.7  1998/12/14 13:31:06  curt
+// LaRCsim maintains all it's variables internally.  I had been copying all of
+// them back and forth to the FG struture everytime I updated the flight model.
+// However, I have realized that this is not necessary.  I just need to copy
+// the control positions and environmental parameters into the LaRCsim structure
+// before updating the FDM, then copy every thing back out into the publick FGFS
+// structure afterwords.  This seems to solve (or at least help) a westward
+// drift problem some poeple had been observing.
+//
+// Revision 1.6  1998/12/05 15:54:08  curt
+// Renamed class fgFLIGHT to class FGState as per request by JSB.
+//
 // Revision 1.5  1998/12/03 04:25:02  curt
 // Working on fixing up new fgFLIGHT class.
 //