XML Introduction and Uses of XML in JSBSim Wai Nwe Tun
Contents • XML Introduction o XML in Brief o Schema - XML Elements Definition o Use of XML Elements o General Uses of XML o XML vs. Programming langages • XML Uses in JSBSim o Preliminaries o Configuration files o Scripting • References • Back Matter 2
XML Introduction XML Basics 3
XML in Brief • Extensible Markup Language o is designed to describe data. • XML tags are not predefined in XML. • XML content layout or schemas have two main flavors: o Document Type Definitions (DTDs) – older style o XML Schema Documents (XSDs) – newer style • Schemas are not required for informal data encoding. • Schemas are required for widely shared data to represent a contract between provider and user. • Rule: each tag must be ended correspondingly and hierarchically. 4
Schema - XML Elements Definition http://jsbsim.sf.net/JSBSim.xsd* metrics element definition Sub-elements of metrics wingarea element definition Attribute of wingarea <xs:element name="metrics"> <xs:annotation> <xs:documentation>…</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element ref="wingarea" /> <xs:element ref="location" minOccurs="1" maxOccurs="3" /> </xs:sequence> </xs:complexType> </xs:element> <!-- Wing Area --> <xs:element name="wingarea"> <xs:annotation> <xs:documentation> … </xs:documentation> </xs:annotation> <xs:complexType> <xs:simpleContent> <xs:extension base="PositiveNumber"> <xs:attribute name="unit" use="optional" default="FT2" type="AreaType" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> 5
Use of XML Elements <metrics> <wingarea> 174.0 </wingarea> <location name="AERORP" unit="IN"> <x> 43.2 </x> <y> 0.0 </y> <z> 59.4 </z> </location> </metrics> metrics element Opening tag Closing tag location element Configuration file* 6
General Uses of XML • XML is for identification, transmission, and storage. o Information identification • Define own markup for specific information items o Information storage • Since XML is portable, it can be used to store information across any platforms o Information structure • Structure in nest like a tree hierarchy o Publishing • Publish to web as HTML, paper as PDF, or to other formats using appropriate stylesheets (JSBSim uses JSBSim.xsl and JSBSimScript.xsl) o Messaging and data transfer • Heavily use for encapsulating information to pass between computing systems 7
Displaying XML file in a Browser http://jsbsim.sourceforge.net/f16.xml* • F16.xml is shown in a XML-supported browser using JSBSim.xsl stylesheet. • XML not-supported browser: o Netscape o Internet Explorer 6 or earlier o Mozilla Firefox 0.8 or earlier • For local XML files, chrome has blocked their XSL transformation. 8
XML Vs. C, C++, or FORTRAN • C and C++ o programming languages used for performing some actions, calculations, and decisions • XML o markup specification language to design ways of describing information, for storage, transmission, or processing by a program • XML documents don’t run or execute! • XMLs are just data files and wait there until an associated program is run. 9
XML Use in JSBSim (Preliminaries) 10
Properties • Properties o global variables with selectively limited visibility (read or read/write) o categorized into a hierarchical, tree-like structure o includes a root node, sub nodes, and end-nodes o referenced relative to the current node, or to the root node o refer to specific parameters in program code o can be assigned from • command line • specification/configuration files • scripts • Example: o fcs/left-brake-cmd-norm and ap/altitude_setpoint • Standard properties of acceleration, altitude, fcs, position, propulsion, and velocities can be seen in [1]. 11
Tables • Three types of table o 1-dimensional, 2-dimensional, 3-dimensional • Can be defined using proper lookup indices and breakpoints • Table values are linearly interpolated if the required values are not specified. • No extrapolation is done at the table limits but return the value at the highest key value. 12
1D-Table • The data is in vector format. If alpha is 0.26 radians, the value from lookup table would be 0.033 <table name="property_name"> <independentVar lookup="row"> property_name </independentVar> <tableData> key_1 value_1 key_2 value_2 ... ... key_n value_n </tableData> </table> <table> <independentVar lookup="row"> aero/alpha-rad </independentVar> <tableData> -1.57 1.500 -0.26 0.033 0.00 0.025 0.26 0.033 1.57 1.500 </tableData> </table> Key Value -1.57 1.5 -0.26 0.033 0 0.025 0.26 0.033 1.57 1.5 13
2D-Table • The data is in a grid-format. <table name="property_name"> <independentVar lookup="row"> property_name </independentVar> <independentVar lookup="column"> property_name </independentVar> <tableData> {col_1_key col_2_key ... col_n_key } {row_1_key} {col_1_data col_2_data ... col_n_data} {row_2_key} {... ... ... ... } { ... } {... ... ... ... } {row_n_key} {... ... ... ... } </tableData> </table> <table> <independentVar lookup="row">aero/alpha-rad</independentVar> <independentVar lookup="column">fcs/flap-pos-deg</independentVar> <tableData> 0.0 10.0 20.0 30.0 -0.0523599 8.96747e-05 0.00231942 0.0059252 0.00835082 -0.0349066 0.000313268 0.00567451 0.0108461 0.0140545 -0.0174533 0.00201318 0.0105059 0.0172432 0.0212346 0.0 0.0051894 0.0168137 0.0251167 0.0298909 0.0174533 0.00993967 0.0247521 0.0346492 0.0402205 0.0349066 0.0162201 0.0342207 0.0457119 0.0520802 </tableData> </table> 0 10 .. -0.0523599 8.96747e-05 0.00231942 -0.0349066 0.000313268 0.00567451 0 0.0051894 0.0168137 … Alpha = 0, flap = 10, Return value = 0.0168137 14
3D-Table • Defined by three independent lookup variables (properties) o two or more two-dimensional tables of data o the first row represents the breakpoints for the column lookup variable, and the first column represents the breakpoints for the row lookup variable (as in 2D-Table). • Can have arbitrary number of 2D-Table and controlled each by breakpoint variable 15
3D-Table: Structure <table name="property_name"> <independentVar lookup="row"> property_name </independentVar> <independentVar lookup="column"> property_name </independentVar> <independentVar lookup="table"> property_name </independentVar> <tableData breakpoint="table_1_key"> {col_1_key col_2_key ... col_n_key } {row_1_key} {col_1_data col_2_data ... col_n_data} {row_2_key} {... ... ... ... } { ... } {... ... ... ... } {row_n_key} {... ... ... ... } </tableData> <tableData breakpoint="table_2_key"> {col_1_key col_2_key ... col_n_key } {row_1_key} {col_1_data col_2_data ... col_n_data} {row_2_key} {... ... ... ... } { ... } {... ... ... ... } {row_n_key} {... ... ... ... } </tableData> ... <tableData breakpoint="table_n_key"> {col_1_key col_2_key ... col_n_key } {row_1_key} {col_1_data col_2_data ... col_n_data} {row_2_key} {... ... ... ... } { ... } {... ... ... ... } {row_n_key} {... ... ... ... } </tableData> </table> 16
3D-Table: Example <table> <independentVar lookup="row"> fcs/row-value</independentVar> <independentVar lookup="column"> fcs/column-value</independentVar> <independentVar lookup="table"> fcs/table-value</independentVar> <tableData breakPoint="-1.0"> -1.0 1.0 0.0 1.0000 2.0000 1.0 3.0000 4.0000 </tableData> <tableData breakPoint="0.0000"> 0.0 10.0 2.0 1.0000 2.0000 3.0 3.0000 4.0000 </tableData> <tableData breakPoint="1.0"> 0.0 10.0 20.0 2.0 1.0000 2.0000 3.0000 3.0 4.0000 5.0000 6.0000 10.0 7.0000 8.0000 9.0000 </tableData> </table> -1 1 0 1 2 1 3 4 0 10 2 1 2 3 3 4 0 10 20 2 1 2 3 3 4 5 6 10 7 8 9 -1 1 0 17
Function • A powerful and versatile resource that allows algebraic functions to be defined in a JSBSim configuration file. The syntax is similar to MathML • Consists of operation, value, table, or property • cannot have more than one immediate child 18
Function • The following function is the product of the ground-effect- factor-lift, qbar-area, and the value by the table, indexed as a function of flap position • The result can be referenced through the property name of “aero/coefficient/CLDf”. <function name=“aero/coefficient/CLDf"> <description> Delta lift due to flap deflection </description> <product> <property> aero/function/ground-effect-factor-lift</property> <property> aero/qbar-area</property> <table> <independentVar> fcs/flap-pos-deg</independentVar> <tableData> 0 0 10 0.2 20 0.3 30 0.35 </tableData> </table> </product> </function> 19
XML Use in JSBSim (Configuration Files) 20
Configuration Files • Are particularly used for storing aircraft information and specifications such as o File Header Information o Metrics o Mass/Balance o Buoyant Forces o Ground Reactions o External Reactions o Propulsion o Aerodynamics o Systems, Autopilot, and Flight Control o Input o Output 21
File Header Information • is where important information about the model is recorded o authors, their contact information and affiliation o Notes about the model, as well as limitations and reference information http://jsbsim.sf.net/JSBSim.xsd* 22
Metrics • Defines the characteristic measurements of the vehicle and locations of key points • Units may be used as well. http://jsbsim.sf.net/JSBSim.xsd* 23
Mass/Balance • Includes specifications such as o mass properties of the aircraft and empty weight of the aircraft, o the moments and products of inertia, the location of the center of gravity, and the definitions for any point masses http://jsbsim.sf.net/JSBSim.xsd* 24
Buoyant Forces • Include the format of a gas cell and ballonet • Gas Type: HYDROGEN, HELIUM, or AIR. • The element <heat> can contain zero or more function elements. * A ballonet is an air bag inside the gas cell in no-rigit or semi-rigid airships to maintain the shape and volume of the gas cell and keep its internal pressure higher than that of the surrounding environment. 25
Ground Reactions • Model contacts between the aircraft and the ground to facilitate the realistic take-off and landing • Contact points must be listed in this section. Two types of contacts: o BOGEY : for landing gear o STRUCTURE : for any location other than landing gear http://jsbsim.sf.net/JSBSim.xsd* 26
Propulsion • Contains references to specific engines, o Locations of engine, thruster, tank definition (Engine and thruster specifics are in an external file.) • To use an external file, ‘file’ attribute is used http://jsbsim.sf.net/JSBSim.xsd* 27
Aerodynamics • Contains aerodynamic forces and moments. It may be separated as an external file. • There are three coordinate systems: o Wind coordinate system (DRAG, SIDE, LIFT) o Body coordinate system (X, Y, Z) o Axial-normal coordinate system (AXIAL, NORMAL, SIDE) http://jsbsim.sf.net/JSBSim.xsd* 28
System • Can be present any number of times in an aircraft definition. • Defines an arbitrary system such as navigation, guidance, or control avionics, electrical systems, etc. http://jsbsim.sf.net/JSBSim.xsd* 29
System Components • Filter o Is a component in a control system to improve response in a feedback and control system • Switch o Models a switch – either an on/off or multi-choice rotary switch • Summer o Sums two or more inputs, optionally used with bias • Gain o Multiplies the input by a gain 30
System Components • Deadband o Is a component that allows for some play in a control path, in the form of dead zone, or deadband (to trigger the output as zero) • Fcs/function o Is like the normal function and can have a nested series of functions • Actuator o Models more realistic actuator by specifying the additional effects such as deadband, bias, and so on • Sensor o Like actuator, models realistic sensor using some lag, noise, etc. 31
Runtime Input • JSBSim has the capability to input data at runtime via a socket, so as for output. <input port=”port number”/> • JSBSim input command interpreter can understand these commands get 'property_name' set 'property_name' (value) hold|resume|info|help|quit src/jsbsim --script=scripts/c1723.xml --realtime --suspend telnet host port • --realtime: to run at real-time speed • --suspend: to go into hold after initialization so the user can connect from another shell to the JSBSim server, using telnet. 32
Runtime Output • Can output data in many ways by particularly specifying in the ‘type’ attribute: o CSV comma separated data o SOCKET sends data to another machine via a socket o FLIGHTGEAR creates a socket for sending binary data packets to an external instance of FlightGear for visuals o TABULAR columnar data, tab-delimited. o NONE specifies to do nothing. • name : IP address, file name, others <output name=”name” type=”type” [port=”int” protocol=”UDP|TCP”] rate=”number”> [<group> OFF|ON </group>] [<property> name </property>] </output> 33
Runtime Output • ‘rate’ is a rate in Hz that the data is output but it depends on the frame rate. • ‘port’ is used only for socket output, and ‘protocol’ is currently only for socket output to FlightGear. <output name="JSBout172B.csv" type="CSV" rate="10"> <rates> ON </rates> <velocities> ON </velocities> <position> ON </position> <atmosphere> OFF </atmosphere> <fcs> ON </fcs> <ground_reactions> OFF </ground_reactions> <propulsion> ON </propulsion> <simulation> ON </simulation> <massprops> ON </massprops> <forces> OFF </forces> <moments> OFF </moments> <aerosurfaces> OFF </aerosurfaces> <property> position/vrp-gc-latitude_deg </property> <property> position/vrp-longitude_deg </property> <property> position/vrp-radius-ft </property> <function name="velocities/pi-deg_sec"> <todegrees> <p> velocities/pi-rad_sec </p> </todegrees> </function> </output> 34
XML Use in JSBSim (Scripting) 35
Scripting • Is for any time a repeatable set of conditions needs to be performed for testing or analysis. • Is made up of language elements that have some events which consists of two parts: o the conditional tests to be performed and o the actions to be taken when the conditional test evaluate to true. • Uses a reference to an aircraft specification file, to a file containing the set of initial conditions, to a start and stop time, and to the integration step size. o Stop time and step size are mandatory input to JSBSim script. 36
Events • Control which and when actions would take place • Includes : o a condition that must be satisfied for the event to be triggered, o actions that are taken when the conditions are satisfied, and o (optional) notification (whether to print a message stating that the event has been triggered) • Event types : • Continuous : to execute the event every single frame, • Persistent : to execute the event each time the condition evaluates to true • Default: to execute the event once 37
Conditions • Determines when the listed actions should be carried out • The semantic of conditions and actions is exactly the same as ‘if .. then’. • Logic attribute defaults to “AND”. <condition> sim-time-sec gt 0.5 <conditon logic="OR"> aero/qbar-psf gt 4.5 gear/unit/WOW eq 0 </condition> </condition> sim-time-sec>0.5 AND (aero/qbar-psf>4.5 OR gear/unit/WOW==0) 38
Actions • When the condition evaluates to true, any actions specified will be carried out. • Is a set of ‘set’ elements • Attributes of ‘set’ element: o name : property that will be set o value : the value that the property will be set to o action : specify the way in which a new value will be assigned to the named property. (default: step, ramp (slope), exponential) o type : specify whether the new value to be assigned is an actual value, or a delta. (default: value, delta) o tc : specify the numeric time constant that controls how fast an exponential or ram action will be applied to a property value 39
Set: Type and Action • Type o FG_DELTA – the new value is added to the old one. o FG_VALUE – the actual value is copied over the old one. • Action o FG_EXP – the new value is approached exponentially from the old one. o FG_RAMP – the new value ramps linearly from the old value to the new one. o FG_STEP – the new value immediately takes effect. 40
Aircraft State and Initialization • This is simply to specify which aircraft model will be used for simulation. o Here, it uses ‘c172x’ which is an XML configuration file of the aircraft model. o reset00 initializes some properties of the aircraft. • Start, end time and step value for running the script are also described. <?xml-stylesheet type="text/xsl" href="http://jsbsim.sourceforge.net/JSBSimScript.xsl"?> <runscript xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://jsbsim.sf.net/JSBSimScript.xsd" name="C172-01A takeoff run"> <use aircraft="c172x" initialize="reset00"/> <run start="0.0" end="200" dt="0.00833333333333333333"> c1723.xml* 41
Property Initialization • The above example is to make sure that the aircraft is at brake state before starting an engine. • This is also useful to override the properties in the aircraft’s configuration file. <!-- Initialize with brakes on --> <property> simulation/notify-time-trigger </property> <property value="1"> simulation/run_id </property> <property value="1"> fcs/left-brake-cmd-norm </property> <property value="1"> fcs/right-brake-cmd-norm </property> <property value="1"> fcs/center-brake-cmd-norm </property> <property value="3.49"> guidance/specified-heading-rad </property> <property value="1"> guidance/heading-selector-switch </property> c1723.xml* 42
‘Engine Start’ Event • The event is to start an engine. • It will be performed after 0.25 seconds of simulation time. • <notify> is to display the described properties to the command line when triggering this event. • This event will be triggered once. c1723.xml* <event name="engine start"> <description>Start the engine and set roll control to heading hold</description> <condition> simulation/sim-time-sec >= 0.25 </condition> <set name="fcs/throttle-cmd-norm" value="1.0" action="FG_RAMP" tc ="0.5"/> <set name="fcs/mixture-cmd-norm" value="1.00" action="FG_RAMP" tc ="0.5"/> <set name="propulsion/magneto_cmd" value="3"/> <set name="propulsion/starter_cmd" value="1"/> <set name="ap/roll-attitude-mode" value="1"/> <set name="ap/autopilot-roll-on" value="1"/> <notify> <property>simulation/run_id</property> <property>ap/hdg-roll-err-c1</property> </notify> </event> 43
‘Time Notify’ Event • This event is like a timer to display an output message every 1 minute. • The notification from this event is like this: <event name="Time Notify" persistent="true"> <description>Output message at 1 minute intervals</description> <notify> <property>velocities/vc-kts</property> <property>position/h-agl-ft</property> <property>position/lat-geod-deg</property> <property>position/geod-alt-ft</property> </notify> <condition> simulation/sim-time-sec >= simulation/notify-time-trigger </condition> <set name="simulation/notify-time-trigger" value="60" type="FG_DELTA"/> </event> c1723.xml* 44
Running JSBSim in Batch Mode • First, we need to have JSBSim.exe file or JSBSim source code as well as necessary configuration files and script files. • If we have source code, we can build an executable file. • Using the executable file ‘JSBSim’, we can run any script file by using the following sample form in command line. >JSBSim --script=(script_file) • For example, script_file is c1723.xml. Many script files can be found under scripts folder of JSBSim. http://www.holycows.net/JSBSim_Script_Tutorial.pdf* 45
References 1) http://outerra.shoutwiki.com/wiki/JSBSim_Properties 2) http://wiki.flightgear.org/XML 3) http://xml.silmaril.ie/programming.html 4) http://wiki.flightgear.org/PropertyList_XML_files 5) http://jsbsim.sourceforge.net/JSBSim/classJSBSim_1_1FGScript. html 6) Back of the Envelope, JSBSim, XSL Transformations, and XML Schemas, January 2006. 7) Jon S. Berndt and the JSBSim Development Team, JSPSim Reference Manual 8) Jon S. Berndt, JSBSim: An opensource flight Dynamics Model in C++, AIAA, August 2004. 9) http://jsbsim.sourceforge.net/JSBSim/JSBSim_8cpp_source.html 46
Back Matter (System Components, Program Interface to JSBSim) 47
Calling Script from JSBSim • The program interface to JSBSim for scripting can be minimized into: • Entire program source code can be seen in [9] FDMExec = new JSBSim::FGFDMExec(); .... result = FDMExec->LoadScript(ScriptName, override_sim_rate_value, ResetName); .... result = FDMExec->Run(); .... 48
System: Filter Component • The filter element can model several types of filters. The Tustin substitution is used to take filter definitions from Laplace space to the time domain. <typename name=”name”> <input> property </input> <c1> number|property </c1> [<c2> number|property </c2>] [<c3> number|property </c3>] [<c4> number|property </c4>] [<c5> number|property </c5>] [<c6> number|property </c6>] [<clipto> <min> number|property </min> <max> number|property </max> </clipto>] [<output> property </output>] </typename> <lag_filter name=”filter1”> <input> fcs/pitch-cmd </input> <c1> 600 </c1> </lag_filter> 49
System: switch • The switch element models a switch – either an on/off or multi-choice rotary switch. <switch name=”name”> <default value=”{property|number}”/> <test logic=”{AND|OR}” value=”{property|number}”> {property} {conditional} {property|number} … [<test logic=”{AND|OR}” value=”{property|number}”> {property} {conditional} {property|number} … </test>] </test> … [<clipto> <min> number|property </min> <max> number|property </max> </clipto>] [<output> property </output>] </switch> <switch name=”fcs/roll_ap_autoswitch”> <default value=”0.0”/> <test value=”fcs/roll-ap-error-summer”> ap/attitude_hold == 1 </test> </switch> 50
System: summer • It sums two or more inputs. A bias can also be added in using bias keyword. • There can be only one bias statement per component. <summer name=”name”> <input> [-]property </input> … <bias> number </bias> [<clipto> <min> number|property </min> <max> number|property </max> </clipto>] [<output> property </output>] </summer> <summer name=”fcs/pid_sum”> <input> velocities/p-rad_sec </input> <input> -fcs/roll-ap-wing-leveler </input> <input> fcs/roll-ap-error-integrator </input> [<clipto> <min> -1.0 </min> <max> 1.0 </max> </clipto>] </summer> 51
System: pure_gain, scheduled_gain • It multiplies the input by a gain. • The gain defaults to a value of 1. • The scheduled_gain multiplies the input by a variable gain that is dependent on another property. The lookup mapping is in the form of a table. <scheduled_gain name="fcs/pitch_scheduled_gain_1"> <input>fcs/pitch-gain-1</input> <gain>0.017</gain> <table> <independentVar>fcs/elevator-pos-rad</independentVar> <tableData> -0.68 -26.548 -0.595 -20.513 -0.51 -15.328 … 0.527 -20.513 0.612 -26.548 0.697 -33.433 </tableData> </table> </scheduled_gain> <pure_gain name="Roll AP Wing Leveler"> <input>fcs/attitude/sensor/phi- rad</input> <gain>2.0</gain> <clipto> <min>-0.255</min> <max>0.255</max> </clipto> </pure_gain> 52
System: deadband • This is a component that allows for some play in a control path, in the form of a dead zone, or deadband. • The width value is the total deadband region within which an input will produce no output. • For example, assume that the width value is 2. Then, if the input is between -1 and +1, the output will be zero. <deadband name="fcs/windup_trigger"> <input> [-]property </input> <width> number </width> [<clipto> <min> {[-]property|value} </min> <max> {[-]property|value} </max> </clipto>] [<output> {property} </output>] </deadband> 53
System: fcs_function • It allows a function to be created when no other component is suitable. • The function can include a nested series of products, sums, quotients, and so on. <fcs_function name="fcs/windup_trigger"> [<input> [-]property </input>] <function> … </function> [<clipto> <min> {[-]property|value} </min> <max> {[-]property|value} </max> </clipto>] [<output> {property} </output>] </fcs_function > <function name="aero/coefficient/CDo"> <description>Drag_at_zero_lift</description> <product> <property>aero/qbar-psf</property> <property>metrics/Sw-sqft</property> <table> <independentVar>velocities/mach</independentVar> <tableData> 0.0000 0.0220 0.2000 0.0200 0.6500 0.0220 0.9000 0.0240 0.9700 0.0500 </tableData> </table> </product> </function> 54
System: actuator • The actuator can be modeled as a perfect actuator with the output directly to input. • It can be made more realistic by specifying the additional effects such as system lag, rate limiting, deadband, hysteresis, bias, and so on. <actuator name=”name”> <input> {[-]property} </input> <lag> number </lag> <rate_limit> number <rate_limit> <bias> number </bias> <deadband_width> number </deadband_width> <hysteresis_width> number </hysteresis_width> [<clipto> <min> {[-]property|value} </min> <max> {[-]property|value} </max> </clipto>] [<output> {property} </output>] </actuator> <actuator name=”fcs/gimbal_pitch_position”> <input> fcs/gimbal_pitch_command </input> <lag> 60 </lag> <rate_limit> 0.085 <rate_limit> <!-- 5 degrees/sec --> <bias> 0.002 </bias> <deadband_width> 0.002 </deadband_width> <hysteresis_width> 0.05 </hysteresis_width> <clipto> <!-- +/- 10 degrees --> <min> -0.17 </min> <max> 0.17 </max> </clipto> </actuator> 55
System: sensor • When the flight control system uses sensed values such as qbar or orientation, the sensed values are modeled as ‘perfect sensor’. • Using sensor component, imperfections can be modeled, resulting to increase the realism of the control system. The only required element is the input. Variance = +/-2 => actual value from sensor is anywhere from 0.98 to 1.02 of the actual ‘perfect’ value! <sensor name=”name” > <input> property </input> <lag> number </lag> <noise variation={”PERCENT|ABSOLUTE”} distribution={“UNIFORM|GAUSSIAN”}> number </noise> <quantization name="name"> <bits> number </bits> <min> number </min> <max> number </max> </quantization> <drift_rate> number </drift_rate> <delay> number </delay> <bias> number </bias> </sensor> <sensor name=”aero/sensor/qbar” > <input> aero/qbar </input> <lag> 0.5 </lag> <noise variation=”PERCENT”> 2 </noise> <quantization name="aero/sensor/quantized/qbar"> <bits> 12 </bits> <min> 0 </min> <max> 400 </max> </quantization> <bias> 0.5 </bias> </sensor> 56
Thank you.. 57

