From: <sv...@ww...> - 2006-01-22 03:32:50
|
Author: mkrose Date: 2006-01-21 19:32:43 -0800 (Sat, 21 Jan 2006) New Revision: 1827 Modified: trunk/CSP/csp/cspsim/f16/GroundAvoidanceAdvisory.cpp trunk/CSP/csp/cspsim/f16/GroundAvoidanceAdvisory.h Log: Clean up ground-avoidance-advisory logic and convert the advisory states to push channels. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1827 Modified: trunk/CSP/csp/cspsim/f16/GroundAvoidanceAdvisory.cpp =================================================================== --- trunk/CSP/csp/cspsim/f16/GroundAvoidanceAdvisory.cpp 2006-01-22 03:32:15 UTC (rev 1826) +++ trunk/CSP/csp/cspsim/f16/GroundAvoidanceAdvisory.cpp 2006-01-22 03:32:43 UTC (rev 1827) @@ -46,9 +46,9 @@ } void GroundAvoidanceAdvisory::registerChannels(Bus* bus) { - b_AltitudeAdvisory = bus->registerLocalDataChannel<bool>("F16.GroundAvoidance.AltitudeAdvisory", false); + b_AltitudeAdvisory = bus->registerLocalPushChannel<bool>("F16.GroundAvoidance.AltitudeAdvisory", false); b_AdvanceAltitudeAdvisory = bus->registerLocalDataChannel<bool>("F16.GroundAvoidance.AdvanceAdvisory", false); - b_DescentWarningAfterTakeoff = bus->registerLocalDataChannel<bool>("F16.GroundAvoidance.DescentWarningAfterTakeoff", false); + b_DescentWarningAfterTakeoff = bus->registerLocalPushChannel<bool>("F16.GroundAvoidance.DescentWarningAfterTakeoff", false); b_PullupAnticipation = bus->registerLocalDataChannel<double>("F16.GroundAvoidance.PullupAnticipation", 0.0); } @@ -66,18 +66,30 @@ double GroundAvoidanceAdvisory::onUpdate(double dt) { updateTakeoff(dt); - b_AltitudeAdvisory->value() = false; - b_AdvanceAltitudeAdvisory->value() = false; - b_PullupAnticipation->value() = 0.0; - if (!b_GearHandleUp->value()) return 0.5; + if (!b_GearHandleUp->value()) { + reset(); + return 0.5; + } const double descent_velocity = -b_Velocity->value().z(); updateDescentWarning(descent_velocity); - if (descent_velocity < m_MinimumDescentRate * 0.5) return 0.5; - if (descent_velocity < m_MinimumDescentRate) return 0.2; + if (descent_velocity < m_MinimumDescentRate * 0.5) { + reset(); + return 0.5; + } + if (descent_velocity < m_MinimumDescentRate) { + reset(); + return 0.2; + } updateAltitudeAdvisories(descent_velocity); return (b_PullupAnticipation->value() > 0.0) ? 0.0 : 0.2; } +void GroundAvoidanceAdvisory::reset() { + b_AltitudeAdvisory->pushOnChange(false); + b_AdvanceAltitudeAdvisory->value() = false; + b_PullupAnticipation->value() = 0.0; +} + void GroundAvoidanceAdvisory::updateAltitudeAdvisories(const double descent_velocity) { const double advance_altitude_loss = descent_velocity * 2.0; const double reaction_altitude_loss = descent_velocity * 1.0; // TODO 0.45 in A-G mode @@ -91,7 +103,7 @@ const double alow = convert::ft_m(b_CaraAlow->value()); const double maximum_loss = b_Position->value().z() - b_GroundZ->value() - buffer - alow; const double advance_alert_loss = std::max(maximum_loss - (predicted_altitude_loss - advance_altitude_loss), 0.0); - b_AltitudeAdvisory->value() = maximum_loss < (predicted_altitude_loss - advance_altitude_loss); + b_AltitudeAdvisory->pushOnChange(maximum_loss < (predicted_altitude_loss - advance_altitude_loss)); b_AdvanceAltitudeAdvisory->value() = maximum_loss < predicted_altitude_loss; b_PullupAnticipation->value() = 1.0 - clampTo(advance_alert_loss / descent_velocity * 0.125, 0.0, 1.000001); } @@ -101,7 +113,7 @@ m_RunwayAltitude = b_Position->value().z(); m_TakeoffElapsedTime = 0.0; m_DescentWarningState = ENABLED; - b_DescentWarningAfterTakeoff->value() = false; + b_DescentWarningAfterTakeoff->pushOnChange(false); } else if (m_DescentWarningState != DISARMED) { m_TakeoffElapsedTime += dt; const double msl_above_runway = b_Position->value().z() - m_RunwayAltitude; @@ -119,16 +131,16 @@ const double msl_above_runway = b_Position->value().z() - m_RunwayAltitude; const double impact_time = msl_above_runway / descent_velocity; if (impact_time < 30.0) { - b_DescentWarningAfterTakeoff->value() = true; + b_DescentWarningAfterTakeoff->pushOnChange(true); } else if (impact_time > 35.0) { // hysteresis (may not be corrrect) if (b_DescentWarningAfterTakeoff->value()) { - b_DescentWarningAfterTakeoff->value() = false; + b_DescentWarningAfterTakeoff->pushOnChange(false); m_DescentWarningState = DISARMED; } } } else { if (b_DescentWarningAfterTakeoff->value()) { - b_DescentWarningAfterTakeoff->value() = false; + b_DescentWarningAfterTakeoff->pushOnChange(false); m_DescentWarningState = DISARMED; } } Modified: trunk/CSP/csp/cspsim/f16/GroundAvoidanceAdvisory.h =================================================================== --- trunk/CSP/csp/cspsim/f16/GroundAvoidanceAdvisory.h 2006-01-22 03:32:15 UTC (rev 1826) +++ trunk/CSP/csp/cspsim/f16/GroundAvoidanceAdvisory.h 2006-01-22 03:32:43 UTC (rev 1827) @@ -93,6 +93,7 @@ void updateAltitudeAdvisories(const double descent_velocity); void updateTakeoff(const double dt); void updateDescentWarning(const double descent_velocity); + void reset(); DataChannel<bool>::RefT b_AltitudeAdvisory; DataChannel<bool>::RefT b_AdvanceAltitudeAdvisory; |