1 /************************************************************************** 2 * ls_interface.h -- interface to the "LaRCsim" flight model 3 * 4 * Written by Curtis Olson, started May 1997. 5 * 6 * Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License as 10 * published by the Free Software Foundation; either version 2 of the 11 * License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, but 14 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * $Id$ 23 * (Log is kept at end of this file) 24 **************************************************************************/ 25 26 27 #ifndef _LS_INTERFACE_H 28 #define _LS_INTERFACE_H 29 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 36 #include "ls_types.h" 37 38 39 /* reset flight params to a specific position */ 40 int ls_toplevel_init(double dt, char * aircraft); 41 42 /* update position based on inputs, positions, velocities, etc. */ 43 int ls_update(int multiloop); 44 45 void ls_set_model_dt(double dt); 46 47 #if 0 48 /* Convert from the fgFLIGHT struct to the LaRCsim generic_ struct */ 49 int fgFlight_2_LaRCsim (fgFLIGHT *f); 50 51 /* Convert from the LaRCsim generic_ struct to the fgFLIGHT struct */ 52 int fgLaRCsim_2_Flight (fgFLIGHT *f); 53 #endif 54 55 void ls_loop( SCALAR dt, int initialize ); 56 57 /* Set the altitude (force) */ 58 int ls_ForceAltitude(double alt_feet); 59 60 61 #ifdef __cplusplus 62 } 63 #endif 64 65 #endif /* _LS_INTERFACE_H */ 66 67 68 // $Log$ 69 // Revision 1.3 2006/02/21 17:45:03 mfranz 70 // new FSF address (see http://www.gnu.org/licenses/gpl.html) 71 // 72 // Revision 1.2 2004-11-19 22:10:42 curt 73 // Fix my mailing address by replacing it with my web page. 74 // 75 // Revision 1.1.1.1 2002/09/10 01:14:02 curt 76 // Initial revision of FlightGear-0.9.0 77 // 78 // Revision 1.5 2001/03/24 05:03:12 curt 79 // SG-ified logstream. 80 // 81 // Revision 1.4 2000/10/23 22:34:54 curt 82 // I tested: 83 // LaRCsim c172 on-ground and in-air starts, reset: all work 84 // UIUC Cessna172 on-ground and in-air starts work as expected, reset 85 // results in an aircraft that is upside down but does not crash FG. I 86 // don't know what it was like before, so it may well be no change. 87 // JSBSim c172 and X15 in-air starts work fine, resets now work (and are 88 // trimmed), on-ground starts do not -- the c172 ends up on its back. I 89 // suspect this is no worse than before. 90 // 91 // I did not test: 92 // Balloon (the weather code returns nan's for the atmosphere data --this 93 // is in the weather module and apparently is a linux only bug) 94 // ADA (don't know how) 95 // MagicCarpet (needs work yet) 96 // External (don't know how) 97 // 98 // known to be broken: 99 // LaRCsim c172 on-ground starts with a negative terrain altitude (this 100 // happens at KPAO when the scenery is not present). The FDM inits to 101 // about 50 feet AGL and the model falls to the ground. It does stay 102 // upright, however, and seems to be fine once it settles out, FWIW. 103 // 104 // To do: 105 // --implement set_Model on the bus 106 // --bring Christian's weather data into JSBSim 107 // -- add default method to bus for updating things like the sin and cos of 108 // latitude (for Balloon, MagicCarpet) 109 // -- lots of cleanup 110 // 111 // The files: 112 // src/FDM/flight.cxx 113 // src/FDM/flight.hxx 114 // -- all data members now declared protected instead of private. 115 // -- eliminated all but a small set of 'setters', no change to getters. 116 // -- that small set is declared virtual, the default implementation 117 // provided preserves the old behavior 118 // -- all of the vector data members are now initialized. 119 // -- added busdump() method -- SG_LOG's all the bus data when called, 120 // useful for diagnostics. 121 // 122 // src/FDM/ADA.cxx 123 // -- bus data members now directly assigned to 124 // 125 // src/FDM/Balloon.cxx 126 // -- bus data members now directly assigned to 127 // -- changed V_equiv_kts to V_calibrated_kts 128 // 129 // src/FDM/JSBSim.cxx 130 // src/FDM/JSBSim.hxx 131 // -- bus data members now directly assigned to 132 // -- implemented the FGInterface virtual setters with JSBSim specific 133 // logic 134 // -- changed the static FDMExec to a dynamic fdmex (needed so that the 135 // JSBSim object can be deleted when a model change is called for) 136 // -- implemented constructor and destructor, moved some of the logic 137 // formerly in init() to constructor 138 // -- added logic to bring up FGEngInterface objects and set the RPM and 139 // throttle values. 140 // 141 // src/FDM/LaRCsim.cxx 142 // src/FDM/LaRCsim.hxx 143 // -- bus data members now directly assigned to 144 // -- implemented the FGInterface virtual setters with LaRCsim specific 145 // logic, uses LaRCsimIC 146 // -- implemented constructor and destructor, moved some of the logic 147 // formerly in init() to constructor 148 // -- moved default inertias to here from fg_init.cxx 149 // -- eliminated the climb rate calculation. The equivalent, climb_rate = 150 // -1*vdown, is now in copy_from_LaRCsim(). 151 // 152 // src/FDM/LaRCsimIC.cxx 153 // src/FDM/LaRCsimIC.hxx 154 // -- similar to FGInitialCondition, this class has all the logic needed to 155 // turn data like Vc and Mach into the more fundamental quantities LaRCsim 156 // needs to initialize. 157 // -- put it in src/FDM since it is a class 158 // 159 // src/FDM/MagicCarpet.cxx 160 // -- bus data members now directly assigned to 161 // 162 // src/FDM/Makefile.am 163 // -- adds LaRCsimIC.hxx and cxx 164 // 165 // src/FDM/JSBSim/FGAtmosphere.h 166 // src/FDM/JSBSim/FGDefs.h 167 // src/FDM/JSBSim/FGInitialCondition.cpp 168 // src/FDM/JSBSim/FGInitialCondition.h 169 // src/FDM/JSBSim/JSBSim.cpp 170 // -- changes to accomodate the new bus 171 // 172 // src/FDM/LaRCsim/atmos_62.h 173 // src/FDM/LaRCsim/ls_geodesy.h 174 // -- surrounded prototypes with #ifdef __cplusplus ... #endif , functions 175 // here are needed in LaRCsimIC 176 // 177 // src/FDM/LaRCsim/c172_main.c 178 // src/FDM/LaRCsim/cherokee_aero.c 179 // src/FDM/LaRCsim/ls_aux.c 180 // src/FDM/LaRCsim/ls_constants.h 181 // src/FDM/LaRCsim/ls_geodesy.c 182 // src/FDM/LaRCsim/ls_geodesy.h 183 // src/FDM/LaRCsim/ls_step.c 184 // src/FDM/UIUCModel/uiuc_betaprobe.cpp 185 // -- changed PI to LS_PI, eliminates preprocessor naming conflict with 186 // weather module 187 // 188 // src/FDM/LaRCsim/ls_interface.c 189 // src/FDM/LaRCsim/ls_interface.h 190 // -- added function ls_set_model_dt() 191 // 192 // src/Main/bfi.cxx 193 // -- eliminated calls that set the NED speeds to body components. They 194 // are no longer needed and confuse the new bus. 195 // 196 // src/Main/fg_init.cxx 197 // -- eliminated calls that just brought the bus data up-to-date (e.g. 198 // set_sin_cos_latitude). or set default values. The bus now handles the 199 // defaults and updates itself when the setters are called (for LaRCsim and 200 // JSBSim). A default method for doing this needs to be added to the bus. 201 // -- added fgVelocityInit() to set the speed the user asked for. Both 202 // JSBSim and LaRCsim can now be initialized using any of: 203 // vc,mach, NED components, UVW components. 204 // 205 // src/Main/main.cxx 206 // --eliminated call to fgFDMSetGroundElevation, this data is now 'pulled' 207 // onto the bus every update() 208 // 209 // src/Main/options.cxx 210 // src/Main/options.hxx 211 // -- added enum to keep track of the speed requested by the user 212 // -- eliminated calls to set NED velocity properties to body speeds, they 213 // are no longer needed. 214 // -- added options for the NED components. 215 // 216 // src/Network/garmin.cxx 217 // src/Network/nmea.cxx 218 // --eliminated calls that just brought the bus data up-to-date (e.g. 219 // set_sin_cos_latitude). The bus now updates itself when the setters are 220 // called (for LaRCsim and JSBSim). A default method for doing this needs 221 // to be added to the bus. 222 // -- changed set_V_equiv_kts to set_V_calibrated_kts. set_V_equiv_kts no 223 // longer exists ( get_V_equiv_kts still does, though) 224 // 225 // src/WeatherCM/FGLocalWeatherDatabase.cpp 226 // -- commented out the code to put the weather data on the bus, a 227 // different scheme for this is needed. 228 // 229 // Revision 1.3 2000/04/27 19:57:08 curt 230 // MacOS build updates. 231 // 232 // Revision 1.2 2000/04/10 18:09:41 curt 233 // David Megginson made a few (mostly minor) mods to the LaRCsim files, and 234 // it's now possible to choose the LaRCsim model at runtime, as in 235 // 236 // fgfs --aircraft=c172 237 // 238 // or 239 // 240 // fgfs --aircraft=uiuc --aircraft-dir=Aircraft-uiuc/Boeing747 241 // 242 // I did this so that I could play with the UIUC stuff without losing 243 // Tony's C172 with its flaps, etc. I did my best to respect the design 244 // of the LaRCsim code by staying in C, making only minimal changes, and 245 // not introducing any dependencies on the rest of FlightGear. The 246 // modified files are attached. 247 // 248 // Revision 1.1.1.1 1999/06/17 18:07:33 curt 249 // Start of 0.7.x branch 250 // 251 // Revision 1.1.1.1 1999/04/05 21:32:45 curt 252 // Start of 0.6.x branch. 253 // 254 // Revision 1.11 1998/10/17 01:34:15 curt 255 // C++ ifying ... 256 // 257 // Revision 1.10 1998/10/16 23:27:45 curt 258 // C++-ifying. 259 // 260 // Revision 1.9 1998/07/12 03:11:04 curt 261 // Removed some printf()'s. 262 // Fixed the autopilot integration so it should be able to update it's control 263 // positions every time the internal flight model loop is run, and not just 264 // once per rendered frame. 265 // Added a routine to do the necessary stuff to force an arbitrary altitude 266 // change. 267 // Gave the Navion engine just a tad more power. 268 // 269 // Revision 1.8 1998/04/21 16:59:39 curt 270 // Integrated autopilot. 271 // Prepairing for C++ integration. 272 // 273 // Revision 1.7 1998/02/07 15:29:39 curt 274 // Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss 275 // <chotchkiss@namg.us.anritsu.com> 276 // 277 // Revision 1.6 1998/02/03 23:20:17 curt 278 // Lots of little tweaks to fix various consistency problems discovered by 279 // Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper 280 // passed arguments along to the real printf(). Also incorporated HUD changes 281 // by Michele America. 282 // 283 // Revision 1.5 1998/01/19 19:27:05 curt 284 // Merged in make system changes from Bob Kuehne <rpk@sgi.com> 285 // This should simplify things tremendously. 286 // 287 // Revision 1.4 1998/01/19 18:40:27 curt 288 // Tons of little changes to clean up the code and to remove fatal errors 289 // when building with the c++ compiler. 290 // 291 // Revision 1.3 1997/07/23 21:52:20 curt 292 // Put comments around the text after an #endif for increased portability. 293 // 294 // Revision 1.2 1997/05/29 22:39:59 curt 295 // Working on incorporating the LaRCsim flight model. 296 // 297 // Revision 1.1 1997/05/29 00:09:58 curt 298 // Initial Flight Gear revision. 299 // 300