From: Jon S. B. <js...@ha...> - 2006-08-10 13:02:48
|
I have made substantial changes to the scripting capability for JSBSim. In doing so I have upgraded the version number to 0.9.12. The scripting changes were needed for some testing and debugging. Some of the items had been getting thought about for a year or two. Related changes will follow that provide new capability for modeling aerodynamic qualities. The changes to the scripting language are not too expansive, and it should not be too difficult to modify existing scripts to run using the new format. The "when" element is now called "event". The conditional test[s] is/are specified using what has become the standard way to specify conditional tests in JSBSim. There are new attributes and keywords. I'll have more information in the upcoming newsletter. Here's an example of what can be done, based on the C172 script: <?xml version="1.0"?> <runscript name="C172-01A takeoff run"> <!-- This run is for testing the C172 altitude hold autopilot --> <use aircraft="c172x"/> <use initialize="reset00"/> <run start="0.0" end="3000" dt="0.0083333"> <event name="engine start"> <notify/> <condition> 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="0.87" action="FG_RAMP" tc ="0.5"/> <set name="propulsion/magneto_cmd" value="3"/> <set name="propulsion/starter_cmd" value="1"/> </event> <event name="set heading hold"> <!-- Set Heading when reach 5 ft --> <notify/> <condition> position/h-agl-ft >= 5 </condition> <set name="ap/heading_setpoint" value="200"/> <set name="ap/attitude_hold" value="0"/> <set name="ap/heading_hold" value="1"/> </event> <event name="set autopilot"> <!-- Set Autopilot for 20 ft --> <notify/> <condition> aero/qbar-psf >= 4 </condition> <set name="ap/altitude_setpoint" value="100.0" action="FG_EXP" tc ="2.0"/> <set name="ap/altitude_hold" value="1"/> <set name="fcs/flap-cmd-norm" value=".33"/> </event> <event name="set autopilot 2" persistent="true"> <!-- Set Autopilot for 6000 ft --> <notify/> <condition> aero/qbar-psf > 5 </condition> <set name="ap/altitude_setpoint" value="6000.0"/> </event> <event name="adjust throttle/flaps"> <!-- remove flaps at 50 ft --> <notify/> <condition> position/h-agl-ft >= 100 </condition> <set name="fcs/mixture-cmd-norm" value="0.69" action="FG_EXP" tc ="400.0"/> <set name="fcs/flap-cmd-norm" value="0"/> </event> <event name="set autopilot 3" persistent="true"> <!-- Set Autopilot for 4000 ft --> <notify/> <condition> sim-time-sec >= 1500 </condition> <set name="ap/altitude_setpoint" value="4000.0"/> </event> <event name="set autopilot for 7000 ft." persistent="true"> <!-- Set Autopilot for 7000 ft --> <notify/> <condition> sim-time-sec >= 2500 </condition> <set name="ap/altitude_setpoint" value="7000.0"/> </event> <event name="Time Notify"> <notify> <property> position/h-agl-ft </property> </notify> <condition> sim-time-sec >= 500 </condition> </event> <event name="Time Notify"> <notify> <property> position/h-agl-ft </property> </notify> <condition> sim-time-sec >= 1000 </condition> </event> <event name="Time Notify"> <notify> <property> position/h-agl-ft </property> </notify> <condition> sim-time-sec >= 1500 </condition> </event> </run> </runscript> |