]> git.mxchange.org Git - flightgear.git/commitdiff
Merge branch 'next' of D:\Git_New\flightgear into next
authorVivian Meazza <vivian.meazza@lineone.net>
Fri, 5 Nov 2010 20:27:33 +0000 (20:27 +0000)
committerVivian Meazza <vivian.meazza@lineone.net>
Fri, 5 Nov 2010 20:27:33 +0000 (20:27 +0000)
src/AIModel/AIBallistic.cxx
src/AIModel/AIBallistic.hxx
src/AIModel/AIWingman.cxx
src/AIModel/AIWingman.hxx
src/Instrumentation/mrg.cxx
src/Instrumentation/mrg.hxx

index a0faf6eca02894ca8d72a7445ecd938424662dc1..16b15fe1d93f3aec36cb81a45ad6631c09a3398c 100644 (file)
@@ -152,11 +152,11 @@ bool FGAIBallistic::init(bool search_in_AI_path) {
         props->setStringValue("contents/path", _contents_path.c_str());
     }
 
-    if(_parent != ""){
-        setParentNode();
-    }
+    //if(_parent != ""){
+    //    setParentNode();
+    //}
 
-    setParentNodes(_selected_ac);
+    //setParentNodes(_selected_ac);
 
     //props->setStringValue("vector/path", _vector_path.c_str());
 
@@ -168,7 +168,11 @@ bool FGAIBallistic::init(bool search_in_AI_path) {
 
     Transform();
 
-    //cout << _name << " speed init: " << speed << endl;
+    if(_parent != ""){
+        setParentNode();
+    }
+
+    setParentNodes(_selected_ac);
 
     return true;
 }
index b2b140c1727480d4be62e41b1623a2831a81dde4..739f766714b699254eab76f2cfb3a03f5ae1ad82 100644 (file)
@@ -44,6 +44,7 @@ public:
     void readFromScenario(SGPropertyNode* scFileNode);
 
     bool init(bool search_in_AI_path=false);
+
     virtual void bind();
     virtual void unbind();
 
index 7233abd2b5ec36a8d0c8974ff42c57218b146a0c..cef9ad737f5f749f5b707365036a64bdbcc407da 100644 (file)
@@ -215,13 +215,14 @@ bool FGAIWingman::init(bool search_in_AI_path) {
     roll = _rotation;
     _ht_agl_ft = 1e10;
 
-    props->setStringValue("submodels/path", _path.c_str());
-
     if(_parent != ""){
         setParentNode();
     }
 
     setParentNodes(_selected_ac);
+
+    props->setStringValue("submodels/path", _path.c_str());
+    user_WoW_node      = fgGetNode("gear/gear[1]/wow", true);
     return true;
 }
 
