-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AeromatiC++ Segmentation fault #400
Comments
I took a closer look at the code and found that the offending lines are the two commented out lines in the file void Propulsion::param_reset()
{
_param = 0;
// _propulsion[_ptype]->param_reset();
// _propulsion[_ptype]->_thruster->param_reset();
} With this modification, I can get the program to run without crashing. Is this the right thing to do, please? |
@kwanzapili thanks for reporting the issue. Aeromatic++ is Erik Hofman's area of expertise. @ermarch could you please review this issue and @kwanzapili's fix ? |
Personally I think _propulsion[_ptype]->_thruster is NULL somehow and causes the segmentation fault. |
Okay, I can only trigger this when I select an aircraft type number which is not listed. |
For me the effect was very consistent regardless of the parameters I entered. For reference, by session was as follows:
|
I've got valgrind reporting an error when entering those numbers, so no doubt it will get triggered by other input as well. |
Use std::vector where possible, check whether parameters are out of bounds. This fixes issue #400
Incidentally, the program also produces some curious output for "Drag due to alpha", which leads to the simulator crashing/ I got the following: <function name="aero/force/Drag_alpha">
<description>Drag due to alpha</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<table>
<independentVar lookup="row">aero/alpha-rad</independentVar>
<tableData>
-1.57 1.4082
-1.72 0.0246
0.00 0.0000
1.72 0.0246
1.57 1.4082
</tableData>
</table>
</product>
</function> Clearing the 1.72 and 1.57 are not is the proper sequence. Looking at some other configurations, I was tempted to infer that the -+1.72 should be closer to -+1.26, but I have no real estimate for this. Am I mistaken here? |
Yes, that shouldn't have happened. So far I´ve not seen it with any of my test models but the SR-71 is rather extreme in every way. Is there a chance you could run aeromatic again with the option "-l sr71.param" and post the param file? This also comes handy when you want to rerun with a new version of aeromatic because you can then run "aeromatic -i sr71.param" |
So I have run "aeromatic -l sr71.param" to get the following output. Please note that I am using AeromatiC++ version 3.3.12 without the commits you have made, but with the two lines I mentioned before commented out. So the aero file is this: <?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="http://jsbsim.sourceforge.net/JSBSim.xsl"?>
<fdm_config name="SR71" version="2.0" release="ALPHA"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://jsbsim.sourceforge.net/JSBSim.xsd">
<fileheader>
<author> Aeromatic v 3.3.12 </author>
<filecreationdate> 24 Mar 2021 </filecreationdate>
<version>$Revision: 1.80 $</version>
<description> Models a SR71. </description>
</fileheader>
<!--
File: SR71.xml
Inputs:
name: SR71
type: Multi-engine Fighter Jet
stall speed: unspecified
max weight: 172000.00 lb
length: 107.42 ft
wing:
span: 55.58 ft
area: 1795.00 sq-ft
mean chord: 60.53 ft
aspect ratio: 1.94:1
taper ratio: 1.00:1
incidence: 2.00 degrees
dihedral: 0.00 degrees
sweep: 52.63 degrees
no. engines: 2
engine type: Turbine Engine
engine layout: wings
control type: Conventional with Yaw Damper
gear type: tricycle
steering type: steering
retractable?: yes
Outputs:
wing loading: 95.82 lb/sq-ft
- thickness ratio: 15.00%
payload: 68896.00 lbs
CL-alpha: 0.54 per radian
CL-0: 0.08
CL-max: 1.00
CD-0: 0.01
K: 0.12
Mcrit: 0.81
min. turn radius -nan ft
max. turn rate: -nan deg/s
-->
<metrics>
<wingarea unit="FT2"> 1795.00 </wingarea>
<wingspan unit="FT" > 55.58 </wingspan>
<wing_incidence unit="DEG"> 2.00 </wing_incidence>
<chord unit="FT" > 60.53 </chord>
<htailarea unit="FT2"> 359.00 </htailarea>
<htailarm unit="FT" > 42.97 </htailarm>
<vtailarea unit="FT2"> 150.76 </vtailarea>
<vtailarm unit="FT" > 42.97 </vtailarm>
<location name="AERORP" unit="IN">
<x> 773.40 </x>
<y> 0.00 </y>
<z> 0.00 </z>
</location>
<location name="EYEPOINT" unit="IN">
<x> 257.80 </x>
<y> 0.00 </y>
<z> 38.00 </z>
</location>
<location name="VRP" unit="IN">
<x> 0.0 </x>
<y> 0.0 </y>
<z> 0.0 </z>
</location>
</metrics>
<mass_balance>
<ixx unit="SLUG*FT2"> 136167.34 </ixx>
<iyy unit="SLUG*FT2"> 699019.12 </iyy>
<izz unit="SLUG*FT2"> 585154.88 </izz>
<emptywt unit="LBS" > 67500.00 </emptywt>
<location name="CG" unit="IN">
<x> 811.67 </x>
<y> 0.00 </y>
<z> -32.22 </z>
</location>
<pointmass name="Payload">
<description> 68896.00 LBS should bring model up to entered max weight </description>
<weight unit="LBS"> 34448.00 </weight>
<location name="POINTMASS" unit="IN">
<x> 811.67 </x>
<y> 0.00 </y>
<z> -32.22 </z>
</location>
</pointmass>
</mass_balance>
<propulsion>
<engine file="J58">
<location unit="IN">
<x> 811.67 </x>
<y> -111.17 </y>
<z> -40.00 </z>
</location>
<orient unit="DEG">
<pitch> 0.00 </pitch>
<roll> -0.00 </roll>
<yaw> 0.00 </yaw>
</orient>
<feed> 0 </feed>
<thruster file="direct">
<sense> 1 </sense>
<location unit="IN">
<x> 811.67 </x>
<y> -111.17 </y>
<z> -40.00 </z>
</location>
<orient unit="DEG">
<pitch> 0.00 </pitch>
<roll> 0.00 </roll>
<yaw> 0.00 </yaw>
</orient>
</thruster>
</engine>
<engine file="J58">
<location unit="IN">
<x> 811.67 </x>
<y> 111.17 </y>
<z> -40.00 </z>
</location>
<orient unit="DEG">
<pitch> 0.00 </pitch>
<roll> -0.00 </roll>
<yaw> 0.00 </yaw>
</orient>
<feed> 1 </feed>
<thruster file="direct">
<sense> 1 </sense>
<location unit="IN">
<x> 811.67 </x>
<y> 111.17 </y>
<z> -40.00 </z>
</location>
<orient unit="DEG">
<pitch> 0.00 </pitch>
<roll> 0.00 </roll>
<yaw> 0.00 </yaw>
</orient>
</thruster>
</engine>
<tank type="FUEL" number="0">
<location unit="IN">
<x> 811.67 </x>
<y> 0.00 </y>
<z> -32.22 </z>
</location>
<capacity unit="LBS"> 11868.00 </capacity>
<contents unit="LBS"> 5934.00 </contents>
</tank>
<tank type="FUEL" number="1">
<location unit="IN">
<x> 811.67 </x>
<y> 0.00 </y>
<z> -32.22 </z>
</location>
<capacity unit="LBS"> 11868.00 </capacity>
<contents unit="LBS"> 5934.00 </contents>
</tank>
<tank type="FUEL" number="2">
<location unit="IN">
<x> 811.67 </x>
<y> 0.00 </y>
<z> -32.22 </z>
</location>
<capacity unit="LBS"> 11868.00 </capacity>
<contents unit="LBS"> 5934.00 </contents>
</tank>
</propulsion>
<ground_reactions>
<contact type="BOGEY" name="NOSE">
<location unit="IN">
<x> 167.57 </x>
<y> 0.00 </y>
<z> -154.68 </z>
</location>
<static_friction> 0.80 </static_friction>
<dynamic_friction> 0.50 </dynamic_friction>
<rolling_friction> 0.02 </rolling_friction>
<spring_coeff unit="LBS/FT"> 51600.00 </spring_coeff>
<damping_coeff unit="LBS/FT/SEC"> 25800.00 </damping_coeff>
<max_steer unit="DEG"> 5.00 </max_steer>
<brake_group> NONE </brake_group>
<retractable> 1 </retractable>
</contact>
<contact type="BOGEY" name="LEFT_MAIN">
<location unit="IN">
<x> 844.13 </x>
<y> -60.03 </y>
<z> -154.68 </z>
</location>
<static_friction> 0.80 </static_friction>
<dynamic_friction> 0.50 </dynamic_friction>
<rolling_friction> 0.02 </rolling_friction>
<spring_coeff unit="LBS/FT"> 172000.00 </spring_coeff>
<damping_coeff unit="LBS/FT/SEC"> 86000.00 </damping_coeff>
<max_steer unit="DEG">0</max_steer>
<brake_group> LEFT </brake_group>
<retractable> 1 </retractable>
</contact>
<contact type="BOGEY" name="RIGHT_MAIN">
<location unit="IN">
<x> 844.13 </x>
<y> 60.03 </y>
<z> -154.68 </z>
</location>
<static_friction> 0.80 </static_friction>
<dynamic_friction> 0.50 </dynamic_friction>
<rolling_friction> 0.02 </rolling_friction>
<spring_coeff unit="LBS/FT"> 172000.00 </spring_coeff>
<damping_coeff unit="LBS/FT/SEC"> 86000.00 </damping_coeff>
<max_steer unit="DEG">0</max_steer>
<brake_group> RIGHT </brake_group>
<retractable> 1 </retractable>
</contact>
<contact type="STRUCTURE" name="LEFT_WING">
<location unit="IN">
<x> 811.67 </x>
<y> -333.50 </y>
<z> -32.22 </z>
</location>
<static_friction> 1 </static_friction>
<dynamic_friction> 1 </dynamic_friction>
<spring_coeff unit="LBS/FT"> 172000.00 </spring_coeff>
<damping_coeff unit="LBS/FT/SEC"> 172000.00 </damping_coeff>
</contact>
<contact type="STRUCTURE" name="RIGHT_WING">
<location unit="IN">
<x> 811.67 </x>
<y> 333.50 </y>
<z> -32.22 </z>
</location>
<static_friction> 1 </static_friction>
<dynamic_friction> 1 </dynamic_friction>
<spring_coeff unit="LBS/FT"> 172000.00 </spring_coeff>
<damping_coeff unit="LBS/FT/SEC"> 172000.00 </damping_coeff>
</contact>
</ground_reactions>
<system file="Propulsion.xml"/>
<system file="Aircraft control.xml"/>
<system file="Landing Gear.xml"/>
<system file="Drag Chute.xml"/>
<flight_control name="FCS: SR71">
</flight_control>
<aerodynamics>
<axis name="LIFT">
<!-- Lift above 0.85 and below -0.85 is generalised -->
<function name="aero/force/Lift_alpha">
<description>Lift due to alpha</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<table>
<independentVar lookup="row">aero/alpha-rad</independentVar>
<tableData>
-1.57 0.0000
-1.22 -0.5464
-1.05 -0.7361
-0.88 -0.8500
-0.75 -0.3680
-1.86 -0.9200
0.00 0.0800
1.72 1.0000
0.60 0.4480
0.88 1.1500
1.05 0.9959
1.22 0.7392
1.57 0.0000
</tableData>
</table>
</product>
</function>
<function name="aero/force/Lift_pitch_rate">
<description>Lift due to pitch rate</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>velocities/q-aero-rad_sec</property>
<property>aero/ci2vel</property>
<value> 1.1738 </value>
</product>
</function>
<function name="aero/force/Lift_alpha_rate">
<description>Lift due to alpha rate</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>aero/alphadot-rad_sec</property>
<property>aero/ci2vel</property>
<value> 1.1920 </value>
</product>
</function>
<function name="aero/force/Lift_elevator">
<description>Lift due to Elevator Deflection</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>fcs/elevator-pos-rad</property>
<value> 0.5364 </value>
</product>
</function>
</axis>
<axis name="DRAG">
<!-- CD0 is based on fuselage, wing, horizontal- en vertical tail -->
<!-- Antennas, struts and wires are not taken into account -->
<!-- CD for gear (fixed and retractable) is defined below -->
<function name="aero/force/Drag_minimum">
<description>Minimum drag</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<value> 0.0104 </value>
</product>
</function>
<function name="aero/force/Drag_alpha">
<description>Drag due to alpha</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<table>
<independentVar lookup="row">aero/alpha-rad</independentVar>
<tableData>
-1.57 1.4082
-1.72 0.0246
0.00 0.0000
1.72 0.0246
1.57 1.4082
</tableData>
</table>
</product>
</function>
<function name="aero/force/Drag_induced">
<description>Induced drag</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>aero/cl-squared</property>
<value> 0.1674 </value>
</product>
</function>
<function name="aero/force/Drag_mach">
<description>Drag due to mach</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<table>
<independentVar lookup="row">velocities/mach</independentVar>
<tableData>
0.00 0.0000
0.81 0.0000
1.10 0.0230
1.80 0.0150
</tableData>
</table>
</product>
</function>
<function name="aero/force/Drag_beta">
<description>Drag due to sideslip</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<table>
<independentVar lookup="row">aero/beta-rad</independentVar>
<tableData>
-1.57 1.2300
-0.26 0.0500
0.00 0.0000
0.26 0.0500
1.57 1.2300
</tableData>
</table>
</product>
</function>
<function name="aero/force/Drag_elevator">
<description>Drag due to Elevator Deflection</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<abs><property>fcs/elevator-pos-rad</property></abs>
<value> 0.0400 </value>
</product>
</function>
<function name="aero/force/Drag_gear">
<description>Drag due to gear</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>gear/gear-pos-norm</property>
<value> 0.0200 </value>
</product>
</function>
</axis>
<axis name="SIDE">
<function name="aero/force/Side_beta">
<description>Side force due to beta</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>aero/beta-rad</property>
<value> -0.3963 </value>
</product>
</function>
<function name="aero/force/Side_roll_rate">
<description>Side force due to roll rate</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>aero/bi2vel</property>
<property>velocities/p-aero-rad_sec</property>
<value> 0.001500 </value>
</product>
</function>
<function name="aero/force/Side_yaw_rate">
<description>Side force due to yaw rate</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>aero/bi2vel</property>
<property>velocities/r-aero-rad_sec</property>
<value> 0.6127 </value>
</product>
</function>
<function name="aero/force/Side_rudder">
<description>Side force due to rudder</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>fcs/rudder-pos-rad</property>
<value> 0.1181 </value>
</product>
</function>
</axis>
<axis name="PITCH">
<function name="aero/moment/Pitch_alpha">
<description>Pitch moment due to alpha</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>metrics/cbarw-ft</property>
<property>aero/alpha-rad</property>
<value> -0.0246 </value>
</product>
</function>
<function name="aero/moment/Pitch_elevator">
<description>Pitch moment due to elevator</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>metrics/cbarw-ft</property>
<property>fcs/elevator-pos-rad</property>
<table>
<independentVar lookup="row">velocities/mach</independentVar>
<tableData>
0.0 -0.3415
2.0 -0.0854
</tableData>
</table>
</product>
</function>
<function name="aero/moment/Pitch_damp">
<description>Pitch moment due to pitch rate</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>metrics/cbarw-ft</property>
<property>aero/ci2vel</property>
<property>velocities/q-aero-rad_sec</property>
<value> -0.8332 </value>
</product>
</function>
<function name="aero/moment/Pitch_alphadot">
<description>Pitch moment due to alpha rate</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>metrics/cbarw-ft</property>
<property>aero/ci2vel</property>
<property>aero/alphadot-rad_sec</property>
<value> -0.8461 </value>
</product>
</function>
</axis>
<axis name="ROLL">
<function name="aero/moment/Roll_beta">
<description>Roll moment due to beta</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>metrics/bw-ft</property>
<property>aero/beta-rad</property>
<property>fcs/gear-no-wow</property>
<value> -0.066188 </value>
</product>
</function>
<function name="aero/moment/Roll_damp">
<description>Roll moment due to roll rate</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>metrics/bw-ft</property>
<property>aero/bi2vel</property>
<property>velocities/p-aero-rad_sec</property>
<value> 0.0825 </value>
</product>
</function>
<function name="aero/moment/Roll_yaw">
<description>Roll moment due to yaw rate</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>metrics/bw-ft</property>
<property>aero/bi2vel</property>
<property>velocities/r-aero-rad_sec</property>
<value> 0.004297 </value>
</product>
</function>
<function name="aero/moment/Roll_aileron">
<description>Roll moment due to aileron</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>metrics/bw-ft</property>
<property>fcs/left-aileron-pos-rad</property>
<table>
<independentVar lookup="row">velocities/mach</independentVar>
<tableData>
0.0 0.1200
2.0 0.0300
</tableData>
</table>
</product>
</function>
<function name="aero/moment/Roll_rudder">
<description>Roll moment due to rudder</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>metrics/bw-ft</property>
<property>fcs/rudder-pos-rad</property>
<value> 0.0100 </value>
</product>
</function>
</axis>
<axis name="YAW">
<function name="aero/moment/Yaw_beta">
<description>Yaw moment due to beta</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>metrics/bw-ft</property>
<property>aero/beta-rad</property>
<value> 0.147207 </value>
</product>
</function>
<function name="aero/moment/Yaw_roll_rate">
<description>Yaw moment due to roll rate</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>metrics/bw-ft</property>
<property>aero/bi2vel</property>
<property>velocities/p-rad_sec</property>
<value> -0.001159 </value>
</product>
</function>
<function name="aero/moment/Yaw_damp">
<description>Yaw moment due to yaw rate</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>metrics/bw-ft</property>
<property>aero/bi2vel</property>
<property>velocities/r-aero-rad_sec</property>
<value> -0.229859 </value>
</product>
</function>
<function name="aero/moment/Yaw_rudder">
<description>Yaw moment due to rudder</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>metrics/bw-ft</property>
<property>fcs/rudder-pos-rad</property>
<value> -0.0913172 </value>
</product>
</function>
<function name="aero/moment/Yaw_aileron">
<description>Adverse yaw</description>
<product>
<property>aero/qbar-psf</property>
<property>metrics/Sw-sqft</property>
<property>metrics/bw-ft</property>
<property>fcs/left-aileron-pos-rad</property>
<value> 0 </value>
</product>
</function>
</axis>
</aerodynamics>
<external_reactions>
<property value="0">systems/chute/chute-reef-pos-norm</property>
<property value="0">systems/chute/chute-size-factor</property>
<force name="chute" frame="WIND">
<function>
<product>
<property>aero/qbar-psf</property>
<property>systems/chute/chute-reef-pos-norm</property>
<property>systems/chute/chute-size-factor</property>
<value> 0.9 </value>
<value> 115 </value>
</product>
</function>
<location unit="FT">
<x> 97.7492 </x>
<y> 0 </y>
<z> 0 </z>
</location>
<direction>
<x>-1 </x>
<y> 0 </y>
<z> 0 </z>
</direction>
</force>
</external_reactions>
</fdm_config>
|
Oh I was hoping to get the created sr71.param file so I could reproduce your inputs locally. |
I am sorry I misunderstood you completely. I didn't even realise that Aeromatic created this file until looked for it. Here it is.
|
Great, thanks. |
The problem comes from calculating CLalpha for delta-wings. And I think the real problem is the fact that vortex lift is not taken into account. |
Fix a delta-wing Lift_alpha and Drag_alpha problem where the values of alpha increase improperly. (issue #400) Fix a bug introduced by the previous pull request. Convert more code to C++11
A new fix (commit 375f5be) has been pushed to |
Use std::vector where possible, check whether parameters are out of bounds. This fixes issue #400
Fix a delta-wing Lift_alpha and Drag_alpha problem where the values of alpha increase improperly. (issue #400) Fix a bug introduced by the previous pull request. Convert more code to C++11
Thanks a lot. I revised the configuration and tested. My first observation was this key changes in the parameters:
|
@kwanzapili Thanks for the bug report and testing ! Issues are dedicated to bug reports and feature requests: if you confirm that the bug you initially reported is now fixed then I suggest this issue should be closed and that the discussion should continue in JSBSim Discussions. Thanks. |
Sure, thanks a lot for fixing the problem. |
I downloaded jsbsim-1.1.5 and built on an opensuse linux platform so that I could run aeromatic. The consistent problem I am facing is a segmentation fault at the same step every time I run it. I go through the Q/A session and as soon as I enter "Systems", it fails. The last few of the session are as follows:
A brief look at the backtrace shows that it fails at:
Could someone please advise on what is going on?
Thanks.
The text was updated successfully, but these errors were encountered: