本文整理汇总了Python中JSBSim_utils.CreateFDM.load_model方法的典型用法代码示例。如果您正苦于以下问题:Python CreateFDM.load_model方法的具体用法?Python CreateFDM.load_model怎么用?Python CreateFDM.load_model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSBSim_utils.CreateFDM
的用法示例。
在下文中一共展示了CreateFDM.load_model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_trim_doesnt_ignite_rockets
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def test_trim_doesnt_ignite_rockets(self):
# Run a longitudinal trim with a rocket equipped with solid propellant
# boosters (aka SRBs). The trim algorithm will try to reach a vertical
# equilibrium by tweaking the throttle but since the rocket is nose up,
# the trim cannot converge. As a result the algorithm will set full
# throttle which will result in the SRBs ignition if the integration is
# not suspended. This bug has been reported in FlightGear and this test
# is checking that there is no regression.
fdm = CreateFDM(self.sandbox)
fdm.load_model('J246')
fdm.load_ic(self.sandbox.path_to_jsbsim_file('aircraft', 'J246',
'LC39'), False)
fdm.run_ic()
# Check that the SRBs are not ignited
self.assertEqual(fdm['propulsion/engine[0]/thrust-lbs'], 0.0)
self.assertEqual(fdm['propulsion/engine[1]/thrust-lbs'], 0.0)
try:
fdm['simulation/do_simple_trim'] = 1
except RuntimeError as e:
# The trim cannot succeed. Just make sure that the raised exception
# is due to the trim failure otherwise rethrow.
if e.args[0] != 'Trim Failed':
raise
# Check that the trim did not ignite the SRBs
self.assertEqual(fdm['propulsion/engine[0]/thrust-lbs'], 0.0)
self.assertEqual(fdm['propulsion/engine[1]/thrust-lbs'], 0.0)
示例2: test_FG_reset
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def test_FG_reset(self):
# This test reproduces how FlightGear resets. The important thing is
# that the property manager is managed by FlightGear. So it is not
# deleted when the JSBSim instance is killed.
pm = jsbsim.FGPropertyManager(new_instance=True)
self.assertFalse(pm.hasNode('fdm/jsbsim/ic/lat-geod-deg'))
fdm = CreateFDM(self.sandbox, pm)
fdm.load_model('ball')
self.assertAlmostEqual(fdm['ic/lat-geod-deg'], 0.0)
fdm['ic/lat-geod-deg'] = 45.0
fdm.run_ic()
del fdm
# Check that the property ic/lat-geod-deg has survived the JSBSim
# instance.
self.assertTrue(pm.hasNode('fdm/jsbsim/ic/lat-geod-deg'))
# Re-use the property manager just as FlightGear does.
fdm = CreateFDM(self.sandbox, pm)
self.assertAlmostEqual(fdm['ic/lat-geod-deg'], 45.0)
del fdm
示例3: test_steer_with_fcs
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def test_steer_with_fcs(self):
fdm = CreateFDM(self.sandbox)
fdm.load_model('L410')
aircraft_path = self.sandbox.path_to_jsbsim_file('aircraft')
fdm.load_ic(os.path.join(aircraft_path, 'L410', 'reset00'), False)
fdm.run_ic()
self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], 0.0)
self.assertAlmostEqual(fdm['fcs/steer-pos-deg'], 0.0)
fdm['fcs/steer-cmd-norm'] = 1.0
self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], 1.0)
fdm.run()
self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], 1.0)
self.assertAlmostEqual(fdm['fcs/steer-pos-deg'], 5.0)
fdm['/controls/switches/full-steering-sw'] = 1.0
fdm.run()
self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], 1.0)
self.assertAlmostEqual(fdm['fcs/steer-pos-deg'], 0.0)
fdm['/controls/switches/full-steering-sw'] = 2.0
fdm.run()
self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], 1.0)
self.assertAlmostEqual(fdm['fcs/steer-pos-deg'], 45.0)
fdm['fcs/steer-cmd-norm'] = -0.5
fdm.run()
self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], -0.5)
self.assertAlmostEqual(fdm['fcs/steer-pos-deg'], -22.5)
示例4: testKinematicTiming
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def testKinematicTiming(self):
fdm = CreateFDM(self.sandbox)
fdm.load_model('c172r')
fdm.load_ic(self.sandbox.path_to_jsbsim_file('aircraft', 'c172r',
'reset00'), False)
fdm.run_ic()
self.assertEqual(fdm['fcs/flap-cmd-norm'], 0.0)
self.assertEqual(fdm['fcs/flap-pos-deg'], 0.0)
# Test the flap down sequence. The flap command is set to a value
# higher than 1.0 to check that JSBSim clamps it to 1.0
fdm['fcs/flap-cmd-norm'] = 1.5
t = fdm['simulation/sim-time-sec']
while t < 2.0:
self.assertAlmostEqual(fdm['fcs/flap-pos-deg'], 5.*t)
fdm.run()
t = fdm['simulation/sim-time-sec']
while t < 4.0:
self.assertAlmostEqual(fdm['fcs/flap-pos-deg'], 10.*(t-1.))
fdm.run()
t = fdm['simulation/sim-time-sec']
while t < 5.0:
self.assertAlmostEqual(fdm['fcs/flap-pos-deg'], 30.)
fdm.run()
t = fdm['simulation/sim-time-sec']
# Test the flap up sequence with an interruption at 7.5 deg
fdm['fcs/flap-cmd-norm'] = 0.25
while t < 7.0:
self.assertAlmostEqual(fdm['fcs/flap-pos-deg'], 30.-10.*(t-5.))
fdm.run()
t = fdm['simulation/sim-time-sec']
while t < 7.5:
self.assertAlmostEqual(fdm['fcs/flap-pos-deg'], 10.-5.*(t-7.))
fdm.run()
t = fdm['simulation/sim-time-sec']
while t < 8.0:
self.assertAlmostEqual(fdm['fcs/flap-pos-deg'], 7.5)
fdm.run()
t = fdm['simulation/sim-time-sec']
# Complete the flap up sequence. The flap command is set to a value
# lower than 0.0 to check that JSBSim clamps it to 0.0
fdm['fcs/flap-cmd-norm'] = -1.
while t < 9.5:
self.assertAlmostEqual(fdm['fcs/flap-pos-deg'], 10.-5.*(t-7.5))
fdm.run()
t = fdm['simulation/sim-time-sec']
while t < 10.0:
self.assertAlmostEqual(fdm['fcs/flap-pos-deg'], 0.0)
fdm.run()
t = fdm['simulation/sim-time-sec']
示例5: test_direct_steer
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def test_direct_steer(self):
fdm = CreateFDM(self.sandbox)
fdm.load_model('c172r')
aircraft_path = self.sandbox.path_to_jsbsim_file('aircraft')
fdm.load_ic(os.path.join(aircraft_path, 'c172r', 'reset00'), False)
fdm.run_ic()
self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], 0.0)
self.assertAlmostEqual(fdm['fcs/steer-pos-deg'], 0.0)
# Should be part of a unit test in C++ ?
fpectl.turnon_sigfpe()
grndreact = fdm.get_ground_reactions()
for i in xrange(grndreact.get_num_gear_units()):
gear = grndreact.get_gear_unit(i)
self.assertEqual(gear.get_steer_norm(), 0.0)
fpectl.turnoff_sigfpe()
fdm['fcs/steer-pos-deg'] = 5.0
self.assertAlmostEqual(fdm['fcs/steer-pos-deg'], 5.0)
fdm.run()
self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], 0.0)
fdm['fcs/steer-cmd-norm'] = 1.0
self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], 1.0)
fdm.run()
self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], 1.0)
self.assertAlmostEqual(fdm['fcs/steer-pos-deg'], 10.0)
示例6: test_trim_on_ground
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def test_trim_on_ground(self):
fdm = CreateFDM(self.sandbox)
fdm.load_model('c172x')
fdm['ic/theta-deg'] = 10.0
fdm.run_ic()
fdm['ic/theta-deg'] = 0.0
fdm['simulation/do_simple_trim'] = 2
示例7: test_waypoint
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def test_waypoint(self):
fdm = CreateFDM(self.sandbox)
fdm.load_model('c310')
aircraft_path = self.sandbox.path_to_jsbsim_file('aircraft')
fdm.load_ic(os.path.join(aircraft_path, 'c310', 'reset00'), False)
slr = 20925646.32546 # Sea Level Radius
TestCases = ((0.25*math.pi, 0.5*math.pi, 0.0, 0.0),
(0.0, 0.5*math.pi, math.pi, slr*0.25*math.pi),
# North pole
(0.5*math.pi, 0.5*math.pi, 0.0, slr*0.25*math.pi),
# South pole
(-0.5*math.pi, 0.5*math.pi, math.pi, slr*0.75*math.pi),
(0.0, 0.0, 1.5*math.pi, slr*0.5*math.pi),
(0.0, math.pi, 0.5*math.pi, slr*0.5*math.pi))
fdm['ic/lat-gc-rad'] = TestCases[0][0]
fdm['ic/long-gc-rad'] = TestCases[0][1]
for case in TestCases:
fdm['guidance/target_wp_latitude_rad'] = case[0]
fdm['guidance/target_wp_longitude_rad'] = case[1]
fdm.run_ic()
self.assertAlmostEqual(fdm['guidance/wp-heading-rad'], case[2])
self.assertAlmostEqual(fdm['guidance/wp-distance'], case[3])
示例8: test_asl_override_vs_geod_lat
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def test_asl_override_vs_geod_lat(self):
fdm = CreateFDM(self.sandbox)
fdm.load_model('c310')
fdm.load_ic(self.sandbox.path_to_jsbsim_file('aircraft', 'c310',
'ellington.xml'), False)
geod_lat = fdm['ic/lat-geod-deg']
fdm['ic/h-sl-ft'] = 35000.
self.assertAlmostEqual(fdm['ic/lat-geod-deg'], geod_lat)
示例9: test_pitot_angle
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def test_pitot_angle(self):
script_name = 'ball_chute.xml'
script_path = self.sandbox.path_to_jsbsim_file('scripts', script_name)
# Add a Pitot angle to the Cessna 172
tree, aircraft_name, path_to_jsbsim_aircrafts = CopyAircraftDef(script_path, self.sandbox)
root = tree.getroot()
pitot_angle_deg = 5.0
self.addPitotTube(root, 5.0)
contact_tag = root.find('./ground_reactions/contact')
contact_tag.attrib['type'] = 'STRUCTURE'
tree.write(self.sandbox('aircraft', aircraft_name,
aircraft_name+'.xml'))
fdm = CreateFDM(self.sandbox)
fdm.set_aircraft_path('aircraft')
fdm.load_model('ball')
pitot_angle = pitot_angle_deg * math.pi / 180.
weight = fdm['inertia/weight-lbs']
spring_tag = contact_tag.find('./spring_coeff')
spring_coeff = float(spring_tag.text)
print "Weight=%d Spring=%d" % (weight, spring_coeff)
fdm['ic/h-sl-ft'] = weight / spring_coeff
fdm['forces/hold-down'] = 1.0
fdm.run_ic()
ExecuteUntil(fdm, 10.)
for i in xrange(36):
for j in xrange(-9, 10):
angle = math.pi * i / 18.0
angle2 = math.pi * j / 18.0
ca2 = math.cos(angle2)
fdm['atmosphere/wind-north-fps'] = 10. * math.cos(angle) * ca2
fdm['atmosphere/wind-east-fps'] = 10. * math.sin(angle) * ca2
fdm['atmosphere/wind-down-fps'] = 10. * math.sin(angle2)
fdm.run()
vg = fdm['velocities/vg-fps']
self.assertAlmostEqual(vg, 0.0, delta=1E-7)
vt = fdm['velocities/vt-fps']
self.assertAlmostEqual(vt, 10., delta=1E-7)
mach = vt / fdm['atmosphere/a-fps']
P = fdm['atmosphere/P-psf']
pt = P * math.pow(1+0.2*mach*mach, 3.5)
psl = fdm['atmosphere/P-sl-psf']
rhosl = fdm['atmosphere/rho-sl-slugs_ft3']
A = math.pow((pt-P)/psl+1.0, 1.0/3.5)
alpha = fdm['aero/alpha-rad']
beta = fdm['aero/beta-rad']
vc = math.sqrt(7.0*psl/rhosl*(A-1.0))*math.cos(alpha+pitot_angle)*math.cos(beta)
self.assertAlmostEqual(fdm['velocities/vc-kts'],
max(0.0, vc) / 1.68781, delta=1E-7)
示例10: test_initial_latitude
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def test_initial_latitude(self):
Output_file = self.sandbox.path_to_jsbsim_file('tests', 'output.xml')
GEODETIC, ELEVATION, ALTITUDE = (1, 2, 4)
for v in ('', '_v2'):
IC_file = self.sandbox.path_to_jsbsim_file('aircraft', 'ball',
'reset00'+v+'.xml')
for i in xrange(8):
for latitude_pos in xrange(4):
IC_tree = et.parse(IC_file)
IC_root = IC_tree.getroot()
if v:
position_tag = IC_root.find('position')
latitude_tag = et.SubElement(position_tag, 'latitude')
latitude_tag.attrib['unit'] = 'DEG'
else:
position_tag = IC_root
latitude_tag = IC_root.find('latitude')
latitude_tag.text = str(latitude_pos*30.)
if i & GEODETIC:
latitude_tag.attrib['type'] = 'geod'
if i & ELEVATION:
elevation_tag = et.SubElement(IC_root, 'elevation')
elevation_tag.text = '1000.'
if i & ALTITUDE:
if v:
altitude_tag = position_tag.find('altitudeMSL')
altitude_tag.tag = 'altitudeAGL'
else:
altitude_tag = position_tag.find('altitude')
altitude_tag.tag = 'altitudeMSL'
IC_tree.write('IC.xml')
fdm = CreateFDM(self.sandbox)
fdm.load_model('ball')
fdm.set_output_directive(Output_file)
fdm.set_output_filename(1, 'check_csv_values.csv')
fdm.load_ic('IC.xml', False)
fdm.run_ic()
self.CheckICValues(self.GetVariables(latitude_tag),
'IC%d' % (i,), fdm, position_tag)
del fdm
示例11: testKinematicSetInitialValue
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def testKinematicSetInitialValue(self):
fdm = CreateFDM(self.sandbox)
fdm.load_model('p51d')
fdm.load_ic(self.sandbox.path_to_jsbsim_file('aircraft', 'p51d',
'reset01'), False)
fdm.run_ic()
fdm['gear/gear-cmd-norm'] = 0.5
fdm['gear/gear-pos-norm'] = 0.5
while fdm['simulation/sim-time-sec'] < 1.0:
fdm.run()
self.assertAlmostEqual(fdm['gear/gear-cmd-norm'], 0.5)
self.assertAlmostEqual(fdm['gear/gear-pos-norm'], 0.5)
示例12: test_static_hold_down
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def test_static_hold_down(self):
fdm = CreateFDM(self.sandbox)
fdm.load_model('J246')
aircraft_path = self.sandbox.path_to_jsbsim_file('aircraft')
fdm.load_ic(os.path.join(aircraft_path, 'J246', 'LC39'), False)
fdm['forces/hold-down'] = 1.0
fdm.run_ic()
h0 = fdm['position/h-sl-ft']
t = 0.0
while t < 420.0:
fdm.run()
t = fdm['simulation/sim-time-sec']
self.assertAlmostEqual(fdm['position/h-sl-ft'], h0, delta=1E-5)
示例13: testAircrafts
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def testAircrafts(self):
aircraft_path = self.sandbox.path_to_jsbsim_file('aircraft')
for d in os.listdir(aircraft_path):
fullpath = os.path.join(aircraft_path, d)
# Is d a directory ?
if not os.path.isdir(fullpath):
continue
f = os.path.join(aircraft_path, d, d+'.xml')
# Is f an aircraft definition file ?
if not CheckXMLFile(f, 'fdm_config'):
continue
if d in ('blank'):
continue
fdm = CreateFDM(self.sandbox)
self.assertTrue(fdm.load_model(d),
msg='Failed to load aircraft %s' % (d,))
for f in os.listdir(fullpath):
f = os.path.join(aircraft_path, d, f)
if CheckXMLFile(f, 'initialize'):
self.assertTrue(fdm.load_ic(f, False),
msg='Failed to load IC %s for aircraft %s' % (f, d))
try:
fdm.run_ic()
except RuntimeError:
self.fail('Failed to run IC %s for aircraft %s' % (f, d))
del fdm
示例14: test_property_catalog
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def test_property_catalog(self):
fdm = CreateFDM(self.sandbox)
fdm.load_model('ball')
fdm.run_ic()
catalog = fdm.query_property_catalog('geod-deg')
self.assertEqual(len(catalog), 2)
self.assertEqual(catalog[0], 'position/lat-geod-deg (R)')
self.assertEqual(catalog[1], 'ic/lat-geod-deg (RW)')
values = fdm.get_property_catalog('geod-deg')
item = 'position/lat-geod-deg'
self.assertEqual(values[item], fdm[item])
item = 'ic/lat-geod-deg'
self.assertEqual(values[item], fdm[item])
del fdm
示例15: test_direct_steer
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import load_model [as 别名]
def test_direct_steer(self):
fdm = CreateFDM(self.sandbox)
fdm.load_model('c172r')
aircraft_path = self.sandbox.path_to_jsbsim_file('aircraft')
fdm.load_ic(os.path.join(aircraft_path, 'c172r', 'reset00'), False)
fdm.run_ic()
self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], 0.0)
self.assertAlmostEqual(fdm['fcs/steer-pos-deg'], 0.0)
fdm['fcs/steer-pos-deg'] = 5.0
self.assertAlmostEqual(fdm['fcs/steer-pos-deg'], 5.0)
fdm.run()
self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], 0.0)
fdm['fcs/steer-cmd-norm'] = 1.0
self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], 1.0)
fdm.run()
self.assertAlmostEqual(fdm['fcs/steer-cmd-norm'], 1.0)
self.assertAlmostEqual(fdm['fcs/steer-pos-deg'], 10.0)