1 // LaRCsim.cxx -- interface to the LaRCsim flight model
3 // Written by Curtis Olson, started October 1998.
5 // Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <string.h> // strcmp()
25 #include <simgear/constants.h>
26 #include <simgear/debug/logstream.hxx>
28 #include <Scenery/scenery.hxx>
30 #include <Main/fg_props.hxx>
31 #include <Aircraft/aircraft.hxx>
32 #include <Controls/controls.hxx>
33 #include <FDM/flight.hxx>
34 #include <FDM/LaRCsim/ls_cockpit.h>
35 #include <FDM/LaRCsim/ls_generic.h>
36 #include <FDM/LaRCsim/ls_interface.h>
37 #include <FDM/LaRCsimIC.hxx>
38 #include <FDM/UIUCModel/uiuc_aircraft.h>
41 #include "LaRCsim.hxx"
43 FGLaRCsim::FGLaRCsim( double dt ) {
46 speed_up = fgGetNode("/sim/speed-up", true);
47 aero = fgGetNode("/sim/aero", true);
49 ls_toplevel_init( 0.0, (char *)(aero->getStringValue()) );
51 lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
52 if ( !strcmp(aero->getStringValue(), "c172") ) {
53 copy_to_LaRCsim(); // initialize all of LaRCsim's vars
55 //this should go away someday -- formerly done in fg_init.cxx
63 ls_set_model_dt( get_delta_t() );
65 // Initialize our little engine that hopefully might
66 eng.init( get_delta_t() );
67 // dcl - in passing dt to init rather than update I am assuming
68 // that the LaRCsim dt is fixed at one value (yes it is 120hz CLO)
71 FGLaRCsim::~FGLaRCsim(void) {
78 // Initialize the LaRCsim flight model, dt is the time increment for
79 // each subsequent iteration through the EOM
80 void FGLaRCsim::init() {
81 //do init common to all FDM's
86 // Run an iteration of the EOM (equations of motion)
87 void FGLaRCsim::update( int multiloop ) {
89 if ( !strcmp(aero->getStringValue(), "c172") ) {
91 // cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
92 eng.set_IAS( V_calibrated_kts );
93 eng.set_Throttle_Lever_Pos( globals->get_controls()->get_throttle( 0 )
95 eng.set_Propeller_Lever_Pos( 100 );
96 eng.set_Mixture_Lever_Pos( globals->get_controls()->get_mixture( 0 )
98 eng.set_Magneto_Switch_Pos( globals->get_controls()->get_magnetos(0) );
99 eng.setStarterFlag( globals->get_controls()->get_starter(0) );
100 eng.set_p_amb( Static_pressure );
101 eng.set_T_amb( Static_temperature );
103 // update engine model
106 // Fake control-surface positions
107 fgSetDouble("/surface-positions/flap-pos-norm",
108 fgGetDouble("/controls/flaps"));
109 // FIXME: ignoring trim
110 fgSetDouble("/surface-positions/elevator-pos-norm",
111 fgGetDouble("/controls/elevator"));
112 // FIXME: ignoring trim
113 fgSetDouble("/surface-positions/left-aileron-pos-norm",
114 fgGetDouble("/controls/aileron"));
115 // FIXME: ignoring trim
116 fgSetDouble("/surface-positions/right-aileron-pos-norm",
117 -1 * fgGetDouble("/controls/aileron"));
118 // FIXME: ignoring trim
119 fgSetDouble("/surface-positions/rudder-pos-norm",
120 fgGetDouble("/controls/rudder"));
122 // copy engine state values onto "bus"
123 fgSetDouble("/engines/engine/rpm", eng.get_RPM());
124 fgSetDouble("/engines/engine/mp-osi", eng.get_Manifold_Pressure());
125 fgSetDouble("/engines/engine/max-hp", eng.get_MaxHP());
126 fgSetDouble("/engines/engine/power-pct", eng.get_Percentage_Power());
127 fgSetDouble("/engines/engine/egt-degf", eng.get_EGT());
128 fgSetDouble("/engines/engine/cht-degf", eng.get_CHT());
129 fgSetDouble("/engines/engine/prop-thrust", eng.get_prop_thrust_SI());
130 fgSetDouble("/engines/engine/fuel-flow-gph",
131 eng.get_fuel_flow_gals_hr());
132 fgSetDouble("/engines/engine/oil-temperature-degf",
134 fgSetDouble("/engines/engine/running", eng.getRunningFlag());
135 fgSetDouble("/engines/engine/cranking", eng.getCrankingFlag());
137 static const SGPropertyNode *fuel_freeze
138 = fgGetNode("/sim/freeze/fuel");
140 if ( ! fuel_freeze->getBoolValue() ) {
141 //Assume we are using both tanks equally for now
142 fgSetDouble("/consumables/fuel/tank[0]/level-gal_us",
143 fgGetDouble("/consumables/fuel/tank[0]/level-gal_us")
144 - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
146 fgSetDouble("/consumables/fuel/tank[1]/level-gal_us",
147 fgGetDouble("/consumables/fuel/tank[1]/level-gal_us")
148 - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
152 F_X_engine = eng.get_prop_thrust_lbs();
153 // cout << "F_X_engine = " << F_X_engine << '\n';
156 double save_alt = 0.0;
158 // lets try to avoid really screwing up the LaRCsim model
159 if ( get_Altitude() < -9000.0 ) {
160 save_alt = get_Altitude();
164 // copy control positions into the LaRCsim structure
165 Lat_control = globals->get_controls()->get_aileron() /
166 speed_up->getIntValue();
167 Long_control = globals->get_controls()->get_elevator();
168 Long_trim = globals->get_controls()->get_elevator_trim();
169 Rudder_pedal = globals->get_controls()->get_rudder() /
170 speed_up->getIntValue();
171 Flap_handle = 30.0 * globals->get_controls()->get_flaps();
173 if ( !strcmp(aero->getStringValue(), "c172") ) {
174 Use_External_Engine = 1;
176 Use_External_Engine = 0;
179 Throttle_pct = globals->get_controls()->get_throttle( 0 ) * 1.0;
181 Brake_pct[0] = globals->get_controls()->get_brake( 1 );
182 Brake_pct[1] = globals->get_controls()->get_brake( 0 );
184 // Inform LaRCsim of the local terrain altitude
185 // Runway_altitude = get_Runway_altitude();
186 Runway_altitude = scenery.get_cur_elev() * SG_METER_TO_FEET;
189 /* V_north_airmass = get_V_north_airmass();
190 V_east_airmass = get_V_east_airmass();
191 V_down_airmass = get_V_down_airmass(); */
194 // old -- FGInterface_2_LaRCsim() not needed except for Init()
195 // translate FG to LaRCsim structure
196 // FGInterface_2_LaRCsim(f);
197 // printf("FG_Altitude = %.2f\n", FG_Altitude * 0.3048);
198 // printf("Altitude = %.2f\n", Altitude * 0.3048);
199 // printf("Radius to Vehicle = %.2f\n", Radius_to_vehicle * 0.3048);
201 // for engine functions (sounds and instruments)
202 // drive the rpm gauge
203 fgSetDouble("/engines/engine/rpm", (globals->get_controls()->get_throttle( 0 ) * 100.0 * 25 ));
204 // manifold air pressure, which drives the sound (see *sound.xml file)
205 fgSetDouble("/engines/engine/mp-osi", (globals->get_controls()->get_throttle( 0 ) * 100.0 ));
206 // make the engine cranking and running sounds when fgfs starts up
207 fgSetDouble("/engines/engine/cranking", 1);
208 fgSetDouble("/engines/engine/running", 1);
210 ls_update(multiloop);
212 // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
213 // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
215 // translate LaRCsim back to FG structure so that the
216 // autopilot (and the rest of the sim can use the updated
220 // but lets restore our original bogus altitude when we are done
221 if ( save_alt < -9000.0 ) {
222 set_Altitude( save_alt );
227 // Convert from the FGInterface struct to the LaRCsim generic_ struct
228 bool FGLaRCsim::copy_to_LaRCsim () {
234 // Dx_pilot = get_Dx_pilot();
235 // Dy_pilot = get_Dy_pilot();
236 // Dz_pilot = get_Dz_pilot();
243 // F_north = get_F_north();
244 // F_east = get_F_east();
245 // F_down = get_F_down();
246 // F_X_aero = get_F_X_aero();
247 // F_Y_aero = get_F_Y_aero();
248 // F_Z_aero = get_F_Z_aero();
249 // F_X_engine = get_F_X_engine();
250 // F_Y_engine = get_F_Y_engine();
251 // F_Z_engine = get_F_Z_engine();
252 // F_X_gear = get_F_X_gear();
253 // F_Y_gear = get_F_Y_gear();
254 // F_Z_gear = get_F_Z_gear();
255 // M_l_rp = get_M_l_rp();
256 // M_m_rp = get_M_m_rp();
257 // M_n_rp = get_M_n_rp();
258 // M_l_cg = get_M_l_cg();
259 // M_m_cg = get_M_m_cg();
260 // M_n_cg = get_M_n_cg();
261 // M_l_aero = get_M_l_aero();
262 // M_m_aero = get_M_m_aero();
263 // M_n_aero = get_M_n_aero();
264 // M_l_engine = get_M_l_engine();
265 // M_m_engine = get_M_m_engine();
266 // M_n_engine = get_M_n_engine();
267 // M_l_gear = get_M_l_gear();
268 // M_m_gear = get_M_m_gear();
269 // M_n_gear = get_M_n_gear();
270 // V_dot_north = get_V_dot_north();
271 // V_dot_east = get_V_dot_east();
272 // V_dot_down = get_V_dot_down();
273 // U_dot_body = get_U_dot_body();
274 // V_dot_body = get_V_dot_body();
275 // W_dot_body = get_W_dot_body();
276 // A_X_cg = get_A_X_cg();
277 // A_Y_cg = get_A_Y_cg();
278 // A_Z_cg = get_A_Z_cg();
279 // A_X_pilot = get_A_X_pilot();
280 // A_Y_pilot = get_A_Y_pilot();
281 // A_Z_pilot = get_A_Z_pilot();
282 // N_X_cg = get_N_X_cg();
283 // N_Y_cg = get_N_Y_cg();
284 // N_Z_cg = get_N_Z_cg();
285 // N_X_pilot = get_N_X_pilot();
286 // N_Y_pilot = get_N_Y_pilot();
287 // N_Z_pilot = get_N_Z_pilot();
288 // P_dot_body = get_P_dot_body();
289 // Q_dot_body = get_Q_dot_body();
290 // R_dot_body = get_R_dot_body();
291 // V_north = get_V_north();
292 // V_east = get_V_east();
293 // V_down = get_V_down();
294 // V_north_rel_ground = get_V_north_rel_ground();
295 // V_east_rel_ground = get_V_east_rel_ground();
296 // V_down_rel_ground = get_V_down_rel_ground();
297 // V_north_airmass = get_V_north_airmass();
298 // V_east_airmass = get_V_east_airmass();
299 // V_down_airmass = get_V_down_airmass();
300 // V_north_rel_airmass = get_V_north_rel_airmass();
301 // V_east_rel_airmass = get_V_east_rel_airmass();
302 // V_down_rel_airmass = get_V_down_rel_airmass();
303 // U_gust = get_U_gust();
304 // V_gust = get_V_gust();
305 // W_gust = get_W_gust();
306 // U_body = get_U_body();
307 // V_body = get_V_body();
308 // W_body = get_W_body();
309 // V_rel_wind = get_V_rel_wind();
310 // V_true_kts = get_V_true_kts();
311 // V_rel_ground = get_V_rel_ground();
312 // V_inertial = get_V_inertial();
313 // V_ground_speed = get_V_ground_speed();
314 // V_equiv = get_V_equiv();
315 // V_equiv_kts = get_V_equiv_kts();
316 // V_calibrated = get_V_calibrated();
317 // V_calibrated_kts = get_V_calibrated_kts();
318 // P_body = get_P_body();
319 // Q_body = get_Q_body();
320 // R_body = get_R_body();
321 // P_local = get_P_local();
322 // Q_local = get_Q_local();
323 // R_local = get_R_local();
324 // P_total = get_P_total();
325 // Q_total = get_Q_total();
326 // R_total = get_R_total();
327 // Phi_dot = get_Phi_dot();
328 // Theta_dot = get_Theta_dot();
329 // Psi_dot = get_Psi_dot();
330 // Latitude_dot = get_Latitude_dot();
331 // Longitude_dot = get_Longitude_dot();
332 // Radius_dot = get_Radius_dot();
333 // Lat_geocentric = get_Lat_geocentric();
334 // Lon_geocentric = get_Lon_geocentric();
335 // Radius_to_vehicle = get_Radius_to_vehicle();
336 // Latitude = get_Latitude();
337 // Longitude = get_Longitude();
338 // Altitude = get_Altitude();
340 // Theta = get_Theta();
342 // T_local_to_body_11 = get_T_local_to_body_11();
343 // T_local_to_body_12 = get_T_local_to_body_12();
344 // T_local_to_body_13 = get_T_local_to_body_13();
345 // T_local_to_body_21 = get_T_local_to_body_21();
346 // T_local_to_body_22 = get_T_local_to_body_22();
347 // T_local_to_body_23 = get_T_local_to_body_23();
348 // T_local_to_body_31 = get_T_local_to_body_31();
349 // T_local_to_body_32 = get_T_local_to_body_32();
350 // T_local_to_body_33 = get_T_local_to_body_33();
351 // Gravity = get_Gravity();
352 // Centrifugal_relief = get_Centrifugal_relief();
353 // Alpha = get_Alpha();
354 // Beta = get_Beta();
355 // Alpha_dot = get_Alpha_dot();
356 // Beta_dot = get_Beta_dot();
357 // Cos_alpha = get_Cos_alpha();
358 // Sin_alpha = get_Sin_alpha();
359 // Cos_beta = get_Cos_beta();
360 // Sin_beta = get_Sin_beta();
361 // Cos_phi = get_Cos_phi();
362 // Sin_phi = get_Sin_phi();
363 // Cos_theta = get_Cos_theta();
364 // Sin_theta = get_Sin_theta();
365 // Cos_psi = get_Cos_psi();
366 // Sin_psi = get_Sin_psi();
367 // Gamma_vert_rad = get_Gamma_vert_rad();
368 // Gamma_horiz_rad = get_Gamma_horiz_rad();
369 // Sigma = get_Sigma();
370 // Density = get_Density();
371 // V_sound = get_V_sound();
372 // Mach_number = get_Mach_number();
373 // Static_pressure = get_Static_pressure();
374 // Total_pressure = get_Total_pressure();
375 // Impact_pressure = get_Impact_pressure();
376 // Dynamic_pressure = get_Dynamic_pressure();
377 // Static_temperature = get_Static_temperature();
378 // Total_temperature = get_Total_temperature();
379 // Sea_level_radius = get_Sea_level_radius();
380 // Earth_position_angle = get_Earth_position_angle();
381 // Runway_altitude = get_Runway_altitude();
382 // Runway_latitude = get_Runway_latitude();
383 // Runway_longitude = get_Runway_longitude();
384 // Runway_heading = get_Runway_heading();
385 // Radius_to_rwy = get_Radius_to_rwy();
386 // D_cg_north_of_rwy = get_D_cg_north_of_rwy();
387 // D_cg_east_of_rwy = get_D_cg_east_of_rwy();
388 // D_cg_above_rwy = get_D_cg_above_rwy();
389 // X_cg_rwy = get_X_cg_rwy();
390 // Y_cg_rwy = get_Y_cg_rwy();
391 // H_cg_rwy = get_H_cg_rwy();
392 // D_pilot_north_of_rwy = get_D_pilot_north_of_rwy();
393 // D_pilot_east_of_rwy = get_D_pilot_east_of_rwy();
394 // D_pilot_above_rwy = get_D_pilot_above_rwy();
395 // X_pilot_rwy = get_X_pilot_rwy();
396 // Y_pilot_rwy = get_Y_pilot_rwy();
397 // H_pilot_rwy = get_H_pilot_rwy();
403 // Convert from the LaRCsim generic_ struct to the FGInterface struct
404 bool FGLaRCsim::copy_from_LaRCsim() {
406 // Mass properties and geometry values
407 _set_Inertias( Mass, I_xx, I_yy, I_zz, I_xz );
408 // set_Pilot_Location( Dx_pilot, Dy_pilot, Dz_pilot );
409 _set_CG_Position( Dx_cg, Dy_cg, Dz_cg );
412 // set_Forces_Body_Total( F_X, F_Y, F_Z );
413 // set_Forces_Local_Total( F_north, F_east, F_down );
414 // set_Forces_Aero( F_X_aero, F_Y_aero, F_Z_aero );
415 // set_Forces_Engine( F_X_engine, F_Y_engine, F_Z_engine );
416 // set_Forces_Gear( F_X_gear, F_Y_gear, F_Z_gear );
419 // set_Moments_Total_RP( M_l_rp, M_m_rp, M_n_rp );
420 // set_Moments_Total_CG( M_l_cg, M_m_cg, M_n_cg );
421 // set_Moments_Aero( M_l_aero, M_m_aero, M_n_aero );
422 // set_Moments_Engine( M_l_engine, M_m_engine, M_n_engine );
423 // set_Moments_Gear( M_l_gear, M_m_gear, M_n_gear );
426 _set_Accels_Local( V_dot_north, V_dot_east, V_dot_down );
427 _set_Accels_Body( U_dot_body, V_dot_body, W_dot_body );
428 _set_Accels_CG_Body( A_X_cg, A_Y_cg, A_Z_cg );
429 _set_Accels_Pilot_Body( A_X_pilot, A_Y_pilot, A_Z_pilot );
430 // set_Accels_CG_Body_N( N_X_cg, N_Y_cg, N_Z_cg );
431 // set_Accels_Pilot_Body_N( N_X_pilot, N_Y_pilot, N_Z_pilot );
432 // set_Accels_Omega( P_dot_body, Q_dot_body, R_dot_body );
435 _set_Velocities_Local( V_north, V_east, V_down );
436 // set_Velocities_Ground( V_north_rel_ground, V_east_rel_ground,
437 // V_down_rel_ground );
438 _set_Velocities_Local_Airmass( V_north_airmass, V_east_airmass,
440 // set_Velocities_Local_Rel_Airmass( V_north_rel_airmass,
441 // V_east_rel_airmass, V_down_rel_airmass );
442 // set_Velocities_Gust( U_gust, V_gust, W_gust );
443 _set_Velocities_Wind_Body( U_body, V_body, W_body );
445 _set_V_rel_wind( V_rel_wind );
446 // set_V_true_kts( V_true_kts );
447 // set_V_rel_ground( V_rel_ground );
448 // set_V_inertial( V_inertial );
449 _set_V_ground_speed( V_ground_speed );
450 // set_V_equiv( V_equiv );
451 _set_V_equiv_kts( V_equiv_kts );
452 // set_V_calibrated( V_calibrated );
453 _set_V_calibrated_kts( V_calibrated_kts );
455 _set_Omega_Body( P_body, Q_body, R_body );
456 // set_Omega_Local( P_local, Q_local, R_local );
457 // set_Omega_Total( P_total, Q_total, R_total );
459 _set_Euler_Rates( Phi_dot, Theta_dot, Psi_dot );
460 _set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
462 _set_Mach_number( Mach_number );
464 SG_LOG( SG_FLIGHT, SG_DEBUG, "lon = " << Longitude
465 << " lat_geoc = " << Lat_geocentric << " lat_geod = " << Latitude
466 << " alt = " << Altitude << " sl_radius = " << Sea_level_radius
467 << " radius_to_vehicle = " << Radius_to_vehicle );
469 double tmp_lon_geoc = Lon_geocentric;
470 while ( tmp_lon_geoc < -SGD_PI ) { tmp_lon_geoc += SGD_2PI; }
471 while ( tmp_lon_geoc > SGD_PI ) { tmp_lon_geoc -= SGD_2PI; }
473 double tmp_lon = Longitude;
474 while ( tmp_lon < -SGD_PI ) { tmp_lon += SGD_2PI; }
475 while ( tmp_lon > SGD_PI ) { tmp_lon -= SGD_2PI; }
478 _set_Geocentric_Position( Lat_geocentric, tmp_lon_geoc,
480 _set_Geodetic_Position( Latitude, tmp_lon, Altitude );
481 _set_Euler_Angles( Phi, Theta, Psi );
483 _set_Altitude_AGL( Altitude - Runway_altitude );
485 // Miscellaneous quantities
486 _set_T_Local_to_Body(T_local_to_body_m);
487 // set_Gravity( Gravity );
488 // set_Centrifugal_relief( Centrifugal_relief );
492 // set_Alpha_dot( Alpha_dot );
493 // set_Beta_dot( Beta_dot );
495 // set_Cos_alpha( Cos_alpha );
496 // set_Sin_alpha( Sin_alpha );
497 // set_Cos_beta( Cos_beta );
498 // set_Sin_beta( Sin_beta );
500 _set_Cos_phi( Cos_phi );
501 // set_Sin_phi( Sin_phi );
502 _set_Cos_theta( Cos_theta );
503 // set_Sin_theta( Sin_theta );
504 // set_Cos_psi( Cos_psi );
505 // set_Sin_psi( Sin_psi );
507 _set_Gamma_vert_rad( Gamma_vert_rad );
508 // set_Gamma_horiz_rad( Gamma_horiz_rad );
510 // set_Sigma( Sigma );
511 _set_Density( Density );
512 // set_V_sound( V_sound );
513 // set_Mach_number( Mach_number );
515 _set_Static_pressure( Static_pressure );
516 // set_Total_pressure( Total_pressure );
517 // set_Impact_pressure( Impact_pressure );
518 // set_Dynamic_pressure( Dynamic_pressure );
520 _set_Static_temperature( Static_temperature );
521 // set_Total_temperature( Total_temperature );
523 _set_Sea_level_radius( Sea_level_radius );
524 _set_Earth_position_angle( Earth_position_angle );
526 _set_Runway_altitude( Runway_altitude );
527 // set_Runway_latitude( Runway_latitude );
528 // set_Runway_longitude( Runway_longitude );
529 // set_Runway_heading( Runway_heading );
530 // set_Radius_to_rwy( Radius_to_rwy );
532 // set_CG_Rwy_Local( D_cg_north_of_rwy, D_cg_east_of_rwy, D_cg_above_rwy);
533 // set_CG_Rwy_Rwy( X_cg_rwy, Y_cg_rwy, H_cg_rwy );
534 // set_Pilot_Rwy_Local( D_pilot_north_of_rwy, D_pilot_east_of_rwy,
535 // D_pilot_above_rwy );
536 // set_Pilot_Rwy_Rwy( X_pilot_rwy, Y_pilot_rwy, H_pilot_rwy );
538 _set_sin_lat_geocentric(Lat_geocentric);
539 _set_cos_lat_geocentric(Lat_geocentric);
540 _set_sin_cos_longitude(Longitude);
541 _set_sin_cos_latitude(Latitude);
543 // printf("sin_lat_geo %f cos_lat_geo %f\n", sin_Lat_geoc, cos_Lat_geoc);
544 // printf("sin_lat %f cos_lat %f\n",
545 // get_sin_latitude(), get_cos_latitude());
546 // printf("sin_lon %f cos_lon %f\n",
547 // get_sin_longitude(), get_cos_longitude());
549 _set_Climb_Rate( -1 * V_down );
550 // cout << "climb rate = " << -V_down * 60 << endl;
552 if ( !strcmp(aero->getStringValue(), "uiuc") ) {
554 globals->get_controls()->set_elevator(Long_control);
555 globals->get_controls()->set_elevator_trim(Long_trim);
556 // controls.set_elevator(Long_control);
557 // controls.set_elevator_trim(Long_trim);
560 globals->get_controls()->set_aileron(Lat_control);
561 // controls.set_aileron(Lat_control);
564 globals->get_controls()->set_rudder(Rudder_pedal);
565 // controls.set_rudder(Rudder_pedal);
567 if (Throttle_pct_input) {
568 globals->get_controls()->set_throttle(0,Throttle_pct);
569 // controls.set_throttle(0,Throttle_pct);
577 void FGLaRCsim::set_ls(void) {
578 Phi=lsic->GetRollAngleRadIC();
579 Theta=lsic->GetPitchAngleRadIC();
580 Psi=lsic->GetHeadingRadIC();
581 V_north=lsic->GetVnorthFpsIC();
582 V_east=lsic->GetVeastFpsIC();
583 V_down=lsic->GetVdownFpsIC();
584 Altitude=lsic->GetAltitudeFtIC();
585 Latitude=lsic->GetLatitudeGDRadIC();
586 Longitude=lsic->GetLongitudeRadIC();
587 Runway_altitude=lsic->GetRunwayAltitudeFtIC();
588 V_north_airmass = lsic->GetVnorthAirmassFpsIC() * -1;
589 V_east_airmass = lsic->GetVeastAirmassFpsIC() * -1;
590 V_down_airmass = lsic->GetVdownAirmassFpsIC() * -1;
595 void FGLaRCsim::snap_shot(void) {
596 lsic->SetLatitudeGDRadIC( get_Latitude() );
597 lsic->SetLongitudeRadIC( get_Longitude() );
598 lsic->SetAltitudeFtIC( get_Altitude() );
599 lsic->SetRunwayAltitudeFtIC( get_Runway_altitude() );
600 lsic->SetVtrueFpsIC( get_V_rel_wind() );
601 lsic->SetPitchAngleRadIC( get_Theta() );
602 lsic->SetRollAngleRadIC( get_Phi() );
603 lsic->SetHeadingRadIC( get_Psi() );
604 lsic->SetClimbRateFpsIC( get_Climb_Rate() );
605 lsic->SetVNEDAirmassFpsIC( get_V_north_airmass(),
606 get_V_east_airmass(),
607 get_V_down_airmass() );
611 void FGLaRCsim::set_Latitude(double lat) {
612 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Latitude: " << lat );
614 _set_Runway_altitude( scenery.get_cur_elev() * SG_METER_TO_FEET );
615 lsic->SetLatitudeGDRadIC(lat);
617 copy_from_LaRCsim(); //update the bus
620 void FGLaRCsim::set_Longitude(double lon) {
621 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Longitude: " << lon );
624 _set_Runway_altitude( scenery.get_cur_elev() * SG_METER_TO_FEET );
625 lsic->SetLongitudeRadIC(lon);
627 copy_from_LaRCsim(); //update the bus
630 void FGLaRCsim::set_Altitude(double alt) {
631 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Altitude: " << alt );
633 _set_Runway_altitude( scenery.get_cur_elev() * SG_METER_TO_FEET );
634 lsic->SetAltitudeFtIC(alt);
636 copy_from_LaRCsim(); //update the bus
639 void FGLaRCsim::set_V_calibrated_kts(double vc) {
640 SG_LOG( SG_FLIGHT, SG_INFO,
641 "FGLaRCsim::set_V_calibrated_kts: " << vc );
643 lsic->SetVcalibratedKtsIC(vc);
645 copy_from_LaRCsim(); //update the bus
648 void FGLaRCsim::set_Mach_number(double mach) {
649 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Mach_number: " << mach );
651 lsic->SetMachIC(mach);
653 copy_from_LaRCsim(); //update the bus
656 void FGLaRCsim::set_Velocities_Local( double north, double east, double down ){
657 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_local: "
658 << north << " " << east << " " << down );
660 lsic->SetVNEDFpsIC(north, east, down);
662 copy_from_LaRCsim(); //update the bus
665 void FGLaRCsim::set_Velocities_Wind_Body( double u, double v, double w){
666 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_Wind_Body: "
667 << u << " " << v << " " << w );
669 lsic->SetUVWFpsIC(u,v,w);
671 copy_from_LaRCsim(); //update the bus
675 void FGLaRCsim::set_Euler_Angles( double phi, double theta, double psi ) {
676 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Euler_angles: "
677 << phi << " " << theta << " " << psi );
680 lsic->SetPitchAngleRadIC(theta);
681 lsic->SetRollAngleRadIC(phi);
682 lsic->SetHeadingRadIC(psi);
684 copy_from_LaRCsim(); //update the bus
688 void FGLaRCsim::set_Climb_Rate( double roc) {
689 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Climb_rate: " << roc );
691 lsic->SetClimbRateFpsIC(roc);
693 copy_from_LaRCsim(); //update the bus
696 void FGLaRCsim::set_Gamma_vert_rad( double gamma) {
697 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Gamma_vert_rad: " << gamma );
699 lsic->SetFlightPathAngleRadIC(gamma);
701 copy_from_LaRCsim(); //update the bus
704 void FGLaRCsim::set_AltitudeAGL(double altagl) {
705 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_AltitudeAGL: " << altagl );
707 lsic->SetAltitudeAGLFtIC(altagl);
712 void FGLaRCsim::set_Velocities_Local_Airmass (double wnorth,
715 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_Local_Airmass: "
716 << wnorth << " " << weast << " " << wdown );
718 lsic->SetVNEDAirmassFpsIC( wnorth, weast, wdown );
723 void FGLaRCsim::set_Static_pressure(double p) {
724 SG_LOG( SG_FLIGHT, SG_INFO,
725 "FGLaRCsim::set_Static_pressure: " << p );
726 SG_LOG( SG_FLIGHT, SG_INFO,
727 "LaRCsim does not support externally supplied atmospheric data" );
730 void FGLaRCsim::set_Static_temperature(double T) {
731 SG_LOG( SG_FLIGHT, SG_INFO,
732 "FGLaRCsim::set_Static_temperature: " << T );
733 SG_LOG( SG_FLIGHT, SG_INFO,
734 "LaRCsim does not support externally supplied atmospheric data" );
738 void FGLaRCsim::set_Density(double rho) {
739 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Density: " << rho );
740 SG_LOG( SG_FLIGHT, SG_INFO,
741 "LaRCsim does not support externally supplied atmospheric data" );