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