├── LicenseAgreement.pdf ├── README.md └── gtm_design ├── LicenseAgreement.pdf ├── config ├── AC_baseparams_T2.m ├── AC_calcparams_T2.m ├── Cal_params_T2.m ├── DamageModels_T2.m ├── GTMtiny.png ├── NoiseParams_T2.m ├── T2_polynomial_aerodatabase.mat └── init_turbulence.m ├── docs ├── example_plots.pdf ├── gtm_design_DamageDescriptions.doc ├── gtm_design_FAQ.doc ├── gtm_design_GlobalTags.xls ├── gtm_design_QuickStart.doc ├── gtm_design_Reference.doc └── src │ ├── example_plots.tex │ ├── gtm_design_AeroTable.xls │ └── gtm_design_ModelWorkspace.xls ├── example1.m ├── example2.m ├── example3.m ├── example4.m ├── example5.m ├── example6.m ├── gtm_design.slx ├── libs └── UserContent_lib.mdl ├── mfiles ├── CreateSimOut.m ├── appendmws.m ├── clearmws.m ├── euler321.m ├── grabmws.m ├── init_design.m ├── linmodel.m ├── loadmws.m ├── seteomic.m └── trimgtm.m ├── obj ├── RT_mex.mexa64 ├── RT_mex.mexmaci64 ├── RT_mex.mexw64 ├── SimulinkToXPlane.mexa64 ├── SimulinkToXPlane.mexmaci64 ├── SimulinkToXPlane.mexw64 ├── gear_sfcn.mexa64 ├── gear_sfcn.mexmaci64 └── gear_sfcn.mexw64 ├── setup.m └── utils └── Xlink ├── Plugin └── Xlink │ ├── lin.xpl │ ├── mac.xpl │ └── win.xpl ├── Readme.txt └── img └── Speed-Bird_paint_modified.png /LicenseAgreement.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/LicenseAgreement.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #GTM_DesignSim: The Generic Transport Model 2 | 3 | The GTM_DesignSim is a batch simulation intended for design and analysis of flight control laws. It models the 4 | dynamics of a 5.5% scale model of a generic transport aircraft. It was developed to allow fault accomodating control 5 | algorithms to be developed and refined in simulation before being tested on an experimental subscale model. 6 | 7 | See: 8 | 9 | Cunningham, K., Cox, D. E., Murri, D. G., and Riddick, S. E., *“A Piloted Evaluation of Damage Accommodating Flight Control Using a Remotely Piloted Vehicle,”* **AIAA-2011-6451**, AIAA Guidance, Navigation, and Control Conference and Exhibit, Portland Oregon, August 2011." 10 | 11 | and the references therein for a summary of the research. 12 | 13 | The simulation, however, was released as open-source and has been found useful in many other applications where a 14 | non-linear large-envelope flight dynamics simulation is required. 15 | 16 | -------------------------------------------------------------------------------- /gtm_design/LicenseAgreement.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/LicenseAgreement.pdf -------------------------------------------------------------------------------- /gtm_design/config/AC_baseparams_T2.m: -------------------------------------------------------------------------------- 1 | function [MWS] = AC_baseparams_T2(MWS) 2 | % Common (AirSTARsim and gtm_design) Aircraft parameters for T2 3 | % $Id: AC_baseparams_T2.m 4852 2013-08-06 22:12:54Z cox $ 4 | 5 | 6 | % All geometry data is in the Aircraft Reference System (ARS). The datum 7 | % (origin) of this system is 8.745" forward of the nose, on the centerline, 8 | % and 16.86" below the top of the fuselage (between MS 25" and MS 66.6"). 9 | % The X-axis of the ARS is positive forwards, the Y-axis is positive out 10 | % the right wing, and the Z-axis is positive downwards. 11 | 12 | % Mass & Geometry Properties 13 | MWS.w0 = 57.75; %lbs, initial gross weight 14 | 15 | % Inertias for full fuel weight (12lbs), gear up, relative to full fuel CG 16 | % (cg_pos0) 17 | % excel file: T2_Inertia_1-20-10.xls Ixx not measured, held over from previous deployment 18 | %Ixz, Iyz, Ixy not measured. They were obtained from Pro-E estimates. (Note 19 | %that Pro-E inertia tensor is output in -Ixz, -Iyz, -Ixy. In other words, 20 | %the list below is the negative of the Pro-E output of these variables. 21 | % 22 | Ixx0 = 1.221; % slg-ft^2, 23 | Iyy0 = 4.655; % slg-ft^2, 24 | Izz0 = 5.587; % slg-ft^2, 25 | Ixz0 = 0.274; % slg-ft^2, 26 | Iyz0 = 0.0; % slg-ft^2, 27 | Ixy0 = 0.006; % slg-ft^2, 28 | MWS.Inertia0 = [Ixx0 Iyy0 Izz0 Ixz0 Iyz0 Ixy0]; 29 | 30 | % Shift in CG and Inertia when gear are down 31 | MWS.cg_shift_gear = [-0.0025 0 0.0150]; % ft, shift in CG when gear are down, per G. Howland email 9/10/09 32 | MWS.Inertia_shift_gear = [0.0441 0 0.006994 0 0 0];% slg-ft^2, shift in inertias when gear are down, 33 | % per G. Howland email/excel file: T2_Inertia_9-4-09.xls 34 | 35 | % Polynomial coefficients for inertia variation of a single tank as a 36 | % function of fuel burn, relative to the tank centroid 37 | % Based on Pro-E estimates 38 | MWS.Ixx_model = [ 0.000015212259037 -0.000108396795757 0.001076938008733]; 39 | MWS.Iyy_model = [ 0.000032526556068 -0.000298176766717 0.002102173236731]; 40 | MWS.Izz_model = [-0.000019873124706 0.000212146005908 0.001301531989172]; 41 | 42 | % A/C Geometry Parameters 43 | MWS.S = 5.9018; % ft^2, reference wing area 44 | MWS.Cbar = 0.9153; % ft, mean aerodynamic chord 45 | MWS.b = 6.8488; % ft, wing span 46 | MWS.le_mac = 4.5462; % ft, leading edge of MAC 47 | MWS.cg_pos0 = [-(MWS.le_mac + MWS.Cbar*0.2199) -0.1416/12 -0.9761]; % ft, initial CG (21.99% MAC), gear up 48 | MWS.ref_cg = [-(MWS.le_mac + MWS.Cbar*0.25) 0 -0.9401]; %ft, reference CG: 25% MAC in ARS coordinates 49 | 50 | % Fuel Location and weight 51 | MWS.fwdfuel = 5.74; % lbs, initial fuel weight in foward tank 52 | MWS.aftfuel = 5.74; % lbs, initial fuel weight in aft tank 53 | MWS.fwdfuel_pos = [-53.43 0.00 -13.86]/12; % ft, foward fuel tank position 54 | MWS.aftfuel_pos = [-62.30 0.00 -13.86]/12; % ft, aft fuel tank position 55 | 56 | % Engine Position/Orientation 57 | MWS.engl_pos = [-51.903 -14.20 -7.71]/12; % ft, location of right engine, not part of 9/8/09 measurements 58 | MWS.engr_pos = [-51.903 14.20 -7.71]/12; % ft, location of left engine, not part of 9/8/09 measurements 59 | MWS.engl_ang = [ 0 1.98 2.22]; % deg, angluar offsets of left engine 60 | MWS.engr_ang = [ 0 1.95 -1.18]; % deg, angluar offsets of right engine 61 | 62 | % Landing Gear Parameters 63 | % Units ft, ft/sec and lbs 64 | MWS.LandingGear.NoseWheelPos = [-22.24, 0, -1.7]/12; 65 | MWS.LandingGear.LeftMainPos = [-61.31, -8.0, -2.64]/12; 66 | MWS.LandingGear.RightMainPos = [-61.31, 7.8, -2.64]/12; 67 | %MWS.LandingGear.SpringConst = [14 17.2 17.6]*12; 68 | MWS.LandingGear.SpringConst = [25 41.6 42.4]*12; 69 | MWS.LandingGear.DampingConst = [7 7 7]; 70 | MWS.LandingGear.MountStiff = [125 200 200]*12; 71 | MWS.LandingGear.MountDamping = [40 40 40]; 72 | MWS.LandingGear.StrokeLength = [0.82 1.25 1.25]/12; 73 | 74 | % Fuel State at t=0; 75 | MWS.FuelUsed_Init = 0; 76 | 77 | 78 | -------------------------------------------------------------------------------- /gtm_design/config/AC_calcparams_T2.m: -------------------------------------------------------------------------------- 1 | function [MWS] = AC_calcparams_T2(MWS) 2 | % Additional aircraft parameters for T2 3 | % Needed only in AirSTARsim, mostly calculated parameters 4 | %$Id: AC_calcparams_T2.m 4852 2013-08-06 22:12:54Z cox $ 5 | 6 | % Fuel parameters 7 | MWS.fuel_init = 11.52; % lbs, initial fuel weight 8 | MWS.joker_fuel = 4.7; % lbs, joker fuel (weight remaining) 9 | MWS.bingo_fuel = 4.2; % lbs, bingo fuel (weight remaining) 10 | MWS.time_init = 16; % min, initial fuel time 11 | MWS.joker_time = 3; % min, joker fuel (time remaining) 12 | MWS.bingo_time = 1.5; % min, bingo fuel (time remaining) 13 | 14 | % Filtering parameters 15 | MWS.tau_press = 0; % nd, filter time constant for pressures 16 | MWS.tau_rates = 0; % nd, filter time constant for angular rates 17 | MWS.tau_vanes = 0.1; % nd, filter time constant for alpha/beta vanes 18 | MWS.tau_accel = 0.1; % nd, filter time constant for accelerometers 19 | MWS.tau_display = 0.3; % nd, filter time constant for display variables 20 | 21 | 22 | % T2 Sensor Geometry: Measured, 7/8/10 23 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 24 | % Alpha offsets are geometric angle offsets plus nominal upwash correction. 25 | MWS.alphavl_offset = -0.7 - 0.55; %deg, boom angle offset plus upwash correction of left alpha vane, boom angled down = '+' correction 26 | MWS.alphavr_offset = -0.1 + 0.54; %deg, boom angle offset plus upwash correction of right alpha vane, boom angled down = '+' correction 27 | MWS.betavl_offset = -0.6 - 0.48; %deg, boom angle offset plus upwash correction of left beta vane, boom angled right/inwards = '+' correction 28 | MWS.betavr_offset = 0.0 + 0.68; %deg, boom angle offset plus upwash correction of right beta vane, boom angled right/outwards = '+' correction 29 | 30 | MWS.alphavl_pos = [-58.37 -42.35 -14.26]/12; % ft, location of left alpha vane 31 | MWS.alphavr_pos = [-58.32 42.40 -14.04]/12; % ft, location of right alpha vane 32 | MWS.betavl_pos = [-60.87 -40.93 -12.73]/12; % ft, location of left beta vane 33 | MWS.betavr_pos = [-60.82 40.88 -12.57]/12; % ft, location of right beta vane 34 | MWS.MIDG_pos = [-53.92 0.00 -10.73]/12; % ft, location of MIDG 35 | MWS.MAG3_pos = [-53.35 0.00 -9.33]/12; % ft, location of MAG3 sensor 36 | 37 | % Alpha/Beta upwash/sidewash 38 | MWS.alphavr_upwash = [0 1;0 1]; %deg, 2-D table of upwash values (row 2) corresponding to alpha (row 1) 39 | MWS.betavr_sidewash = [0 1;0 1]; %deg, 2-D table of sidewash values (row 2) corresponding to beta (row 1) 40 | MWS.alphavl_upwash = [0 1;0 1]; %deg, 2-D table of upwash values (row 2) corresponding to alpha (row 1) 41 | MWS.betavl_sidewash = [0 1;0 1]; %deg, 2-D table of sidewash values (row 2) corresponding to beta (row 1) 42 | 43 | % Navigation Parameters 44 | MWS.mag_var = 9.733; % deg, variation between true and magnetic north for Fort Pickett(BKT) 45 | % 11.4; WFF (37.824525,-75.497123), from http://www.ngdc.noaa.gov/geomagmodels/Declination.jsp 46 | % 9.7; BKT (37.073026 -77.952019), from http://www.ngdc.noaa.gov/geomagmodels/Declination.jsp 47 | 48 | MWS.wgs84_bias = 32.97 ; % m, Bias between WGS84 ellipse and mean sea level (MSL) for Fort Pickett(BKT) 49 | % 37.975; WFF (37.824525,-75.497123) (sign swapped), from http://earth-info.nga.mil/GandG/wgs84/gravitymod/wgs84_180/intptW.html 50 | % 32.97; BKT (37.073026 -77.952019) (sign swapped), from http://earth-info.nga.mil/GandG/wgs84/gravitymod/wgs84_180/intptW.html 51 | 52 | % Stall speed estimation Parameters, updated 3/31/09 53 | MWS.wt_ref = 49.6; %lbs, reference weight for stall speeds 54 | MWS.vs1g = [51.6 46.1 40.6]; %kts, stall speeds as a function of flap position (0, 15, 30) 55 | 56 | % Engine Parameters- NOTE: Pump voltage/fuel flow tables (here and in 57 | % engine_JetCatP70_lib.mdl) need to be updated with engine bench test data, 58 | % when available. (3/31/09) 59 | MWS.rpm_reference = 123000; %RPM, reference RPM for normalizing 60 | MWS.fflow_RPM_poly=[5.51350196e-007 -6.88734724e-005 6.27511799e-003 0.00000000e+000]; %lbs/min, reduced fuel flow 3rd order polynomial fit using reduced RPM, based on T1_engines_7-25-09.xlsx, with revised fflow cal, 9/2/09 61 | 62 | MWS.thrust_model = [[31.519,38.3721,44.6665,51.361,55.7506,60.6258,62.9154,65.8268,69.2567,73.098,76.9685,80.0465,83.2392,86.3014,92.2054,100.1233;];... % percent of reference RPM - updated with preliminary Jetcat P70 data 63 | [0.877577128039901,1.25154799079791,1.73579024647613,2.42433109574678,2.98545444575323,3.72114226762550,4.11032206326126,4.64776836008787,5.34487096479714,6.21192179998671,7.18276297471701,8.02789361647789,8.97593452341355,9.95620410254875,12.0519157523107,15.3152443615613;];...%lbs, 2-D table of thrust values (row 2) corresponding to power settings 64 | [0.00 6.00 12.00 19.00 24.00 30.00 33.00 37.00 42.00 48.00 54.50 60.00 66.00 72.00 84.00 100.00]];% percent handle corresponding to percent of reference RPM (row 1) 65 | 66 | %Ram Drag Coefficient 67 | MWS.ram_drag_coef = 0.010; 68 | 69 | % OFFSET LANDING --------------------------------------------------------- 70 | % The initial conditions of the offset landing function are specified in 71 | % the vector below. Initial heading and altitude are fairly 72 | % self-explanatory. The reference point, reference heading, and offsets 73 | % are used to specify initial position, and require a little explanation. 74 | % Imagine a typical Cartesian coordinate plane with its origin at the 75 | % reference latitude and longitude, and with its positive Y-axis extending 76 | % away from the origin in the direction of the reference heading. In this 77 | % representation, the initial lateral and longitudinal offsets are a 78 | % coordinate pair that specify X and Y directions in this coordinate 79 | % plane. The initial offset landing position of the model is determined by 80 | % starting from the reference position and applying the specified offsets. 81 | MWS.offset_landing = [44, ... % Initial heading (deg from magnetic north) of model 82 | 48, ... % Initial barometric altitude (ft) of model 83 | -94, ... % Initial lateral position (ft) of the model, specified as an offset from the reference point/heading 84 | -567, ... % Initial longitudinal position (ft) of the model, specified as an offset from the reference point/heading 85 | 37.068706, ... % Reference point latitude (deg) 86 | -77.956996, ... % Reference point longitude (deg) 87 | 44]; % Reference heading (deg from magnetic north) from the reference point -------------------------------------------------------------------------------- /gtm_design/config/Cal_params_T2.m: -------------------------------------------------------------------------------- 1 | function [MWS] = Cal_params_T2(MWS) 2 | %function [MWS] = Cal_params_T2(MWS) 3 | % 4 | % $Id: Cal_params_T2.m 4852 2013-08-06 22:12:54Z cox $ 5 | 6 | % ************** engine identification ****************** 7 | MWS.EngineID = 3; % 3 or 7 8 | 9 | % ************** Downlink Calibration ******************* 10 | RefGainBias=Cal_T2_Downlink(); 11 | MWS.RefGainBias_Vec=cell2mat(struct2cell(RefGainBias)); 12 | 13 | % ************** Uplink Calibration ********************* 14 | [DnCals, UpCals]=Cal_T2_Uplink(); 15 | MWS.UpCals_Eng=cell2mat(struct2cell(DnCals))'; 16 | MWS.UpCals_Pwm=cell2mat(struct2cell(UpCals))'; 17 | 18 | % *************** Surface limits ************************ 19 | [lo,hi,SurfaceLimits]=Cal_T2_Limits(); 20 | MWS.UplinkHiLimit = cell2mat(struct2cell(hi)); 21 | MWS.UplinkLoLimit = cell2mat(struct2cell(lo)); 22 | MWS.SurfaceLimits = cell2mat(struct2cell(SurfaceLimits)'); 23 | 24 | %**************** PWM JR Calibration ******************** 25 | JRCals_Eng.throttle_cmd = DnCals.ENGTL; 26 | JRCals_Eng.ail_cmd = DnCals.AILR; 27 | JRCals_Eng.ele_cmd = DnCals.ELLOB; 28 | JRCals_Eng.rud_cmd = DnCals.RUDU; 29 | JRCals_Eng.gear_cmd = DnCals.GEAR; 30 | JRCals_Eng.flap_cmd = DnCals.FLAPLOB; 31 | JRCals_Eng.spllob_cmd = DnCals.SPLLOB; 32 | JRCals_Eng.splrob_cmd = DnCals.SPLROB; 33 | JRCals_Eng.handoff_switch = [0:.1:1]; 34 | JRCals_Eng.brake_cmd = DnCals.BRAKE; 35 | JRCals_Eng.spdbrake_cmd = DnCals.SPLLIB; % Use left inboard spoiler 36 | JRCals_Eng.steer_trim_cmd = DnCals.STEER; 37 | 38 | JRCals_Pwm.throttle_cmd = UpCals.THROTLC; 39 | JRCals_Pwm.ail_cmd = UpCals.AILRC; 40 | JRCals_Pwm.ele_cmd = UpCals.ELLOBC; 41 | JRCals_Pwm.rud_cmd = UpCals.RUDUPC; 42 | JRCals_Pwm.gear_cmd = UpCals.GEARC; 43 | JRCals_Pwm.flap_cmd = UpCals.FLAPLOC; 44 | JRCals_Pwm.spllob_cmd = UpCals.SPLLOBC; 45 | JRCals_Pwm.splrob_cmd = UpCals.SPLROBC; 46 | JRCals_Pwm.handoff_switch = [0:10]*40 + 1500; 47 | JRCals_Pwm.brake_cmd = UpCals.BRAKEC; 48 | JRCals_Pwm.spdbrake_cmd = UpCals.SPLLIBC; % Use left inboard spoiler 49 | JRCals_Pwm.steer_trim_cmd = UpCals.STEERC; 50 | 51 | MWS.JRCals_Eng=cell2mat(struct2cell(JRCals_Eng))'; 52 | MWS.JRCals_Pwm=cell2mat(struct2cell(JRCals_Pwm))'; 53 | 54 | % MAG3 Temperature Compensation parameters 55 | % Per Murch e-mail, 12/11/09 56 | % Swapped X/Y axes, negated Y axis, negated Z accel to change from Memsense 57 | % axes to aircraft body-axes 58 | MAG3TempComp.XGYRO = 4.9745e-03; % deg/sec/deg 59 | MAG3TempComp.YGYRO = 4.3213e-02; % deg/sec/deg 60 | MAG3TempComp.ZGYRO = -4.2256e-02; % deg/sec/deg 61 | MAG3TempComp.XACCEL = -2.0895e-04; % g/deg C 62 | MAG3TempComp.YACCEL = -1.1745e-04; % g/deg C 63 | MAG3TempComp.ZACCEL = 1.1716e-05; % g/deg C 64 | 65 | MWS.MAG3TempComp = cell2mat(struct2cell(MAG3TempComp)'); 66 | 67 | -------------------------------------------------------------------------------- /gtm_design/config/DamageModels_T2.m: -------------------------------------------------------------------------------- 1 | function MWS=DamageModels_T2(MWS); 2 | %function MWS=DamageModels_T2(MWS); 3 | 4 | % $Id: DamageModels_T2.m 4852 2013-08-06 22:12:54Z cox $ 5 | 6 | % Valid Fields are: 7 | % RUDU.gain 8 | % RUDL.gain 9 | % AILL.gain 10 | % AILR.gain 11 | % SPLLIB.gain 12 | % SPLRIB.gain 13 | % SPLLOB.gain 14 | % SPLROB.gain 15 | % STAB.gain 16 | % ELLOB.gain 17 | % ELLIB.gain 18 | % ELRIB.gain 19 | % ELROB.gain 20 | % FLAPLOB.gain 21 | % FALPLIB.gain 22 | % FLAPRIB.gain 23 | % FLAPROB.gain 24 | % GEAR.gain 25 | % 26 | % Mass.dIxxIyyIzzIxyIyzIx(6) 27 | % Mass.dCG(3) 28 | % Mass.dWeight(1) 29 | % 30 | 31 | 32 | % Case-1: Rudder Off 33 | % Surfaces 34 | MWS.DamageModels{1}.RUDU.gain=0; 35 | MWS.DamageModels{1}.RUDL.gain=0; 36 | MWS.DamageModels{1}.Mass.dCG = [0.126, 0.000, 0.028]/12; 37 | MWS.DamageModels{1}.Mass.dWeight = -0.13; 38 | MWS.DamageModels{1}.Mass.dIxxIyyIzzIxzIyzIxy = [-0.00346, -0.06698, -0.06352, -0.01409, 0.00001, 0.00003]; 39 | 40 | 41 | % Case-2: Vertical Tail Off 42 | % Surfaces 43 | MWS.DamageModels{2}.RUDU.gain=0; 44 | MWS.DamageModels{2}.RUDL.gain=0; 45 | MWS.DamageModels{2}.Mass.dWeight = -1.31; 46 | MWS.DamageModels{2}.Mass.dCG = [1.166 0.000 0.277]/12; 47 | MWS.DamageModels{2}.Mass.dIxxIyyIzzIxzIyzIxy = [-0.03507, -0.57604, -0.54102, -0.13113, 0.00006, 0.00024]; 48 | 49 | 50 | % Case-3: Left Outboard Flap Off 51 | % Surfaces 52 | MWS.DamageModels{3}.FLAPLOB.gain=0; 53 | MWS.DamageModels{3}.Mass.dWeight = -0.09; 54 | MWS.DamageModels{3}.Mass.dCG = [0.014, 0.041, 0.001]/12; 55 | MWS.DamageModels{3}.Mass.dIxxIyyIzzIxzIyzIxy = [-0.01018, -0.00120, -0.01137, -0.00009, -0.00027, -0.00347]; 56 | 57 | 58 | % Case-4: 25% Left Wing Off 59 | % Surfaces 60 | MWS.DamageModels{4}.AILL.gain=0; 61 | MWS.DamageModels{4}.Mass.dWeight = -0.81; 62 | MWS.DamageModels{4}.Mass.dCG = [0.148, 0.628, 0.032]/12; 63 | MWS.DamageModels{4}.Mass.dIxxIyyIzzIxzIyzIxy = [-0.25821, -0.01727, -0.27400, -0.00295, -0.01346, -0.05998]; 64 | 65 | 66 | % Case-5: Left Elevator Off 67 | % Surfaces 68 | MWS.DamageModels{5}.ELLOB.gain=0; 69 | MWS.DamageModels{5}.ELLIB.gain=0; 70 | MWS.DamageModels{5}.Mass.dWeight = -0.07; 71 | MWS.DamageModels{5}.Mass.dCG =[0.065, 0.010, 0.004]/12; 72 | MWS.DamageModels{5}.Mass.dIxxIyyIzzIxzIyzIxy = [-0.00097, -0.03391, -0.03467, -0.00188, -0.00029, -0.00510]; 73 | 74 | 75 | % Case-6: Left Stab Off 76 | % Surfaces 77 | MWS.DamageModels{6}.STAB.gain=0; 78 | MWS.DamageModels{6}.ELLOB.gain=0; 79 | MWS.DamageModels{6}.ELLIB.gain=0; 80 | MWS.DamageModels{6}.Mass.dWeight = -0.59; 81 | MWS.DamageModels{6}.Mass.dCG = [0.553, 0.088, 0.032]/12; 82 | MWS.DamageModels{6}.Mass.dIxxIyyIzzIxzIyzIxy = [-0.00918, -0.27315, -0.28049, -0.01559, -0.00265, -0.04370]; 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /gtm_design/config/GTMtiny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/config/GTMtiny.png -------------------------------------------------------------------------------- /gtm_design/config/NoiseParams_T2.m: -------------------------------------------------------------------------------- 1 | function MWS = NoiseParams_T2(MWS,noise_on) 2 | % Sensor noise, scale factor, and bias parameters. 3 | % Default to off if only one input supplied. 4 | 5 | % $Id: NoiseParams_T2.m 4852 2013-08-06 22:12:54Z cox $ 6 | 7 | if nargin < 2 8 | noise_on = 0; 9 | end 10 | % Sensor noise 11 | MWS.SensorNoise.On = noise_on; % nd, 1 = noise on, 0 = noise off (default) 12 | 13 | % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 14 | % Standard Deviations, estimated from T2 flight 3, card 3, using smoo.m 15 | % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 16 | MWS.SensorNoise.alpha.Std = 0.031; % deg, alpha white noise standard deviation 17 | MWS.SensorNoise.beta.Std = 0.033; % deg, beta white noise standard deviation 18 | MWS.SensorNoise.dyn_press.Std = 0.00028; % psi, dynamic pressure white noise standard deviation 19 | MWS.SensorNoise.static_press.Std = 0.00097; % psi, static pressure white noise standard deviation 20 | MWS.SensorNoise.KTAS.Std = 0.06; % kts, true airspeed white noise standard deviation 21 | MWS.SensorNoise.baro_alt.Std = 2.36; % ft, barometric altitude white noise standard deviation 22 | % MIDG Parameters 23 | MWS.SensorNoise.MIDG.phi.Std = 0.02; % deg, Euler roll white noise standard deviation 24 | MWS.SensorNoise.MIDG.theta.Std = 0.02; % deg, Euler pitch white noise standard deviation 25 | MWS.SensorNoise.MIDG.psi.Std = 0.02; % deg, Euler yaw white noise standard deviation 26 | MWS.SensorNoise.MIDG.pdeg.Std = 0.5350; % deg/sec, roll rate white noise standard deviation 27 | MWS.SensorNoise.MIDG.qdeg.Std = 0.4737; % deg/sec, pitch rate white noise standard deviation 28 | MWS.SensorNoise.MIDG.rdeg.Std = 0.3397; % deg/sec, yaw rate white noise standard deviation 29 | MWS.SensorNoise.MIDG.nxbody.Std = 0.0012; % g, x-axis acclerometer white noise standard deviation 30 | MWS.SensorNoise.MIDG.nybody.Std = 0.0022; % g, y-axis acclerometer white noise standard deviation 31 | MWS.SensorNoise.MIDG.nzbody.Std = 0.0068; % g, z-axis acclerometer white noise standard deviation 32 | % MAG3 Parameters 33 | MWS.SensorNoise.MAG3.phi.Std = 0.05; % deg, Euler roll white noise standard deviation 34 | MWS.SensorNoise.MAG3.theta.Std = 0.05; % deg, Euler pitch white noise standard deviation 35 | MWS.SensorNoise.MAG3.psi.Std = 0.05; % deg, Euler yaw white noise standard deviation 36 | MWS.SensorNoise.MAG3.pdeg.Std = 0.5220; % deg/sec, roll rate white noise standard deviation 37 | MWS.SensorNoise.MAG3.qdeg.Std = 0.3857; % deg/sec, pitch rate white noise standard deviation 38 | MWS.SensorNoise.MAG3.rdeg.Std = 0.3330; % deg/sec, yaw rate white noise standard deviation 39 | MWS.SensorNoise.MAG3.nxbody.Std = 0.0016; % g, x-axis acclerometer white noise standard deviation 40 | MWS.SensorNoise.MAG3.nybody.Std = 0.0065; % g, y-axis acclerometer white noise standard deviation 41 | MWS.SensorNoise.MAG3.nzbody.Std = 0.0082; % g, z-axis acclerometer white noise standard deviation 42 | MWS.SensorNoise.pots.Std = 0.01; % deg, control surface pots white noise standard deviation 43 | MWS.SensorNoise.tempamb.Std = 0.05; % deg F, ambient temperature white noise standard deviation 44 | 45 | 46 | 47 | % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 48 | % Bias parameters, estimated from T2 flight 3, card 3, wavetrain 18 using Data Compatibility Analysis 49 | % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 50 | MWS.SensorNoise.alpha.Bias = 0; % deg, alpha bias, from upwash estimation 51 | MWS.SensorNoise.beta.Bias = 0; % deg, beta bias 52 | MWS.SensorNoise.dyn_press.Bias = 0; % psi, dynamic pressure bias 53 | MWS.SensorNoise.static_press.Bias = 0; % psi, static pressure bias 54 | MWS.SensorNoise.KTAS.Bias = 0.07; % kts, true airspeed bias 55 | MWS.SensorNoise.baro_alt.Bias = 0; % ft, barometric altitude bias 56 | % MIDG Paremeters 57 | MWS.SensorNoise.MIDG.phi.Bias = 0; % deg, Euler roll bias 58 | MWS.SensorNoise.MIDG.theta.Bias = -0.09; % deg, Euler pitch bias 59 | MWS.SensorNoise.MIDG.psi.Bias = -0.04; % deg, Euler yaw bias 60 | MWS.SensorNoise.MIDG.pdeg.Bias = -0.0057; % deg/sec, roll rate bias 61 | MWS.SensorNoise.MIDG.qdeg.Bias = -0.0115; % deg/sec, pitch rate bias 62 | MWS.SensorNoise.MIDG.rdeg.Bias = -0.0286; % deg/sec, yaw rate bias 63 | MWS.SensorNoise.MIDG.nxbody.Bias = -0.00034;% g, x-axis acclerometer bias 64 | MWS.SensorNoise.MIDG.nybody.Bias = 0.00093; % g, y-axis acclerometer bias 65 | MWS.SensorNoise.MIDG.nzbody.Bias = 0.00086; % g, z-axis acclerometer bias 66 | % MAG3 Parameters 67 | MWS.SensorNoise.MAG3.phi.Bias = 0; % deg, Euler roll bias 68 | MWS.SensorNoise.MAG3.theta.Bias = 0; % deg, Euler pitch bias 69 | MWS.SensorNoise.MAG3.psi.Bias = 0; % deg, Euler yaw bias 70 | MWS.SensorNoise.MAG3.pdeg.Bias = -0.338; % deg/sec, roll rate bias 71 | MWS.SensorNoise.MAG3.qdeg.Bias = 0.1547; % deg/sec, pitch rate bias 72 | MWS.SensorNoise.MAG3.rdeg.Bias = 0.6761; % deg/sec, yaw rate bias 73 | MWS.SensorNoise.MAG3.nxbody.Bias = 0.0162; % g, x-axis acclerometer bias 74 | MWS.SensorNoise.MAG3.nybody.Bias = -0.0189; % g, y-axis acclerometer bias 75 | MWS.SensorNoise.MAG3.nzbody.Bias = 0.0009; % g, z-axis acclerometer bias 76 | MWS.SensorNoise.pots.Bias = 0; % deg, control surface pots bias 77 | MWS.SensorNoise.tempamb.Bias = 0; % deg F, ambient temperature bias 78 | 79 | % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 80 | % Scale Factor parameters, estimated from S2_flt8 using Data Compatibility Analysis 81 | % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 82 | MWS.SensorNoise.alpha.Scf = 1; % nd, alpha scale factor, from upwash estimation 83 | MWS.SensorNoise.beta.Scf = 1; % nd, beta scale factor 84 | MWS.SensorNoise.dyn_press.Scf = 1; % nd, dynamic pressure scale factor 85 | MWS.SensorNoise.static_press.Scf = 1; % nd, static pressure scale factor 86 | MWS.SensorNoise.KTAS.Scf = 1; % kts, true airspeed scale factor 87 | MWS.SensorNoise.baro_alt.Scf = 1; % ft, barometric altitude scale factor 88 | % MIDG Parameters 89 | MWS.SensorNoise.MIDG.phi.Scf = 1; % nd, Euler roll scale factor 90 | MWS.SensorNoise.MIDG.theta.Scf = 1; % nd, Euler pitch scale factor 91 | MWS.SensorNoise.MIDG.psi.Scf = 1; % nd, Euler yaw scale factor 92 | MWS.SensorNoise.MIDG.pdeg.Scf = 1; % nd, roll rate scale factor 93 | MWS.SensorNoise.MIDG.qdeg.Scf = 1; % nd, pitch rate scale factor 94 | MWS.SensorNoise.MIDG.rdeg.Scf = 1; % nd, yaw rate scale factor 95 | MWS.SensorNoise.MIDG.nxbody.Scf = 1; % nd, x-axis acclerometer scale factor 96 | MWS.SensorNoise.MIDG.nybody.Scf = 1; % nd, y-axis acclerometer scale factor 97 | MWS.SensorNoise.MIDG.nzbody.Scf = 1; % nd, z-axis acclerometer scale factor 98 | % MAG3 Parameters 99 | MWS.SensorNoise.MAG3.phi.Scf = 1; % nd, Euler roll scale factor 100 | MWS.SensorNoise.MAG3.theta.Scf = 1; % nd, Euler pitch scale factor 101 | MWS.SensorNoise.MAG3.psi.Scf = 1; % nd, Euler yaw scale factor 102 | MWS.SensorNoise.MAG3.pdeg.Scf = 1; % nd, roll rate scale factor 103 | MWS.SensorNoise.MAG3.qdeg.Scf = 1; % nd, pitch rate scale factor 104 | MWS.SensorNoise.MAG3.rdeg.Scf = 1; % nd, yaw rate scale factor 105 | MWS.SensorNoise.MAG3.nxbody.Scf = 1; % nd, x-axis acclerometer scale factor 106 | MWS.SensorNoise.MAG3.nybody.Scf = 1; % nd, y-axis acclerometer scale factor 107 | MWS.SensorNoise.MAG3.nzbody.Scf = 1; % nd, z-axis acclerometer scale factor 108 | MWS.SensorNoise.pots.Scf = 1; % nd, control surface pots scale factor 109 | MWS.SensorNoise.tempamb.Scf = 1; % nd, ambient temperature scale factor 110 | 111 | -------------------------------------------------------------------------------- /gtm_design/config/T2_polynomial_aerodatabase.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/config/T2_polynomial_aerodatabase.mat -------------------------------------------------------------------------------- /gtm_design/config/init_turbulence.m: -------------------------------------------------------------------------------- 1 | function [ mws ] = init_turbulence( mws ) 2 | % Adds the Dryden turbulence model gain parameters as variables in the 3 | % Model Workspace Structure for gtm_design simulation. 4 | % 5 | % Inputs: 6 | % mws - the existing model workspace structure 7 | % 8 | % Outputs: 9 | % mws - the updated model workspace structure 10 | 11 | % $Id: init_turbulence.m 4852 2013-08-06 22:12:54Z cox $ 12 | 13 | 14 | % The u, v, and w gust velocities are calculated using the Dryden Model and 15 | % data obtained from NASA Tm-4511. For altitudes less than 1000 m, the 16 | % model contains only severe data from Tm-4511. As a result, all turbulence 17 | % conditions are calculated using the severe parameters and the resulting 18 | % gusts are passed through gain blocks which can be manipulated to produce 19 | % a variety of turbulence levels. Analysis of flight data yielded the 20 | % following gain settings to simulate the levels of turbulence experienced 21 | % at Fort Pickett. 22 | 23 | % Light turbulence (no turbulence) 24 | 25 | mws.u_gain_light = 0.2; 26 | mws.v_gain_light = 0.2; 27 | mws.w_gain_light = 0.17; 28 | 29 | % Moderate turbulence 30 | 31 | mws.u_gain_moderate = 0.4; 32 | mws.v_gain_moderate = 0.4; 33 | mws.w_gain_moderate = 0.34; 34 | 35 | % Severe turbulence 36 | 37 | mws.u_gain_severe = 0.4; 38 | mws.v_gain_severe = 1.152; 39 | mws.w_gain_severe = 0.34; 40 | 41 | % Simulation turbulence settings: 42 | 43 | mws.ugain = 0; 44 | mws.vgain = 0; 45 | mws.wgain = 0; 46 | 47 | % This switch enables the turbulence model subsystem. 48 | % To turn on turbulence, set the switch to 1. 49 | mws.DrydenModelSwitch = 0; 50 | 51 | end 52 | 53 | -------------------------------------------------------------------------------- /gtm_design/docs/example_plots.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/docs/example_plots.pdf -------------------------------------------------------------------------------- /gtm_design/docs/gtm_design_DamageDescriptions.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/docs/gtm_design_DamageDescriptions.doc -------------------------------------------------------------------------------- /gtm_design/docs/gtm_design_FAQ.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/docs/gtm_design_FAQ.doc -------------------------------------------------------------------------------- /gtm_design/docs/gtm_design_GlobalTags.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/docs/gtm_design_GlobalTags.xls -------------------------------------------------------------------------------- /gtm_design/docs/gtm_design_QuickStart.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/docs/gtm_design_QuickStart.doc -------------------------------------------------------------------------------- /gtm_design/docs/gtm_design_Reference.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/docs/gtm_design_Reference.doc -------------------------------------------------------------------------------- /gtm_design/docs/src/example_plots.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{graphicx} 3 | \usepackage{color} 4 | 5 | \sloppy 6 | \definecolor{lightgray}{gray}{0.5} 7 | \setlength{\parindent}{0pt} 8 | \textwidth 6.75in 9 | \textheight 8.75in 10 | \footskip 0.5in 11 | \oddsidemargin -.25in 12 | \evensidemargin -.25in 13 | \topmargin -0.5in 14 | 15 | \begin{document} 16 | 17 | \centerline{\includegraphics [width=6.5in]{exampleplot01.png}} 18 | \centerline{Example-1: Linear and nonlinear response to pitch-yaw-roll doublet sequence} 19 | 20 | \newpage 21 | \centerline{\includegraphics [width=6.5in]{exampleplot02.png}} 22 | \centerline{Example-2: Locus of trim states and surface commands for level flight} 23 | 24 | \newpage 25 | \centerline{\includegraphics [width=6.5in]{exampleplot03.png}} 26 | \centerline{Example-3: Frequency and damping of decopuled linear models in level flight} 27 | 28 | \newpage 29 | \centerline{\includegraphics [width=6.5in]{exampleplot04.png}} 30 | \centerline{Example-4: Trim to climbing turn, linear and nonlinear response to perturbed initial condition} 31 | 32 | \newpage 33 | \centerline{\includegraphics [width=6.5in]{exampleplot05.png}} 34 | \centerline{Example-5: Trim to spin equilibrium condition} 35 | 36 | \newpage 37 | \centerline{\includegraphics [width=6.5in]{exampleplot06-1.png}} 38 | \centerline{Example-6: DamageCase-01, Rudder Off} 39 | \newpage 40 | \centerline{\includegraphics [width=6.5in]{exampleplot06-2.png}} 41 | \centerline{Example-6: DamageCase-02, Vertical Tail Off} 42 | \newpage 43 | \centerline{\includegraphics [width=6.5in]{exampleplot06-3.png}} 44 | \centerline{Example-6: DamageCase-03, Left Outboard Flap Off} 45 | \newpage 46 | \centerline{\includegraphics [width=6.5in]{exampleplot06-4.png}} 47 | \centerline{Example-6: DamageCase-04, Left Wingtip(25\%) Off} 48 | \newpage 49 | \centerline{\includegraphics [width=6.5in]{exampleplot06-5.png}} 50 | \centerline{Example-6: DamageCase-05, Left Elevator Off} 51 | \newpage 52 | \centerline{\includegraphics [width=6.5in]{exampleplot06-6.png}} 53 | \centerline{Example-6: DamageCase-06, Left Stabilizer Off} 54 | 55 | \end{document} 56 | 57 | -------------------------------------------------------------------------------- /gtm_design/docs/src/gtm_design_AeroTable.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/docs/src/gtm_design_AeroTable.xls -------------------------------------------------------------------------------- /gtm_design/docs/src/gtm_design_ModelWorkspace.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/docs/src/gtm_design_ModelWorkspace.xls -------------------------------------------------------------------------------- /gtm_design/example1.m: -------------------------------------------------------------------------------- 1 | 2 | % 3 | %-------------- Doublet response, Simulation and Linear Models ------------ 4 | % 5 | % Script trims the model to a level flight condition and linearizes. 6 | % It compares doublet responses between full nonlinear sim and 7 | % the linearized model 8 | 9 | % $Id: example1.m 4852 2013-08-06 22:12:54Z cox $ 10 | % david.e.cox@nasa.gov 11 | 12 | % load nominal starting point into simulation model workspace 13 | loadmws(init_design('GTM_T2')); 14 | 15 | % Trim to nominal condition: level flight, alpha=3 16 | SimVars=trimgtm(struct('alpha',3, 'gamma',0)); 17 | 18 | % Load Simulation Variables (at trim condition) into Model Workspace 19 | loadmws(SimVars); 20 | 21 | % Linearize model about this condition 22 | fprintf(1,'Linearizing...') 23 | [sys,londyn,latdyn]=linmodel(); 24 | fprintf(1,' Done\n'); 25 | 26 | % Construct 1 degree double sequence. 27 | f=100; % 100 Hz input sampling on sequence 28 | d=0.5; % 2 sec pulse duration 29 | a=[1 1 1];% pulse amplitude(deg), [ele,rud,ail] 30 | 31 | dub=[zeros(4*f*d,1);ones(f*d,1);-1*ones(f*d,1);zeros(4*f*d,1)]; % a doublet 32 | ulin = [ [a(1)*dub;0*dub;0*dub], [0*dub;0*dub;a(3)*dub], [0*dub;a(2)*dub;0*dub] ]; % doublet sequence 33 | tlin=[0:length(ulin)-1]/f; 34 | 35 | % Run linear simulation 36 | ylin=lsim(sys(:,[1,2,3]),ulin,tlin); 37 | 38 | % Construct same doublet sequence via simulink 39 | set_param('gtm_design/Input Generator/Doublet Generator','timeon','[2 12 7]'); 40 | set_param('gtm_design/Input Generator/Doublet Generator','pulsewidth','[0.5 0.5 0.5]'); 41 | set_param('gtm_design/Input Generator/Doublet Generator','amplitude',sprintf('[%f %f %f]',a(1),a(3),a(2))); 42 | [tsim,xsim,ysim]=sim('gtm_design',[0 max(tlin)]); 43 | 44 | % Turn simulink doublet generation off 45 | set_param('gtm_design/Input Generator/Doublet Generator','amplitude','[0 0 0]'); 46 | 47 | % Grab state in ysim First 6 are trim outputs, next 12 are state. 48 | ysim=ysim(:,7:18); 49 | 50 | 51 | % Plot results 52 | set(figure(1),'Position',[20 80 900 700]); 53 | subplot(321), 54 | plot(tsim,ysim(:,1), tlin,ylin(:,1)+ysim(1,1)); grid on 55 | title('Linear Velocity to Doublet Sequence [elevator,rudder,aileron]'); 56 | xlabel('Time (sec)');ylabel('u (ft/sec)') 57 | legend('Simulation', 'Linear'); 58 | subplot(323), 59 | plot(tsim,ysim(:,2), tlin,ylin(:,2)+ysim(1,2)); grid on 60 | xlabel('Time (sec)');ylabel('v (ft/sec)') 61 | subplot(325), 62 | plot(tsim,ysim(:,3), tlin,ylin(:,3)+ysim(1,3)); grid on 63 | xlabel('Time (sec)');ylabel('w (ft/sec)') 64 | 65 | subplot(322), 66 | plot(tsim,180/pi*ysim(:,4), tlin,180/pi*(ylin(:,4)+ysim(1,4))); grid on 67 | title('Angular Velocity to Doublet Sequence [elevator,rudder,aileron]'); 68 | xlabel('Time (sec)');ylabel('p (deg/sec)') 69 | subplot(324), 70 | plot(tsim,180/pi*ysim(:,5), tlin,180/pi*(ylin(:,5)+ysim(1,5))); grid on 71 | xlabel('Time (sec)');ylabel('q (deg/sec)') 72 | subplot(326), 73 | plot(tsim,180/pi*ysim(:,6), tlin,180/pi*(ylin(:,6)+ysim(1,6))); grid on 74 | xlabel('Time (sec)');ylabel('r (deg/sec)') 75 | 76 | if (exist('AutoRun','var')) 77 | pause(.2); 78 | orient portrait; print -dpng exampleplot01; 79 | end 80 | 81 | % Print damping/frequency info for decoupled models 82 | fprintf('\nLongitudinal Dynamics:\n');damp(londyn); 83 | fprintf('\nLateral Dynamics:\n');damp(latdyn); 84 | 85 | 86 | -------------------------------------------------------------------------------- /gtm_design/example2.m: -------------------------------------------------------------------------------- 1 | % 2 | %--------------- Calculate set of level flight trim conditions ---------------- 3 | % 4 | % Script calculates a set of level flight trim condtions for different 5 | % calibrated airspeeds and angles-of-attack. Plots trim conditions as 6 | % a function of specified target condition 7 | 8 | % $Id: example2.m 4852 2013-08-06 22:12:54Z cox $ 9 | % d.e.cox@larc.nasa.gov 10 | 11 | % -------------eas plot---------------- 12 | % Trim to set of equivalent air speeds 13 | speeds=[[46:2:58],[60:10:130]]; 14 | 15 | % Allocate variables to plot 16 | alpha=zeros(length(speeds),1); 17 | elevator=zeros(length(speeds),1); 18 | throttle=zeros(length(speeds),1); 19 | 20 | % Compute trim points 21 | MWS=init_design(); 22 | fprintf('\nLevel Flight Trim\n Trimming at eas:\n'); 23 | for trimpt=[1:length(speeds)], 24 | fprintf(1,' %3.2f,',speeds(trimpt)); 25 | loadmws(MWS,'gtm_design'); 26 | [MWS,Xt,Tc,Err]=trimgtm(struct('eas',speeds(trimpt),'gamma',0), 'elev', 0); 27 | if (Err>1e-3), % try again, different starting poing 28 | loadmws(init_design(),'gtm_design'); 29 | fprintf(' Poor convergence, trying again. '); 30 | [MWS,Xt,Tc,Err]=trimgtm(struct('eas',speeds(trimpt),'gamma',0), 'elev', 0); 31 | if (Err>1e-3) % No joy, skip point. 32 | Tc=struct('alpha',NaN,'elevator',NaN,'throttle',NaN); 33 | fprintf(1,'Failed to Trim '); 34 | else fprintf(1,'Done '); 35 | end 36 | end 37 | fprintf(1,' Residual=%3.2e\n',Err); 38 | alpha(trimpt) =Tc.alpha; 39 | elevator(trimpt)=Tc.elevator; 40 | throttle(trimpt)=Tc.throttle; 41 | end 42 | fprintf(' Done\n'); 43 | 44 | % Make eas trim point plot 45 | figure(1),clf 46 | subplot(121), 47 | [ax,h1,h2]=plotyy(speeds,[elevator,alpha],speeds,throttle); grid on 48 | set(ax,{'YColor'},{'blue';'red'}); 49 | set([h1;h2],{'Color'},{'blue';'blue';'red'}); 50 | set([h1;h2],{'Marker'},{'o';'s';'>'}) 51 | set([h1;h2],{'MarkerFaceColor'},{'blue';'none';'red'}); 52 | title('Trimmed level flight by eas'); 53 | legend([h1;h2], { 'elevator','alpha','throttle'} ); 54 | set([h1;h2],{'Marker'},{'o';'s';'>'}); 55 | ylabel(ax(1),'Elevator(deg), alpha(deg)'); 56 | ylabel(ax(2),'Throttle(%)'); 57 | xlabel('eas (knots)') 58 | 59 | 60 | %----------AOA plot--------------- 61 | 62 | %% Trim to set of angles of attack 63 | AOA=[2:2:28]; 64 | 65 | % Variables to plot 66 | eas=zeros(length(AOA),1); 67 | elevator=zeros(length(AOA),1); 68 | throttle=zeros(length(AOA),1); 69 | fprintf(' Trimming at alpha:\n'); 70 | 71 | % Comute Trim poin 72 | MWS=init_design(); 73 | for trimpt=[1:length(AOA)], 74 | fprintf(1,' %3.2f,',AOA(trimpt)); 75 | loadmws(MWS,'gtm_design'); 76 | [MWS,Xt,Tc,Err]=trimgtm(struct('alpha',AOA(trimpt),'gamma',0), 'elev', 0); 77 | if (Err>1e-3), % try again, different starting poing 78 | loadmws(init_design(),'gtm_design'); 79 | fprintf(' Poor convergence, trying again. '); 80 | [MWS,Xt,Tc,Err]=trimgtm(struct('alpha',AOA(trimpt),'gamma',0), 'elev', 0); 81 | if (Err>1e-3) % No joy, skip point. 82 | Tc=struct('eas',NaN,'elevator',NaN,'throttle',NaN); 83 | fprintf(1,'Failed to Trim '); 84 | else fprintf(1,'Done '); 85 | end 86 | end 87 | fprintf(1,' Residual=%3.2e\n',Err); 88 | eas(trimpt) =Tc.eas; 89 | elevator(trimpt)=Tc.elevator; 90 | throttle(trimpt)=Tc.throttle; 91 | end 92 | fprintf(' Done\n'); 93 | 94 | % Make alpha trim point plot 95 | subplot(122), 96 | [ax,h1,h2]=plotyy(AOA,elevator,AOA,[eas,throttle]); grid on 97 | set(ax,{'YColor'},{[0 0 1];[1 0 0]}); 98 | set([h1;h2],{'Color'},{'blue';'red';'red'}); 99 | set([h1;h2],{'Marker'},{'o';'s';'>'}) 100 | set([h1;h2],{'MarkerFaceColor'},{'blue';'none';'red'}); 101 | title('Trimmed level flight by AOA'); 102 | legend([h1;h2],{ 'elevator','eas','throttle'}); 103 | ylabel(ax(1),'Elevator(deg)'); 104 | ylabel(ax(2),'eas(knots) and throttle(%)'); 105 | xlabel(ax(1),'alpha (deg)'); 106 | 107 | if (exist('AutoRun','var')) 108 | pause(.2); 109 | orient portrait; print -dpng exampleplot02; 110 | end 111 | -------------------------------------------------------------------------------- /gtm_design/example3.m: -------------------------------------------------------------------------------- 1 | % 2 | %----------- Frequency/Damping for level-flight trim conditions ------------ 3 | % 4 | % Script calculates frequency and damping of approximate 4th order models over 5 | % a set of level flight trim condtions. 6 | 7 | % $Id: example3.m 4852 2013-08-06 22:12:54Z cox $ 8 | % d.e.cox@larc.nasa.gov 9 | 10 | 11 | 12 | %% Trim to set of angles of attack 13 | AOA=[2,4,6,8, 10,11,12,13,14, 16,18,20]; 14 | %AOA=[2:3:20]; 15 | 16 | % Allocate memory 17 | shortperiod = zeros(length(AOA),2); 18 | phugiod = zeros(length(AOA),2); 19 | 20 | % Comute Trim points 21 | loadmws(init_design(),'gtm_design'); 22 | fprintf(' Trimming/Linearizing at alpha:\n'); 23 | for trimpt=[1:length(AOA)], 24 | fprintf(1,' %3.2f,',AOA(trimpt)); 25 | [MWS,Xt,Tc,Err]=trimgtm( struct('alpha',AOA(trimpt),'gamma',0),[],0); 26 | fprintf(1,' Residual=%3.2e\n',Err); 27 | loadmws(MWS,'gtm_design'); 28 | [sys,lon,lat]=linmodel(MWS); 29 | [wn,z]=damp(lon); 30 | % Just assuming frequency seperation here... 31 | phugoid(trimpt,:) = [wn(1)/2/pi,z(1)]; 32 | shortperiod(trimpt,:) = [wn(3)/2/pi,z(3)]; 33 | end 34 | fprintf(' Done\n'); 35 | 36 | % Make alpha trim point plot 37 | figure(1),clf 38 | subplot(221),plot(AOA,phugoid(:,1),'-s'),grid on 39 | title('Phugoid Mode by AOA');ylabel('Frequency (Hz)');xlabel('alpha (deg)'); 40 | 41 | subplot(223),plot(AOA,phugoid(:,2),'-s'),grid on 42 | title('Phugoid Mode by AOA');ylabel('Damping');xlabel('alpha (deg)'); 43 | 44 | subplot(222),plot(AOA,shortperiod(:,1),'-s'),grid on 45 | title('Short-Period Mode by AOA');ylabel('Frequency (Hz)');xlabel('alpha (deg)'); 46 | 47 | subplot(224),plot(AOA,shortperiod(:,2),'-s'),grid on 48 | title('Short-Period Mode by AOA');ylabel('Damping');xlabel('alpha (deg)'); 49 | 50 | if (exist('AutoRun','var')) 51 | pause(.2); 52 | orient portrait; print -dpng exampleplot03; 53 | end 54 | 55 | -------------------------------------------------------------------------------- /gtm_design/example4.m: -------------------------------------------------------------------------------- 1 | % 2 | %------------------ Trim to climbing turn------------------ 3 | % 4 | % Script trims to a climbing turn and linearizes 5 | % Runs three simulations and plots comparison 6 | % Sim-1: Nonlinear sim starting from trim condition 7 | % Sim-2: Nonlinear sim starting from perturbed trim condition 8 | % Sim-3: Linear sim starting from perturbed trim condition 9 | 10 | % $Id: example4.m 4852 2013-08-06 22:12:54Z cox $ 11 | % d.e.cox@larc.nasa.gov 12 | 13 | % Load nominal starting parameter set 14 | loadmws(init_design(),'gtm_design'); 15 | % Retrim vehicle into climbing turn 16 | [MWS,Xtrim,Fcond,Err]=trimgtm( struct('eas',95, 'gamma',3, 'yawrate',10),'elev',1 ); 17 | 18 | % Get linear model of system in climbing turn 19 | fprintf(1,'Linearizing...') 20 | loadmws(MWS,'gtm_design'); 21 | sys_clbtrn=linmodel(MWS); 22 | fprintf(1,' Done\n'); 23 | 24 | % Simulate and plot 25 | figure(1),clf 26 | fprintf(1,'Simulating...'); 27 | tic;sim('gtm_design',[0 60]);realdt=toc; 28 | tout1=tout;Lon1=sout.eom.longitude*180/pi; Lat1=sout.eom.latitude*180/pi; Alt1=sout.eom.altitude; 29 | fprintf(1,' Done, Running at %6.2f times real-time\n',60/realdt) 30 | 31 | % Tweak initial conditions (+2 step in angle of attack) 32 | MWS_off=seteomic(MWS,'alpha', Fcond.alpha+2 ); 33 | loadmws(MWS_off,'gtm_design'); 34 | 35 | % Simulate nonlinear model 36 | fprintf(1,'Simulating...'); 37 | tic;sim('gtm_design',[0 60]);realdt=toc; 38 | tout2=tout;Lon2=sout.eom.longitude*180/pi; Lat2=sout.eom.latitude*180/pi; Alt2=sout.eom.altitude; 39 | fprintf(1,' Done, Running at %6.2f times real-time\n',60/realdt) 40 | 41 | % Simulate linear model, tweaked initial conditions 42 | Xo=MWS_off.StatesInp(1:12)-Fcond.Xo(1:12); 43 | tlin=[0:0.00463:max(tout)]'; 44 | y=lsim(sys_clbtrn,zeros(length(tlin),size(sys_clbtrn,2)),tlin,Xo); 45 | 46 | % Plot 47 | h1=plot3(Lon1,Lat1,Alt1'); grid on,hold on 48 | h2=plot3(Lon2,Lat2,Alt2','r'); 49 | axlim=axis; 50 | h3=plot3(interp1(tout1,Lon1,tlin,'linear')+y(:,7)*180/pi,... 51 | interp1(tout1,Lat1,tlin,'linear')+y(:,8)*180/pi,... 52 | interp1(tout1,Alt1,tlin,'linear')+y(:,9),'g'); 53 | axis(axlim); 54 | legend([h1 h2 h3],'IC on trim point', 'IC off trim point','IC-off, Linear Model'); 55 | title({'Trimmed to climbing turn, 60 sec run', 'Off Initial Condition: +2deg step in angle of attack'}); 56 | xlabel('Longitude (deg)'),ylabel('Latitude (deg)'),zlabel('Altitude (ft)'); 57 | 58 | if(exist('AutoRun','var')) 59 | pause(.2); 60 | orient portrait; print -dpng exampleplot04; 61 | end 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /gtm_design/example5.m: -------------------------------------------------------------------------------- 1 | % 2 | %------------------ Trim to Steady Spin Condition------------------ 3 | % 4 | % Script trims to a targeted spin condition, simulates from that condition 5 | % and plots trajectory. 6 | % 7 | % alpha,beta,p,q,r, are all steady non-zero values. 8 | % 9 | 10 | % $Id: example5.m 4852 2013-08-06 22:12:54Z cox $ 11 | % d.e.cox@larc.nasa.gov 12 | 13 | 14 | % Target conditions taken from Austin Murch's piloted spin data, 15 | % done after sign-error correction of revision 296. 16 | target=[]; %clear target variable 17 | target.eas = 70.66; 18 | target.alpha= 21.34; 19 | target.beta = -1.33; 20 | target.pdeg = -6.61*180/pi; 21 | target.qdeg = 0.827*180/pi; 22 | target.rdeg = -2.58*180/pi; 23 | 24 | % Allow yawrate to be free variable 25 | target.yawrate=[]; 26 | 27 | % Start with some altitude,otherwise nominal init 28 | loadmws(seteomic(init_design(),'alt',4000),'gtm_design'); 29 | 30 | % Trim to spiral for initial guess 31 | % This is *very* sensitive, if spin does not have constant parameters 32 | % then try changing this initial guess 33 | MWS=trimgtm(struct('gamma',-5,'yawrate',30)); 34 | % MWS=trimgtm(struct('gamma',0,'yawrate',30)); 35 | %MWS=trimgtm(struct('gamma',-10,'beta',0,'alpha',20)); 36 | loadmws(MWS,'gtm_design'); 37 | 38 | % Trim to spin conditions 39 | [MWS,Xt,Tc,Err]=trimgtm(target); 40 | loadmws(MWS,'gtm_design'); 41 | 42 | % Simulate 43 | [t,x,y]=sim('gtm_design',[0 10]); 44 | 45 | % Convert from lat/lon to ft (Calibrated at Smithfield) 46 | Xeom=y(:,7:18); 47 | dist_lat=(Xeom(:,7)-Xeom(1,7)) * 180/pi*364100.79; 48 | dist_lon=(Xeom(:,8)-Xeom(1,8)) * 180/pi*291925.24; 49 | alt=Xeom(:,9); 50 | 51 | % Define simple airplane shape 52 | scale=.30; 53 | x1=scale*([0.0,-.5, -2.0, -3.0,-4.0, -3.25, -5.5, -6.0, -6.0]+3.0); 54 | y1=scale*[0.0, 0.5, 0.5, 4.25, 4.5, 0.5, 0.5, 1.5, 0.0]; 55 | Vehicletop=[ [x1,fliplr(x1)]; [y1,fliplr(-y1)]; -.01*ones(1,2*length(x1))]; 56 | Vehiclebot=[ [x1,fliplr(x1)]; [y1,fliplr(-y1)]; .01*ones(1,2*length(x1))]; 57 | 58 | 59 | % ------------------------Plots--------------------------- 60 | h=figure(1);,set(h,'Position',[20,20,1000,800]);clf 61 | 62 | % Alpha/Beta 63 | axes('position',[.1 .70 .2 .2]) 64 | plot(t,[sout.aux.alpha,sout.aux.beta]); 65 | legend({'\alpha','\beta'},'Location','SouthEast');,grid on 66 | xlabel('time (sec)'), 67 | ylabel('\alpha (deg), \beta (deg)'); 68 | title('Alpha/Beta'); 69 | 70 | % Flight Path Angle and Airspeed 71 | axes('position',[.1 .40 .2 .2]) 72 | [ax,h1,h2]=plotyy(t,sout.aux.gamma,t,sout.aux.eas);grid on 73 | xlabel('time (sec)'), 74 | ylabel(ax(1),'Flight Path, \gamma (deg)'); 75 | ylabel(ax(2),'Equivalent Airspeed (konts)') 76 | legend([h1;h2],{'\gamma','eas'},'Location','SouthEast'); 77 | title('Flight Path Angle and Airspeed'); 78 | 79 | % Angular Rates 80 | axes('position',[.1 .10 .2 .2]) 81 | plot(t,Xeom(:,4:6)*180/pi);grid on 82 | legend({ 'p','q','r'},'Location','SouthEast'); 83 | xlabel('time (sec)'),ylabel('angular rates (deg/sec)') 84 | title('Angular Rates'); 85 | 86 | % Trajectory: 3D plot with orientated vehicle 87 | axes('position',[.45,.1,.45,.8]) 88 | plot3(dist_lat,dist_lon,alt);grid on, axset=axis; % Just get axis limits 89 | %cnt=0; 90 | % resample at equally spaced points for animation plot 91 | tplot=[0:.1:max(t)]; 92 | X_ani=interp1(t,Xeom,tplot); 93 | lat_ani=interp1(t,dist_lat,tplot); 94 | lon_ani=interp1(t,dist_lon,tplot); 95 | alt_ani=interp1(t,alt,tplot); 96 | tic 97 | for i=[1:length(tplot)] 98 | plot3(dist_lat,dist_lon,alt);grid on 99 | Offset=repmat([lat_ani(i);lon_ani(i);alt_ani(i)],1,size(Vehicletop,2)); 100 | Ptmp=diag([1,1,-1])*transpose(euler321(X_ani(i,10:12)))*Vehicletop + Offset; 101 | patch(Ptmp(1,:),Ptmp(2,:),Ptmp(3,:),'g'); 102 | Ptmp=diag([1,1,-1])*transpose(euler321(X_ani(i,10:12)))*Vehiclebot + Offset; 103 | patch(Ptmp(1,:),Ptmp(2,:),Ptmp(3,:),'c'); 104 | view(25,10),axis(axset),hold off 105 | xlabel('Lat. Crossrange(ft)'); 106 | ylabel('Long. Crossrange(ft)'); 107 | zlabel('Altitude(ft)'); 108 | title('Simulation Trajectory and Orientation'); 109 | pause(.1); % Adjust to get plotting close to real-time 110 | % cnt=cnt+1;M(cnt)=getframe; 111 | end 112 | toc 113 | if(exist('AutoRun','var')) 114 | pause(.2); 115 | orient portrait; print -dpng exampleplot05; 116 | end 117 | %movie(gca,M,3,4); 118 | -------------------------------------------------------------------------------- /gtm_design/example6.m: -------------------------------------------------------------------------------- 1 | % 2 | %--------------- During 45 degree bank angle turn incur damage------------------ 3 | % 4 | % Script trims to a climbing 45 degree bank angle turn then simulates 5 | % each preprogramed failure condition. 6 | 7 | 8 | % $Id: example6.m 4852 2013-08-06 22:12:54Z cox $ 9 | % david.e.cox@.nasa.gov 10 | 11 | 12 | % Load nominal starting parameter set 13 | MWS_Nominal=init_design(); 14 | 15 | % Set nominal trim to climbing turn 16 | MWS_Nominal.DamageCase=0; 17 | MWS_Nominal.DamageOnsetTime=120; 18 | loadmws(MWS_Nominal); 19 | [MWS_Nominal,Xtrim,Fcond,Err]=trimgtm(struct('eas',95, 'gamma',3,... 20 | 'yawrate',[],'roll',45)); 21 | 22 | 23 | % Simulate flight without damage 24 | loadmws(MWS_Nominal); 25 | fprintf(1,'Simulating...'); 26 | sim('gtm_design',[0 15]); 27 | fprintf(1,'Done\n'); 28 | tout1=tout;Lon1=sout.eom.longitude*180/pi; Lat1=sout.eom.latitude*180/pi; Alt1=sout.eom.altitude; 29 | eas1=sout.aux.eas;alpha1=sout.aux.alpha; beta1=sout.aux.beta; gamma1=sout.aux.gamma; 30 | pqr1=180/pi*[sout.eom.pb sout.eom.qb sout.eom.rb]; 31 | phi1=180/pi*sout.eom.phi; 32 | theta1=180/pi*sout.eom.theta; 33 | psi1=180/pi*sout.eom.psi; 34 | 35 | % Simlate each damage case and plot 36 | for i=[1:length(MWSout.Aero.dC6_damage.cases)], 37 | % Simulate flight with Damage 38 | % Set Damage Conditions 39 | MWS_Damage=MWS_Nominal; 40 | MWS_Damage.DamageCase=i; 41 | MWS_Damage.DamageOnsetTime=10; 42 | %MWS_Damage.Aero.dC6_damage.ddscale.data=ones(18,6,3,6); 43 | loadmws(MWS_Damage); 44 | fprintf(1,'Simulating...'); 45 | fprintf(1,'Done\n'); 46 | sim('gtm_design',[0 15]); 47 | tout2=tout;Lon2=sout.eom.longitude*180/pi; Lat2=sout.eom.latitude*180/pi; Alt2=sout.eom.altitude; 48 | eas2=sout.aux.eas;alpha2=sout.aux.alpha; beta2=sout.aux.beta; gamma2=sout.aux.gamma; 49 | pqr2=180/pi*[sout.eom.pb sout.eom.qb sout.eom.rb]; 50 | phi2=180/pi*sout.eom.phi; 51 | theta2=180/pi*sout.eom.theta; 52 | psi2=180/pi*sout.eom.psi; 53 | 54 | % Plot 55 | % ------------------------Plots--------------------------- 56 | h=figure(1);,set(h,'Position',[20,20,1000,800]);clf 57 | % Alpha/Beta 58 | ax=axes('position',[.05 .70 .2 .2]); 59 | plot(tout2,[alpha2,beta2]); 60 | legend({'\alpha','\beta'},'Location','SouthWest');,grid on 61 | xlabel('time (sec)'), 62 | ylabel('\alpha (deg), \beta (deg)'); 63 | %set(ax,'Ylim',[-10 20]); 64 | title('Alpha/Beta'); 65 | 66 | % Flight Path Angle and Airspeed 67 | axes('position',[.05 .40 .2 .2]); 68 | [ax,h1,h2]=plotyy(tout2,gamma2,tout2,eas2);grid on 69 | xlabel('time (sec)'), 70 | ylabel(ax(1),'Flight Path, \gamma (deg)'); 71 | ylabel(ax(2),'Equivalent Airspeed (konts)') 72 | legend([h1;h2],{'\gamma','eas'},'Location','SouthWest'); 73 | title('Flight Path Angle and Airspeed'); 74 | 75 | % Angular Rates 76 | ax=axes('position',[.05 .10 .2 .2]); 77 | plot(tout2,pqr2);grid on 78 | legend({ 'p','q','r'},'Location','SouthWest'); 79 | xlabel('time (sec)'),ylabel('angular rates (deg/sec)') 80 | %set(ax,'Ylim',[-15 15]); 81 | title('Angular Rates'); 82 | 83 | % Euler Angles 84 | ax=axes('position',[.50 .70 .45 .2]); 85 | plot(tout2,[phi2,theta2,psi2]); 86 | legend({'roll','pitch','yaw'},'Location','SouthWest');,grid on 87 | xlabel('time (sec)'), 88 | ylabel('\phi (deg), \theta (deg), \psi (deg)'); 89 | %set(ax,'Ylim',[-10 20]); 90 | title('Euler Angles'); 91 | 92 | % Trajectory: 3D plot with orientated vehicle 93 | ax=axes('position',[.50,.1,.45,.45]); 94 | titlestr=sprintf('Nominal and DamageCase:%s',... 95 | strrep(MWSout.Aero.dC6_damage.cases{MWSout.DamageCase},'_','\_'));; 96 | h1=plot3(Lat1,Lon1,Alt1','b'); grid on,hold on 97 | h2=plot3(Lat2,Lon2,Alt2','r'); 98 | legend([h1 h2],{'Nominal Flight Path','Damage Flight Path'},... 99 | 'Location','NorthWest'); 100 | title(titlestr); 101 | xlabel('Latitude (deg)'),ylabel('Longitude (deg)'),zlabel('Altitude (ft)'); 102 | view(-45,5);set(ax,'Zlim',[600 1000]); 103 | if (exist('AutoRun','var')) 104 | pause(.2); 105 | orient portrait 106 | eval(sprintf('print -dpng exampleplot06-%d',i)); 107 | else 108 | fprintf(1,'Finished Damage Case %d, Hit Return to Continue...',i),pause,fprintf(1,'.\n'); 109 | end 110 | end 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /gtm_design/gtm_design.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/gtm_design.slx -------------------------------------------------------------------------------- /gtm_design/mfiles/CreateSimOut.m: -------------------------------------------------------------------------------- 1 | function [SimOut] = CreateSimOut(logsout) 2 | % Create structure from logged bus signal that is named SimOut. All 3 | % signals in SimOut must be the same sample time and rate. SimOut signal 4 | % must be inside a block on the top level of the diagram named 5 | % "Format_Outputs". 6 | 7 | % $Id: CreateSimOut.m 2 2015-05-07 21:03:59Z cox $ 8 | 9 | % Paste the commented code below into the Model StopFcn callback: 10 | 11 | % if SimIn.Switches.LogData 12 | % if exist('logsout','var') 13 | % clear SimOut 14 | % SimOut = CreatSimOut(logsout); 15 | % else 16 | % Disp('No Log Data Variable') 17 | % end 18 | % end 19 | % clear logsout 20 | 21 | % Eugene Heim, NASA Langley Research Center 22 | % Modified, david.e.cox NASA Langley Research Center 23 | 24 | 25 | if (isa(logsout,'Simulink.ModelDataLogs')==1), % Old ModelDataLogs format for logsout 26 | temp = logsout.whos('all');% Get all field names 27 | index = find(strcmp('Timeseries',{temp(:).simulinkClass}));% Find signals 28 | for ii = 1:length(index) 29 | % Remove blockname hierarchy. Cut string before first occurance of SimOut 30 | tmpstr=temp(index(ii)).name; 31 | VariableName = tmpstr([min(strfind(tmpstr,'SimOut')):end]); 32 | % Grab TimeSeries data, remove singletons and make time vector first dimension, if necessary 33 | eval(sprintf('data = squeeze(logsout.%s.Data);', temp(index(ii)).name)); 34 | eval(sprintf('timelen = length(logsout.%s.Time);',temp(index(ii)).name)) 35 | if ndims(data) > 2 && timelen>1 % for N-D matrices time is last dim, unless time is singleton. 36 | eval([VariableName, ' = permute(data,[ndims(data),[1:ndims(data)-1]]);']) 37 | else 38 | eval([VariableName,' = data;']); 39 | end 40 | end 41 | elseif (isa(logsout,'Simulink.SimulationData.Dataset')==1), % New Dataset format for logsout 42 | tmp=logsout.getElement(1); %Should only be one. 43 | SimOut_TS=tmp.Values; %Already a data struct 44 | SimOut=ts2vec(SimOut_TS); %Convert timeseries to simple vector/matrix, recursive function 45 | end 46 | 47 | 48 | function sout = ts2vec(sin); 49 | %function sout = ts2vec(sin); 50 | 51 | sout=sin; 52 | fn=fieldnames(sin); 53 | for i=1:length(fn), 54 | if (isa(sin.(fn{i}),'timeseries')==1), 55 | tstmp=sin.(fn{i}); 56 | sout.(fn{i})=tstmp.Data; 57 | elseif (isa(sin.(fn{i}),'struct')==1), 58 | sout.(fn{i})=ts2vec(sin.(fn{i})); % Recursive voodoo... 59 | else 60 | fprintf(1,'WARNING: Action for class %s at field %s is undefined, ignoring\n',class(sin.(fn{i})),fn{i}); 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /gtm_design/mfiles/appendmws.m: -------------------------------------------------------------------------------- 1 | function appendmws(MWS,model) 2 | %function appendmws(MWS,model) 3 | % 4 | % Appends model workspace with variables 5 | % given by the fields of the structure MWS. 6 | % 7 | % ! Warning ! Will overwrite indentically named variables without warning! 8 | % 9 | % Inputs: 10 | % MWS - Model Workspace Structure, contains simulation parameters 11 | % model - Name of model to load into, default is 'gtm_design' 12 | % 13 | 14 | % $Id: appendmws.m 4852 2013-08-06 22:12:54Z cox $ 15 | % Author: Austin Murch (Austin.M.Murch@nasa.gov) 16 | % Adpated from code by Dave Cox (d.e.cox@larc.nasa.gov) 17 | 18 | 19 | % By default use the bdroot model 20 | if ( ~exist('model','var') || isempty(model) ), 21 | model=bdroot; 22 | end 23 | 24 | mws=get_param(model,'modelworkspace'); 25 | 26 | fn=fieldnames(MWS); 27 | for i=1:length(fn) 28 | mws.assignin(fn{i},MWS.(fn{i})); 29 | end 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /gtm_design/mfiles/clearmws.m: -------------------------------------------------------------------------------- 1 | function clearmws(model); 2 | %function clearmws(model); 3 | % 4 | % Clears the current model workspace. 5 | % 6 | % Inputs: 7 | % model - name of model, defaults to 'gtm_design' 8 | % 9 | 10 | % d.e.cox@larc.nasa.gov 11 | % $Id: clearmws.m 4852 2013-08-06 22:12:54Z cox $ 12 | 13 | % By default use the bdroot model 14 | if ( ~exist('model','var') || isempty(model) ), 15 | model=bdroot; 16 | end 17 | 18 | mws=get_param(model,'modelworkspace'); 19 | mws.clear; 20 | 21 | 22 | -------------------------------------------------------------------------------- /gtm_design/mfiles/euler321.m: -------------------------------------------------------------------------------- 1 | function DCM = euler321(p); 2 | %function DCM = euler321(p); 3 | % 4 | % Creates directional cosine matrix for euler 321 rotation 5 | % sequence. 6 | % 7 | % Inputs: 8 | % p - phi/theta/psi vector, in radians 9 | % 10 | % Outputs: 11 | % DCM - Directional cosine matrix 12 | % 13 | 14 | % $Id: euler321.m 4852 2013-08-06 22:12:54Z cox $ 15 | 16 | p=p(:); 17 | cp=cos(p); 18 | sp=sin(p); 19 | 20 | DCM=[cp(2)*cp(3), cp(2)*sp(3), -sp(2); 21 | sp(1)*sp(2)*cp(3)-cp(1)*sp(3),sp(1)*sp(2)*sp(3)+cp(1)*cp(3), sp(1)*cp(2); 22 | cp(1)*sp(2)*cp(3)+sp(1)*sp(3),cp(1)*sp(2)*sp(3)-sp(1)*cp(3), cp(1)*cp(2)]; 23 | 24 | -------------------------------------------------------------------------------- /gtm_design/mfiles/grabmws.m: -------------------------------------------------------------------------------- 1 | function MWS = grabmws(model); 2 | %function MWS = grabmws(model); 3 | % 4 | % Grabs current model workspace and returns as 5 | % fields in a strucure 6 | % 7 | % Inputs: 8 | % model - name of model, defaults to 'gtm_design' 9 | % 10 | % Outputs: 11 | % MWS - simlation parameters from the model workspace 12 | % 13 | 14 | % d.e.cox@larc.nasa.gov 15 | % $Id: grabmws.m 4852 2013-08-06 22:12:54Z cox $ 16 | 17 | % By default use the bdroot model 18 | if ( ~exist('model','var') || isempty(model) ), 19 | model=bdroot; 20 | end 21 | 22 | mws=get_param(model,'modelworkspace'); 23 | mws_vars=mws.whos; 24 | for i=[1:length(mws_vars)], 25 | MWS.(mws_vars(i).name)=mws.evalin(mws_vars(i).name); 26 | end 27 | 28 | 29 | -------------------------------------------------------------------------------- /gtm_design/mfiles/init_design.m: -------------------------------------------------------------------------------- 1 | function MWS = init_design(vehicle,noise_on,fuelburn_on) 2 | %function MWS = init_design(vehicle); 3 | % 4 | % Creates Model Workspace Structure for gtm_design simulation. 5 | % 6 | % Inputs: 7 | % vehicle - type of vehicle, currently only 'GTM_T2' (default = 'GTM_T2') 8 | % noise_on - flag for turning sensor noise models on (default = 0) 9 | % fuelburn_on - flag for turning fuel burn model on (default = 0) 10 | % 11 | % Outputs: 12 | % MWS - Simulation parameters, to be loaded into Model Workspace 13 | % with loadmws(MWS) or appendmws(MWS). 14 | % 15 | 16 | % d.e.cox@larc.nasa.gov 17 | % $Id: init_design.m 4852 2013-08-06 22:12:54Z cox $ 18 | 19 | if ~exist('vehicle','var') || isempty(vehicle) 20 | vehicle='GTM_T2'; 21 | end 22 | 23 | if strcmp(vehicle,'GTM'), 24 | vehicle='GTM_T2'; % Backwards compatible 25 | end 26 | 27 | if ~exist('noise_on','var') || isempty(noise_on) 28 | noise_on = 0; 29 | end 30 | 31 | if ~exist('fuelburn_on','var') || isempty(fuelburn_on) 32 | fuelburn_on = 0; 33 | end 34 | 35 | % Initialize MWS structure 36 | MWS=[]; 37 | 38 | % Winds 39 | MWS.WindDir = 270; %deg, true heading wind is coming FROM 40 | MWS.WindSpd = 0; %kts, wind speed 41 | MWS.WindShearOn = 1; 42 | 43 | % Sim timestep 44 | MWS.Timestep = 1/200; % sec 45 | 46 | % Initial Conditions 47 | ini.Altitude = 800; % ft 48 | ini.tas = 75; % knots 49 | ini.alpha = 3; % deg 50 | ini.gamma = 1; % deg 51 | ini.stab = 0; 52 | % ini.lat = 37.02814654; %Smithfield, deg 53 | % ini.lon = -76.58696588; %Smithfield, deg 54 | % Flying at Wallops 55 | ini.lat = 37.827926944; 56 | ini.lon = -75.494061666; 57 | MWS.StatesInp = SetICs(ini); 58 | MWS.runway_alt = 12; %ft 59 | 60 | MWS.fuel_in_use = fuelburn_on; % fuel burn on/off 61 | 62 | 63 | switch(upper(vehicle)) 64 | case 'GTM_T2', 65 | %MWS.Aero=load('T2_restricted_aerodatabase'); 66 | MWS.Aero=load('T2_polynomial_aerodatabase'); 67 | 68 | % Load aircraft parameters and noise models 69 | MWS = AC_baseparams_T2(MWS); 70 | MWS = NoiseParams_T2(MWS,noise_on); % Second parameter is on/off 71 | 72 | % Generate Damage Models 73 | MWS = DamageModels_T2(MWS); 74 | otherwise, 75 | error('No Parameters defined for vehicles: %s',vehicle); 76 | end 77 | 78 | % Surface/Throttle Offsets for trim 79 | MWS.bias.aileron =0; 80 | MWS.bias.speedbrake =0; 81 | MWS.bias.elevator =0; 82 | MWS.bias.flaps =0; 83 | MWS.bias.rudder =0; 84 | MWS.bias.stabilizer =0; 85 | MWS.bias.throttle =20; 86 | MWS.bias.geardown =0; 87 | 88 | % Basic Table Options 89 | MWS.LinearizeModeOn=0; 90 | MWS.TrimModeOn=0; 91 | MWS.SurfaceDeadbandOn=0; 92 | MWS.TrimWithStab=0; 93 | MWS.symmetric_aero_on = 1; 94 | MWS.DamageCase = 0; 95 | MWS.DamageOnsetTime=10; % In secs. 96 | 97 | % Engine on/off parameters 98 | MWS.LengON = 1; 99 | MWS.RengON = 1; 100 | 101 | %Engine Ram Drag Coefficient 102 | MWS.ram_drag_coef = 0.010; 103 | 104 | % Set turbulence model parameters 105 | MWS = init_turbulence(MWS); 106 | 107 | % The following increase asymetric response at stall and 108 | % have been used for pilot training 109 | MWS.stall_cl_asym_enabled = 0; % turn the Cl asymetry at stall on/off 110 | %MWS.stall_cl_asym_add_uncertainty = 0; % add random uncertainties to Cl 111 | %MWS.stall_cl_asym_vary_sign = 0; % apply random +/-1 gain to Cl 112 | 113 | 114 | %--------------------SubFunctions-------------------- 115 | 116 | function [StatesInp] = SetICs(ini) 117 | StatesInp= zeros(12,1); 118 | 119 | knots2fps = 1/0.592487; 120 | d2r=pi/180; 121 | 122 | ub = (knots2fps)*ini.tas*cos(ini.alpha*d2r); 123 | wb = (knots2fps)*ini.tas*sin(ini.alpha*d2r); 124 | 125 | theta = ini.alpha + ini.gamma; 126 | 127 | StatesInp(1) = ub; % 1 - ub (ft/s) 128 | StatesInp(2) = 0; % 2 - vb (ft/s) 129 | StatesInp(3) = wb; % 3 - wb (ft/s) 130 | StatesInp(4) = 0; % 4 - pb (rad/s) 131 | StatesInp(5) = 0; % 5 - qb (rad/s) 132 | StatesInp(6) = 0; % 6 - rb (rad/s) 133 | StatesInp(7) = ini.lat*d2r; % 7 - lat (rad), +north, 134 | StatesInp(8) = ini.lon*d2r; % 8 - lon (rad), +east, 135 | StatesInp(9) = ini.Altitude; % 9 - h (ft) 136 | StatesInp(10) = 0; % 10 - phi (rad) 137 | StatesInp(11) = theta*d2r; % 11 - theta (rad) 138 | StatesInp(12) = pi/2; % 12 - psi (rad) 139 | 140 | 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /gtm_design/mfiles/linmodel.m: -------------------------------------------------------------------------------- 1 | function [sys,londyn,latdyn] = linmodel(MWS,vabflag,use_all_inputs,Ts) 2 | %function [sys,londyn,latdyn] = linmodel(MWS,vabflag,use_all_inputs,Ts) 3 | % 4 | % Linearize gtm_design simulation at the current trim point. The 5 | % linear model is continuous by default, discrete if the 'Ts' argument 6 | % is non-zero. 7 | % 8 | % Inputs: 9 | % MWS - simulation parameters, defaults to pre-loaded model workspace 10 | % vabflag - flag to get linear models in terms of V, alpha, beta (0 default) 11 | % use_all_inputs -for using full set of inputs rather than groups (0 default) 12 | % Ts - Timestep for generating a discrete linear model (0 default) 13 | % 14 | % Outputs: 15 | % sys - 6dof system with control surface inputs/state outputs 16 | % londyn - Approximate (4th order) longitudinal dynamics 17 | % latdyn - Approximate (4th order) lateral dynamics 18 | % 19 | 20 | % d.e.cox@larc.nasa.gov 21 | % $Id: linmodel.m 4852 2013-08-06 22:12:54Z cox $ 22 | 23 | %% Parse Input Arguments 24 | % Load new model workspace if supplied 25 | if (exist('MWS','var') && ~isempty(MWS)) 26 | if isstruct(MWS) 27 | loadmws(MWS,'gtm_design'); 28 | else 29 | error('MWS input must be a data structure') 30 | end 31 | end 32 | 33 | % Set optional flags 34 | if ~exist('vabflag','var') || isempty(vabflag), 35 | vabflag = 0; 36 | end 37 | 38 | if ~exist('use_all_inputs','var') || isempty(use_all_inputs) 39 | use_all_inputs = 0; 40 | end 41 | 42 | Args = []; 43 | if ~exist('Ts','var') || isempty(Ts) || Ts <= 0 44 | Ts = 0; 45 | Args = 'IgnoreDiscreteStates'; 46 | end 47 | 48 | %% Initializations and sim setup 49 | % Set Inline Params to off. 50 | % If not "off", trim results degrade (why??) 51 | dirtyflag =get_param('gtm_design','Dirty'); 52 | inlineflag=get_param('gtm_design','InlineParams'); 53 | set_param('gtm_design','InlineParams','off'); 54 | 55 | % Grab state names 56 | [tmp1,tmp2,Statename]=gtm_design; 57 | 58 | % Get index for Equations of Motion states 59 | EOM =find(strcmp(Statename,['gtm_design/GTM_T2/EOM/Integrator'])==1); 60 | 61 | % Set LinearizationFlag 62 | appendmws(struct('LinearizeModeOn',1),'gtm_design'); 63 | 64 | %% Run sim for 0.1 seconds. 65 | % This initializes some states that are not set by trimgtm, e.g. 66 | % memory blocks, filter states, etc. 67 | [t,Xtime,y]=sim('gtm_design',[0 0.1]); 68 | Xo=Xtime(end,:); 69 | 70 | %% Check to ensure non-accelerating set point 71 | tol=1e-3; 72 | delta_vel=Xtime(1,EOM(1:6))-Xtime(end,EOM(1:6)); 73 | if max(abs(delta_vel))>tol, 74 | fprintf(1,'\n at t=%3.2f sec Xvel=[%5.2e %5.2e %5.2e %5.2e %5.2e %5.2e]',t(1), Xtime(1,EOM(1:6))); 75 | fprintf(1,'\n at t=%3.2f sec Xvel=[%5.2e %5.2e %5.2e %5.2e %5.2e %5.2e]\n',t(end),Xtime(end,EOM(1:6))); 76 | warning('Model does not appear to be at a stationary point, deltaV=%3.2f',max(abs(delta_vel))); 77 | end 78 | 79 | %% Extract the Linear Model using dlinmod. For Ts > 0, the model is discrete. 80 | warning('off','Simulink:tools:dlinmodIgnoreDiscreteStates'); 81 | [a,b,c,d]=dlinmod('gtm_design',Ts,Xo,Args); 82 | sys=ss(a,b,c,d,Ts); 83 | warning('on','Simulink:tools:dlinmodIgnoreDiscreteStates'); 84 | 85 | % Define states to retain, remove others 86 | keep=EOM(1)+[0:11]'; 87 | elim=setdiff([1:length(a)]',keep); 88 | sys=modred(sys,elim,'del'); 89 | 90 | % Remove some of the outputs that are used for trim only 91 | % First 6 are from AUX, last 12 are from the EOM 92 | sys=sys([2:4,7:18],:); 93 | 94 | % Remove firsst four inputs (trim inputs) 95 | sys=sys(:,[5:23]); 96 | 97 | % Convert units on selected outputs 98 | sys.c(1,:) = sys.c(1,:)*1.6878; % convert tas to feet per second 99 | sys.c(2,:) = sys.c(2,:)*pi/180; % convert alpha to radians 100 | sys.c(3,:) = sys.c(3,:)*pi/180; % convert beta to radians 101 | 102 | % Set names, hardwired from ordering in block diagram 103 | 104 | Inames={'ElevLOB','ElevLIB','ElevROB','ElevRIB', ...% 1 2 3 4 105 | 'AileronL', 'AileronR', ...% 5 6 106 | 'RudderUpper','RudderLower', ...% 7 8 107 | 'SpoilerLIB', 'SpoilerLOB', 'SpoilerRIB','SpoilerROB',...% 9 10 11 12 108 | 'FlapsLIB', 'FlapsLOB', 'FlapsRIB', 'FlapsROB', ...% 13 14 15 16 109 | 'Stabilizer', ...% 17 110 | 'L Throttle', 'R Throttle'}; % 18 19 111 | 112 | Snames={'u', 'v', 'w', ... % 1 2 3 113 | 'p', 'q', 'r', ... % 4 5 6 114 | 'Lat', 'Lon', 'Alt', ... % 7 8 9 115 | 'phi', 'theta', 'psi'}; % 10 11 12 116 | 117 | Onames={'tas', 'alpha', 'beta', ... % 1 2 3 118 | 'u', 'v', 'w', ... % 4 5 6 119 | 'p', 'q', 'r', ... % 7 8 9 120 | 'Lat', 'Lon', 'Alt', ... % 10 11 12 121 | 'phi', 'theta', 'psi'}; % 13 14 15 122 | 123 | set(sys,'Statename',Snames,'Outputname',Onames,'Inputname',Inames); 124 | 125 | % Create 4th order longitudinal/lateral models 126 | Xlon=[1 3 5 11]; % States to keep (u,w,q,theta) 127 | Xlat=[2 4 6 10]; % States to keep (v,p,r,phi) 128 | 129 | 130 | if use_all_inputs 131 | 132 | % Keep the inputs using indices for the full set of control surface inputs 133 | Ilon=[1 2 3 4 9 10 11 12 18 19]; % inputs to keep: elev, spoilers, thrott 134 | Ilat=[5 6 7 8 9 10 11 12]; % inputs to keep: ail, rudder, spoilers 135 | 136 | else 137 | 138 | % Keep the inputs using indices for a subset of control surface inputs 139 | 140 | % Model inputs are: elevator, aileron, rudder, LSpoiler, RSpoiler, 141 | % Flap, Stab, LThrottle, RThrottle 142 | % 143 | % Reduce/group the full set of control surfaces into the subsets: 144 | % 145 | sys.b(:,1) = sys.b(:,1) + sys.b(:,2) + sys.b(:,3) + sys.b(:,4); %1 elev 146 | sys.b(:,2) = sys.b(:,5) + sys.b(:,6); %2 ail 147 | sys.b(:,3) = sys.b(:,7) + sys.b(:,8); %3 rud 148 | sys.b(:,4) = sys.b(:,9) + sys.b(:,10); %4 Lspoil 149 | sys.b(:,5) = sys.b(:,11) + sys.b(:,12); %5 Rspoil 150 | sys.b(:,6) = sys.b(:,13) + sys.b(:,14) + sys.b(:,15) + sys.b(:,16); %6 flap 151 | sys.b(:,7) = sys.b(:,17); %7 stab 152 | sys.b(:,8) = sys.b(:,18); %8 Lthrot 153 | sys.b(:,9) = sys.b(:,19); %9 Rthrot 154 | 155 | sys.d(:,1) = sys.d(:,1) + sys.d(:,2) + sys.d(:,3) + sys.d(:,4); %1 elev 156 | sys.d(:,2) = sys.d(:,5) + sys.d(:,6); %2 ail 157 | sys.d(:,3) = sys.d(:,7) + sys.d(:,8); %3 rud 158 | sys.d(:,4) = sys.d(:,9) + sys.d(:,10); %4 Lspoil 159 | sys.d(:,5) = sys.d(:,11) + sys.d(:,12); %5 Rspoil 160 | sys.d(:,6) = sys.d(:,13) + sys.d(:,14) + sys.d(:,15) + sys.d(:,16); %6 flap 161 | sys.d(:,7) = sys.d(:,17); %7 stab 162 | sys.d(:,8) = sys.d(:,18); %8 Lthrot 163 | sys.d(:,9) = sys.d(:,19); %9 Rthrot 164 | 165 | Ilon=[1 4 5 8 9]; % inputs to keep: elev, spoilers, throttle 166 | Ilat=[2 3 4 5]; % inputs to keep: aileron, rudder, spoilers 167 | 168 | sys(:,10:19) = []; % Remove the unused inputs 169 | 170 | Inames={'Elevator', 'Aileron','Rudder',... % 1 2 3 171 | 'L Spoiler', 'R Spoiler', ... % 4 5 172 | 'Flaps', 'Stabilizer', ... % 6 7 173 | 'L Throttle','R Throttle'}; % 8-9 174 | 175 | set(sys,'Inputname',Inames); 176 | 177 | end 178 | 179 | 180 | if vabflag 181 | Ylon = [1 2 8 14]; % outputs to keep (tas,alpha,q,theta) 182 | Ylat = [3 7 9 13]; % outputs to keep (beta,p,r,phi) 183 | londyn=modred(sys(Ylon,Ilon),setdiff(1:12,Xlon),'del'); 184 | londyn.a = londyn.c*londyn.a*inv(londyn.c); 185 | londyn.b = londyn.c*londyn.b; 186 | londyn.c = eye(4); 187 | set(londyn,'Statename',Onames([1 2 8 14])) 188 | 189 | latdyn=modred(sys(Ylat,Ilat),setdiff(1:12,Xlat),'del'); 190 | latdyn.a = latdyn.c*latdyn.a*inv(latdyn.c); 191 | latdyn.b = latdyn.c*latdyn.b; 192 | latdyn.c = eye(4); 193 | set(latdyn,'Statename',Onames([3 7 9 13])) 194 | 195 | sys = sys([1:3, 7:15],:); 196 | sys.a = sys.c*sys.a*inv(sys.c); 197 | sys.b = sys.c*sys.b; 198 | sys.c = eye(12); 199 | set(sys,'Statename',Onames([1:3, 7:15])) 200 | 201 | else 202 | Ylon = [4 6 8 14]; % outputs to keep (u,w,q,theta) 203 | Ylat = [5 7 9 13]; % outputs to keep (v,p,r,phi) 204 | londyn=modred(sys(Ylon,Ilon),setdiff(1:12,Xlon),'del'); 205 | latdyn=modred(sys(Ylat,Ilat),setdiff(1:12,Xlat),'del'); 206 | sys = sys(4:15,:); 207 | end 208 | 209 | %% Return to initial parameters 210 | set_param('gtm_design','InlineParams',inlineflag); 211 | set_param('gtm_design','Dirty',dirtyflag); 212 | 213 | % reset Linearization Flag 214 | appendmws(struct('LinearizeModeOn',0),'gtm_design'); 215 | 216 | 217 | 218 | -------------------------------------------------------------------------------- /gtm_design/mfiles/loadmws.m: -------------------------------------------------------------------------------- 1 | function loadmws(MWS,model); 2 | %function loadmws(MWS,model); 3 | % 4 | % Clears model workspace and replaces with variables 5 | % given by the fields of the structure MWS 6 | % 7 | % Inputs: 8 | % MWS - Model Workspace Structure, contains simulation parameters 9 | % model - Name of model to load into, default is 'gtm_design' 10 | % 11 | 12 | % d.e.cox@larc.nasa.gov 13 | % $Id: loadmws.m 4852 2013-08-06 22:12:54Z cox $ 14 | 15 | % By default use the bdroot model 16 | if ( ~exist('model','var') || isempty(model) ), 17 | model=bdroot; 18 | end 19 | 20 | mws=get_param(model,'modelworkspace'); 21 | 22 | if ( ~exist('MWS') || isempty(MWS) ), 23 | mws.clear; 24 | return 25 | else 26 | mws.clear; 27 | fn=fieldnames(MWS); 28 | for i=[1:length(fn)], 29 | mws.assignin(fn{i},MWS.(fn{i})); 30 | end 31 | end 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /gtm_design/mfiles/seteomic.m: -------------------------------------------------------------------------------- 1 | function MWS_out = seteomic(MWS,varargin); 2 | %function MWS_out = seteomic(MWS,statename,value,statename,value,...) 3 | % 4 | % This function allows the initial condtions of the gtm_design simulation's 5 | % equation of motion (MWS.StatesInp) to be specified by named values. 6 | % 7 | % Specifically statename is one of: 8 | % tas - total airspeed (knots) 9 | % alpha - angle of attack (deg) 10 | % beta - sideslip (deg) 11 | % p - body rate (deg/sec) 12 | % q - body rate (deg/sec) 13 | % r - body rate (deg/sec) 14 | % lat - latitude (deg) 15 | % lon - longitude (deg) 16 | % alt - altitude (ft) 17 | % phi - Euler angle (deg) 18 | % theta - Euler angle (deg) 19 | % psi - Euler angle (deg) 20 | % 21 | % Values not explictly specified remain at the value they had in MWS 22 | % 23 | % Examples: 24 | % MWS=seteomic(init_design(),'alt',3000); 25 | % MWS=seteomic(MWS,'tas',90,'beta',3,'p',15); 26 | % 27 | 28 | % d.e.cox@larc.nasa.gov 29 | % $Id: seteomic.m 4852 2013-08-06 22:12:54Z cox $ 30 | 31 | % Constants 32 | fps2knots = 0.592487; 33 | knots2fps = 1/fps2knots; 34 | d2r=pi/180; 35 | r2d=180/pi; 36 | 37 | % default to incoming parameters 38 | MWS_out=MWS; 39 | 40 | % put named IC values into a structure 41 | ini=struct(varargin{:}); 42 | 43 | 44 | % Only set these if one of tas/alpha/beta is being specified 45 | fn=fieldnames(ini); 46 | if ~isempty(strmatch('tas',fn)) || ~isempty(strmatch('alpha',fn))|| ~isempty(strmatch('beta',fn)), 47 | V=MWS.StatesInp(1:3); 48 | Vt=sqrt(sum(V.^2)); 49 | % For unspecified but coupled parameters, preserve incoming condition. 50 | if ~isfield(ini,'alpha'), ini.alpha=atan2(V(3),V(1))*r2d; end 51 | if ~isfield(ini,'beta'); ini.beta =atan2(V(2)*cos(ini.alpha),V(1))*r2d; end 52 | if ~isfield(ini,'tas'), ini.tas=Vt/knots2fps; end 53 | end 54 | 55 | % Error Check input, kick out on unknown names 56 | fn=fieldnames(ini); 57 | knownames={ 'alpha','beta','tas','p','q','r','alt','lat','lon','phi','theta','psi'}; 58 | for i=[1:length(fn)], 59 | if isempty(strmatch(fn{i},knownames,'exact')), 60 | error(sprintf('Unknown name: %s\n',fn{i})); 61 | end 62 | end 63 | 64 | for i=[1:length(fn)], 65 | switch(fn{i}) 66 | case {'alpha','beta','tas'}, % coupled params, this sets IC multiple times,... inefficient but harmless 67 | ub = (knots2fps)*ini.tas*cos(ini.alpha*d2r)*cos(ini.beta*d2r); 68 | vb = (knots2fps)*ini.tas*sin(ini.beta*d2r); 69 | wb = (knots2fps)*ini.tas*sin(ini.alpha*d2r)*cos(ini.beta*d2r); 70 | MWS_out.StatesInp(1) = ub; % 1 - ub (ft/s) 71 | MWS_out.StatesInp(2) = vb; % 2 - vb (ft/s) 72 | MWS_out.StatesInp(3) = wb; % 3 - wb (ft/s) 73 | 74 | case 'p' 75 | MWS_out.StatesInp(4)=ini.p*d2r; 76 | case 'q' 77 | MWS_out.StatesInp(5)=ini.q*d2r; 78 | case 'r' 79 | MWS_out.StatesInp(6)=ini.r*d2r; 80 | 81 | case 'lat' 82 | MWS_out.StatesInp(7)=ini.lat*d2r; 83 | case 'lon' 84 | MWS_out.StatesInp(8)=ini.lon*d2r; 85 | case 'alt' 86 | MWS_out.StatesInp(9)=ini.alt; 87 | 88 | case 'phi', 89 | MWS_out.StatesInp(10)=ini.phi*d2r; 90 | case 'theta', 91 | MWS_out.StatesInp(11)=ini.theta*d2r; 92 | case 'psi', 93 | MWS_out.StatesInp(12)=ini.psi*d2r; 94 | 95 | end 96 | end 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /gtm_design/mfiles/trimgtm.m: -------------------------------------------------------------------------------- 1 | function [MWS,Xtrim,Trimcond,Err] = trimgtm(target,PitchSurf,verbose) 2 | %function [MWS,Xtrim,Trimcond,Err] = trimgtm(target,PitchSurf,verbose) 3 | % 4 | % Trims gtm_design simulation to target conditions. 5 | % 6 | % Inputs: 7 | % Target is a structure which has some subset of the following fields: 8 | % eas - Equivalent air speed (knots) 9 | % tas - True airspeed (knots) 10 | % alpha - Angle of attack (deg) 11 | % beta - Sideslip (deg), defaults to zero 12 | % gamma - Flight path angle (deg) 13 | % gndtrack - Ground track angle (deg) 14 | % roll - Roll angle (deg) 15 | % pitch - Pitch angle (deg) 16 | % yaw - Heading angle (0-360) 17 | % rollrate - d/dt(phi) (deg/sec), defaults to zero 18 | % pitchrate - d/dt(theta) (deg/sec), defaults to zero 19 | % yawrate - d/dt(psi) (deg/sec), defaults to zero 20 | % pdeg - Angular velocity (deg/sec) 21 | % qdeg - Angular velocity (deg/sec) 22 | % rdeg - Angular velocity (deg/sec) 23 | % 24 | % PitchSurf - 'elev' for elevator (default) or 'stab' for stabalizer 25 | % verbose - 0(quiet), 1(soln disp), or 2(iterations), defaults to 2 26 | % 27 | %Outputs: 28 | % MWS - simulation parameter set, updated to be at trim condition 29 | % Xtrim - simulation full-state, at trim 30 | % Trimcond - values of state and control surfaces at trim. 31 | % Err - max error in trim condition 32 | % 33 | % Unspecified variables are free, or defaulted to the values shown above. 34 | % To force a defaulted variable to be free define it with an empty matrix. 35 | % For example, by default beta=0 but "target.beta=[];" will allow beta 36 | % to be free in searching for a trim condition. 37 | % 38 | % Examples: 39 | % MWS=trimgtm(struct('eas',95,'gamma',0)); 40 | % [MWS,Xt,Tc,Er]=trimgtm(struct('alpha',3,'gamma',0,'yaw',120),1); 41 | % [MWS,Xt,Tc,Er]=trimgtm(struct('tas',100,'gamma',3,'yawrate',10),0,0); 42 | % 43 | 44 | % d.e.cox@larc.nasa.gov 45 | % $Id: trimgtm.m 4852 2013-08-06 22:12:54Z cox $ 46 | 47 | %Define surface bounds for trim conditions 48 | ThrLim = [ 0; 100]; % Throttle limits (%) 49 | EleLim = [-30.0; 30.0]; % Elevator bounds (degrees) 50 | StbLim = [-12.0; 4.0]; % Stabilizer bounds (degrees) 51 | AilLim = [-20; 20]; % Aileron limits (degrees) 52 | RudLim = [-30; 30]; % Rudder limits (deg) 53 | 54 | 55 | 56 | % Elevator Trim by default 57 | if (~exist('PitchSurf','var') || isempty (PitchSurf)), 58 | PitchSurf='elev'; 59 | end 60 | 61 | % Assign logical TrimWithStab variable, set appropriate pitchsurface limits 62 | if strncmpi(PitchSurf,'elev',4), 63 | appendmws(struct('TrimWithStab',0),'gtm_design'); 64 | PitchSurfLim=EleLim; 65 | elseif strncmpi(PitchSurf,'stab',4) 66 | appendmws(struct('TrimWithStab',1),'gtm_design'); 67 | PitchSurfLim=StbLim; 68 | else 69 | error('String variable PitchSurf must be one of ''elev'' or ''stab'' '); 70 | end 71 | 72 | % Noisy by default 73 | if ( ~exist('verbose','var') || isempty(verbose) ), verbose=2; end 74 | 75 | % Error checking input 76 | if ( isfield(target,'eas') && isfield(target,'tas') ) 77 | error('May specify a eas or tas, but not both'); 78 | end 79 | 80 | if isfield(target,'alpha')&&isfield(target,'pitch')&&isfield(target,'gamma'), 81 | error('Lacking free variable, cannot specify target in alpha,pitch and gamma'); 82 | end 83 | 84 | knownfields={ 'eas','tas','alpha','beta','gamma','gndtrack',... 85 | 'roll','pitch','yaw',... 86 | 'rollrate','pitchrate','yawrate',... 87 | 'pdeg','qdeg','rdeg'}; 88 | saywhat=setdiff(fieldnames(target),knownfields); 89 | if ~isempty(saywhat), 90 | for i=1:length(saywhat),fprintf(1,'Unknown field in target: %s\n',saywhat{i}),end 91 | error('Unknown fields'); 92 | end 93 | 94 | % Defaults if not specified 95 | if ~isfield(target,'beta'), target.beta=0; end 96 | if ~isfield(target,'rollrate'), target.rollrate=0; end 97 | if ~isfield(target,'pitchrate'),target.pitchrate=0; end 98 | if ~isfield(target,'yawrate'), target.yawrate=0; end 99 | 100 | % Remove fields assocated with empty targets (overrides defaults); 101 | fn=fieldnames(target); 102 | for i=1:length(fn) 103 | if isempty(target.(fn{i})) 104 | target=rmfield(target,fn{i}); 105 | end 106 | end 107 | 108 | % Warn on zero gndtrack|yaw 109 | if isfield(target,'yaw') && target.yaw==0, 110 | warning('0 degree yaw is at 0/360 discontinuity, optimizer may stall'); pause(1); 111 | end 112 | 113 | 114 | 115 | % Set Inline Params to off. 116 | % If not "off", optimization stalls completely. 117 | dirtyflag =get_param('gtm_design','Dirty'); 118 | inlineflag=get_param('gtm_design','InlineParams'); 119 | initwarnflag=get_param('gtm_design','InitInArrayFormatMsg'); 120 | set_param('gtm_design','InlineParams','off'); 121 | set_param('gtm_design','InitInArrayFormatMsg','None'); 122 | 123 | % Configure sim for trim inputs 124 | appendmws(struct('TrimModeOn',1),'gtm_design'); 125 | 126 | % Compile model, setup initial conds and bounds 127 | [tmp1,Xo,StateNames]=gtm_design([],[],[],'compile'); 128 | 129 | % Index.EOM below maps the 12 EOM states into the larger simulation state. 130 | % This index mapping should be used for all access to variables Xo, Xtrim, dx 131 | 132 | % Get index offsets to relevant states, EOM, Engine dynamics and actuator servos 133 | Index.EOM = find(strcmp(StateNames,'gtm_design/GTM_T2/EOM/Integrator')==1); 134 | 135 | XU_0=[Xo(Index.EOM(1:6)); Xo(Index.EOM(10:12));0;0;0;20;1e4]; 136 | 137 | % Set limits on variables used to constrain optimization, roll angle (phi) 138 | % is limited to +/- 90 deg 139 | XU_lower=[ -inf*ones(6,1); -pi/2; -inf; -inf; PitchSurfLim(1); AilLim(1); RudLim(1); ThrLim(1); 0]; 140 | XU_upper=[ inf*ones(6,1); pi/2; inf; inf; PitchSurfLim(2); AilLim(2); RudLim(2); ThrLim(2); inf]; 141 | 142 | % Setup optimization parameters 143 | para=[]; 144 | if (verbose==2), para(1)=1; end % Verbose display 145 | para(2)=1e-7; % Convergence criteria 146 | para(7)=1; % Update Hessian 147 | para(13)=6; % 6 equality constraints d/dt[pqr;uvw] = 0 148 | para(14)=2500; % Iteration limit 149 | 150 | % Run optimization 151 | 152 | if (verbose==1), fprintf(1,'Optimizing using simulink function nlconst...'); end 153 | warning('off','MATLAB:nearlySingularMatrix'); 154 | warning('off','MATLAB:divideByZero'); 155 | [XU_opt,opt] = simcnstr('trim',@(x) simio(x,Xo,Index,target),XU_0,para,XU_lower,XU_upper,[]); 156 | warning('on','MATLAB:nearlySingularMatrix'); 157 | warning('on','MATLAB:divideByZero'); 158 | if (verbose==1), fprintf(1,' Done\n'), end 159 | 160 | 161 | % Map angular trim conditions to this range: 162 | % phi=[-pi:pi] theta=[-pi:pi] psi=[0:2*pi] 163 | % Note: using XU_lower/upper constraints for these 164 | % seems to make optimization more difficult 165 | XU_opt(7:9)=mod(XU_opt(7:9),2*pi); 166 | if(XU_opt(7)>+pi), XU_opt(7)=XU_opt(7)-2*pi; end 167 | if(XU_opt(7)<-pi), XU_opt(7)=XU_opt(7)+2*pi; end 168 | if(XU_opt(8)>+pi), XU_opt(8)=XU_opt(8)-2*pi; end 169 | if(XU_opt(8)<-pi), XU_opt(8)=XU_opt(8)+2*pi; end 170 | if(XU_opt(9)<0), XU_opt(9)=XU_opt(9)+2*pi; end 171 | 172 | % Extract trim state from optimization variable 173 | Xtrim=Xo; 174 | Xtrim(Index.EOM(1:6)) = XU_opt(1:6); 175 | Xtrim(Index.EOM(10:12))= XU_opt(7:9); 176 | Utrim=zeros(23,1); 177 | Utrim(1:4)=XU_opt(10:13); 178 | 179 | % Return MWS (Model WorkSpace) variables that reflect trimmed values 180 | % Grab model workspace into structure 181 | % Reset trim mode to off 182 | appendmws(struct('TrimModeOn',0),'gtm_design'); 183 | MWS=grabmws('gtm_design'); 184 | 185 | % Update values effected by trimming 186 | MWS.StatesInp(1:6) = XU_opt(1:6); 187 | MWS.StatesInp(10:12) = XU_opt(7:9); 188 | if (MWS.TrimWithStab), 189 | MWS.bias.stabilizer = XU_opt(10); 190 | else 191 | MWS.bias.elevator = XU_opt(10); 192 | end 193 | MWS.bias.aileron = XU_opt(11); 194 | MWS.bias.rudder = XU_opt(12); 195 | MWS.bias.throttle = XU_opt(13); 196 | 197 | yout=gtm_design(0,Xtrim,Utrim,'outputs'); 198 | dx =gtm_design(0,Xtrim,Utrim,'derivs'); 199 | gtm_design([],[],[],'term'); 200 | 201 | 202 | % Calculate Error in trim condition 203 | Err = max(abs(dx(Index.EOM(1:6)))); %Accelerations, should all be zero 204 | outnames={'eas','tas','alpha','beta','gamma','gndtrack','roll','pitch','yaw','rollrate','pitchrate','yawrate','pdeg','qdeg','rdeg'}; 205 | outvalues=[yout(1:6);Xtrim(Index.EOM(10:12))*180/pi;dx(Index.EOM(10:12))*180/pi; Xtrim(Index.EOM(4:6))*180/pi]; 206 | for i=1:length(outnames) 207 | if isfield(target,outnames{i}), % for ones that are specified target points 208 | Err = max(Err,abs(outvalues(i)-target.(outnames{i}))); 209 | end 210 | end 211 | 212 | % Print results to screen 213 | if (verbose), 214 | fprintf(1,'\nTarget conditions:\n '); 215 | fn=sort(fieldnames(target)); 216 | for i=1:length(fn), if (target.(fn{i})~=0), fprintf(1,'%s: %5.2f ',fn{i},target.(fn{i})); end, end 217 | fprintf('\n '); 218 | for i=1:length(fn), if (target.(fn{i})==0), fprintf(1,'%s: %5.2f ',fn{i},target.(fn{i})); end, end 219 | fprintf(1,'\n\nTrim conditions (Err=%5.3e)\n',Err); 220 | fprintf(1,' gamma: %5.2f\t\ttas: %5.2f\t\talt: %8.2f\n',yout(5),yout(2),Xtrim(Index.EOM(9))); 221 | fprintf(1,' eas: %5.2f\t\talpha: %5.2f\t\tbeta: %5.2f\n',yout(1),yout(3),yout(4)); 222 | fprintf(1,' pdeg: %5.2f\t\tqdeg: %5.2f\t\trdeg: %5.2f\n',Xtrim(Index.EOM(4:6))*180/pi); 223 | fprintf(1,' roll: %5.2f\t\tpitch: %5.2f\t\tyaw: %5.2f\t\tgndtrack:%5.2f\n',Xtrim(Index.EOM(10:12))*180/pi,yout(6)); 224 | fprintf(1,' rollrate: %5.2f\tpitchrate: %5.2f\tyawrate: %5.2f\n\n',dx(Index.EOM(10:12))*180/pi); 225 | fprintf(1,' elevator: %5.2f\tstabilizer: %5.2f\tailerons: %5.2f\t\trudder:% 5.2f\n',... 226 | MWS.bias.elevator, MWS.bias.stabilizer, MWS.bias.aileron, MWS.bias.rudder); 227 | fprintf(1,' throttle: %5.2f\tspeedbrake: %5.2f\tflaps: %5.2f\t\tgeardown:% 5.2f\n\n',... 228 | MWS.bias.throttle, MWS.bias.speedbrake, MWS.bias.flaps, MWS.bias.geardown); 229 | fprintf(1,' d/dt(u,v,w,p,q,r)\t[%5.2e %5.2e %5.2e %5.2e %5.2e %5.2e]\n',dx(Index.EOM(1:6))); 230 | fprintf(1,' d/dt(phi,theta,psi)\t[%5.2e %5.2e %5.2e]\n\n',dx(Index.EOM(10:12))); 231 | end 232 | 233 | % Tabulate results in Trim Condition structure 234 | Trimcond.eas =yout(1); 235 | Trimcond.tas =yout(2); 236 | Trimcond.alpha =yout(3); 237 | Trimcond.beta =yout(4); 238 | Trimcond.gamma =yout(5); 239 | Trimcond.pdeg =Xtrim(Index.EOM(4))*180/pi; 240 | Trimcond.qdeg =Xtrim(Index.EOM(5))*180/pi; 241 | Trimcond.rdeg =Xtrim(Index.EOM(6))*180/pi; 242 | Trimcond.altitude =Xtrim(Index.EOM(9)); 243 | Trimcond.roll =Xtrim(Index.EOM(10))*180/pi; 244 | Trimcond.pitch =Xtrim(Index.EOM(11))*180/pi; 245 | Trimcond.yaw =Xtrim(Index.EOM(12))*180/pi; 246 | Trimcond.gndtrack =yout(6); 247 | Trimcond.pitchrate=dx(Index.EOM(10))*180/pi; 248 | Trimcond.rollrate =dx(Index.EOM(11))*180/pi; 249 | Trimcond.yawrate =dx(Index.EOM(12))*180/pi; 250 | Trimcond.throttle =MWS.bias.throttle; 251 | Trimcond.stab =MWS.bias.stabilizer; 252 | Trimcond.aileron =MWS.bias.aileron; 253 | Trimcond.rudder =MWS.bias.rudder; 254 | Trimcond.elevator =MWS.bias.elevator; 255 | Trimcond.spdbrake =MWS.bias.speedbrake; 256 | Trimcond.flaps =MWS.bias.flaps; 257 | Trimcond.geardown =MWS.bias.geardown; 258 | Trimcond.Xo =Xtrim(Index.EOM); 259 | 260 | % return model to initial parameters 261 | set_param('gtm_design','InlineParams',inlineflag); 262 | set_param('gtm_design','Dirty',dirtyflag); 263 | set_param('gtm_design','InitInArrayFormatMsg',initwarnflag); 264 | 265 | %============================== SubFunctions ============================== 266 | function [f,g]=simio(xu,Xo,Index,target) 267 | %function [f,g]=gtmio(xu,Xo,Index,target,TrimWithStab) 268 | % 269 | % Calls model simulation in "precompiled" mode 270 | % sets up objective function and constraints for optimization 271 | 272 | % 273 | % Setup tweaked vector 274 | Xtweak=Xo; 275 | Xtweak(Index.EOM(1:6)) = xu(1:6); % [u;v;w;p;q;r] 276 | Xtweak(Index.EOM(10:12)) = xu(7:9); % [phi;theta;psi] 277 | 278 | Utweak = zeros(23,1); 279 | Utweak(1) = xu(10); % PitchSurf (Elevator or Stab) 280 | Utweak(2) = xu(11); % Aileron 281 | Utweak(3) = xu(12); % Rudder 282 | Utweak(4) = xu(13); % Engine 283 | 284 | % Calculate outputs and derivatives 285 | trim_at_time=1e-3; % sec, Avoiding zero as it might trigger IC blocks or 286 | % other initialization procedures. 287 | yout = gtm_design(trim_at_time,Xtweak,Utweak,'outputs'); 288 | dx = gtm_design(trim_at_time,Xtweak,Utweak,'derivs'); 289 | 290 | % Form trim error on auxilary variables 291 | delta=zeros(15,1); 292 | if isfield(target,'eas'), delta(1) =yout(1)-target.eas; end % eas 293 | if isfield(target,'tas'), delta(2) =yout(2)-target.tas; end % tash 294 | if isfield(target,'alpha'), delta(3) =yout(3)-target.alpha; end % alpha 295 | if isfield(target,'beta'), delta(4) =yout(4)-target.beta; end % beta 296 | if isfield(target,'gamma'), delta(5) =yout(5)-target.gamma; end % gamma 297 | if isfield(target,'gndtrack'), delta(6) =yout(6)-target.gndtrack;end % ground track 298 | if isfield(target,'roll'), delta(7) =Xtweak(Index.EOM(10))-target.roll*pi/180;end % roll 299 | if isfield(target,'pitch'), delta(8) =Xtweak(Index.EOM(11))-target.pitch*pi/180;end % pitch 300 | if isfield(target,'yaw'), delta(9) =Xtweak(Index.EOM(12))-target.yaw*pi/180;end % yaw (heading) 301 | if isfield(target,'rollrate'), delta(10) =dx(Index.EOM(10))-target.rollrate*pi/180; end % phidot 302 | if isfield(target,'pitchrate'),delta(11) =dx(Index.EOM(11))-target.pitchrate*pi/180; end % thetadot 303 | if isfield(target,'yawrate'), delta(12) =dx(Index.EOM(12))-target.yawrate*pi/180; end % psidot 304 | if isfield(target,'pdeg'), delta(13) =Xtweak(Index.EOM(4))-target.pdeg*pi/180; end % p 305 | if isfield(target,'qdeg'), delta(14) =Xtweak(Index.EOM(5))-target.qdeg*pi/180; end % q 306 | if isfield(target,'rdeg'), delta(15) =Xtweak(Index.EOM(6))-target.rdeg*pi/180; end % r 307 | 308 | f=xu(end); %Lagrange Multiplier 309 | g=[dx(Index.EOM(1:6)); delta(:)-f; -delta(:)-f ]; % d/dt[uwv,pqr]=0 equality constraint, 310 | % minimize trim error with Lagrange multiplier 311 | 312 | 313 | 314 | 315 | 316 | -------------------------------------------------------------------------------- /gtm_design/obj/RT_mex.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/obj/RT_mex.mexa64 -------------------------------------------------------------------------------- /gtm_design/obj/RT_mex.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/obj/RT_mex.mexmaci64 -------------------------------------------------------------------------------- /gtm_design/obj/RT_mex.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/obj/RT_mex.mexw64 -------------------------------------------------------------------------------- /gtm_design/obj/SimulinkToXPlane.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/obj/SimulinkToXPlane.mexa64 -------------------------------------------------------------------------------- /gtm_design/obj/SimulinkToXPlane.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/obj/SimulinkToXPlane.mexmaci64 -------------------------------------------------------------------------------- /gtm_design/obj/SimulinkToXPlane.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/obj/SimulinkToXPlane.mexw64 -------------------------------------------------------------------------------- /gtm_design/obj/gear_sfcn.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/obj/gear_sfcn.mexa64 -------------------------------------------------------------------------------- /gtm_design/obj/gear_sfcn.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/obj/gear_sfcn.mexmaci64 -------------------------------------------------------------------------------- /gtm_design/obj/gear_sfcn.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/obj/gear_sfcn.mexw64 -------------------------------------------------------------------------------- /gtm_design/setup.m: -------------------------------------------------------------------------------- 1 | % d.e.cox@larc.nasa.gov 2 | % $Id: setup.m 4852 2013-08-06 22:12:54Z cox $ 3 | 4 | % Add mat file directory 5 | addpath(genpath('./config/')); 6 | 7 | % Add mfiles directories. 8 | addpath('./mfiles'); 9 | 10 | % Add compilex code directory 11 | addpath('./obj'); 12 | 13 | % Add libriary directory 14 | addpath('./libs'); 15 | 16 | rehash path 17 | 18 | 19 | % Close model if open, prompt if changed. 20 | if not(isempty(find_system('SearchDepth',0,'Name','gtm_design'))) 21 | if strcmp(get_param('gtm_design','Dirty'),'on'); 22 | savechanges=input(' gtm_design model has been changed, save changes (y/N) ?','s'); 23 | if ~isempty(savechanges) && strcmpi(savechanges(1),'y'); 24 | fprintf(1,'Saving System...'); 25 | clearmws % Suppreses warning mesage about model workspace 26 | clear savechanges % clear temporary response variable 27 | save_system('gtm_design'); 28 | fprintf(1,' Done.\n'); 29 | end 30 | end 31 | % terminate if left in paused state. matlab will not close paused model. 32 | if strcmp(get_param('gtm_design','SimulationStatus'),'paused'), 33 | gtm_design([],[],[],'term'); 34 | end 35 | bdclose('gtm_design'); 36 | end 37 | 38 | % Clear simout* variables to ensure clean initialization 39 | clear simout simout_names SimWSout 40 | 41 | % Clear precompiled functions, required to reflect changes in mfiles 42 | % that exist outside working directory. 43 | clear functions 44 | 45 | % Open block diagram 46 | warning('off','Simulink:SL_MdlFileNotOnPath'); % Suppress spurious warnings 47 | open_system('gtm_design'); 48 | 49 | % load nominal starting point 50 | loadmws(init_design('GTM'),'gtm_design'); 51 | 52 | % Trim model, and load trimmed conditions 53 | appendmws(trimgtm(struct('eas',75, 'gamma',0))); 54 | 55 | warning('on','Simulink:SL_MdlFileNotOnPath'); 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /gtm_design/utils/Xlink/Plugin/Xlink/lin.xpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/utils/Xlink/Plugin/Xlink/lin.xpl -------------------------------------------------------------------------------- /gtm_design/utils/Xlink/Plugin/Xlink/mac.xpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/utils/Xlink/Plugin/Xlink/mac.xpl -------------------------------------------------------------------------------- /gtm_design/utils/Xlink/Plugin/Xlink/win.xpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/utils/Xlink/Plugin/Xlink/win.xpl -------------------------------------------------------------------------------- /gtm_design/utils/Xlink/Readme.txt: -------------------------------------------------------------------------------- 1 | ---------Using the Xlink plugin with Xplane9--------- 2 | 3 | To install the plugin copy the ./bin/Plugin/Xlink folder over to 4 | /Resources/plugins 5 | where is the X-Plane 9 installation directory. 6 | 7 | Next time you start Xplane there should be an Xlink menu item under 8 | the plugins menu. Options within this menu toggle on/off when 9 | selected and, they include: 10 | 11 | - Receiving flight-path info from matlab via UPD messages 12 | - Displaying internal data in a text overlay 13 | - Display simulation data in a text overlay 14 | 15 | Instruments in the vehicles cockpit and the vehicle HUD will not 16 | display the correct information. The plugin is best used with a 17 | chase-plane view. Keyboard commands +,-, and arrows control the 18 | camera position in chase plane view. 19 | 20 | The surfaces are mapped to X-Planes B777 vehicle, but should work with 21 | most others as well. The file ./img/Speed-Bird_paint_modified.png can 22 | be used to replace the file 23 | /Aircraft/Heavy Metal/B777-200 British Airways/Speed-Bird_paint.png 24 | to provide a vehicle that does not have British-Airways logos. 25 | 26 | Joysticks axis are configured with X-Planes "Joystick and Equipment" 27 | menu. Joystick Buttons (or keyboard keys) can be also configured 28 | under this way, with "custom commands" - Look for an Xlink item in the 29 | "X-System" folder. 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /gtm_design/utils/Xlink/img/Speed-Bird_paint_modified.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nasa/GTM_DesignSim/9717143270144aca1f5d38d7c24c0fce678d1589/gtm_design/utils/Xlink/img/Speed-Bird_paint_modified.png --------------------------------------------------------------------------------