]> git.mxchange.org Git - flightgear.git/commitdiff
Begin supporting a starting speed for YASim:
authordavid <david>
Sat, 22 Feb 2003 20:29:43 +0000 (20:29 +0000)
committerdavid <david>
Sat, 22 Feb 2003 20:29:43 +0000 (20:29 +0000)
- NED and UVW are working correctly
- knots is giving true airspeed instead of calibrated airspeed
- mach is not working at all

This desperately needs a trimming routine.

src/FDM/YASim/YASim.cxx
src/FDM/YASim/YASim.hxx

index 80bc0970dba591cc0592f20cc1c8579ae03c7878..f4c87bbbeb8b4f14517f43e58e382fd4e5f0acfb 100644 (file)
@@ -128,6 +128,21 @@ void YASim::init()
 
     m->setCrashed(false);
 
+    // Figure out the initial speed type
+    string speed_set = fgGetString("/sim/presets/speed-set", "UVW");
+    if (speed_set == "NED")
+        _speed_set = NED;
+    else if (speed_set == "UVW")
+        _speed_set = UVW;
+    else if (speed_set == "knots")
+        _speed_set = KNOTS;
+    else if (speed_set == "mach")
+        _speed_set = MACH;
+    else {
+        _speed_set = UVW;
+        SG_LOG(SG_FLIGHT, SG_ALERT, "Unknown speed type " << speed_set);
+    }
+
     // Build a filename and parse it
     SGPath f(globals->get_fg_root());
     f.append("Aircraft-yasim");
@@ -258,8 +273,42 @@ void YASim::copyToYASim(bool copyState)
     Glue::euler2orient(roll, pitch, hdg, s.orient);
     Math::mmul33(s.orient, xyz2ned, s.orient);
 
-    // Copy in the existing velocity for now...
-    Math::set3(model->getState()->v, s.v);
+    // Velocity
+    string speed_set = fgGetString("/sim/presets/speed-set", "UVW");
+    float v[3];
+    switch (_speed_set) {
+    case NED:
+        v[0] = get_V_north() * FT2M * -1.0;
+        v[1] = get_V_east() * FT2M * -1.0;
+        v[2] = get_V_down() * FT2M * -1.0;
+        break;
+    case UVW:
+        v[0] = get_uBody() * FT2M;
+        v[1] = get_vBody() * FT2M;
+        v[2] = get_wBody() * FT2M;
+        Math::tmul33(s.orient, v, v);
+        break;
+    case KNOTS:
+        // FIXME: right now this does true instead of calibrated airspeed
+        v[0] = get_V_calibrated_kts()/MPS2KTS;
+        v[1] = 0;
+        v[2] = 0;
+        Math::tmul33(s.orient, v, v);
+        break;
+    case MACH:
+        // FIXME: not even trying to implement this yet
+        v[0] = 0;
+        v[1] = 0;
+        v[2] = 0;
+        break;
+    default:
+        v[0] = 0;
+        v[1] = 0;
+        v[2] = 0;
+        break;
+    }
+    _speed_set = UVW;           // change to this after initial setting
+    Math::set3(v, s.v);
 
     if(copyState)
        model->setState(&s);
index 1498d5126e133d406bc682bc0848b90c59ec5f5e..935fb1903f02e066351544d37b5e9462c93eea8c 100644 (file)
@@ -17,6 +17,7 @@ public:
     virtual void update(double dt);
 
  private:
+
     void report();
     void copyFromYASim();
     void copyToYASim(bool copyState);
@@ -25,6 +26,13 @@ public:
 
     yasim::FGFDM* _fdm;
     float _dt;
+    enum {
+        NED,
+        UVW,
+        KNOTS,
+        MACH
+    } _speed_set;
+
 };
 
 #endif // _YASIM_HXX