1
0
Fork 0

Improved tumbling behaviour -- the AI doesn't just freeze now, but

appears still to be indicating.

Added a 'caged' property to the AI, for aerobatic work.

Temporarily disabled tumbling due to pitch, until I can learn more
about it.

Publish the current amount of tumble (-1.0:1.0) under
/instrumentation/attitude-indicator/tumble-norm.
This commit is contained in:
david 2003-04-05 14:37:12 +00:00
parent cbf244aeda
commit e4dc8fc3fd
2 changed files with 38 additions and 24 deletions

View file

@ -14,7 +14,6 @@
AttitudeIndicator::AttitudeIndicator ()
: _tumble(0)
{
}
@ -33,6 +32,10 @@ AttitudeIndicator::init ()
_tumble_flag_node =
fgGetNode("/instrumentation/attitude-indicator/config/tumble-flag",
true);
_caged_node =
fgGetNode("/instrumentation/attitude-indicator/caged-flag", true);
_tumble_node =
fgGetNode("/instrumentation/attitude-indicator/tumble-norm", true);
_pitch_out_node =
fgGetNode("/instrumentation/attitude-indicator/indicated-pitch-deg",
true);
@ -60,6 +63,13 @@ AttitudeIndicator::unbind ()
void
AttitudeIndicator::update (double dt)
{
// If it's caged, it doesn't indicate
if (_caged_node->getBoolValue()) {
_roll_out_node->setDoubleValue(0.0);
_pitch_out_node->setDoubleValue(0.0);
return;
}
// Get the spin from the gyro
_gyro.set_power_norm(_suction_node->getDoubleValue()/5.0);
_gyro.update(dt);
@ -75,29 +85,30 @@ AttitudeIndicator::update (double dt)
// Calculate the tumble for the
// next pass.
if (_tumble_flag_node->getBoolValue()) {
if (_tumble < 1.0) {
if (fabs(roll) > 45.0) {
double target = (fabs(roll) - 45.0) / 45.0;
if (_tumble < target)
_tumble = target;
}
if (fabs(pitch) > 45.0) {
double target = (fabs(pitch) - 45.0) / 45.0;
if (_tumble < target)
_tumble = target;
}
if (_tumble > 1.0) {
_tumble = 1.0;
}
double tumble = _tumble_node->getDoubleValue();
if (fabs(roll) > 45.0) {
double target = (fabs(roll) - 45.0) / 45.0;
target *= target; // exponential past +-45 degrees
if (roll < 0)
target = -target;
if (fabs(target) > fabs(tumble))
tumble = target;
if (tumble > 1.0)
tumble = 1.0;
else if (tumble < -1.0)
tumble = -1.0;
}
// Reerect in 5 minutes
_tumble -= dt/300.0;
if (_tumble < 0.0)
_tumble = 0.0;
responsiveness *= ((1.0 - _tumble) * (1.0 - _tumble) *
(1.0 - _tumble) * (1.0 - _tumble));
// Reerect in 5 minutes
double step = dt/300.0;
if (tumble < -step)
tumble += step;
else if (tumble > step)
tumble -= step;
roll += tumble * 45;
_tumble_node->setDoubleValue(tumble);
}
roll = fgGetLowPass(_roll_out_node->getDoubleValue(), roll,

View file

@ -26,6 +26,8 @@
*
* /instrumentation/attitude-indicator/config/tumble-flag
* /instrumentation/attitude-indicator/serviceable
* /instrumentation/attitude-indicator/caged-flag
* /instrumentation/attitude-indicator/tumble-norm
* /orientation/pitch-deg
* /orientation/roll-deg
* /systems/vacuum[0]/suction-inhg
@ -34,6 +36,7 @@
*
* /instrumentation/attitude-indicator/indicated-pitch-deg
* /instrumentation/attitude-indicator/indicated-roll-deg
* /instrumentation/attitude-indicator/tumble-norm
*/
class AttitudeIndicator : public FGSubsystem
{
@ -52,9 +55,9 @@ private:
Gyro _gyro;
double _tumble;
SGPropertyNode_ptr _tumble_flag_node;
SGPropertyNode_ptr _caged_node;
SGPropertyNode_ptr _tumble_node;
SGPropertyNode_ptr _pitch_in_node;
SGPropertyNode_ptr _roll_in_node;
SGPropertyNode_ptr _suction_node;