XML introduction and Uses of XML in JSBSim

  • 1.
    XML Introduction and Uses ofXML in JSBSim Wai Nwe Tun
  • 2.
    Contents • XML Introduction oXML in Brief o Schema - XML Elements Definition o Use of XML Elements o General Uses of XML o XML vs. Programming langages • XML Uses in JSBSim o Preliminaries o Configuration files o Scripting • References • Back Matter 2
  • 3.
  • 4.
    XML in Brief •Extensible Markup Language o is designed to describe data. • XML tags are not predefined in XML. • XML content layout or schemas have two main flavors: o Document Type Definitions (DTDs) – older style o XML Schema Documents (XSDs) – newer style • Schemas are not required for informal data encoding. • Schemas are required for widely shared data to represent a contract between provider and user. • Rule: each tag must be ended correspondingly and hierarchically. 4
  • 5.
    Schema - XMLElements Definition http://jsbsim.sf.net/JSBSim.xsd* metrics element definition Sub-elements of metrics wingarea element definition Attribute of wingarea <xs:element name="metrics"> <xs:annotation> <xs:documentation>…</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element ref="wingarea" /> <xs:element ref="location" minOccurs="1" maxOccurs="3" /> </xs:sequence> </xs:complexType> </xs:element> <!-- Wing Area --> <xs:element name="wingarea"> <xs:annotation> <xs:documentation> … </xs:documentation> </xs:annotation> <xs:complexType> <xs:simpleContent> <xs:extension base="PositiveNumber"> <xs:attribute name="unit" use="optional" default="FT2" type="AreaType" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> 5
  • 6.
    Use of XMLElements <metrics> <wingarea> 174.0 </wingarea> <location name="AERORP" unit="IN"> <x> 43.2 </x> <y> 0.0 </y> <z> 59.4 </z> </location> </metrics> metrics element Opening tag Closing tag location element Configuration file* 6
  • 7.
    General Uses ofXML • XML is for identification, transmission, and storage. o Information identification • Define own markup for specific information items o Information storage • Since XML is portable, it can be used to store information across any platforms o Information structure • Structure in nest like a tree hierarchy o Publishing • Publish to web as HTML, paper as PDF, or to other formats using appropriate stylesheets (JSBSim uses JSBSim.xsl and JSBSimScript.xsl) o Messaging and data transfer • Heavily use for encapsulating information to pass between computing systems 7
  • 8.
    Displaying XML filein a Browser http://jsbsim.sourceforge.net/f16.xml* • F16.xml is shown in a XML-supported browser using JSBSim.xsl stylesheet. • XML not-supported browser: o Netscape o Internet Explorer 6 or earlier o Mozilla Firefox 0.8 or earlier • For local XML files, chrome has blocked their XSL transformation. 8
  • 9.
    XML Vs. C,C++, or FORTRAN • C and C++ o programming languages used for performing some actions, calculations, and decisions • XML o markup specification language to design ways of describing information, for storage, transmission, or processing by a program • XML documents don’t run or execute! • XMLs are just data files and wait there until an associated program is run. 9
  • 10.
    XML Use inJSBSim (Preliminaries) 10
  • 11.
    Properties • Properties o globalvariables with selectively limited visibility (read or read/write) o categorized into a hierarchical, tree-like structure o includes a root node, sub nodes, and end-nodes o referenced relative to the current node, or to the root node o refer to specific parameters in program code o can be assigned from • command line • specification/configuration files • scripts • Example: o fcs/left-brake-cmd-norm and ap/altitude_setpoint • Standard properties of acceleration, altitude, fcs, position, propulsion, and velocities can be seen in [1]. 11
  • 12.
    Tables • Three typesof table o 1-dimensional, 2-dimensional, 3-dimensional • Can be defined using proper lookup indices and breakpoints • Table values are linearly interpolated if the required values are not specified. • No extrapolation is done at the table limits but return the value at the highest key value. 12
  • 13.
    1D-Table • The datais in vector format. If alpha is 0.26 radians, the value from lookup table would be 0.033 <table name="property_name"> <independentVar lookup="row"> property_name </independentVar> <tableData> key_1 value_1 key_2 value_2 ... ... key_n value_n </tableData> </table> <table> <independentVar lookup="row"> aero/alpha-rad </independentVar> <tableData> -1.57 1.500 -0.26 0.033 0.00 0.025 0.26 0.033 1.57 1.500 </tableData> </table> Key Value -1.57 1.5 -0.26 0.033 0 0.025 0.26 0.033 1.57 1.5 13
  • 14.
    2D-Table • The datais in a grid-format. <table name="property_name"> <independentVar lookup="row"> property_name </independentVar> <independentVar lookup="column"> property_name </independentVar> <tableData> {col_1_key col_2_key ... col_n_key } {row_1_key} {col_1_data col_2_data ... col_n_data} {row_2_key} {... ... ... ... } { ... } {... ... ... ... } {row_n_key} {... ... ... ... } </tableData> </table> <table> <independentVar lookup="row">aero/alpha-rad</independentVar> <independentVar lookup="column">fcs/flap-pos-deg</independentVar> <tableData> 0.0 10.0 20.0 30.0 -0.0523599 8.96747e-05 0.00231942 0.0059252 0.00835082 -0.0349066 0.000313268 0.00567451 0.0108461 0.0140545 -0.0174533 0.00201318 0.0105059 0.0172432 0.0212346 0.0 0.0051894 0.0168137 0.0251167 0.0298909 0.0174533 0.00993967 0.0247521 0.0346492 0.0402205 0.0349066 0.0162201 0.0342207 0.0457119 0.0520802 </tableData> </table> 0 10 .. -0.0523599 8.96747e-05 0.00231942 -0.0349066 0.000313268 0.00567451 0 0.0051894 0.0168137 … Alpha = 0, flap = 10, Return value = 0.0168137 14
  • 15.
    3D-Table • Defined bythree independent lookup variables (properties) o two or more two-dimensional tables of data o the first row represents the breakpoints for the column lookup variable, and the first column represents the breakpoints for the row lookup variable (as in 2D-Table). • Can have arbitrary number of 2D-Table and controlled each by breakpoint variable 15
  • 16.
    3D-Table: Structure <table name="property_name"> <independentVarlookup="row"> property_name </independentVar> <independentVar lookup="column"> property_name </independentVar> <independentVar lookup="table"> property_name </independentVar> <tableData breakpoint="table_1_key"> {col_1_key col_2_key ... col_n_key } {row_1_key} {col_1_data col_2_data ... col_n_data} {row_2_key} {... ... ... ... } { ... } {... ... ... ... } {row_n_key} {... ... ... ... } </tableData> <tableData breakpoint="table_2_key"> {col_1_key col_2_key ... col_n_key } {row_1_key} {col_1_data col_2_data ... col_n_data} {row_2_key} {... ... ... ... } { ... } {... ... ... ... } {row_n_key} {... ... ... ... } </tableData> ... <tableData breakpoint="table_n_key"> {col_1_key col_2_key ... col_n_key } {row_1_key} {col_1_data col_2_data ... col_n_data} {row_2_key} {... ... ... ... } { ... } {... ... ... ... } {row_n_key} {... ... ... ... } </tableData> </table> 16
  • 17.
    3D-Table: Example <table> <independentVar lookup="row">fcs/row-value</independentVar> <independentVar lookup="column"> fcs/column-value</independentVar> <independentVar lookup="table"> fcs/table-value</independentVar> <tableData breakPoint="-1.0"> -1.0 1.0 0.0 1.0000 2.0000 1.0 3.0000 4.0000 </tableData> <tableData breakPoint="0.0000"> 0.0 10.0 2.0 1.0000 2.0000 3.0 3.0000 4.0000 </tableData> <tableData breakPoint="1.0"> 0.0 10.0 20.0 2.0 1.0000 2.0000 3.0000 3.0 4.0000 5.0000 6.0000 10.0 7.0000 8.0000 9.0000 </tableData> </table> -1 1 0 1 2 1 3 4 0 10 2 1 2 3 3 4 0 10 20 2 1 2 3 3 4 5 6 10 7 8 9 -1 1 0 17
  • 18.
    Function • A powerfuland versatile resource that allows algebraic functions to be defined in a JSBSim configuration file. The syntax is similar to MathML • Consists of operation, value, table, or property • cannot have more than one immediate child 18
  • 19.
    Function • The followingfunction is the product of the ground-effect- factor-lift, qbar-area, and the value by the table, indexed as a function of flap position • The result can be referenced through the property name of “aero/coefficient/CLDf”. <function name=“aero/coefficient/CLDf"> <description> Delta lift due to flap deflection </description> <product> <property> aero/function/ground-effect-factor-lift</property> <property> aero/qbar-area</property> <table> <independentVar> fcs/flap-pos-deg</independentVar> <tableData> 0 0 10 0.2 20 0.3 30 0.35 </tableData> </table> </product> </function> 19
  • 20.
    XML Use inJSBSim (Configuration Files) 20
  • 21.
    Configuration Files • Areparticularly used for storing aircraft information and specifications such as o File Header Information o Metrics o Mass/Balance o Buoyant Forces o Ground Reactions o External Reactions o Propulsion o Aerodynamics o Systems, Autopilot, and Flight Control o Input o Output 21
  • 22.
    File Header Information •is where important information about the model is recorded o authors, their contact information and affiliation o Notes about the model, as well as limitations and reference information http://jsbsim.sf.net/JSBSim.xsd* 22
  • 23.
    Metrics • Defines thecharacteristic measurements of the vehicle and locations of key points • Units may be used as well. http://jsbsim.sf.net/JSBSim.xsd* 23
  • 24.
    Mass/Balance • Includes specificationssuch as o mass properties of the aircraft and empty weight of the aircraft, o the moments and products of inertia, the location of the center of gravity, and the definitions for any point masses http://jsbsim.sf.net/JSBSim.xsd* 24
  • 25.
    Buoyant Forces • Includethe format of a gas cell and ballonet • Gas Type: HYDROGEN, HELIUM, or AIR. • The element <heat> can contain zero or more function elements. * A ballonet is an air bag inside the gas cell in no-rigit or semi-rigid airships to maintain the shape and volume of the gas cell and keep its internal pressure higher than that of the surrounding environment. 25
  • 26.
    Ground Reactions • Modelcontacts between the aircraft and the ground to facilitate the realistic take-off and landing • Contact points must be listed in this section. Two types of contacts: o BOGEY : for landing gear o STRUCTURE : for any location other than landing gear http://jsbsim.sf.net/JSBSim.xsd* 26
  • 27.
    Propulsion • Contains referencesto specific engines, o Locations of engine, thruster, tank definition (Engine and thruster specifics are in an external file.) • To use an external file, ‘file’ attribute is used http://jsbsim.sf.net/JSBSim.xsd* 27
  • 28.
    Aerodynamics • Contains aerodynamicforces and moments. It may be separated as an external file. • There are three coordinate systems: o Wind coordinate system (DRAG, SIDE, LIFT) o Body coordinate system (X, Y, Z) o Axial-normal coordinate system (AXIAL, NORMAL, SIDE) http://jsbsim.sf.net/JSBSim.xsd* 28
  • 29.
    System • Can bepresent any number of times in an aircraft definition. • Defines an arbitrary system such as navigation, guidance, or control avionics, electrical systems, etc. http://jsbsim.sf.net/JSBSim.xsd* 29
  • 30.
    System Components • Filter oIs a component in a control system to improve response in a feedback and control system • Switch o Models a switch – either an on/off or multi-choice rotary switch • Summer o Sums two or more inputs, optionally used with bias • Gain o Multiplies the input by a gain 30
  • 31.
    System Components • Deadband oIs a component that allows for some play in a control path, in the form of dead zone, or deadband (to trigger the output as zero) • Fcs/function o Is like the normal function and can have a nested series of functions • Actuator o Models more realistic actuator by specifying the additional effects such as deadband, bias, and so on • Sensor o Like actuator, models realistic sensor using some lag, noise, etc. 31
  • 32.
    Runtime Input • JSBSimhas the capability to input data at runtime via a socket, so as for output. <input port=”port number”/> • JSBSim input command interpreter can understand these commands get 'property_name' set 'property_name' (value) hold|resume|info|help|quit src/jsbsim --script=scripts/c1723.xml --realtime --suspend telnet host port • --realtime: to run at real-time speed • --suspend: to go into hold after initialization so the user can connect from another shell to the JSBSim server, using telnet. 32
  • 33.
    Runtime Output • Canoutput data in many ways by particularly specifying in the ‘type’ attribute: o CSV comma separated data o SOCKET sends data to another machine via a socket o FLIGHTGEAR creates a socket for sending binary data packets to an external instance of FlightGear for visuals o TABULAR columnar data, tab-delimited. o NONE specifies to do nothing. • name : IP address, file name, others <output name=”name” type=”type” [port=”int” protocol=”UDP|TCP”] rate=”number”> [<group> OFF|ON </group>] [<property> name </property>] </output> 33
  • 34.
    Runtime Output • ‘rate’is a rate in Hz that the data is output but it depends on the frame rate. • ‘port’ is used only for socket output, and ‘protocol’ is currently only for socket output to FlightGear. <output name="JSBout172B.csv" type="CSV" rate="10"> <rates> ON </rates> <velocities> ON </velocities> <position> ON </position> <atmosphere> OFF </atmosphere> <fcs> ON </fcs> <ground_reactions> OFF </ground_reactions> <propulsion> ON </propulsion> <simulation> ON </simulation> <massprops> ON </massprops> <forces> OFF </forces> <moments> OFF </moments> <aerosurfaces> OFF </aerosurfaces> <property> position/vrp-gc-latitude_deg </property> <property> position/vrp-longitude_deg </property> <property> position/vrp-radius-ft </property> <function name="velocities/pi-deg_sec"> <todegrees> <p> velocities/pi-rad_sec </p> </todegrees> </function> </output> 34
  • 35.
    XML Use inJSBSim (Scripting) 35
  • 36.
    Scripting • Is forany time a repeatable set of conditions needs to be performed for testing or analysis. • Is made up of language elements that have some events which consists of two parts: o the conditional tests to be performed and o the actions to be taken when the conditional test evaluate to true. • Uses a reference to an aircraft specification file, to a file containing the set of initial conditions, to a start and stop time, and to the integration step size. o Stop time and step size are mandatory input to JSBSim script. 36
  • 37.
    Events • Control whichand when actions would take place • Includes : o a condition that must be satisfied for the event to be triggered, o actions that are taken when the conditions are satisfied, and o (optional) notification (whether to print a message stating that the event has been triggered) • Event types : • Continuous : to execute the event every single frame, • Persistent : to execute the event each time the condition evaluates to true • Default: to execute the event once 37
  • 38.
    Conditions • Determines whenthe listed actions should be carried out • The semantic of conditions and actions is exactly the same as ‘if .. then’. • Logic attribute defaults to “AND”. <condition> sim-time-sec gt 0.5 <conditon logic="OR"> aero/qbar-psf gt 4.5 gear/unit/WOW eq 0 </condition> </condition> sim-time-sec>0.5 AND (aero/qbar-psf>4.5 OR gear/unit/WOW==0) 38
  • 39.
    Actions • When thecondition evaluates to true, any actions specified will be carried out. • Is a set of ‘set’ elements • Attributes of ‘set’ element: o name : property that will be set o value : the value that the property will be set to o action : specify the way in which a new value will be assigned to the named property. (default: step, ramp (slope), exponential) o type : specify whether the new value to be assigned is an actual value, or a delta. (default: value, delta) o tc : specify the numeric time constant that controls how fast an exponential or ram action will be applied to a property value 39
  • 40.
    Set: Type andAction • Type o FG_DELTA – the new value is added to the old one. o FG_VALUE – the actual value is copied over the old one. • Action o FG_EXP – the new value is approached exponentially from the old one. o FG_RAMP – the new value ramps linearly from the old value to the new one. o FG_STEP – the new value immediately takes effect. 40
  • 41.
    Aircraft State andInitialization • This is simply to specify which aircraft model will be used for simulation. o Here, it uses ‘c172x’ which is an XML configuration file of the aircraft model. o reset00 initializes some properties of the aircraft. • Start, end time and step value for running the script are also described. <?xml-stylesheet type="text/xsl" href="http://jsbsim.sourceforge.net/JSBSimScript.xsl"?> <runscript xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://jsbsim.sf.net/JSBSimScript.xsd" name="C172-01A takeoff run"> <use aircraft="c172x" initialize="reset00"/> <run start="0.0" end="200" dt="0.00833333333333333333"> c1723.xml* 41
  • 42.
    Property Initialization • Theabove example is to make sure that the aircraft is at brake state before starting an engine. • This is also useful to override the properties in the aircraft’s configuration file. <!-- Initialize with brakes on --> <property> simulation/notify-time-trigger </property> <property value="1"> simulation/run_id </property> <property value="1"> fcs/left-brake-cmd-norm </property> <property value="1"> fcs/right-brake-cmd-norm </property> <property value="1"> fcs/center-brake-cmd-norm </property> <property value="3.49"> guidance/specified-heading-rad </property> <property value="1"> guidance/heading-selector-switch </property> c1723.xml* 42
  • 43.
    ‘Engine Start’ Event •The event is to start an engine. • It will be performed after 0.25 seconds of simulation time. • <notify> is to display the described properties to the command line when triggering this event. • This event will be triggered once. c1723.xml* <event name="engine start"> <description>Start the engine and set roll control to heading hold</description> <condition> simulation/sim-time-sec >= 0.25 </condition> <set name="fcs/throttle-cmd-norm" value="1.0" action="FG_RAMP" tc ="0.5"/> <set name="fcs/mixture-cmd-norm" value="1.00" action="FG_RAMP" tc ="0.5"/> <set name="propulsion/magneto_cmd" value="3"/> <set name="propulsion/starter_cmd" value="1"/> <set name="ap/roll-attitude-mode" value="1"/> <set name="ap/autopilot-roll-on" value="1"/> <notify> <property>simulation/run_id</property> <property>ap/hdg-roll-err-c1</property> </notify> </event> 43
  • 44.
    ‘Time Notify’ Event •This event is like a timer to display an output message every 1 minute. • The notification from this event is like this: <event name="Time Notify" persistent="true"> <description>Output message at 1 minute intervals</description> <notify> <property>velocities/vc-kts</property> <property>position/h-agl-ft</property> <property>position/lat-geod-deg</property> <property>position/geod-alt-ft</property> </notify> <condition> simulation/sim-time-sec >= simulation/notify-time-trigger </condition> <set name="simulation/notify-time-trigger" value="60" type="FG_DELTA"/> </event> c1723.xml* 44
  • 45.
    Running JSBSim inBatch Mode • First, we need to have JSBSim.exe file or JSBSim source code as well as necessary configuration files and script files. • If we have source code, we can build an executable file. • Using the executable file ‘JSBSim’, we can run any script file by using the following sample form in command line. >JSBSim --script=(script_file) • For example, script_file is c1723.xml. Many script files can be found under scripts folder of JSBSim. http://www.holycows.net/JSBSim_Script_Tutorial.pdf* 45
  • 46.
    References 1) http://outerra.shoutwiki.com/wiki/JSBSim_Properties 2) http://wiki.flightgear.org/XML 3)http://xml.silmaril.ie/programming.html 4) http://wiki.flightgear.org/PropertyList_XML_files 5) http://jsbsim.sourceforge.net/JSBSim/classJSBSim_1_1FGScript. html 6) Back of the Envelope, JSBSim, XSL Transformations, and XML Schemas, January 2006. 7) Jon S. Berndt and the JSBSim Development Team, JSPSim Reference Manual 8) Jon S. Berndt, JSBSim: An opensource flight Dynamics Model in C++, AIAA, August 2004. 9) http://jsbsim.sourceforge.net/JSBSim/JSBSim_8cpp_source.html 46
  • 47.
    Back Matter (System Components,Program Interface to JSBSim) 47
  • 48.
    Calling Script fromJSBSim • The program interface to JSBSim for scripting can be minimized into: • Entire program source code can be seen in [9] FDMExec = new JSBSim::FGFDMExec(); .... result = FDMExec->LoadScript(ScriptName, override_sim_rate_value, ResetName); .... result = FDMExec->Run(); .... 48
  • 49.
    System: Filter Component •The filter element can model several types of filters. The Tustin substitution is used to take filter definitions from Laplace space to the time domain. <typename name=”name”> <input> property </input> <c1> number|property </c1> [<c2> number|property </c2>] [<c3> number|property </c3>] [<c4> number|property </c4>] [<c5> number|property </c5>] [<c6> number|property </c6>] [<clipto> <min> number|property </min> <max> number|property </max> </clipto>] [<output> property </output>] </typename> <lag_filter name=”filter1”> <input> fcs/pitch-cmd </input> <c1> 600 </c1> </lag_filter> 49
  • 50.
    System: switch • Theswitch element models a switch – either an on/off or multi-choice rotary switch. <switch name=”name”> <default value=”{property|number}”/> <test logic=”{AND|OR}” value=”{property|number}”> {property} {conditional} {property|number} … [<test logic=”{AND|OR}” value=”{property|number}”> {property} {conditional} {property|number} … </test>] </test> … [<clipto> <min> number|property </min> <max> number|property </max> </clipto>] [<output> property </output>] </switch> <switch name=”fcs/roll_ap_autoswitch”> <default value=”0.0”/> <test value=”fcs/roll-ap-error-summer”> ap/attitude_hold == 1 </test> </switch> 50
  • 51.
    System: summer • Itsums two or more inputs. A bias can also be added in using bias keyword. • There can be only one bias statement per component. <summer name=”name”> <input> [-]property </input> … <bias> number </bias> [<clipto> <min> number|property </min> <max> number|property </max> </clipto>] [<output> property </output>] </summer> <summer name=”fcs/pid_sum”> <input> velocities/p-rad_sec </input> <input> -fcs/roll-ap-wing-leveler </input> <input> fcs/roll-ap-error-integrator </input> [<clipto> <min> -1.0 </min> <max> 1.0 </max> </clipto>] </summer> 51
  • 52.
    System: pure_gain, scheduled_gain •It multiplies the input by a gain. • The gain defaults to a value of 1. • The scheduled_gain multiplies the input by a variable gain that is dependent on another property. The lookup mapping is in the form of a table. <scheduled_gain name="fcs/pitch_scheduled_gain_1"> <input>fcs/pitch-gain-1</input> <gain>0.017</gain> <table> <independentVar>fcs/elevator-pos-rad</independentVar> <tableData> -0.68 -26.548 -0.595 -20.513 -0.51 -15.328 … 0.527 -20.513 0.612 -26.548 0.697 -33.433 </tableData> </table> </scheduled_gain> <pure_gain name="Roll AP Wing Leveler"> <input>fcs/attitude/sensor/phi- rad</input> <gain>2.0</gain> <clipto> <min>-0.255</min> <max>0.255</max> </clipto> </pure_gain> 52
  • 53.
    System: deadband • Thisis a component that allows for some play in a control path, in the form of a dead zone, or deadband. • The width value is the total deadband region within which an input will produce no output. • For example, assume that the width value is 2. Then, if the input is between -1 and +1, the output will be zero. <deadband name="fcs/windup_trigger"> <input> [-]property </input> <width> number </width> [<clipto> <min> {[-]property|value} </min> <max> {[-]property|value} </max> </clipto>] [<output> {property} </output>] </deadband> 53
  • 54.
    System: fcs_function • Itallows a function to be created when no other component is suitable. • The function can include a nested series of products, sums, quotients, and so on. <fcs_function name="fcs/windup_trigger"> [<input> [-]property </input>] <function> … </function> [<clipto> <min> {[-]property|value} </min> <max> {[-]property|value} </max> </clipto>] [<output> {property} </output>] </fcs_function > <function name="aero/coefficient/CDo"> <description>Drag_at_zero_lift</description> <product> <property>aero/qbar-psf</property> <property>metrics/Sw-sqft</property> <table> <independentVar>velocities/mach</independentVar> <tableData> 0.0000 0.0220 0.2000 0.0200 0.6500 0.0220 0.9000 0.0240 0.9700 0.0500 </tableData> </table> </product> </function> 54
  • 55.
    System: actuator • Theactuator can be modeled as a perfect actuator with the output directly to input. • It can be made more realistic by specifying the additional effects such as system lag, rate limiting, deadband, hysteresis, bias, and so on. <actuator name=”name”> <input> {[-]property} </input> <lag> number </lag> <rate_limit> number <rate_limit> <bias> number </bias> <deadband_width> number </deadband_width> <hysteresis_width> number </hysteresis_width> [<clipto> <min> {[-]property|value} </min> <max> {[-]property|value} </max> </clipto>] [<output> {property} </output>] </actuator> <actuator name=”fcs/gimbal_pitch_position”> <input> fcs/gimbal_pitch_command </input> <lag> 60 </lag> <rate_limit> 0.085 <rate_limit> <!-- 5 degrees/sec --> <bias> 0.002 </bias> <deadband_width> 0.002 </deadband_width> <hysteresis_width> 0.05 </hysteresis_width> <clipto> <!-- +/- 10 degrees --> <min> -0.17 </min> <max> 0.17 </max> </clipto> </actuator> 55
  • 56.
    System: sensor • Whenthe flight control system uses sensed values such as qbar or orientation, the sensed values are modeled as ‘perfect sensor’. • Using sensor component, imperfections can be modeled, resulting to increase the realism of the control system. The only required element is the input. Variance = +/-2 => actual value from sensor is anywhere from 0.98 to 1.02 of the actual ‘perfect’ value! <sensor name=”name” > <input> property </input> <lag> number </lag> <noise variation={”PERCENT|ABSOLUTE”} distribution={“UNIFORM|GAUSSIAN”}> number </noise> <quantization name="name"> <bits> number </bits> <min> number </min> <max> number </max> </quantization> <drift_rate> number </drift_rate> <delay> number </delay> <bias> number </bias> </sensor> <sensor name=”aero/sensor/qbar” > <input> aero/qbar </input> <lag> 0.5 </lag> <noise variation=”PERCENT”> 2 </noise> <quantization name="aero/sensor/quantized/qbar"> <bits> 12 </bits> <min> 0 </min> <max> 400 </max> </quantization> <bias> 0.5 </bias> </sensor> 56
  • 57.