virtualair
contact us
Air traffic simulation and visualization platform.

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:

  • JSBSim providing the flight dynamic model and a scripting language interpreter to execute the flight.
  • JSBSim Python bindings providing interface to the Python scripring language.
  • PyHLA providing Python language bindings for the M&S HLA 1.3.

The flight can be visualized in the Simulation Monitor. (The following screenshots show the c3104.xml script from the JSBSim distribution.)

_images/py_aircraft1s.png _images/py_aircraft2s.png

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.