Skip to content

Commit

Permalink
Add negated_crossproduct_inertia to models with cross product inertia.
Browse files Browse the repository at this point in the history
Folowing the PR JSBSim-Team#502, JSBSim now allows to specify how the sign of cross product inertia is interpreted. In order to educate users to this new parameter, all the aircraft models with cross product inertia are updated with the new parameter `negated_crossproduct_inertia` set to `true` (which is the default).
  • Loading branch information
bcoconni committed Nov 6, 2021
1 parent a128d9f commit 9a1b7db
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 15 deletions.
59 changes: 59 additions & 0 deletions admin/XML_mass_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/python
#
# This script adds the attribute `negated_crossproduct_inertia="true"` to
# all the aircraft models of JSBSim that have at least one non zero cross
# product inertia.

import os
import xml.etree.ElementTree as et

def CheckXMLFile(f, header):
# Is f an XML file ?
try:
tree = et.parse(f)
except et.ParseError:
return False

# Check the file header
return tree.getroot().tag.upper() == header.upper()

def recursive_scan_XML(dir_name, header):
for d in os.scandir(dir_name):
if d.is_file():
fname = os.path.join(dir_name,d.name)
if CheckXMLFile(fname, header):
yield fname
continue
if d.is_dir():
for f in recursive_scan_XML(os.path.join(dir_name, d.name), header):
yield f

shift = len('mass_balance')
for fname in recursive_scan_XML('.', 'fdm_config'):
tree = et.parse(fname)
mass_balance_tag = tree.getroot().find('./mass_balance')
if mass_balance_tag is None:
continue

# Check if there is a non zero cross product inertia
ixy_tag = mass_balance_tag.find('ixy')
if ixy_tag is None or float(ixy_tag.text) == 0.0:
ixz_tag = mass_balance_tag.find('ixz')
if ixz_tag is None or float(ixz_tag.text) == 0.0:
iyz_tag = mass_balance_tag.find('iyz')
if iyz_tag is None or float(iyz_tag.text) == 0.0:
continue

with open(fname, 'r') as f:
lines = f.readlines()

for i, l in enumerate(lines):
index = l.find('mass_balance')
if index == -1:
continue
index += shift
lines[i] = l[:index]+' negated_crossproduct_inertia="true"'+l[index:]
break

with open(fname, 'w') as f:
f.writelines(lines)
2 changes: 1 addition & 1 deletion aircraft/737/737.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 562000 </ixx>
<iyy unit="SLUG*FT2"> 1.473e+06 </iyy>
<izz unit="SLUG*FT2"> 1.894e+06 </izz>
Expand Down
2 changes: 1 addition & 1 deletion aircraft/A320/A320.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 942877 </ixx>
<iyy unit="SLUG*FT2"> 2.78892e+06 </iyy>
<izz unit="SLUG*FT2"> 3.59757e+06 </izz>
Expand Down
2 changes: 1 addition & 1 deletion aircraft/B747/B747.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 1.82e+07 </ixx>
<iyy unit="SLUG*FT2"> 3.31e+07 </iyy>
<izz unit="SLUG*FT2"> 4.97e+07 </izz>
Expand Down
2 changes: 1 addition & 1 deletion aircraft/DHC6/DHC6.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 19317 </ixx>
<iyy unit="SLUG*FT2"> 24679 </iyy>
<izz unit="SLUG*FT2"> 35344 </izz>
Expand Down
2 changes: 1 addition & 1 deletion aircraft/SGS/SGS.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 1015 </ixx>
<iyy unit="SLUG*FT2"> 672 </iyy>
<izz unit="SLUG*FT2"> 1663 </izz>
Expand Down
2 changes: 1 addition & 1 deletion aircraft/Shuttle/Shuttle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 953159 </ixx>
<iyy unit="SLUG*FT2"> 7.46508e+06 </iyy>
<izz unit="SLUG*FT2"> 7.74758e+06 </izz>
Expand Down
2 changes: 1 addition & 1 deletion aircraft/X15/X15.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 3650 </ixx>
<iyy unit="SLUG*FT2"> 80000 </iyy>
<izz unit="SLUG*FT2"> 82000 </izz>
Expand Down
2 changes: 1 addition & 1 deletion aircraft/XB-70/XB-70.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 1.34e+06 </ixx>
<iyy unit="SLUG*FT2"> 1.6e+07 </iyy>
<izz unit="SLUG*FT2"> 1.68e+07 </izz>
Expand Down
2 changes: 1 addition & 1 deletion aircraft/f15/f15.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 28700 </ixx>
<iyy unit="SLUG*FT2"> 165100 </iyy>
<izz unit="SLUG*FT2"> 187900 </izz>
Expand Down
2 changes: 1 addition & 1 deletion aircraft/f16/f16.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 9496 </ixx>
<iyy unit="SLUG*FT2"> 55814 </iyy>
<izz unit="SLUG*FT2"> 63100 </izz>
Expand Down
2 changes: 1 addition & 1 deletion aircraft/f22/f22.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 56005 </ixx>
<iyy unit="SLUG*FT2"> 280766 </iyy>
<izz unit="SLUG*FT2"> 354090 </izz>
Expand Down
2 changes: 1 addition & 1 deletion aircraft/f22/yf22.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 40843 </ixx>
<iyy unit="SLUG*FT2"> 204751 </iyy>
<izz unit="SLUG*FT2"> 258201 </izz>
Expand Down
2 changes: 1 addition & 1 deletion aircraft/minisgs/minisgs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 0.4752 </ixx>
<iyy unit="SLUG*FT2"> 0.3147 </iyy>
<izz unit="SLUG*FT2"> 0.7785 </izz>
Expand Down
2 changes: 1 addition & 1 deletion aircraft/t6texan2/t6texan2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 4216.3 </ixx>
<iyy unit="SLUG*FT2"> 7608 </iyy>
<izz unit="SLUG*FT2"> 10355 </izz>
Expand Down
2 changes: 1 addition & 1 deletion aircraft/x24b/x24b.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</location>
</metrics>

<mass_balance>
<mass_balance negated_crossproduct_inertia="true">
<ixx unit="SLUG*FT2"> 2650 </ixx>
<iyy unit="SLUG*FT2"> 23710 </iyy>
<izz unit="SLUG*FT2"> 24120 </izz>
Expand Down

0 comments on commit 9a1b7db

Please sign in to comment.