Aircraft failure system

From FlightGear wiki
Revision as of 14:06, 30 June 2014 by Necolatis (talk | contribs) (→‎Using the Failure System: Explained MCBF)
Jump to navigation Jump to search
Note  Also see A Failure Management Framework for FlightGear (committed in 06/2014)

Want an engine or instrument to fail mid-flight? Flightgear has such a system, but not every aircraft supports it fully. The failure system is disabled by default, the system can be accessed in Flightgear in the Equipment menu.

Flying with failures

Using the Failure System

Should you for example wish to fail an instrument, you can open the Instrument failure panel as seen below.

The instrument failure panel

A checked field means that the instrument has not failed. To fail it, simply uncheck it, and click apply. If the aircraft suports it, it will fail immidiatly.

For each instrument, there is also a MTBF (Mean time between failures), where you can specify the how often an instrument should fail. MTBF is in seconds.

To make the instrument work again, simply open the panel, check it, and click apply.

Systems works in the same way as instruments, but some components have a MCBF (Mean cyclus between failures) field, instead of a MTBF. A cycle is each time the system is changed into the other direction. E.g. for flaps each time it is moved in or out, opposite of last movement counts for a cycle:

The system failure panel

Using the Random Failure Manager

The random failure manager is a convenient way to enter the same MTBF/MCBF for all systems/instruments.

The random failure panel

If you want a red message on the screen to tell when it fails, the click the checkbox for that.

Adapting an aircraft to fail

Some things will work pretty much out of the box. For example engine and control surfaces. Some control surfaces like elevons, spoilers and instruments like CDU you have to either find a matchable serviceable property and make the object depend on it or make your own.

Serviceable properties are found various places.

Examples:

/instrumentation/airspeed-indicator/serviceable

/gear/serviceable

/systems/vacuum/serviceable

/controls/flight/elevator/serviceable

They are either true or false.

Some things depend on more serviceables, for example airspeed indicator can fail on its own, or the electrical system can fail on which it depend.

For some systems/instruments, when it becomes unserviceable, some properties will also become read-only. For example the rudder will get 'stuck'. Some elements of Flightgear give some Alerts in the console, when the try to change a property and cannot. For example JSBSim will output an error when trying to change the rudder position after it failed, when you try to yaw the plane. Most of these messages can be ignored.

Making a custom failure

At the moment the panels for failure cannot be extended with custom elements, but you can write in NASAL your own code on when/how to fail a system.

Make a serviceable property where you have other properties for that system. And then write some script/xml to make the system depend on that property.

Examples of what you could make a custom failure for:

Brakes, CDU, instrumentation light, HUD, Canopy, doors, cabin pressure system, autopilot, radar etc.

Extending the random failure manager

With Nasal the random failure manager can be extended.

Here is an example of adding Canvas HUD, Canopy and Instrumentation lights to the list of systems that might fail:

# random failure code:

  var fail = { SERVICEABLE : 1, JAM : 2, ENGINE: 3};
  var type = { MTBF : 1, MCBF: 2 };
  var failure_root = "/sim/failure-manager";
  #HUD
  var prop = "/instrumentation/head-up-display";
  failures.breakHash[prop] = {
    type: type.MTBF, failure: fail.SERVICEABLE, desc: "Head up display"};
  var o = failures.breakHash[prop];
  var t = "/mtbf";
  props.globals.initNode(failure_root ~ prop ~ t, 0);
  props.globals.initNode(prop ~ "/serviceable", 1, "BOOL");
  # Instrument light:
  prop = "/instrumentation/instrumentation-light";
  failures.breakHash[prop] = {
    type: type.MTBF, failure: fail.SERVICEABLE, desc: "Instrumentation light"};
  props.globals.initNode(failure_root ~ prop ~ t, 0);
  props.globals.initNode(prop ~ "/serviceable", 1, "BOOL");
  # Canopy:
  prop = "/fdm/jsbsim/fcs/canopy";
  failures.breakHash[prop] = {
    type: type.MTBF, failure: fail.SERVICEABLE, desc: "Canopy"};
  props.globals.initNode(failure_root ~ prop ~ t, 0);
  props.globals.initNode(prop ~ "/serviceable", 1, "BOOL");
  # Set all MTBF to 24 hours:
  setprop("/sim/failure-manager/display-on-screen", 1);
  setprop("/sim/failure-manager/global-mcbf-0", 0);
  setprop("/sim/failure-manager/global-mcbf-500", 1);
  setprop("/sim/failure-manager/global-mcbf", 500);
  setprop("/sim/failure-manager/global-mtbf-0", 0);
  setprop("/sim/failure-manager/global-mtbf-86400", 1);
  setprop("/sim/failure-manager/global-mtbf", 86400);
  failures.setAllMCBF(500);
  failures.setAllMTBF(86400);

For example for canopy it will make a property called:

/fdm/jsbsim/fcs/canopy/serviceable

In the above code its MTBF is set to 24 hours, but this can be changed in the Random Failure panel.

See $FGDATA/Nasal/failures.nas for more info.