@@ -277,7 +278,7 @@ double FGAIWingman::calcAngle(double range, SGGeod pos1, SGGeod pos2){
 
 void FGAIWingman::formateToAC(double dt){
 
-    double p_hdg, p_pch, p_rll, p_agl, p_ht = 0;
+    double p_hdg, p_pch, p_rll, p_agl, p_ht, p_wow = 0;
 
     setTgtOffsets(dt, 25);
 
@@ -312,8 +313,9 @@ void FGAIWingman::formateToAC(double dt){
     double h_feet  = 3 * factor;
 
     p_agl = manager->get_user_agl();
+    p_wow = user_WoW_node->getDoubleValue();
 
-    if(p_agl <= 10) {
+    if(p_agl <= 10 || p_wow == 1) {
         _height = p_ht;
         //cout << "ht case1 " ;
     } else if (p_agl > 10 && p_agl <= 150 ) {
@@ -332,7 +334,8 @@ void FGAIWingman::formateToAC(double dt){
     pos.setLongitudeDeg(_offsetpos.getLongitudeDeg());
 
     // these calculations are unreliable at slow speeds
-    if(speed >= 10) {
+    // and we don't want random movement on the ground
+    if(speed >= 10 && p_wow != 1) {
         setHdg(p_hdg + h_angle, dt, 0.9);
         setPch(p_pch + p_angle + _pitch_offset, dt, 0.9);
 
index 038df5d0827c9292a834f2d06acbc45c69f290ed..42c51094c333303120aa0660931478cf0b4afa42 100644 (file)
@@ -67,7 +67,7 @@ private:
     double _coeff_bnk; //dimensionless coefficient
     double _coeff_spd; //dimensionless coefficient
 
-
+    SGPropertyNode_ptr user_WoW_node;
 
     inline void setFormate(bool f);
     inline void setTgtHdg(double hdg);
index 539231da46bd85c12d7f724045f6c5cffa27f18c..365447b45a99f45ce519b321d5c156d45ad6d56c 100644 (file)
 
 #include "mrg.hxx"
 
+const double MasterReferenceGyro::gravity = -32.1740485564;
 
 MasterReferenceGyro::MasterReferenceGyro ( SGPropertyNode *node ) :
-       _name(node->getStringValue("name", "master-reference-gyro")),
-       _num(node->getIntValue("number", 0))
+_name(node->getStringValue("name", "master-reference-gyro")),
+_num(node->getIntValue("number", 0))
 {
 }
 
@@ -34,237 +35,252 @@ MasterReferenceGyro::~MasterReferenceGyro ()
 void
 MasterReferenceGyro::init ()
 {
-       _last_hdg = 0;
-       _last_roll = 0;
-       _last_pitch = 0;
-       _indicated_hdg = 0;
-       _indicated_roll = 0;
-       _indicated_pitch = 0;
-       _indicated_hdg_rate = 0;
-       _indicated_roll_rate = 0;
-       _indicated_pitch_rate = 0;
-        _erect_time = 0;
-       
-       string branch;
-       branch = "/instrumentation/" + _name;
-
-       _pitch_in_node = fgGetNode("/orientation/pitch-deg", true);
-       _roll_in_node = fgGetNode("/orientation/roll-deg", true);
-       _hdg_in_node = fgGetNode("/orientation/heading-deg", true);
-       _hdg_mag_in_node = fgGetNode("/orientation/heading-magnetic-deg", true);
-       _pitch_rate_node = fgGetNode("/orientation/pitch-rate-degps", true);
-       _roll_rate_node = fgGetNode("/orientation/roll-rate-degps", true);
-       _yaw_rate_node = fgGetNode("/orientation/yaw-rate-degps", true);
-       _g_in_node =   fgGetNode("/accelerations/pilot-g", true);
-       _electrical_node = fgGetNode("/systems/electrical/outputs/MRG", true);
-       _hdg_mag_in_node = fgGetNode("/orientation/heading-magnetic-deg", true);
-       
-       SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
-       _off_node = node->getChild("off-flag", 0, true);
-       _pitch_out_node = node->getChild("indicated-pitch-deg", 0, true);
-       _roll_out_node = node->getChild("indicated-roll-deg", 0, true);
-       _hdg_out_node = node->getChild("indicated-hdg-deg", 0, true);
-       _hdg_mag_out_node = node->getChild("indicated-mag-hdg-deg", 0, true);
-       _pitch_rate_out_node = node->getChild("indicated-pitch-rate-degps", 0, true);
-       _roll_rate_out_node = node->getChild("indicated-roll-rate-degps", 0, true);
-       _hdg_rate_out_node = node->getChild("indicated-hdg-rate-degps", 0, true);
-       _responsiveness_node = node->getChild("responsiveness", 0, true);
-       _error_out_node = node->getChild("heading-bug-error-deg", 0, true);
-       _hdg_input_source_node = node->getChild("heading-source", 0, true);
-        _fast_erect_node = node->getChild("fast-erect", 0, true);
-
-       _electrical_node->setDoubleValue(0);
-       _responsiveness_node->setDoubleValue(0.75);
-       _off_node->setBoolValue(false);
-       _hdg_input_source_node->setBoolValue(false);
-        _fast_erect_node->setBoolValue(false);
+    _last_hdg = 0;
+    _last_roll = 0;
+    _last_pitch = 0;
+    _indicated_hdg = 0;
+    _indicated_roll = 0;
+    _indicated_pitch = 0;
+    _indicated_hdg_rate = 0;
+    _indicated_roll_rate = 0;
+    _indicated_pitch_rate = 0;
+    _erect_time = 180;
+    _last_g = 1;
+    _g_error = 10;
+
+    string branch;
+    branch = "/instrumentation/" + _name;
+
+    _pitch_in_node = fgGetNode("/orientation/pitch-deg", true);
+    _roll_in_node = fgGetNode("/orientation/roll-deg", true);
+    _hdg_in_node = fgGetNode("/orientation/heading-deg", true);
+    _hdg_mag_in_node = fgGetNode("/orientation/heading-magnetic-deg", true);
+    _pitch_rate_node = fgGetNode("/orientation/pitch-rate-degps", true);
+    _roll_rate_node = fgGetNode("/orientation/roll-rate-degps", true);
+    _yaw_rate_node = fgGetNode("/orientation/yaw-rate-degps", true);
+    //_g_in_node =   fgGetNode("/accelerations/pilot/z-accel-fps_sec", true);
+    _g_in_node =   fgGetNode("/accelerations/pilot-g", true);
+    _electrical_node = fgGetNode("/systems/electrical/outputs/MRG", true);
+    _hdg_mag_in_node = fgGetNode("/orientation/heading-magnetic-deg", true);
+
+    SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
+    _off_node = node->getChild("off-flag", 0, true);
+    _pitch_out_node = node->getChild("indicated-pitch-deg", 0, true);
+    _roll_out_node = node->getChild("indicated-roll-deg", 0, true);
+    _hdg_out_node = node->getChild("indicated-hdg-deg", 0, true);
+    _hdg_mag_out_node = node->getChild("indicated-mag-hdg-deg", 0, true);
+    _pitch_rate_out_node = node->getChild("indicated-pitch-rate-degps", 0, true);
+    _roll_rate_out_node = node->getChild("indicated-roll-rate-degps", 0, true);
+    _hdg_rate_out_node = node->getChild("indicated-hdg-rate-degps", 0, true);
+    _responsiveness_node = node->getChild("responsiveness", 0, true);
+    _error_out_node = node->getChild("heading-bug-error-deg", 0, true);
+    _hdg_input_source_node = node->getChild("heading-source", 0, true);
+    _fast_erect_node = node->getChild("fast-erect", 0, true);
+
+    _electrical_node->setDoubleValue(0);
+    _responsiveness_node->setDoubleValue(0.75);
+    _off_node->setBoolValue(false);
+    _hdg_input_source_node->setBoolValue(false);
+    _fast_erect_node->setBoolValue(false);
+    _g_in_node->setDoubleValue(1);
 }
 
 void
 MasterReferenceGyro::bind ()
 {
-       std::ostringstream temp;
-       string branch;
-       temp << _num;
-       branch = "/instrumentation/" + _name + "[" + temp.str() + "]";
-
-       fgTie((branch + "/serviceable").c_str(),
-               &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable);
-       fgTie((branch + "/spin").c_str(),
-               &_gyro, &Gyro::get_spin_norm, &Gyro::set_spin_norm);
+    std::ostringstream temp;
+    string branch;
+    temp << _num;
+    branch = "/instrumentation/" + _name + "[" + temp.str() + "]";
+
+    fgTie((branch + "/serviceable").c_str(),
+        &_gyro, &Gyro::is_serviceable, &Gyro::set_serviceable);
+    fgTie((branch + "/spin").c_str(),
+        &_gyro, &Gyro::get_spin_norm, &Gyro::set_spin_norm);
 }
 
 void
 MasterReferenceGyro::unbind ()
 {
-       std::ostringstream temp;
-       string branch;
-       temp << _num;
-       branch = "/instrumentation/" + _name + "[" + temp.str() + "]";
+    std::ostringstream temp;
+    string branch;
+    temp << _num;
+    branch = "/instrumentation/" + _name + "[" + temp.str() + "]";
 
-       fgUntie((branch + "/serviceable").c_str());
-       fgUntie((branch + "/spin").c_str());
+    fgUntie((branch + "/serviceable").c_str());
+    fgUntie((branch + "/spin").c_str());
 }
 
 void
 MasterReferenceGyro::update (double dt)
 {
-       double indicated_roll = 0;
-       double indicated_pitch = 0;
-       double indicated_hdg = 0;
-       double indicated_roll_rate = 0;
-       double indicated_pitch_rate = 0;
-       double indicated_hdg_rate = 0;
-
-       // Get the spin from the gyro
-       _gyro.set_power_norm( _electrical_node->getDoubleValue()/24 );
-       _gyro.update(dt);
-       double spin = _gyro.get_spin_norm();
-       
-       // set the "off-flag"
-        if ( _electrical_node->getDoubleValue() > 0 && spin >= 0.25) {
-               _off_node->setBoolValue(false);
-       } else {
-               _off_node->setBoolValue(true);
+    //sanity check
+    if (!fgGetBool("/sim/fdm-initialized", false)) {
         return;
-       }
-
-       // Get the input values
-       double hdg = _hdg_mag_in_node->getDoubleValue();
-
-       if(_hdg_input_source_node->getBoolValue())
-               hdg = _hdg_in_node->getDoubleValue();
-
-       double roll = _roll_in_node->getDoubleValue();
-       double pitch = _pitch_in_node->getDoubleValue();
-       
-       double roll_rate = _yaw_rate_node->getDoubleValue();
-       double pitch_rate = _yaw_rate_node->getDoubleValue();
-       double yaw_rate = _yaw_rate_node->getDoubleValue();
-       double g = _g_in_node->getDoubleValue();
-
-       //modulate the input by the spin rate
-       double responsiveness = spin * spin * spin * spin * spin * spin;
-       roll = fgGetLowPass( _last_roll, roll, responsiveness );
-       pitch = fgGetLowPass( _last_pitch , pitch, responsiveness );
-
-       if ((hdg - _last_hdg) > 180)
-               _last_hdg += 360;
-       if ((hdg - _last_hdg) < -180)
-               _last_hdg -= 360;
-
-       hdg = fgGetLowPass( _last_hdg , hdg, responsiveness );
+    }
 
-       //but we need to filter the hdg and yaw_rate as well - yuk!
-       responsiveness = 0.1 / (spin * spin * spin * spin * spin * spin);
-       yaw_rate = fgGetLowPass( _last_yaw_rate , yaw_rate, responsiveness );
-        g = fgGetLowPass( _last_g , g, 0.015 );
+    double indicated_roll = 0;
+    double indicated_pitch = 0;
+    double indicated_hdg = 0;
+    double indicated_roll_rate = 0;
+    double indicated_pitch_rate = 0;
+    double indicated_hdg_rate = 0;
+    double hdg = 0;
+    double erect_time_factor = 1;
+
+    const double erect_time = 180;
+    const double max_g_error = 10.0;
+
+    //Get the spin from the gyro
+    _gyro.set_power_norm( _electrical_node->getDoubleValue()/24 );
+    _gyro.update(dt);
+    double spin = _gyro.get_spin_norm();
+
+    // set the "off-flag"
+    if ( _electrical_node->getDoubleValue() > 0 && spin >= 0.25) {
+        _off_node->setBoolValue(false);
+    } else {
+        _off_node->setBoolValue(true);
+        return;
+    }
 
+    // Get the input values
+    if(_hdg_input_source_node->getBoolValue()){
+        hdg = _hdg_in_node->getDoubleValue();
+    } else {
+        hdg = _hdg_mag_in_node->getDoubleValue();
+    }
 
-       // store the new values
-       _last_roll = roll;
-       _last_pitch = pitch;
-       _last_hdg = hdg;
-       _last_roll_rate = roll_rate;
-       _last_pitch_rate = pitch_rate;
-       _last_yaw_rate = yaw_rate;
-       _last_g = g;
+    double roll = _roll_in_node->getDoubleValue();
+    double pitch = _pitch_in_node->getDoubleValue();
+    double g = _g_in_node->getDoubleValue()/* / gravity*/;
+
+    double roll_rate = _yaw_rate_node->getDoubleValue();
+    double pitch_rate = _pitch_rate_node->getDoubleValue();
+    double yaw_rate = _yaw_rate_node->getDoubleValue();
+
+    //modulate the input by the spin rate
+    double responsiveness = spin * spin * spin * spin * spin * spin;
+    roll = fgGetLowPass( _last_roll, roll, responsiveness );
+    pitch = fgGetLowPass( _last_pitch , pitch, responsiveness );
+
+    if ((hdg - _last_hdg) > 180)
+        _last_hdg += 360;
+    if ((hdg - _last_hdg) < -180)
+        _last_hdg -= 360;
+
+    hdg = fgGetLowPass( _last_hdg , hdg, responsiveness );
+
+    //but we need to filter the hdg and yaw_rate as well - yuk!
+    responsiveness = 0.1 / (spin * spin * spin * spin * spin * spin);
+    yaw_rate = fgGetLowPass( _last_yaw_rate , yaw_rate, responsiveness );
+    g = fgGetLowPass( _last_g , g, 1.5);
+
+
+    // store the new values
+    _last_roll = roll;
+    _last_pitch = pitch;
+    _last_hdg = hdg;
+    _last_roll_rate = roll_rate;
+    _last_pitch_rate = pitch_rate;
+    _last_yaw_rate = yaw_rate;
+    _last_g = g;
+
+    //the gyro only erects inside limits
+    if ( fabs ( yaw_rate ) <= 5
+        && g <= 1.5 && g >= -0.5){
+
+            if ( !_fast_erect_node->getBoolValue() ){
+                erect_time_factor = 1;
+            } else {
+                erect_time_factor = 2;
+            }
+
+        _g_error -= (max_g_error/(erect_time * 0.33)) * dt * erect_time_factor;
+    } else {
+        _g_error += (max_g_error /(erect_time * 0.33)) * dt * 2; 
+
+        //SG_LOG(SG_GENERAL, SG_ALERT,_num <<
+        //    " g input " << _g_in_node->getDoubleValue() * gravity
+        //    <<" _erect_time " << _erect_time 
+        //    << " yaw " <<   yaw_rate
+        //    << " pitch " << _pitch_rate_node->getDoubleValue()
+        //    << " roll " << _roll_rate_node->getDoubleValue());
 
-    if (_erect_time > 0){
+    }
 
-        if ( !_fast_erect_node->getBoolValue() )
-            _erect_time -= dt;
-        else 
-            _erect_time -= 2 * dt;
+    //cout << "_g_error "<< _g_error << endl;
+    _g_error = SGMiscd::clip(_g_error, 0, 10);
+//     cout << "_g_error clip "<< _g_error << endl;
+    indicated_roll = _last_roll + _g_error;
+    indicated_pitch = _last_pitch + _g_error;
+    indicated_hdg = _last_hdg + _g_error;
+    indicated_roll_rate = _last_roll_rate;
+    indicated_pitch_rate = _last_pitch_rate;
+    indicated_hdg_rate = _last_yaw_rate;
+    // calculate the difference between the indicated heading
+    // and the selected heading for use with an autopilot
+    static SGPropertyNode *bnode
+        = fgGetNode( "/autopilot/settings/heading-bug-deg", false );
+
+    if ( bnode ) {
+        double diff = bnode->getDoubleValue() - indicated_hdg;
+        if ( diff < -180.0 ) { diff += 360.0; }
+        if ( diff > 180.0 ) { diff -= 360.0; }
+        _error_out_node->setDoubleValue( diff );
+        //SG_LOG(SG_GENERAL, SG_ALERT,
+        //"autopilot input " << bnode->getDoubleValue() 
+        //<< " output " << _error_out_node->getDoubleValue()<<);
+    }
 
+    //smooth the output
+    double factor = _responsiveness_node->getDoubleValue() * dt;
+
+    indicated_roll = fgGetLowPass( _indicated_roll, indicated_roll, factor );
+    indicated_pitch = fgGetLowPass( _indicated_pitch , indicated_pitch, factor );
+    //indicated_hdg = fgGetLowPass( _indicated_hdg , indicated_hdg, factor );
+
+    indicated_roll_rate = fgGetLowPass( _indicated_roll_rate, indicated_roll_rate, factor );
+    indicated_pitch_rate = fgGetLowPass( _indicated_pitch_rate , indicated_pitch_rate, factor );
+    indicated_hdg_rate = fgGetLowPass( _indicated_hdg_rate , indicated_hdg_rate, factor );
+
+    // store the new values
+    _indicated_roll = indicated_roll;
+    _indicated_pitch = indicated_pitch;
+    _indicated_hdg = indicated_hdg;
+
+    _indicated_roll_rate = indicated_roll_rate;
+    _indicated_pitch_rate = indicated_pitch_rate;
+    _indicated_hdg_rate = indicated_hdg_rate;
+
+    // add in a gyro underspin "error" if gyro is spinning too slowly
+    const double spin_thresh = 0.8;
+    const double max_roll_error = 40.0;
+    const double max_pitch_error = 12.0;
+    const double max_hdg_error = 140.0;
+    double roll_error;
+    double pitch_error;
+    double hdg_error;
+
+    if ( spin <= spin_thresh ) {
+        double roll_error_factor       = ( spin_thresh - spin ) / spin_thresh;
+        double pitch_error_factor      = ( spin_thresh - spin ) / spin_thresh;
+        double hdg_error_factor                = ( spin_thresh - spin ) / spin_thresh;
+        roll_error     = roll_error_factor * roll_error_factor * max_roll_error;
+        pitch_error = pitch_error_factor * pitch_error_factor * max_pitch_error;
+        hdg_error      = hdg_error_factor * hdg_error_factor * max_hdg_error;
+    } else {
+        roll_error = 0.0;
+        pitch_error = 0.0;
+        hdg_error = 0.0;
     }
 
-    //SG_LOG(SG_GENERAL, SG_ALERT,
-    //    "g input " << g <<" _erect_time " << _erect_time << " spin " << spin);
-
-       //the gyro only erects inside limits
-       if ( fabs ( yaw_rate ) <= 5
-            && ( g <= 1.5 || g >= -0.5)
-            && _erect_time <=0 ) {
-               indicated_roll = _last_roll;
-               indicated_pitch = _last_pitch;
-               indicated_hdg = _last_hdg;
-               indicated_roll_rate = _last_roll_rate;
-               indicated_pitch_rate = _last_pitch_rate;
-               indicated_hdg_rate = _last_yaw_rate;
-       } else {
-               indicated_roll_rate = 0;
-               indicated_pitch_rate = 0;
-               indicated_hdg_rate = 0;
-        
-        if (_erect_time <= 0 )
-            _erect_time = 34;
-
-       }
-
-       // calculate the difference between the indicated heading
-       // and the selected heading for use with an autopilot
-       static SGPropertyNode *bnode
-               = fgGetNode( "/autopilot/settings/heading-bug-deg", false );
-
-       if ( bnode ) {
-               double diff = bnode->getDoubleValue() - indicated_hdg;
-               if ( diff < -180.0 ) { diff += 360.0; }
-               if ( diff > 180.0 ) { diff -= 360.0; }
-               _error_out_node->setDoubleValue( diff );
-               //SG_LOG(SG_GENERAL, SG_ALERT,
-               //"autopilot input " << bnode->getDoubleValue() 
-               //<< " output " << _error_out_node->getDoubleValue()<<);
-       }
-       
-       //smooth the output
-       double factor = _responsiveness_node->getDoubleValue() * dt;
-
-       indicated_roll = fgGetLowPass( _indicated_roll, indicated_roll, factor );
-       indicated_pitch = fgGetLowPass( _indicated_pitch , indicated_pitch, factor );
-       //indicated_hdg = fgGetLowPass( _indicated_hdg , indicated_hdg, factor );
-
-       indicated_roll_rate = fgGetLowPass( _indicated_roll_rate, indicated_roll_rate, factor );
-       indicated_pitch_rate = fgGetLowPass( _indicated_pitch_rate , indicated_pitch_rate, factor );
-       indicated_hdg_rate = fgGetLowPass( _indicated_hdg_rate , indicated_hdg_rate, factor );
-
-       // store the new values
-       _indicated_roll = indicated_roll;
-       _indicated_pitch = indicated_pitch;
-       _indicated_hdg = indicated_hdg;
-
-       _indicated_roll_rate = indicated_roll_rate;
-       _indicated_pitch_rate = indicated_pitch_rate;
-       _indicated_hdg_rate = indicated_hdg_rate;
-
-       // add in a gyro underspin "error" if gyro is spinning too slowly
-       const double spin_thresh = 0.8;
-       const double max_roll_error = 40.0;
-       const double max_pitch_error = 12.0;
-       const double max_hdg_error = 140.0;
-       double roll_error;
-       double pitch_error;
-       double hdg_error;
-
-       if ( spin <= spin_thresh ) {
-               double roll_error_factor        = ( spin_thresh - spin ) / spin_thresh;
-               double pitch_error_factor       = ( spin_thresh - spin ) / spin_thresh;
-               double hdg_error_factor         = ( spin_thresh - spin ) / spin_thresh;
-               roll_error      = roll_error_factor * roll_error_factor * max_roll_error;
-               pitch_error = pitch_error_factor * pitch_error_factor * max_pitch_error;
-               hdg_error       = hdg_error_factor * hdg_error_factor * max_hdg_error;
-       } else {
-               roll_error = 0.0;
-               pitch_error = 0.0;
-               hdg_error = 0.0;
-       }
-
-       _roll_out_node->setDoubleValue( _indicated_roll + roll_error );
-       _pitch_out_node->setDoubleValue( _indicated_pitch + pitch_error );
-       _hdg_out_node->setDoubleValue( _indicated_hdg + hdg_error );
-       _pitch_rate_out_node ->setDoubleValue( _indicated_pitch_rate );
-       _roll_rate_out_node ->setDoubleValue( _indicated_roll_rate );
-       _hdg_rate_out_node ->setDoubleValue( _indicated_hdg_rate );
+    _roll_out_node->setDoubleValue( _indicated_roll + roll_error );
+    _pitch_out_node->setDoubleValue( _indicated_pitch + pitch_error );
+    _hdg_out_node->setDoubleValue( _indicated_hdg + hdg_error );
+    _pitch_rate_out_node ->setDoubleValue( _indicated_pitch_rate );
+    _roll_rate_out_node ->setDoubleValue( _indicated_roll_rate );
+    _hdg_rate_out_node ->setDoubleValue( _indicated_hdg_rate );
 }
 
 // end of mrg.cxx
index 4fc8fdee3610ceaac0063c179ad07f5107bbe464..b925353a5aa6737a22042ac3b81e8efe27f0997a 100644 (file)
@@ -49,6 +49,8 @@ public:
 
 private:
 
+    static const double gravity; //conversion factor
+
     string _name;
     int _num;
 
@@ -66,6 +68,7 @@ private:
     double _last_yaw_rate;
     double _last_g;
     double _erect_time;
+    double _g_error;
 
     Gyro _gyro;