| 1 | /*************************************************************************** |
| 2 | |
| 3 | TITLE: ls_model() |
| 4 | |
| 5 | ---------------------------------------------------------------------------- |
| 6 | |
| 7 | FUNCTION: Model loop executive |
| 8 | |
| 9 | ---------------------------------------------------------------------------- |
| 10 | |
| 11 | MODULE STATUS: developmental |
| 12 | |
| 13 | ---------------------------------------------------------------------------- |
| 14 | |
| 15 | GENEALOGY: Created 15 October 1992 as part of LaRCSIM project |
| 16 | by Bruce Jackson. |
| 17 | |
| 18 | ---------------------------------------------------------------------------- |
| 19 | |
| 20 | DESIGNED BY: Bruce Jackson |
| 21 | |
| 22 | CODED BY: Bruce Jackson |
| 23 | |
| 24 | MAINTAINED BY: maintainer |
| 25 | |
| 26 | ---------------------------------------------------------------------------- |
| 27 | |
| 28 | MODIFICATION HISTORY: |
| 29 | |
| 30 | DATE PURPOSE BY |
| 31 | |
| 32 | 950306 Added parameters to call: dt, which is the step size |
| 33 | to be taken this loop (caution: may vary from call to call) |
| 34 | and Initialize, which if non-zero, implies an initialization |
| 35 | is requested. EBJ |
| 36 | |
| 37 | CURRENT RCS HEADER INFO: |
| 38 | $Header$ |
| 39 | $Log$ |
| 40 | Revision 1.5 2005/12/19 12:53:21 ehofman |
| 41 | Vassilii Khachaturov: |
| 42 | |
| 43 | clean up some build warnings caught with gcc-4.0. |
| 44 | |
| 45 | Revision 1.4 2003/07/25 17:53:41 mselig |
| 46 | UIUC code initilization mods to tidy things up a bit. |
| 47 | |
| 48 | Revision 1.3 2003/05/13 18:45:06 curt |
| 49 | Robert Deters: |
| 50 | |
| 51 | I have attached some revisions for the UIUCModel and some LaRCsim. |
| 52 | The only thing you should need to check is LaRCsim.cxx. The file |
| 53 | I attached is a revised version of 1.5 and the latest is 1.7. Also, |
| 54 | uiuc_getwind.c and uiuc_getwind.h are no longer in the LaRCsim |
| 55 | directory. They have been moved over to UIUCModel. |
| 56 | |
| 57 | Revision 1.2 2003/03/31 03:05:41 m-selig |
| 58 | uiuc wind changes, MSS |
| 59 | |
| 60 | Revision 1.1.1.1 2003/02/28 01:33:39 rob |
| 61 | uiuc version of FlightGear v0.9.0 |
| 62 | |
| 63 | Revision 1.3 2002/12/12 00:01:04 rob |
| 64 | *** empty log message *** |
| 65 | |
| 66 | Revision 1.2 2002/10/22 21:06:49 rob |
| 67 | *** empty log message *** |
| 68 | |
| 69 | Revision 1.2 2002/08/29 18:56:37 rob |
| 70 | *** empty log message *** |
| 71 | |
| 72 | Revision 1.1.1.1 2002/04/24 17:08:23 rob |
| 73 | UIUC version of FlightGear-0.7.pre11 |
| 74 | |
| 75 | Revision 1.5 2002/04/01 19:37:34 curt |
| 76 | I have attached revisions to the UIUC code. The revisions include the |
| 77 | ability to run a nonlinear model with flaps. The files ls_model.c and |
| 78 | uiuc_aero.c were changed since we had some functions with the same |
| 79 | name. The name changes doesn't affect the code, it just makes it a |
| 80 | little easier to read. There are changes in LaRCsim.cxx so UIUC |
| 81 | models have engine sound. Could you send me an email when you receive |
| 82 | this and/or when the changes make it to the CVS? Thanks. |
| 83 | |
| 84 | Also I noticed you have some outdated files that are no longer used in |
| 85 | the UIUCModel directory. They are uiuc_initializemaps1.cpp, |
| 86 | uiuc_initializemaps2.cpp, uiuc_initializemaps3.cpp, and |
| 87 | uiuc_initializemaps4.cpp |
| 88 | |
| 89 | Rob |
| 90 | |
| 91 | Revision 1.4 2001/09/14 18:47:27 curt |
| 92 | More changes in support of UIUCModel. |
| 93 | |
| 94 | Revision 1.3 2000/10/28 14:30:33 curt |
| 95 | Updates by Tony working on the FDM interface bus. |
| 96 | |
| 97 | Revision 1.2 2000/04/10 18:09:41 curt |
| 98 | David Megginson made a few (mostly minor) mods to the LaRCsim files, and |
| 99 | it's now possible to choose the LaRCsim model at runtime, as in |
| 100 | |
| 101 | fgfs --aircraft=c172 |
| 102 | |
| 103 | or |
| 104 | |
| 105 | fgfs --aircraft=uiuc --aircraft-dir=Aircraft-uiuc/Boeing747 |
| 106 | |
| 107 | I did this so that I could play with the UIUC stuff without losing |
| 108 | Tony's C172 with its flaps, etc. I did my best to respect the design |
| 109 | of the LaRCsim code by staying in C, making only minimal changes, and |
| 110 | not introducing any dependencies on the rest of FlightGear. The |
| 111 | modified files are attached. |
| 112 | |
| 113 | Revision 1.1.1.1 1999/06/17 18:07:33 curt |
| 114 | Start of 0.7.x branch |
| 115 | |
| 116 | Revision 1.1.1.1 1999/04/05 21:32:45 curt |
| 117 | Start of 0.6.x branch. |
| 118 | |
| 119 | Revision 1.3 1998/08/06 12:46:39 curt |
| 120 | Header change. |
| 121 | |
| 122 | Revision 1.2 1998/01/19 18:40:27 curt |
| 123 | Tons of little changes to clean up the code and to remove fatal errors |
| 124 | when building with the c++ compiler. |
| 125 | |
| 126 | Revision 1.1 1997/05/29 00:09:58 curt |
| 127 | Initial Flight Gear revision. |
| 128 | |
| 129 | * Revision 1.3 1995/03/06 18:49:46 bjax |
| 130 | * Added dt and initialize flag parameters to subroutine calls. This will |
| 131 | * support trim routine (to allow single throttle setting to drive |
| 132 | * all four throttle positions, for example, if initialize is TRUE). |
| 133 | * |
| 134 | * Revision 1.2 1993/03/10 06:38:09 bjax |
| 135 | * Added additional calls: inertias() and subsystems()... EBJ |
| 136 | * |
| 137 | * Revision 1.1 92/12/30 13:19:08 bjax |
| 138 | * Initial revision |
| 139 | * |
| 140 | |
| 141 | ---------------------------------------------------------------------------- |
| 142 | |
| 143 | REFERENCES: |
| 144 | |
| 145 | ---------------------------------------------------------------------------- |
| 146 | |
| 147 | CALLED BY: ls_step (in initialization), ls_loop (planned) |
| 148 | |
| 149 | ---------------------------------------------------------------------------- |
| 150 | |
| 151 | CALLS TO: aero(), engine(), gear() |
| 152 | |
| 153 | ---------------------------------------------------------------------------- |
| 154 | |
| 155 | INPUTS: |
| 156 | |
| 157 | ---------------------------------------------------------------------------- |
| 158 | |
| 159 | OUTPUTS: |
| 160 | |
| 161 | --------------------------------------------------------------------------*/ |
| 162 | |
| 163 | #include "config.h" |
| 164 | |
| 165 | #include <stdio.h> |
| 166 | |
| 167 | #include "ls_types.h" |
| 168 | #include "ls_model.h" |
| 169 | #include "default_model_routines.h" |
| 170 | |
| 171 | Model current_model; |
| 172 | |
| 173 | |
| 174 | void ls_model( SCALAR dt, int Initialize ) { |
| 175 | switch (current_model) { |
| 176 | case NAVION: |
| 177 | inertias( dt, Initialize ); |
| 178 | subsystems( dt, Initialize ); |
| 179 | navion_aero( dt, Initialize ); |
| 180 | navion_engine( dt, Initialize ); |
| 181 | navion_gear( dt, Initialize ); |
| 182 | break; |
| 183 | case C172: |
| 184 | printf("here we are in C172 \n"); |
| 185 | if(Initialize < 0) c172_init(); |
| 186 | inertias( dt, Initialize ); |
| 187 | subsystems( dt, Initialize ); |
| 188 | c172_aero( dt, Initialize ); |
| 189 | c172_engine( dt, Initialize ); |
| 190 | c172_gear( dt, Initialize ); |
| 191 | break; |
| 192 | case CHEROKEE: |
| 193 | inertias( dt, Initialize ); |
| 194 | subsystems( dt, Initialize ); |
| 195 | cherokee_aero( dt, Initialize ); |
| 196 | cherokee_engine( dt, Initialize ); |
| 197 | cherokee_gear( dt, Initialize ); |
| 198 | break; |
| 199 | case BASIC: |
| 200 | // printf("here we are in BASIC \n"); |
| 201 | if(Initialize < 0) basic_init(); |
| 202 | printf("Initialize %d \n", Initialize); |
| 203 | inertias( dt, Initialize ); |
| 204 | subsystems( dt, Initialize ); |
| 205 | basic_aero( dt, Initialize ); |
| 206 | basic_engine( dt, Initialize ); |
| 207 | basic_gear( dt, Initialize ); |
| 208 | break; |
| 209 | case UIUC: |
| 210 | #ifdef ENABLE_UIUC_MODEL |
| 211 | inertias( dt, Initialize ); |
| 212 | subsystems( dt, Initialize ); |
| 213 | // During initialization period, re-initialize velocities |
| 214 | // and euler angles |
| 215 | if (Initialize != 0) { |
| 216 | uiuc_init_2_wrapper(); |
| 217 | } |
| 218 | |
| 219 | uiuc_network_recv_2_wrapper(); |
| 220 | uiuc_engine_2_wrapper( dt, Initialize ); |
| 221 | uiuc_wind_2_wrapper( dt, Initialize ); |
| 222 | uiuc_aero_2_wrapper( dt, Initialize ); |
| 223 | uiuc_gear_2_wrapper( dt, Initialize ); |
| 224 | uiuc_network_send_2_wrapper(); |
| 225 | uiuc_record_2_wrapper(dt); |
| 226 | #endif |
| 227 | break; |
| 228 | } |
| 229 | } |