1
0
Fork 0

Put gyro spin into a property so that it can be restored after a save.

This commit is contained in:
david 2002-09-29 18:26:24 +00:00
parent 09cb9b750c
commit b0afca93d5
4 changed files with 27 additions and 19 deletions

View file

@ -26,6 +26,7 @@ AttitudeIndicator::init ()
// to be configured.
_serviceable_node =
fgGetNode("/instrumentation/attitude-indicator/serviceable", true);
_spin_node = fgGetNode("/instrumentation/attitude-indicator/spin", true);
_pitch_in_node = fgGetNode("/orientation/pitch-deg", true);
_roll_in_node = fgGetNode("/orientation/roll-deg", true);
_suction_node = fgGetNode("/systems/vacuum[0]/suction-inhg", true);
@ -53,7 +54,8 @@ AttitudeIndicator::update (double dt)
// First, calculate the bogo-spin from 0 to 1.
// All numbers are made up.
_spin -= 0.005 * dt; // spin decays every 0.5% every second.
double spin = _spin_node->getDoubleValue();
spin -= 0.005 * dt; // spin decays every 0.5% every second.
// spin increases up to 25% every second
// if suction is available and the gauge
@ -61,17 +63,18 @@ AttitudeIndicator::update (double dt)
if (_serviceable_node->getBoolValue()) {
double suction = _suction_node->getDoubleValue();
double step = 0.25 * (suction / 5.0) * dt;
if ((_spin + step) <= (suction / 5.0))
_spin += step;
if ((spin + step) <= (suction / 5.0))
spin += step;
}
if (_spin > 1.0)
_spin = 1.0;
else if (_spin < 0.0)
_spin = 0.0;
if (spin > 1.0)
spin = 1.0;
else if (spin < 0.0)
spin = 0.0;
_spin_node->setDoubleValue(spin);
// Next, calculate the indicated roll
// and pitch, introducing errors.
double factor = 1.0 - ((1.0 - _spin) * (1.0 - _spin));
double factor = 1.0 - ((1.0 - spin) * (1.0 - spin));
double roll = _roll_in_node->getDoubleValue();
double pitch = _pitch_in_node->getDoubleValue();
roll = 35 + (factor * (roll - 35));

View file

@ -23,6 +23,7 @@
* Input properties:
*
* /instrumentation/attitude-indicator/serviceable
* /instrumentation/attitude-indicator/spin
* /orientation/pitch-deg
* /orientation/roll-deg
* /systems/vacuum[0]/suction-inhg
@ -47,9 +48,8 @@ public:
private:
double _spin;
SGPropertyNode_ptr _serviceable_node;
SGPropertyNode_ptr _spin_node;
SGPropertyNode_ptr _pitch_in_node;
SGPropertyNode_ptr _roll_in_node;
SGPropertyNode_ptr _suction_node;

View file

@ -21,6 +21,8 @@ HeadingIndicator::init ()
{
_serviceable_node =
fgGetNode("/instrumentation/heading-indicator/serviceable", true);
_spin_node =
fgGetNode("/instrumentation/heading-indicator/spin", true);
_offset_node =
fgGetNode("/instrumentation/heading-indicator/offset-deg", true);
_heading_in_node = fgGetNode("/orientation/heading-deg", true);
@ -48,7 +50,8 @@ HeadingIndicator::update (double dt)
// First, calculate the bogo-spin from 0 to 1.
// All numbers are made up.
_spin -= 0.005 * dt; // spin decays every 0.5% every second.
double spin = _spin_node->getDoubleValue();
spin -= 0.005 * dt; // spin decays every 0.5% every second.
// spin increases up to 25% every second
// if suction is available and the gauge
@ -56,13 +59,14 @@ HeadingIndicator::update (double dt)
if (_serviceable_node->getBoolValue()) {
double suction = _suction_node->getDoubleValue();
double step = 0.25 * (suction / 5.0) * dt;
if ((_spin + step) <= (suction / 5.0))
_spin += step;
if ((spin + step) <= (suction / 5.0))
spin += step;
}
if (_spin > 1.0)
_spin = 1.0;
else if (_spin < 0.0)
_spin = 0.0;
if (spin > 1.0)
spin = 1.0;
else if (spin < 0.0)
spin = 0.0;
_spin_node->setDoubleValue(spin);
// Next, calculate time-based precession
double offset = _offset_node->getDoubleValue();
@ -77,7 +81,7 @@ HeadingIndicator::update (double dt)
// Next, calculate the indicated heading,
// introducing errors.
double factor = 0.01 / (_spin * _spin * _spin * _spin * _spin * _spin);
double factor = 0.01 / (spin * spin * spin * spin * spin * spin);
double heading = _heading_in_node->getDoubleValue();
heading = fgGetLowPass(_last_heading_deg, heading, dt/factor);
_last_heading_deg = heading;

View file

@ -23,6 +23,7 @@
* Input properties:
*
* /instrumentation/heading-indicator/serviceable
* /instrumentation/heading-indicator/spin
* /instrumentation/heading-indicator/offset-deg
* /orientation/heading-deg
* /systems/vacuum[0]/suction-inhg
@ -46,10 +47,10 @@ public:
private:
double _spin;
double _last_heading_deg;
SGPropertyNode_ptr _serviceable_node;
SGPropertyNode_ptr _spin_node;
SGPropertyNode_ptr _offset_node;
SGPropertyNode_ptr _heading_in_node;
SGPropertyNode_ptr _suction_node;