From 289023da1ddbdbf0381238369d51ba9b4faabefc Mon Sep 17 00:00:00 2001 From: jmt Date: Mon, 21 Sep 2009 16:26:07 +0000 Subject: [PATCH] Don't crash with UFO FDM, etc, or other FDMs that don't define global props needed - just go into passive mode. --- src/Autopilot/autobrake.cxx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Autopilot/autobrake.cxx b/src/Autopilot/autobrake.cxx index f97b56c2d..0eae0fe1b 100644 --- a/src/Autopilot/autobrake.cxx +++ b/src/Autopilot/autobrake.cxx @@ -107,6 +107,20 @@ void FGAutoBrake::unbind() void FGAutoBrake::update(double dt) { + _leftBrakeInput = SGMiscd::max(_brakeInputs[0]->getDoubleValue(), + _brakeInputs[2]->getDoubleValue()); + _rightBrakeInput = SGMiscd::max(_brakeInputs[1]->getDoubleValue(), + _brakeInputs[3]->getDoubleValue()); + + // various FDMs don't supply sufficent information for us to work, + // so just be passive in those cases. + if (!_weightOnWheelsNode || !_groundspeedNode || !_engineControlsNode) { + // pass the values straight through + _leftBrakeOutput = _leftBrakeInput; + _rightBrakeOutput = _rightBrakeInput; + return; + } + if (dt <= 0.0) { return; // paused } @@ -115,11 +129,6 @@ void FGAutoBrake::update(double dt) _actualDecel = (_lastGroundspeedKts - gs) / dt; _lastGroundspeedKts = gs; - _leftBrakeInput = SGMiscd::max(_brakeInputs[0]->getDoubleValue(), - _brakeInputs[2]->getDoubleValue()); - _rightBrakeInput = SGMiscd::max(_brakeInputs[1]->getDoubleValue(), - _brakeInputs[3]->getDoubleValue()); - if (!_armed || (_step == 0)) { // even if we're off or disarmed, the physical valve system must pass // pilot control values through. -- 2.39.5