|
JSBSim Intergration¶The JSBSim can be used to insert a flight-script driven aircraft to an HLA 1.3 simulation environment. Multiple aircraft can be simulated by executing multiple JSBSim instances. The following components are necessary:
The flight can be visualized in the Simulation Monitor. (The following screenshots show the c3104.xml script from the JSBSim distribution.) User Instructions¶Write a Python script to execute the JSBSim model and publish its properties to the HLA environment. The script may have the following structure: import JSBSim
import hla.rti
import hla.omt as fom
class MyAmbassador(hla.rti.FederateAmbassador):
pass
rtia = hla.rti.RTIAmbassador()
rtia.createFederationExecution("VirtualAir", "AviationSimNet-v3.1.fed")
mya = MyAmbassador()
rtia.joinFederationExecution("jsbsim-01", "VirtualAir", mya)
aircraftHandle = rtia.getObjectClassHandle("aircraft")
altitudeHandle = rtia.getAttributeHandle("altitudeMSL", aircraftHandle)
# ... initialize the object handles
rtia.publishObjectClass(aircraftHandle, [altitudeHandle, ...])
object = rtia.registerObjectInstance(aircraftHandle, "instance")
model = JSBSim.FGFDMExec()
# ... initialize the aircraft model
model.LoadScript("JSBSim/scripts/c3104.xml")
while model.Run():
rtia.updateAttributeValues(object,
{altitudeHandle:fom.HLAfloat32BE.pack(model.GetPropertyValue("position/geod-alt-ft")),
# ... read properties and publish the data to the HLA environment
"update")
rtia.tick(1.0)
See the test-hla-asn.py script provided by JSBSim Python for more details. |