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.
24 #include <simgear/constants.h>
25 #include <simgear/debug/logstream.hxx>
27 #include <Scenery/scenery.hxx>
29 #include <Main/fg_props.hxx>
30 #include <Aircraft/aircraft.hxx>
31 #include <Controls/controls.hxx>
32 #include <FDM/flight.hxx>
33 #include <FDM/LaRCsim/ls_cockpit.h>
34 #include <FDM/LaRCsim/ls_generic.h>
35 #include <FDM/LaRCsim/ls_interface.h>
36 #include <FDM/LaRCsimIC.hxx>
37 #include <FDM/UIUCModel/uiuc_aircraft.h>
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().c_str()) );
50 lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
51 if ( 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
62 ls_set_model_dt( get_delta_t() );
64 // Initialize our little engine that hopefully might
65 eng.init( get_delta_t() );
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)
69 // update the engines interface
73 // Fill the fuel tanks
74 // Hardwired to C172 full tanks for now - need to fix this sometime
75 // Also note that this is the max quantity - the usable quantity
81 FGLaRCsim::~FGLaRCsim(void) {
89 // Initialize the LaRCsim flight model, dt is the time increment for
90 // each subsequent iteration through the EOM
91 void FGLaRCsim::init() {
92 //do init common to all FDM's
95 //now do any specific to LaRCsim
99 // Run an iteration of the EOM (equations of motion)
100 bool FGLaRCsim::update( int multiloop ) {
102 if ( aero->getStringValue() == "c172" ) {
103 // set control inputs
104 // cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
105 eng.set_IAS( V_calibrated_kts );
106 eng.set_Throttle_Lever_Pos( globals->get_controls()->get_throttle( 0 )
108 eng.set_Propeller_Lever_Pos( 100 );
109 eng.set_Mixture_Lever_Pos( globals->get_controls()->get_mixture( 0 )
111 eng.set_Magneto_Switch_Pos( globals->get_controls()->get_magnetos(0) );
112 eng.setStarterFlag( globals->get_controls()->get_starter(0) );
113 eng.set_p_amb( Static_pressure );
114 eng.set_T_amb( Static_temperature );
116 // update engine model
119 // copy engine state values onto "bus"
120 FGEngInterface *e = get_engine( 0 );
121 e->set_Throttle( globals->get_controls()->get_throttle(0) * 100.0 );
122 e->set_Mixture( 80 ); // ???????
123 e->set_Prop_Advance( 100 );
124 e->set_RPM( eng.get_RPM() );
125 e->set_Manifold_Pressure( eng.get_Manifold_Pressure() );
126 e->set_MaxHP( eng.get_MaxHP() );
127 e->set_Percentage_Power( eng.get_Percentage_Power() );
128 e->set_EGT( eng.get_EGT() );
129 e->set_CHT( eng.get_CHT() );
130 e->set_prop_thrust( eng.get_prop_thrust_SI() );
131 e->set_Fuel_Flow( eng.get_fuel_flow_gals_hr() );
132 e->set_Oil_Temp( eng.get_oil_temp() );
133 e->set_Running_Flag( eng.getRunningFlag() );
134 e->set_Cranking_Flag( eng.getCrankingFlag() );
136 //Assume we are using both tanks equally for now
137 reduce_Tank1Fuel( (eng.get_fuel_flow_gals_hr() / (2 * 3600))
139 reduce_Tank2Fuel( (eng.get_fuel_flow_gals_hr() / (2 * 3600))
143 SG_LOG( SG_FLIGHT, SG_INFO, "Throttle = "
144 << globals->get_controls()->get_throttle( 0 ) * 100.0);
145 SG_LOG( SG_FLIGHT, SG_INFO, " Mixture = " << 80);
146 SG_LOG( SG_FLIGHT, SG_INFO, " RPM = " << eng.get_RPM());
147 SG_LOG( SG_FLIGHT, SG_INFO, " MP = " << eng.get_Manifold_Pressure());
148 SG_LOG( SG_FLIGHT, SG_INFO, " HP = "
149 << ( eng.get_MaxHP() * eng.get_Percentage_Power()/ 100.0) );
150 SG_LOG( SG_FLIGHT, SG_INFO, " EGT = " << eng.get_EGT());
151 SG_LOG( SG_FLIGHT, SG_INFO, " Thrust (N) "
152 << eng.get_prop_thrust_SI()); // Thrust in Newtons
153 SG_LOG( SG_FLIGHT, SG_INFO, '\n');
155 F_X_engine = eng.get_prop_thrust_lbs();
156 // cout << "F_X_engine = " << F_X_engine << '\n';
159 double save_alt = 0.0;
161 // lets try to avoid really screwing up the LaRCsim model
162 if ( get_Altitude() < -9000.0 ) {
163 save_alt = get_Altitude();
167 // copy control positions into the LaRCsim structure
168 Lat_control = globals->get_controls()->get_aileron() /
169 speed_up->getIntValue();
170 Long_control = globals->get_controls()->get_elevator();
171 Long_trim = globals->get_controls()->get_elevator_trim();
172 Rudder_pedal = globals->get_controls()->get_rudder() /
173 speed_up->getIntValue();
174 Flap_handle = 30.0 * globals->get_controls()->get_flaps();
176 if ( aero->getStringValue() == "c172" ) {
177 Use_External_Engine = 1;
179 Use_External_Engine = 0;
182 Throttle_pct = globals->get_controls()->get_throttle( 0 ) * 1.0;
184 Brake_pct[0] = globals->get_controls()->get_brake( 1 );
185 Brake_pct[1] = globals->get_controls()->get_brake( 0 );
187 // Inform LaRCsim of the local terrain altitude
188 // Runway_altitude = get_Runway_altitude();
189 Runway_altitude = scenery.get_cur_elev() * 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 ls_update(multiloop);
206 // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
207 // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
209 // translate LaRCsim back to FG structure so that the
210 // autopilot (and the rest of the sim can use the updated
214 // but lets restore our original bogus altitude when we are done
215 if ( save_alt < -9000.0 ) {
216 set_Altitude( save_alt );
223 // Convert from the FGInterface struct to the LaRCsim generic_ struct
224 bool FGLaRCsim::copy_to_LaRCsim () {
230 // Dx_pilot = get_Dx_pilot();
231 // Dy_pilot = get_Dy_pilot();
232 // Dz_pilot = get_Dz_pilot();
239 // F_north = get_F_north();
240 // F_east = get_F_east();
241 // F_down = get_F_down();
242 // F_X_aero = get_F_X_aero();
243 // F_Y_aero = get_F_Y_aero();
244 // F_Z_aero = get_F_Z_aero();
245 // F_X_engine = get_F_X_engine();
246 // F_Y_engine = get_F_Y_engine();
247 // F_Z_engine = get_F_Z_engine();
248 // F_X_gear = get_F_X_gear();
249 // F_Y_gear = get_F_Y_gear();
250 // F_Z_gear = get_F_Z_gear();
251 // M_l_rp = get_M_l_rp();
252 // M_m_rp = get_M_m_rp();
253 // M_n_rp = get_M_n_rp();
254 // M_l_cg = get_M_l_cg();
255 // M_m_cg = get_M_m_cg();
256 // M_n_cg = get_M_n_cg();
257 // M_l_aero = get_M_l_aero();
258 // M_m_aero = get_M_m_aero();
259 // M_n_aero = get_M_n_aero();
260 // M_l_engine = get_M_l_engine();
261 // M_m_engine = get_M_m_engine();
262 // M_n_engine = get_M_n_engine();
263 // M_l_gear = get_M_l_gear();
264 // M_m_gear = get_M_m_gear();
265 // M_n_gear = get_M_n_gear();
266 // V_dot_north = get_V_dot_north();
267 // V_dot_east = get_V_dot_east();
268 // V_dot_down = get_V_dot_down();
269 // U_dot_body = get_U_dot_body();
270 // V_dot_body = get_V_dot_body();
271 // W_dot_body = get_W_dot_body();
272 // A_X_cg = get_A_X_cg();
273 // A_Y_cg = get_A_Y_cg();
274 // A_Z_cg = get_A_Z_cg();
275 // A_X_pilot = get_A_X_pilot();
276 // A_Y_pilot = get_A_Y_pilot();
277 // A_Z_pilot = get_A_Z_pilot();
278 // N_X_cg = get_N_X_cg();
279 // N_Y_cg = get_N_Y_cg();
280 // N_Z_cg = get_N_Z_cg();
281 // N_X_pilot = get_N_X_pilot();
282 // N_Y_pilot = get_N_Y_pilot();
283 // N_Z_pilot = get_N_Z_pilot();
284 // P_dot_body = get_P_dot_body();
285 // Q_dot_body = get_Q_dot_body();
286 // R_dot_body = get_R_dot_body();
287 // V_north = get_V_north();
288 // V_east = get_V_east();
289 // V_down = get_V_down();
290 // V_north_rel_ground = get_V_north_rel_ground();
291 // V_east_rel_ground = get_V_east_rel_ground();
292 // V_down_rel_ground = get_V_down_rel_ground();
293 // V_north_airmass = get_V_north_airmass();
294 // V_east_airmass = get_V_east_airmass();
295 // V_down_airmass = get_V_down_airmass();
296 // V_north_rel_airmass = get_V_north_rel_airmass();
297 // V_east_rel_airmass = get_V_east_rel_airmass();
298 // V_down_rel_airmass = get_V_down_rel_airmass();
299 // U_gust = get_U_gust();
300 // V_gust = get_V_gust();
301 // W_gust = get_W_gust();
302 // U_body = get_U_body();
303 // V_body = get_V_body();
304 // W_body = get_W_body();
305 // V_rel_wind = get_V_rel_wind();
306 // V_true_kts = get_V_true_kts();
307 // V_rel_ground = get_V_rel_ground();
308 // V_inertial = get_V_inertial();
309 // V_ground_speed = get_V_ground_speed();
310 // V_equiv = get_V_equiv();
311 // V_equiv_kts = get_V_equiv_kts();
312 // V_calibrated = get_V_calibrated();
313 // V_calibrated_kts = get_V_calibrated_kts();
314 // P_body = get_P_body();
315 // Q_body = get_Q_body();
316 // R_body = get_R_body();
317 // P_local = get_P_local();
318 // Q_local = get_Q_local();
319 // R_local = get_R_local();
320 // P_total = get_P_total();
321 // Q_total = get_Q_total();
322 // R_total = get_R_total();
323 // Phi_dot = get_Phi_dot();
324 // Theta_dot = get_Theta_dot();
325 // Psi_dot = get_Psi_dot();
326 // Latitude_dot = get_Latitude_dot();
327 // Longitude_dot = get_Longitude_dot();
328 // Radius_dot = get_Radius_dot();
329 // Lat_geocentric = get_Lat_geocentric();
330 // Lon_geocentric = get_Lon_geocentric();
331 // Radius_to_vehicle = get_Radius_to_vehicle();
332 // Latitude = get_Latitude();
333 // Longitude = get_Longitude();
334 // Altitude = get_Altitude();
336 // Theta = get_Theta();
338 // T_local_to_body_11 = get_T_local_to_body_11();
339 // T_local_to_body_12 = get_T_local_to_body_12();
340 // T_local_to_body_13 = get_T_local_to_body_13();
341 // T_local_to_body_21 = get_T_local_to_body_21();
342 // T_local_to_body_22 = get_T_local_to_body_22();
343 // T_local_to_body_23 = get_T_local_to_body_23();
344 // T_local_to_body_31 = get_T_local_to_body_31();
345 // T_local_to_body_32 = get_T_local_to_body_32();
346 // T_local_to_body_33 = get_T_local_to_body_33();
347 // Gravity = get_Gravity();
348 // Centrifugal_relief = get_Centrifugal_relief();
349 // Alpha = get_Alpha();
350 // Beta = get_Beta();
351 // Alpha_dot = get_Alpha_dot();
352 // Beta_dot = get_Beta_dot();
353 // Cos_alpha = get_Cos_alpha();
354 // Sin_alpha = get_Sin_alpha();
355 // Cos_beta = get_Cos_beta();
356 // Sin_beta = get_Sin_beta();
357 // Cos_phi = get_Cos_phi();
358 // Sin_phi = get_Sin_phi();
359 // Cos_theta = get_Cos_theta();
360 // Sin_theta = get_Sin_theta();
361 // Cos_psi = get_Cos_psi();
362 // Sin_psi = get_Sin_psi();
363 // Gamma_vert_rad = get_Gamma_vert_rad();
364 // Gamma_horiz_rad = get_Gamma_horiz_rad();
365 // Sigma = get_Sigma();
366 // Density = get_Density();
367 // V_sound = get_V_sound();
368 // Mach_number = get_Mach_number();
369 // Static_pressure = get_Static_pressure();
370 // Total_pressure = get_Total_pressure();
371 // Impact_pressure = get_Impact_pressure();
372 // Dynamic_pressure = get_Dynamic_pressure();
373 // Static_temperature = get_Static_temperature();
374 // Total_temperature = get_Total_temperature();
375 // Sea_level_radius = get_Sea_level_radius();
376 // Earth_position_angle = get_Earth_position_angle();
377 // Runway_altitude = get_Runway_altitude();
378 // Runway_latitude = get_Runway_latitude();
379 // Runway_longitude = get_Runway_longitude();
380 // Runway_heading = get_Runway_heading();
381 // Radius_to_rwy = get_Radius_to_rwy();
382 // D_cg_north_of_rwy = get_D_cg_north_of_rwy();
383 // D_cg_east_of_rwy = get_D_cg_east_of_rwy();
384 // D_cg_above_rwy = get_D_cg_above_rwy();
385 // X_cg_rwy = get_X_cg_rwy();
386 // Y_cg_rwy = get_Y_cg_rwy();
387 // H_cg_rwy = get_H_cg_rwy();
388 // D_pilot_north_of_rwy = get_D_pilot_north_of_rwy();
389 // D_pilot_east_of_rwy = get_D_pilot_east_of_rwy();
390 // D_pilot_above_rwy = get_D_pilot_above_rwy();
391 // X_pilot_rwy = get_X_pilot_rwy();
392 // Y_pilot_rwy = get_Y_pilot_rwy();
393 // H_pilot_rwy = get_H_pilot_rwy();
399 // Convert from the LaRCsim generic_ struct to the FGInterface struct
400 bool FGLaRCsim::copy_from_LaRCsim() {
402 // Mass properties and geometry values
403 _set_Inertias( Mass, I_xx, I_yy, I_zz, I_xz );
404 // set_Pilot_Location( Dx_pilot, Dy_pilot, Dz_pilot );
405 _set_CG_Position( Dx_cg, Dy_cg, Dz_cg );
408 // set_Forces_Body_Total( F_X, F_Y, F_Z );
409 // set_Forces_Local_Total( F_north, F_east, F_down );
410 // set_Forces_Aero( F_X_aero, F_Y_aero, F_Z_aero );
411 // set_Forces_Engine( F_X_engine, F_Y_engine, F_Z_engine );
412 // set_Forces_Gear( F_X_gear, F_Y_gear, F_Z_gear );
415 // set_Moments_Total_RP( M_l_rp, M_m_rp, M_n_rp );
416 // set_Moments_Total_CG( M_l_cg, M_m_cg, M_n_cg );
417 // set_Moments_Aero( M_l_aero, M_m_aero, M_n_aero );
418 // set_Moments_Engine( M_l_engine, M_m_engine, M_n_engine );
419 // set_Moments_Gear( M_l_gear, M_m_gear, M_n_gear );
422 _set_Accels_Local( V_dot_north, V_dot_east, V_dot_down );
423 _set_Accels_Body( U_dot_body, V_dot_body, W_dot_body );
424 _set_Accels_CG_Body( A_X_cg, A_Y_cg, A_Z_cg );
425 _set_Accels_Pilot_Body( A_X_pilot, A_Y_pilot, A_Z_pilot );
426 // set_Accels_CG_Body_N( N_X_cg, N_Y_cg, N_Z_cg );
427 // set_Accels_Pilot_Body_N( N_X_pilot, N_Y_pilot, N_Z_pilot );
428 // set_Accels_Omega( P_dot_body, Q_dot_body, R_dot_body );
431 _set_Velocities_Local( V_north, V_east, V_down );
432 // set_Velocities_Ground( V_north_rel_ground, V_east_rel_ground,
433 // V_down_rel_ground );
434 _set_Velocities_Local_Airmass( V_north_airmass, V_east_airmass,
436 // set_Velocities_Local_Rel_Airmass( V_north_rel_airmass,
437 // V_east_rel_airmass, V_down_rel_airmass );
438 // set_Velocities_Gust( U_gust, V_gust, W_gust );
439 _set_Velocities_Wind_Body( U_body, V_body, W_body );
441 _set_V_rel_wind( V_rel_wind );
442 // set_V_true_kts( V_true_kts );
443 // set_V_rel_ground( V_rel_ground );
444 // set_V_inertial( V_inertial );
445 _set_V_ground_speed( V_ground_speed );
446 // set_V_equiv( V_equiv );
447 _set_V_equiv_kts( V_equiv_kts );
448 // set_V_calibrated( V_calibrated );
449 _set_V_calibrated_kts( V_calibrated_kts );
451 _set_Omega_Body( P_body, Q_body, R_body );
452 // set_Omega_Local( P_local, Q_local, R_local );
453 // set_Omega_Total( P_total, Q_total, R_total );
455 _set_Euler_Rates( Phi_dot, Theta_dot, Psi_dot );
456 _set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
458 _set_Mach_number( Mach_number );
460 SG_LOG( SG_FLIGHT, SG_DEBUG, "lon = " << Longitude
461 << " lat_geoc = " << Lat_geocentric << " lat_geod = " << Latitude
462 << " alt = " << Altitude << " sl_radius = " << Sea_level_radius
463 << " radius_to_vehicle = " << Radius_to_vehicle );
465 double tmp_lon_geoc = Lon_geocentric;
466 while ( tmp_lon_geoc < -SGD_PI ) { tmp_lon_geoc += SGD_2PI; }
467 while ( tmp_lon_geoc > SGD_PI ) { tmp_lon_geoc -= SGD_2PI; }
469 double tmp_lon = Longitude;
470 while ( tmp_lon < -SGD_PI ) { tmp_lon += SGD_2PI; }
471 while ( tmp_lon > SGD_PI ) { tmp_lon -= SGD_2PI; }
474 _set_Geocentric_Position( Lat_geocentric, tmp_lon_geoc,
476 _set_Geodetic_Position( Latitude, tmp_lon, Altitude );
477 _set_Euler_Angles( Phi, Theta, Psi );
479 _set_Altitude_AGL( Altitude - Runway_altitude );
481 // Miscellaneous quantities
482 _set_T_Local_to_Body(T_local_to_body_m);
483 // set_Gravity( Gravity );
484 // set_Centrifugal_relief( Centrifugal_relief );
488 // set_Alpha_dot( Alpha_dot );
489 // set_Beta_dot( Beta_dot );
491 // set_Cos_alpha( Cos_alpha );
492 // set_Sin_alpha( Sin_alpha );
493 // set_Cos_beta( Cos_beta );
494 // set_Sin_beta( Sin_beta );
496 _set_Cos_phi( Cos_phi );
497 // set_Sin_phi( Sin_phi );
498 _set_Cos_theta( Cos_theta );
499 // set_Sin_theta( Sin_theta );
500 // set_Cos_psi( Cos_psi );
501 // set_Sin_psi( Sin_psi );
503 _set_Gamma_vert_rad( Gamma_vert_rad );
504 // set_Gamma_horiz_rad( Gamma_horiz_rad );
506 // set_Sigma( Sigma );
507 _set_Density( Density );
508 // set_V_sound( V_sound );
509 // set_Mach_number( Mach_number );
511 _set_Static_pressure( Static_pressure );
512 // set_Total_pressure( Total_pressure );
513 // set_Impact_pressure( Impact_pressure );
514 // set_Dynamic_pressure( Dynamic_pressure );
516 _set_Static_temperature( Static_temperature );
517 // set_Total_temperature( Total_temperature );
519 _set_Sea_level_radius( Sea_level_radius );
520 _set_Earth_position_angle( Earth_position_angle );
522 _set_Runway_altitude( Runway_altitude );
523 // set_Runway_latitude( Runway_latitude );
524 // set_Runway_longitude( Runway_longitude );
525 // set_Runway_heading( Runway_heading );
526 // set_Radius_to_rwy( Radius_to_rwy );
528 // set_CG_Rwy_Local( D_cg_north_of_rwy, D_cg_east_of_rwy, D_cg_above_rwy);
529 // set_CG_Rwy_Rwy( X_cg_rwy, Y_cg_rwy, H_cg_rwy );
530 // set_Pilot_Rwy_Local( D_pilot_north_of_rwy, D_pilot_east_of_rwy,
531 // D_pilot_above_rwy );
532 // set_Pilot_Rwy_Rwy( X_pilot_rwy, Y_pilot_rwy, H_pilot_rwy );
534 _set_sin_lat_geocentric(Lat_geocentric);
535 _set_cos_lat_geocentric(Lat_geocentric);
536 _set_sin_cos_longitude(Longitude);
537 _set_sin_cos_latitude(Latitude);
539 // printf("sin_lat_geo %f cos_lat_geo %f\n", sin_Lat_geoc, cos_Lat_geoc);
540 // printf("sin_lat %f cos_lat %f\n",
541 // get_sin_latitude(), get_cos_latitude());
542 // printf("sin_lon %f cos_lon %f\n",
543 // get_sin_longitude(), get_cos_longitude());
545 _set_Climb_Rate( -1 * V_down );
546 // cout << "climb rate = " << -V_down * 60 << endl;
548 if ( aero->getStringValue() == "uiuc" ) {
550 globals->get_controls()->set_elevator(Long_control);
551 globals->get_controls()->set_elevator_trim(Long_trim);
552 // controls.set_elevator(Long_control);
553 // controls.set_elevator_trim(Long_trim);
556 globals->get_controls()->set_aileron(Lat_control);
557 // controls.set_aileron(Lat_control);
560 globals->get_controls()->set_rudder(Rudder_pedal);
561 // controls.set_rudder(Rudder_pedal);
563 if (Throttle_pct_input) {
564 globals->get_controls()->set_throttle(0,Throttle_pct);
565 // controls.set_throttle(0,Throttle_pct);
573 void FGLaRCsim::set_ls(void) {
574 Phi=lsic->GetRollAngleRadIC();
575 Theta=lsic->GetPitchAngleRadIC();
576 Psi=lsic->GetHeadingRadIC();
577 V_north=lsic->GetVnorthFpsIC();
578 V_east=lsic->GetVeastFpsIC();
579 V_down=lsic->GetVdownFpsIC();
580 Altitude=lsic->GetAltitudeFtIC();
581 Latitude=lsic->GetLatitudeGDRadIC();
582 Longitude=lsic->GetLongitudeRadIC();
583 Runway_altitude=lsic->GetRunwayAltitudeFtIC();
584 V_north_airmass = lsic->GetVnorthAirmassFpsIC();
585 V_east_airmass = lsic->GetVeastAirmassFpsIC();
586 V_down_airmass = lsic->GetVdownAirmassFpsIC();
589 SG_LOG( SG_FLIGHT, SG_INFO, " FGLaRCsim::set_ls(): " );
590 SG_LOG( SG_FLIGHT, SG_INFO, " Phi: " << Phi );
591 SG_LOG( SG_FLIGHT, SG_INFO, " Theta: " << Theta );
592 SG_LOG( SG_FLIGHT, SG_INFO, " Psi: " << Psi );
593 SG_LOG( SG_FLIGHT, SG_INFO, " V_north: " << V_north );
594 SG_LOG( SG_FLIGHT, SG_INFO, " V_east: " << V_east );
595 SG_LOG( SG_FLIGHT, SG_INFO, " V_down: " << V_down );
596 SG_LOG( SG_FLIGHT, SG_INFO, " Altitude: " << Altitude );
597 SG_LOG( SG_FLIGHT, SG_INFO, " Latitude: " << Latitude );
598 SG_LOG( SG_FLIGHT, SG_INFO, " Longitude: " << Longitude );
599 SG_LOG( SG_FLIGHT, SG_INFO, " Runway_altitude: " << Runway_altitude );
600 SG_LOG( SG_FLIGHT, SG_INFO, " V_north_airmass: " << V_north_airmass );
601 SG_LOG( SG_FLIGHT, SG_INFO, " V_east_airmass: " << V_east_airmass );
602 SG_LOG( SG_FLIGHT, SG_INFO, " V_down_airmass: " << V_down_airmass );
605 void FGLaRCsim::snap_shot(void) {
606 lsic->SetLatitudeGDRadIC( get_Latitude() );
607 lsic->SetLongitudeRadIC( get_Longitude() );
608 lsic->SetAltitudeFtIC( get_Altitude() );
609 lsic->SetRunwayAltitudeFtIC( get_Runway_altitude() );
610 lsic->SetVtrueFpsIC( get_V_rel_wind() );
611 lsic->SetPitchAngleRadIC( get_Theta() );
612 lsic->SetRollAngleRadIC( get_Phi() );
613 lsic->SetHeadingRadIC( get_Psi() );
614 lsic->SetClimbRateFpsIC( get_Climb_Rate() );
615 lsic->SetVNEDAirmassFpsIC( get_V_north_airmass(),
616 get_V_east_airmass(),
617 get_V_down_airmass() );
621 void FGLaRCsim::set_Latitude(double lat) {
622 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Latitude: " << lat );
624 lsic->SetLatitudeGDRadIC(lat);
626 copy_from_LaRCsim(); //update the bus
629 void FGLaRCsim::set_Longitude(double lon) {
630 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Longitude: " << lon );
632 lsic->SetLongitudeRadIC(lon);
634 copy_from_LaRCsim(); //update the bus
637 void FGLaRCsim::set_Altitude(double alt) {
638 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Altitude: " << alt );
640 lsic->SetAltitudeFtIC(alt);
642 copy_from_LaRCsim(); //update the bus
645 void FGLaRCsim::set_V_calibrated_kts(double vc) {
646 SG_LOG( SG_FLIGHT, SG_INFO,
647 "FGLaRCsim::set_V_calibrated_kts: " << vc );
649 lsic->SetVcalibratedKtsIC(vc);
651 copy_from_LaRCsim(); //update the bus
654 void FGLaRCsim::set_Mach_number(double mach) {
655 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Mach_number: " << mach );
657 lsic->SetMachIC(mach);
659 copy_from_LaRCsim(); //update the bus
662 void FGLaRCsim::set_Velocities_Local( double north, double east, double down ){
663 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_local: "
664 << north << " " << east << " " << down );
666 lsic->SetVNEDFpsIC(north, east, down);
668 copy_from_LaRCsim(); //update the bus
671 void FGLaRCsim::set_Velocities_Wind_Body( double u, double v, double w){
672 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_Wind_Body: "
673 << u << " " << v << " " << w );
675 lsic->SetUVWFpsIC(u,v,w);
677 copy_from_LaRCsim(); //update the bus
681 void FGLaRCsim::set_Euler_Angles( double phi, double theta, double psi ) {
682 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Euler_angles: "
683 << phi << " " << theta << " " << psi );
686 lsic->SetPitchAngleRadIC(theta);
687 lsic->SetRollAngleRadIC(phi);
688 lsic->SetHeadingRadIC(psi);
690 copy_from_LaRCsim(); //update the bus
694 void FGLaRCsim::set_Climb_Rate( double roc) {
695 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Climb_rate: " << roc );
697 lsic->SetClimbRateFpsIC(roc);
699 copy_from_LaRCsim(); //update the bus
702 void FGLaRCsim::set_Gamma_vert_rad( double gamma) {
703 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Gamma_vert_rad: " << gamma );
705 lsic->SetFlightPathAngleRadIC(gamma);
707 copy_from_LaRCsim(); //update the bus
710 void FGLaRCsim::set_Runway_altitude(double ralt) {
711 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Runway_altitude: " << ralt );
713 lsic->SetRunwayAltitudeFtIC(ralt);
715 copy_from_LaRCsim(); //update the bus
718 void FGLaRCsim::set_AltitudeAGL(double altagl) {
719 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_AltitudeAGL: " << altagl );
721 lsic->SetAltitudeAGLFtIC(altagl);
726 void FGLaRCsim::set_Velocities_Local_Airmass (double wnorth,
729 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Velocities_Local_Airmass: "
730 << wnorth << " " << weast << " " << wdown );
732 lsic->SetVNEDAirmassFpsIC( wnorth, weast, wdown );
737 void FGLaRCsim::set_Static_pressure(double p) {
738 SG_LOG( SG_FLIGHT, SG_INFO,
739 "FGLaRCsim::set_Static_pressure: " << p );
740 SG_LOG( SG_FLIGHT, SG_INFO,
741 "LaRCsim does not support externally supplied atmospheric data" );
744 void FGLaRCsim::set_Static_temperature(double T) {
745 SG_LOG( SG_FLIGHT, SG_INFO,
746 "FGLaRCsim::set_Static_temperature: " << T );
747 SG_LOG( SG_FLIGHT, SG_INFO,
748 "LaRCsim does not support externally supplied atmospheric data" );
752 void FGLaRCsim::set_Density(double rho) {
753 SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Density: " << rho );
754 SG_LOG( SG_FLIGHT, SG_INFO,
755 "LaRCsim does not support externally supplied atmospheric data" );