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 <Main/fg_props.hxx>
29 #include <Aircraft/aircraft.hxx>
30 #include <Controls/controls.hxx>
31 #include <FDM/flight.hxx>
32 #include <FDM/LaRCsim/ls_cockpit.h>
33 #include <FDM/LaRCsim/ls_generic.h>
34 #include <FDM/LaRCsim/ls_interface.h>
35 #include <FDM/LaRCsimIC.hxx>
36 #include <FDM/UIUCModel/uiuc_aircraft.h>
37 #include <Model/acmodel.hxx>
40 #include "LaRCsim.hxx"
42 FGLaRCsim::FGLaRCsim( double dt ) {
45 speed_up = fgGetNode("/sim/speed-up", true);
46 aero = fgGetNode("/sim/aero", true);
48 ls_toplevel_init( 0.0, (char *)(aero->getStringValue()) );
50 lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
51 if ( !strcmp(aero->getStringValue(), "c172") ) {
52 copy_to_LaRCsim(); // initialize all of LaRCsim's vars
54 //this should go away someday -- formerly done in fg_init.cxx
64 // Initialize our little engine that hopefully might
66 // dcl - in passing dt to init rather than update I am assuming
67 // that the LaRCsim dt is fixed at one value (yes it is 120hz CLO)
70 FGLaRCsim::~FGLaRCsim(void) {
77 // Initialize the LaRCsim flight model, dt is the time increment for
78 // each subsequent iteration through the EOM
79 void FGLaRCsim::init() {
80 //do init common to all FDM's
85 // Run an iteration of the EOM (equations of motion)
86 void FGLaRCsim::update( double dt ) {
91 int multiloop = _calc_multiloop(dt);
93 if ( !strcmp(aero->getStringValue(), "c172") ) {
95 // cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
96 eng.set_IAS( V_calibrated_kts );
97 eng.set_Throttle_Lever_Pos( globals->get_controls()->get_throttle( 0 )
99 eng.set_Propeller_Lever_Pos( 100 );
100 eng.set_Mixture_Lever_Pos( globals->get_controls()->get_mixture( 0 )
102 eng.set_Magneto_Switch_Pos( globals->get_controls()->get_magnetos(0) );
103 eng.setStarterFlag( globals->get_controls()->get_starter(0) );
104 eng.set_p_amb( Static_pressure );
105 eng.set_T_amb( Static_temperature );
107 // update engine model
110 // Fake control-surface positions
111 fgSetDouble("/surface-positions/flap-pos-norm",
112 fgGetDouble("/controls/flaps"));
113 // FIXME: ignoring trim
114 fgSetDouble("/surface-positions/elevator-pos-norm",
115 fgGetDouble("/controls/elevator"));
116 // FIXME: ignoring trim
117 fgSetDouble("/surface-positions/left-aileron-pos-norm",
118 fgGetDouble("/controls/aileron"));
119 // FIXME: ignoring trim
120 fgSetDouble("/surface-positions/right-aileron-pos-norm",
121 -1 * fgGetDouble("/controls/aileron"));
122 // FIXME: ignoring trim
123 fgSetDouble("/surface-positions/rudder-pos-norm",
124 fgGetDouble("/controls/rudder"));
126 // copy engine state values onto "bus"
127 fgSetDouble("/engines/engine/rpm", eng.get_RPM());
128 fgSetDouble("/engines/engine/mp-osi", eng.get_Manifold_Pressure());
129 fgSetDouble("/engines/engine/max-hp", eng.get_MaxHP());
130 fgSetDouble("/engines/engine/power-pct", eng.get_Percentage_Power());
131 fgSetDouble("/engines/engine/egt-degf", eng.get_EGT());
132 fgSetDouble("/engines/engine/cht-degf", eng.get_CHT());
133 fgSetDouble("/engines/engine/prop-thrust", eng.get_prop_thrust_SI());
134 fgSetDouble("/engines/engine/fuel-flow-gph",
135 eng.get_fuel_flow_gals_hr());
136 fgSetDouble("/engines/engine/oil-temperature-degf",
138 fgSetDouble("/engines/engine/running", eng.getRunningFlag());
139 fgSetDouble("/engines/engine/cranking", eng.getCrankingFlag());
141 static const SGPropertyNode *fuel_freeze
142 = fgGetNode("/sim/freeze/fuel");
144 if ( ! fuel_freeze->getBoolValue() ) {
145 //Assume we are using both tanks equally for now
146 fgSetDouble("/consumables/fuel/tank[0]/level-gal_us",
147 fgGetDouble("/consumables/fuel/tank[0]/level-gal_us")
148 - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
150 fgSetDouble("/consumables/fuel/tank[1]/level-gal_us",
151 fgGetDouble("/consumables/fuel/tank[1]/level-gal_us")
152 - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
156 F_X_engine = eng.get_prop_thrust_lbs();
157 // cout << "F_X_engine = " << F_X_engine << '\n';
160 double save_alt = 0.0;
162 // lets try to avoid really screwing up the LaRCsim model
163 if ( get_Altitude() < -9000.0 ) {
164 save_alt = get_Altitude();
168 // copy control positions into the LaRCsim structure
169 Lat_control = globals->get_controls()->get_aileron() /
170 speed_up->getIntValue();
171 Long_control = globals->get_controls()->get_elevator();
172 Long_trim = globals->get_controls()->get_elevator_trim();
173 Rudder_pedal = globals->get_controls()->get_rudder() /
174 speed_up->getIntValue();
175 Flap_handle = 30.0 * globals->get_controls()->get_flaps();
177 if ( !strcmp(aero->getStringValue(), "c172") ) {
178 Use_External_Engine = 1;
180 Use_External_Engine = 0;
183 Throttle_pct = globals->get_controls()->get_throttle( 0 ) * 1.0;
185 Brake_pct[0] = globals->get_controls()->get_brake( 1 );
186 Brake_pct[1] = globals->get_controls()->get_brake( 0 );
188 // Inform LaRCsim of the local terrain altitude
189 // Runway_altitude = get_Runway_altitude();
190 Runway_altitude = getACModel()->get3DModel()->getFGLocation()->get_cur_elev_m() * SG_METER_TO_FEET;
192 /* V_north_airmass = get_V_north_airmass();
193 V_east_airmass = get_V_east_airmass();
194 V_down_airmass = get_V_down_airmass(); */
197 // old -- FGInterface_2_LaRCsim() not needed except for Init()
198 // translate FG to LaRCsim structure
199 // FGInterface_2_LaRCsim(f);
200 // printf("FG_Altitude = %.2f\n", FG_Altitude * 0.3048);
201 // printf("Altitude = %.2f\n", Altitude * 0.3048);
202 // printf("Radius to Vehicle = %.2f\n", Radius_to_vehicle * 0.3048);
204 // for engine functions (sounds and instruments)
205 // drive the rpm gauge
206 fgSetDouble("/engines/engine/rpm", (globals->get_controls()->get_throttle( 0 ) * 100.0 * 25 ));
207 // manifold air pressure, which drives the sound (see *sound.xml file)
208 fgSetDouble("/engines/engine/mp-osi", (globals->get_controls()->get_throttle( 0 ) * 100.0 ));
209 // make the engine cranking and running sounds when fgfs starts up
210 fgSetDouble("/engines/engine/cranking", 1);
211 fgSetDouble("/engines/engine/running", 1);
213 ls_update(multiloop);
215 // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
216 // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
218 // translate LaRCsim back to FG structure so that the
219 // autopilot (and the rest of the sim can use the updated
223 // but lets restore our original bogus altitude when we are done
224 if ( save_alt < -9000.0 ) {
225 set_Altitude( save_alt );
230 // Convert from the FGInterface struct to the LaRCsim generic_ struct
231 bool FGLaRCsim::copy_to_LaRCsim () {
237 // Dx_pilot = get_Dx_pilot();
238 // Dy_pilot = get_Dy_pilot();
239 // Dz_pilot = get_Dz_pilot();
246 // F_north = get_F_north();
247 // F_east = get_F_east();
248 // F_down = get_F_down();
249 // F_X_aero = get_F_X_aero();
250 // F_Y_aero = get_F_Y_aero();
251 // F_Z_aero = get_F_Z_aero();
252 // F_X_engine = get_F_X_engine();
253 // F_Y_engine = get_F_Y_engine();
254 // F_Z_engine = get_F_Z_engine();
255 // F_X_gear = get_F_X_gear();
256 // F_Y_gear = get_F_Y_gear();
257 // F_Z_gear = get_F_Z_gear();
258 // M_l_rp = get_M_l_rp();
259 // M_m_rp = get_M_m_rp();
260 // M_n_rp = get_M_n_rp();
261 // M_l_cg = get_M_l_cg();
262 // M_m_cg = get_M_m_cg();
263 // M_n_cg = get_M_n_cg();
264 // M_l_aero = get_M_l_aero();
265 // M_m_aero = get_M_m_aero();
266 // M_n_aero = get_M_n_aero();
267 // M_l_engine = get_M_l_engine();
268 // M_m_engine = get_M_m_engine();
269 // M_n_engine = get_M_n_engine();
270 // M_l_gear = get_M_l_gear();
271 // M_m_gear = get_M_m_gear();
272 // M_n_gear = get_M_n_gear();
273 // V_dot_north = get_V_dot_north();
274 // V_dot_east = get_V_dot_east();
275 // V_dot_down = get_V_dot_down();
276 // U_dot_body = get_U_dot_body();
277 // V_dot_body = get_V_dot_body();
278 // W_dot_body = get_W_dot_body();
279 // A_X_cg = get_A_X_cg();
280 // A_Y_cg = get_A_Y_cg();
281 // A_Z_cg = get_A_Z_cg();
282 // A_X_pilot = get_A_X_pilot();
283 // A_Y_pilot = get_A_Y_pilot();
284 // A_Z_pilot = get_A_Z_pilot();
285 // N_X_cg = get_N_X_cg();
286 // N_Y_cg = get_N_Y_cg();
287 // N_Z_cg = get_N_Z_cg();
288 // N_X_pilot = get_N_X_pilot();
289 // N_Y_pilot = get_N_Y_pilot();
290 // N_Z_pilot = get_N_Z_pilot();
291 // P_dot_body = get_P_dot_body();
292 // Q_dot_body = get_Q_dot_body();
293 // R_dot_body = get_R_dot_body();
294 // V_north = get_V_north();
295 // V_east = get_V_east();
296 // V_down = get_V_down();
297 // V_north_rel_ground = get_V_north_rel_ground();
298 // V_east_rel_ground = get_V_east_rel_ground();
299 // V_down_rel_ground = get_V_down_rel_ground();
300 // V_north_airmass = get_V_north_airmass();
301 // V_east_airmass = get_V_east_airmass();
302 // V_down_airmass = get_V_down_airmass();
303 // V_north_rel_airmass = get_V_north_rel_airmass();
304 // V_east_rel_airmass = get_V_east_rel_airmass();
305 // V_down_rel_airmass = get_V_down_rel_airmass();
306 // U_gust = get_U_gust();
307 // V_gust = get_V_gust();
308 // W_gust = get_W_gust();
309 // U_body = get_U_body();
310 // V_body = get_V_body();
311 // W_body = get_W_body();
312 // V_rel_wind = get_V_rel_wind();
313 // V_true_kts = get_V_true_kts();
314 // V_rel_ground = get_V_rel_ground();
315 // V_inertial = get_V_inertial();
316 // V_ground_speed = get_V_ground_speed();
317 // V_equiv = get_V_equiv();
318 // V_equiv_kts = get_V_equiv_kts();
319 // V_calibrated = get_V_calibrated();
320 // V_calibrated_kts = get_V_calibrated_kts();
321 // P_body = get_P_body();
322 // Q_body = get_Q_body();
323 // R_body = get_R_body();
324 // P_local = get_P_local();
325 // Q_local = get_Q_local();
326 // R_local = get_R_local();
327 // P_total = get_P_total();
328 // Q_total = get_Q_total();
329 // R_total = get_R_total();
330 // Phi_dot = get_Phi_dot();
331 // Theta_dot = get_Theta_dot();
332 // Psi_dot = get_Psi_dot();
333 // Latitude_dot = get_Latitude_dot();
334 // Longitude_dot = get_Longitude_dot();
335 // Radius_dot = get_Radius_dot();
336 // Lat_geocentric = get_Lat_geocentric();
337 // Lon_geocentric = get_Lon_geocentric();
338 // Radius_to_vehicle = get_Radius_to_vehicle();
339 // Latitude = get_Latitude();
340 // Longitude = get_Longitude();
341 // Altitude = get_Altitude();
343 // Theta = get_Theta();
345 // T_local_to_body_11 = get_T_local_to_body_11();
346 // T_local_to_body_12 = get_T_local_to_body_12();
347 // T_local_to_body_13 = get_T_local_to_body_13();
348 // T_local_to_body_21 = get_T_local_to_body_21();
349 // T_local_to_body_22 = get_T_local_to_body_22();
350 // T_local_to_body_23 = get_T_local_to_body_23();
351 // T_local_to_body_31 = get_T_local_to_body_31();
352 // T_local_to_body_32 = get_T_local_to_body_32();
353 // T_local_to_body_33 = get_T_local_to_body_33();
354 // Gravity = get_Gravity();
355 // Centrifugal_relief = get_Centrifugal_relief();
356 // Alpha = get_Alpha();
357 // Beta = get_Beta();
358 // Alpha_dot = get_Alpha_dot();
359 // Beta_dot = get_Beta_dot();
360 // Cos_alpha = get_Cos_alpha();
361 // Sin_alpha = get_Sin_alpha();
362 // Cos_beta = get_Cos_beta();
363 // Sin_beta = get_Sin_beta();
364 // Cos_phi = get_Cos_phi();
365 // Sin_phi = get_Sin_phi();
366 // Cos_theta = get_Cos_theta();
367 // Sin_theta = get_Sin_theta();
368 // Cos_psi = get_Cos_psi();
369 // Sin_psi = get_Sin_psi();
370 // Gamma_vert_rad = get_Gamma_vert_rad();
371 // Gamma_horiz_rad = get_Gamma_horiz_rad();
372 // Sigma = get_Sigma();
373 // Density = get_Density();
374 // V_sound = get_V_sound();
375 // Mach_number = get_Mach_number();
376 // Static_pressure = get_Static_pressure();
377 // Total_pressure = get_Total_pressure();
378 // Impact_pressure = get_Impact_pressure();
379 // Dynamic_pressure = get_Dynamic_pressure();
380 // Static_temperature = get_Static_temperature();
381 // Total_temperature = get_Total_temperature();
382 // Sea_level_radius = get_Sea_level_radius();
383 // Earth_position_angle = get_Earth_position_angle();
384 // Runway_altitude = get_Runway_altitude();
385 // Runway_latitude = get_Runway_latitude();
386 // Runway_longitude = get_Runway_longitude();
387 // Runway_heading = get_Runway_heading();
388 // Radius_to_rwy = get_Radius_to_rwy();
389 // D_cg_north_of_rwy = get_D_cg_north_of_rwy();
390 // D_cg_east_of_rwy = get_D_cg_east_of_rwy();
391 // D_cg_above_rwy = get_D_cg_above_rwy();
392 // X_cg_rwy = get_X_cg_rwy();
393 // Y_cg_rwy = get_Y_cg_rwy();
394 // H_cg_rwy = get_H_cg_rwy();
395 // D_pilot_north_of_rwy = get_D_pilot_north_of_rwy();
396 // D_pilot_east_of_rwy = get_D_pilot_east_of_rwy();
397 // D_pilot_above_rwy = get_D_pilot_above_rwy();
398 // X_pilot_rwy = get_X_pilot_rwy();
399 // Y_pilot_rwy = get_Y_pilot_rwy();
400 // H_pilot_rwy = get_H_pilot_rwy();
406 // Convert from the LaRCsim generic_ struct to the FGInterface struct
407 bool FGLaRCsim::copy_from_LaRCsim() {
409 // Mass properties and geometry values
410 _set_Inertias( Mass, I_xx, I_yy, I_zz, I_xz );
411 // set_Pilot_Location( Dx_pilot, Dy_pilot, Dz_pilot );
412 _set_CG_Position( Dx_cg, Dy_cg, Dz_cg );
415 // set_Forces_Body_Total( F_X, F_Y, F_Z );
416 // set_Forces_Local_Total( F_north, F_east, F_down );
417 // set_Forces_Aero( F_X_aero, F_Y_aero, F_Z_aero );
418 // set_Forces_Engine( F_X_engine, F_Y_engine, F_Z_engine );
419 // set_Forces_Gear( F_X_gear, F_Y_gear, F_Z_gear );
422 // set_Moments_Total_RP( M_l_rp, M_m_rp, M_n_rp );
423 // set_Moments_Total_CG( M_l_cg, M_m_cg, M_n_cg );
424 // set_Moments_Aero( M_l_aero, M_m_aero, M_n_aero );
425 // set_Moments_Engine( M_l_engine, M_m_engine, M_n_engine );
426 // set_Moments_Gear( M_l_gear, M_m_gear, M_n_gear );
429 _set_Accels_Local( V_dot_north, V_dot_east, V_dot_down );
430 _set_Accels_Body( U_dot_body, V_dot_body, W_dot_body );
431 _set_Accels_CG_Body( A_X_cg, A_Y_cg, A_Z_cg );
432 _set_Accels_Pilot_Body( A_X_pilot, A_Y_pilot, A_Z_pilot );
433 // set_Accels_CG_Body_N( N_X_cg, N_Y_cg, N_Z_cg );
434 // set_Accels_Pilot_Body_N( N_X_pilot, N_Y_pilot, N_Z_pilot );
435 // set_Accels_Omega( P_dot_body, Q_dot_body, R_dot_body );
438 _set_Velocities_Local( V_north, V_east, V_down );
439 // set_Velocities_Ground( V_north_rel_ground, V_east_rel_ground,
440 // V_down_rel_ground );
441 _set_Velocities_Local_Airmass( V_north_airmass, V_east_airmass,
443 // set_Velocities_Local_Rel_Airmass( V_north_rel_airmass,
444 // V_east_rel_airmass, V_down_rel_airmass );
445 // set_Velocities_Gust( U_gust, V_gust, W_gust );
446 _set_Velocities_Wind_Body( U_body, V_body, W_body );
448 _set_V_rel_wind( V_rel_wind );
449 // set_V_true_kts( V_true_kts );
450 // set_V_rel_ground( V_rel_ground );
451 // set_V_inertial( V_inertial );
452 _set_V_ground_speed( V_ground_speed );
453 // set_V_equiv( V_equiv );
454 _set_V_equiv_kts( V_equiv_kts );
455 // set_V_calibrated( V_calibrated );
456 _set_V_calibrated_kts( V_calibrated_kts );
458 _set_Omega_Body( P_body, Q_body, R_body );
459 // set_Omega_Local( P_local, Q_local, R_local );
460 // set_Omega_Total( P_total, Q_total, R_total );
462 _set_Euler_Rates( Phi_dot, Theta_dot, Psi_dot );
463 _set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
465 _set_Mach_number( Mach_number );
467 SG_LOG( SG_FLIGHT, SG_DEBUG, "lon = " << Longitude
468 << " lat_geoc = " << Lat_geocentric << " lat_geod = " << Latitude
469 << " alt = " << Altitude << " sl_radius = " << Sea_level_radius
470 << " radius_to_vehicle = " << Radius_to_vehicle );
472 double tmp_lon_geoc = Lon_geocentric;
473 while ( tmp_lon_geoc < -SGD_PI ) { tmp_lon_geoc += SGD_2PI; }
474 while ( tmp_lon_geoc > SGD_PI ) { tmp_lon_geoc -= SGD_2PI; }
476 double tmp_lon = Longitude;
477 while ( tmp_lon < -SGD_PI ) { tmp_lon += SGD_2PI; }
478 while ( tmp_lon > SGD_PI ) { tmp_lon -= SGD_2PI; }
481 _set_Geocentric_Position( Lat_geocentric, tmp_lon_geoc,
483 _set_Geodetic_Position( Latitude, tmp_lon, Altitude );
484 _set_Euler_Angles( Phi, Theta, Psi );
486 _set_Altitude_AGL( Altitude - Runway_altitude );
488 // Miscellaneous quantities
489 _set_T_Local_to_Body(T_local_to_body_m);
490 // set_Gravity( Gravity );
491 // set_Centrifugal_relief( Centrifugal_relief );
495 // set_Alpha_dot( Alpha_dot );
496 // set_Beta_dot( Beta_dot );
498 // set_Cos_alpha( Cos_alpha );
499 // set_Sin_alpha( Sin_alpha );
500 // set_Cos_beta( Cos_beta );
501 // set_Sin_beta( Sin_beta );
503 _set_Cos_phi( Cos_phi );
504 // set_Sin_phi( Sin_phi );
505 _set_Cos_theta( Cos_theta );
506 // set_Sin_theta( Sin_theta );
507 // set_Cos_psi( Cos_psi );
508 // set_Sin_psi( Sin_psi );
510 _set_Gamma_vert_rad( Gamma_vert_rad );
511 // set_Gamma_horiz_rad( Gamma_horiz_rad );
513 // set_Sigma( Sigma );
514 _set_Density( Density );
515 // set_V_sound( V_sound );
516 // set_Mach_number( Mach_number );
518 _set_Static_pressure( Static_pressure );
519 // set_Total_pressure( Total_pressure );
520 // set_Impact_pressure( Impact_pressure );
521 // set_Dynamic_pressure( Dynamic_pressure );
523 _set_Static_temperature( Static_temperature );
524 // set_Total_temperature( Total_temperature );
526 _set_Sea_level_radius( Sea_level_radius );
527 _set_Earth_position_angle( Earth_position_angle );
529 _set_Runway_altitude( Runway_altitude );
530 // set_Runway_latitude( Runway_latitude );
531 // set_Runway_longitude( Runway_longitude );
532 // set_Runway_heading( Runway_heading );
533 // set_Radius_to_rwy( Radius_to_rwy );
535 // set_CG_Rwy_Local( D_cg_north_of_rwy, D_cg_east_of_rwy, D_cg_above_rwy);
536 // set_CG_Rwy_Rwy( X_cg_rwy, Y_cg_rwy, H_cg_rwy );
537 // set_Pilot_Rwy_Local( D_pilot_north_of_rwy, D_pilot_east_of_rwy,
538 // D_pilot_above_rwy );
539 // set_Pilot_Rwy_Rwy( X_pilot_rwy, Y_pilot_rwy, H_pilot_rwy );
541 _set_sin_lat_geocentric(Lat_geocentric);
542 _set_cos_lat_geocentric(Lat_geocentric);
543 _set_sin_cos_longitude(Longitude);
544 _set_sin_cos_latitude(Latitude);
546 // printf("sin_lat_geo %f cos_lat_geo %f\n", sin_Lat_geoc, cos_Lat_geoc);
547 // printf("sin_lat %f cos_lat %f\n",
548 // get_sin_latitude(), get_cos_latitude());
549 // printf("sin_lon %f cos_lon %f\n",
550 // get_sin_longitude(), get_cos_longitude());
552 _set_Climb_Rate( -1 * V_down );
553 // cout << "climb rate = " << -V_down * 60 << endl;
555 if ( !strcmp(aero->getStringValue(), "uiuc") ) {
557 globals->get_controls()->set_elevator(Long_control);
558 globals->get_controls()->set_elevator_trim(Long_trim);
559 // controls.set_elevator(Long_control);
560 // controls.set_elevator_trim(Long_trim);
563 globals->get_controls()->set_aileron(Lat_control);
564 // controls.set_aileron(Lat_control);
567 globals->get_controls()->set_rudder(Rudder_pedal);
568 // controls.set_rudder(Rudder_pedal);
570 if (Throttle_pct_input) {
571 globals->get_controls()->set_throttle(0,Throttle_pct);
572 // controls.set_throttle(0,Throttle_pct);
580 void FGLaRCsim::set_ls(void) {
581 Phi=lsic->GetRollAngleRadIC();
582 Theta=lsic->GetPitchAngleRadIC();
583 Psi=lsic->GetHeadingRadIC();
584 V_north=lsic->GetVnorthFpsIC();
585 V_east=lsic->GetVeastFpsIC();
586 V_down=lsic->GetVdownFpsIC();
587 Altitude=lsic->GetAltitudeFtIC();
588 Latitude=lsic->GetLatitudeGDRadIC();
589 Longitude=lsic->GetLongitudeRadIC();
590 Runway_altitude=lsic->GetRunwayAltitudeFtIC();
591 V_north_airmass = lsic->GetVnorthAirmassFpsIC() * -1;
592 V_east_airmass = lsic->GetVeastAirmassFpsIC() * -1;
593 V_down_airmass = lsic->GetVdownAirmassFpsIC() * -1;
598 void FGLaRCsim::snap_shot(void) {
599 lsic->SetLatitudeGDRadIC( get_Latitude() );
600 lsic->SetLongitudeRadIC( get_Longitude() );
601 lsic->SetAltitudeFtIC( get_Altitude() );
602 lsic->SetRunwayAltitudeFtIC( get_Runway_altitude() );
603 lsic->SetVtrueFpsIC( get_V_rel_wind() );
604 lsic->SetPitchAngleRadIC( get_Theta() );
605 lsic->SetRollAngleRadIC( get_Phi() );
606 lsic->SetHeadingRadIC( get_Psi() );
607 lsic->SetClimbRateFpsIC( get_Climb_Rate() );
608 lsic->SetVNEDAirmassFpsIC( get_V_north_airmass(),
609 get_V_east_airmass(),
610 get_V_down_airmass() );
614 void FGLaRCsim::set_Latitude(double lat) {
615 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Latitude: " << lat );
617 lsic->SetLatitudeGDRadIC(lat);
619 copy_from_LaRCsim(); //update the bus
622 void FGLaRCsim::set_Longitude(double lon) {
623 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Longitude: " << lon );
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 lsic->SetAltitudeFtIC(alt);
635 copy_from_LaRCsim(); //update the bus
638 void FGLaRCsim::set_V_calibrated_kts(double vc) {
639 SG_LOG( SG_FLIGHT, SG_INFO,
640 "FGLaRCsim::set_V_calibrated_kts: " << vc );
642 lsic->SetVcalibratedKtsIC(vc);
644 copy_from_LaRCsim(); //update the bus
647 void FGLaRCsim::set_Mach_number(double mach) {
648 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Mach_number: " << mach );
650 lsic->SetMachIC(mach);
652 copy_from_LaRCsim(); //update the bus
655 void FGLaRCsim::set_Velocities_Local( double north, double east, double down ){
656 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_local: "
657 << north << " " << east << " " << down );
659 lsic->SetVNEDFpsIC(north, east, down);
661 copy_from_LaRCsim(); //update the bus
664 void FGLaRCsim::set_Velocities_Wind_Body( double u, double v, double w){
665 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_Wind_Body: "
666 << u << " " << v << " " << w );
668 lsic->SetUVWFpsIC(u,v,w);
670 copy_from_LaRCsim(); //update the bus
674 void FGLaRCsim::set_Euler_Angles( double phi, double theta, double psi ) {
675 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Euler_angles: "
676 << phi << " " << theta << " " << psi );
679 lsic->SetPitchAngleRadIC(theta);
680 lsic->SetRollAngleRadIC(phi);
681 lsic->SetHeadingRadIC(psi);
683 copy_from_LaRCsim(); //update the bus
687 void FGLaRCsim::set_Climb_Rate( double roc) {
688 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Climb_rate: " << roc );
690 lsic->SetClimbRateFpsIC(roc);
692 copy_from_LaRCsim(); //update the bus
695 void FGLaRCsim::set_Gamma_vert_rad( double gamma) {
696 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Gamma_vert_rad: " << gamma );
698 lsic->SetFlightPathAngleRadIC(gamma);
700 copy_from_LaRCsim(); //update the bus
703 void FGLaRCsim::set_AltitudeAGL(double altagl) {
704 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_AltitudeAGL: " << altagl );
706 lsic->SetAltitudeAGLFtIC(altagl);
711 /* getting a namespace conflict...
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 );
724 void FGLaRCsim::set_Static_pressure(double p) {
725 SG_LOG( SG_FLIGHT, SG_INFO,
726 "FGLaRCsim::set_Static_pressure: " << p );
727 SG_LOG( SG_FLIGHT, SG_INFO,
728 "LaRCsim does not support externally supplied atmospheric data" );
731 void FGLaRCsim::set_Static_temperature(double T) {
732 SG_LOG( SG_FLIGHT, SG_INFO,
733 "FGLaRCsim::set_Static_temperature: " << T );
734 SG_LOG( SG_FLIGHT, SG_INFO,
735 "LaRCsim does not support externally supplied atmospheric data" );
739 void FGLaRCsim::set_Density(double rho) {
740 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Density: " << rho );
741 SG_LOG( SG_FLIGHT, SG_INFO,
742 "LaRCsim does not support externally supplied atmospheric data" );