How to use JSBSim - 6 common examples

To help you get started, we’ve selected a few JSBSim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Gor-Ren / gym-jsbsim / test / test_Simulation.py View on Github external
def test_init_jsbsim(self):
        self.assertIsInstance(self.sim.sim, jsbsim.FGFDMExec,
                              msg=f'Expected Simulation.sim to hold an '
                              'instance of JSBSim.')
github JSBSim-Team / jsbsim / tests / JSBSim_utils.py View on Github external
def CreateFDM(sandbox, pm=None):
    _fdm = jsbsim.FGFDMExec(os.path.join(sandbox(), ''), pm)
    path = sandbox.path_to_jsbsim_file()
    _fdm.set_aircraft_path(os.path.join(path, 'aircraft'))
    _fdm.set_engine_path(os.path.join(path, 'engine'))
    _fdm.set_systems_path(os.path.join(path, 'systems'))
    return _fdm
github JSBSim-Team / jsbsim / python / JSBSim.py View on Github external
args.script = args.input

    if root.tag == 'output':
        if args.logdirectivefile:
            args.logdirectivefile += [args.input]
        else:
            args.logdirectivefile = [args.input]

    if root.tag == 'fdm_config':
        if args.aircraft:
            print('Two aircraft files are specified.')
            sys.exit(1)
        else:
            args.aircraft = args.input

fdm = jsbsim.FGFDMExec(args.root, None)

if args.script:
    fdm.load_script(args.script)
elif args.aircraft:
    fdm.load_model(args.aircraft, False)

if args.logdirectivefile:
    for f in args.logdirectivefile:
        if not fdm.set_output_directive(f):
            print("Output directives not properly set in file {}".format(f))
            sys.exit(1)

if args.outputlogfile:
    for n,f in enumerate(args.outputlogfile):
        old_filename = fdm.get_output_filename(n)
        if not fdm.set_output_filename(n, f):
github Gor-Ren / gym-jsbsim / gym_jsbsim / simulation.py View on Github external
sim_frequency_hz: float = 60.0,
                 aircraft: Aircraft = cessna172P,
                 init_conditions: Dict[prp.Property, float] = None,
                 allow_flightgear_output: bool = True):
        """
        Constructor. Creates an instance of JSBSim and sets initial conditions.

        :param sim_frequency_hz: the JSBSim integration frequency in Hz.
        :param aircraft_model_name: name of aircraft to be loaded.
            JSBSim looks for file \model_name\model_name.xml from root dir.
        :param init_conditions: dict mapping properties to their initial values.
            Defaults to None, causing a default set of initial props to be used.
        :param allow_flightgear_output: bool, loads a config file instructing
            JSBSim to connect to an output socket if True.
        """
        self.jsbsim = jsbsim.FGFDMExec(root_dir=self.ROOT_DIR)
        self.jsbsim.set_debug_level(0)
        if allow_flightgear_output:
            flightgear_output_config = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                                    self.OUTPUT_FILE)
            self.jsbsim.set_output_directive(flightgear_output_config)
        self.sim_dt = 1.0 / sim_frequency_hz
        self.aircraft = aircraft
        self.initialise(self.sim_dt, self.aircraft.jsbsim_id, init_conditions)
        self.jsbsim.disable_output()
        self.wall_clock_dt = None
github JSBSim-Team / jsbsim / doc / python / JSBSim_nb_utils.py View on Github external
def CreateFDM(sandbox):
    _fdm = jsbsim.FGFDMExec(root_dir=os.path.join(sandbox(), ''))
    path = sandbox.path_to_jsbsim_file()
    _fdm.set_aircraft_path(os.path.join(path, 'aircraft'))
    _fdm.set_engine_path(os.path.join(path, 'engine'))
    _fdm.set_systems_path(os.path.join(path, 'systems'))
    return _fdm
github JSBSim-Team / jsbsim / python / JSBSim.py View on Github external
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see 
#

import xml.etree.ElementTree as et
import argparse, sys, os
import jsbsim

parser = argparse.ArgumentParser()
parser.add_argument("input", nargs='?', help="script file name")
parser.add_argument("--version", action="version",
                    version="%(prog)s {}".format(jsbsim.FGJSBBase().get_version()))
parser.add_argument("--outputlogfile", action="append", metavar="",
                    help="sets (overrides) the name of a data output file")
parser.add_argument("--logdirectivefile", action="append", metavar="",
                    help="specifies the name of a data logging directives file")
parser.add_argument("--root", default='.', metavar="

JSBSim

An open source flight dynamics & control software library

LGPL-2.1
Latest version published 4 months ago

Package Health Score

78 / 100
Full package analysis

Popular JSBSim functions