From 22ea572da3227ffd512e11553f1b79f23abba003 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Sat, 1 Jan 2011 18:56:36 +0100 Subject: [PATCH 1/6] Merge branch 'next', remote branch 'origin' into next From 1ebab94710faaa5295470ad77cc44be5e8104473 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 26 Jun 2011 16:08:19 +0200 Subject: [PATCH 2/6] #358: Missing option to disable AI scenarios --ai-scenario=... can only add/enable another scenario. Introduce --disable-ai-scenarios option to disable all scenarios (can be used by external launchers, GUIs etc) Also provide error instead of debug message when a scenario cannot be loaded. --- src/AIModel/AIManager.cxx | 6 +++--- src/Main/options.cxx | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index 419098112..91ef65271 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -358,9 +358,9 @@ FGAIManager::loadScenarioFile(const std::string& filename) SGPropertyNode_ptr root = new SGPropertyNode; readProperties(path.str(), root); return root; - } catch (const sg_exception &) { - SG_LOG(SG_GENERAL, SG_DEBUG, "Incorrect path specified for AI " - "scenario: \"" << path.str() << "\""); + } catch (const sg_exception &t) { + SG_LOG(SG_GENERAL, SG_ALERT, "Failed to load scenario '" + << path.str() << "': " << t.getFormattedMessage()); return 0; } } diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 453e68e48..ff306e6d9 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -1167,6 +1167,15 @@ fgOptScenario( const char *arg ) return FG_OPTIONS_OK; } +static int +fgOptNoScenarios( const char *arg ) +{ + SGPropertyNode_ptr ai_node = fgGetNode( "/sim/ai", true ); + ai_node->removeChildren("scenario",false); + ai_node->setBoolValue( "enabled", false ); + return FG_OPTIONS_OK; +} + static int fgOptRunway( const char *arg ) { @@ -1465,6 +1474,7 @@ struct OptionDesc { {"min-status", true, OPTION_STRING, "/sim/aircraft-min-status", false, "all", 0 }, {"livery", true, OPTION_FUNC, "", false, "", fgOptLivery }, {"ai-scenario", true, OPTION_FUNC, "", false, "", fgOptScenario }, + {"disable-ai-scenarios", false, OPTION_FUNC, "", false, "", fgOptNoScenarios}, {"parking-id", true, OPTION_FUNC, "", false, "", fgOptParking }, {"version", false, OPTION_FUNC, "", false, "", fgOptVersion }, {"enable-fpe", false, OPTION_FUNC, "", false, "", fgOptFpe}, From 68dec9af2dae7a46d2ad6a6be18150035ef1299c Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 26 Jun 2011 16:18:36 +0200 Subject: [PATCH 3/6] #178 related: avoid sim from freezing when FDM goes wild --- src/Instrumentation/heading_indicator_dg.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Instrumentation/heading_indicator_dg.cxx b/src/Instrumentation/heading_indicator_dg.cxx index bb9c1620e..a4c478be0 100644 --- a/src/Instrumentation/heading_indicator_dg.cxx +++ b/src/Instrumentation/heading_indicator_dg.cxx @@ -153,6 +153,10 @@ HeadingIndicatorDG::update (double dt) _last_heading_deg = heading; heading += offset + align + error; + // sanity check: bail out when the FDM runs wild, to avoid + // SG_NORMALIZE_RANGE from freezing on huge/infinite numbers. + if (fabs(heading)>1e10) + return; SG_NORMALIZE_RANGE(heading, 0.0, 360.0); _heading_out_node->setDoubleValue(heading); From b2c03e4efcf6b41bfe5660ab8c9098c843b891e7 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 26 Jun 2011 19:05:28 +0200 Subject: [PATCH 4/6] #178: improve normalization issue (avoid loops altogether) thanks to Torsten --- src/Instrumentation/heading_indicator_dg.cxx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Instrumentation/heading_indicator_dg.cxx b/src/Instrumentation/heading_indicator_dg.cxx index a4c478be0..0c4864912 100644 --- a/src/Instrumentation/heading_indicator_dg.cxx +++ b/src/Instrumentation/heading_indicator_dg.cxx @@ -115,7 +115,7 @@ HeadingIndicatorDG::update (double dt) // Next, calculate time-based precession double offset = _offset_node->getDoubleValue(); offset -= dt * (0.25 / 60.0); // 360deg/day - SG_NORMALIZE_RANGE(offset, -360.0, 360.0); + offset = SGMiscd::normalizePeriodic(-360.0,360.0,offset); _offset_node->setDoubleValue(offset); // No magvar - set the alignment manually @@ -153,11 +153,7 @@ HeadingIndicatorDG::update (double dt) _last_heading_deg = heading; heading += offset + align + error; - // sanity check: bail out when the FDM runs wild, to avoid - // SG_NORMALIZE_RANGE from freezing on huge/infinite numbers. - if (fabs(heading)>1e10) - return; - SG_NORMALIZE_RANGE(heading, 0.0, 360.0); + heading = SGMiscd::normalizePeriodic(0.0,360.0,heading); _heading_out_node->setDoubleValue(heading); From 279fbdc8377438c8760eeb8d5b40a3d260af3915 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Tue, 28 Jun 2011 12:51:00 +0200 Subject: [PATCH 5/6] Fix #357: Enabling "fixes" on map dialog crashes FG This happened for fixes with names shorter than 5 characters. range check added, which operator[] does not perform. --- src/GUI/MapWidget.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GUI/MapWidget.cxx b/src/GUI/MapWidget.cxx index e3cc5de77..b6f344497 100644 --- a/src/GUI/MapWidget.cxx +++ b/src/GUI/MapWidget.cxx @@ -917,7 +917,7 @@ public: virtual bool pass(FGPositioned* aPos) const { if (_fixes && (aPos->type() == FGPositioned::FIX)) { // ignore fixes which end in digits - expirmental - if (isdigit(aPos->ident()[3]) && isdigit(aPos->ident()[4])) { + if (aPos->ident().length() > 4 && isdigit(aPos->ident()[3]) && isdigit(aPos->ident()[4])) { return false; } } From 18eff91839ff2534ee08bac71d6e5df42e2a7b2d Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Fri, 1 Jul 2011 08:21:06 +0200 Subject: [PATCH 6/6] Update to sync with JSBSim CVS, small bug fixes. --- .../JSBSim/models/flight_control/FGActuator.cpp | 17 ++++++++++------- .../models/flight_control/FGFCSComponent.cpp | 4 ++-- src/FDM/JSBSim/models/propulsion/FGTank.cpp | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/FDM/JSBSim/models/flight_control/FGActuator.cpp b/src/FDM/JSBSim/models/flight_control/FGActuator.cpp index 6673f0452..9571d33f7 100644 --- a/src/FDM/JSBSim/models/flight_control/FGActuator.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGActuator.cpp @@ -43,7 +43,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGActuator.cpp,v 1.20 2011/06/18 17:46:21 bcoconni Exp $"; +static const char *IdSrc = "$Id: FGActuator.cpp,v 1.21 2011/06/30 03:16:10 jentron Exp $"; static const char *IdHdr = ID_ACTUATOR; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -114,13 +114,16 @@ bool FGActuator::Run(void ) // the Input will be further processed and the eventual Output // will be overwritten from this perfect value. - if (lag != 0.0) Lag(); // models actuator lag - if (rate_limit != 0) RateLimit(); // limit the actuator rate - if (deadband_width != 0.0) Deadband(); - if (hysteresis_width != 0.0) Hysteresis(); - if (bias != 0.0) Bias(); // models a finite bias + if (fail_stuck) { + Output = PreviousOutput; + } else { + if (lag != 0.0) Lag(); // models actuator lag + if (rate_limit != 0) RateLimit(); // limit the actuator rate + if (deadband_width != 0.0) Deadband(); + if (hysteresis_width != 0.0) Hysteresis(); + if (bias != 0.0) Bias(); // models a finite bias + } - if (fail_stuck) Output = PreviousOutput; PreviousOutput = Output; // previous value needed for "stuck" malfunction Clip(); diff --git a/src/FDM/JSBSim/models/flight_control/FGFCSComponent.cpp b/src/FDM/JSBSim/models/flight_control/FGFCSComponent.cpp index 2fc74bd96..68e699adf 100644 --- a/src/FDM/JSBSim/models/flight_control/FGFCSComponent.cpp +++ b/src/FDM/JSBSim/models/flight_control/FGFCSComponent.cpp @@ -48,7 +48,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGFCSComponent.cpp,v 1.32 2011/06/16 03:39:38 jberndt Exp $"; +static const char *IdSrc = "$Id: FGFCSComponent.cpp,v 1.33 2011/06/21 04:41:54 jberndt Exp $"; static const char *IdHdr = ID_FCSCOMPONENT; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -163,7 +163,7 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs) delay = (unsigned int)(delay_time / dt); } output_array.resize(delay); - for (int i=0; iFindElement("clipto"); diff --git a/src/FDM/JSBSim/models/propulsion/FGTank.cpp b/src/FDM/JSBSim/models/propulsion/FGTank.cpp index dbb5b37d1..a39fbcec3 100644 --- a/src/FDM/JSBSim/models/propulsion/FGTank.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGTank.cpp @@ -48,7 +48,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGTank.cpp,v 1.29 2011/06/06 22:39:52 jentron Exp $"; +static const char *IdSrc = "$Id: FGTank.cpp,v 1.30 2011/06/21 04:41:54 jberndt Exp $"; static const char *IdHdr = ID_TANK; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -101,7 +101,7 @@ FGTank::FGTank(FGFDMExec* exec, Element* el, int tank_number) if (el->FindElement("standpipe")) InitialStandpipe = Standpipe = el->FindElementValueAsNumberConvertTo("standpipe", "LBS"); if (el->FindElement("priority")) - InitialPriority = Priority = el->FindElementValueAsNumber("priority"); + InitialPriority = Priority = (int)el->FindElementValueAsNumber("priority"); if (el->FindElement("density")) Density = el->FindElementValueAsNumberConvertTo("density", "LBS/GAL"); if (el->FindElement("type"))