1 #include <FDM/flightProperties.hxx>
3 #include <simgear/props/props.hxx>
4 #include <simgear/math/SGMath.hxx>
6 #include <Main/globals.hxx>
8 FlightProperties::FlightProperties(SGPropertyNode* root) :
12 _root = globals->get_props();
16 FlightProperties::~FlightProperties()
20 double FlightProperties::get_V_north() const
22 return _root->getDoubleValue("velocities/speed-north-fps", 0.0);
25 double FlightProperties::get_V_east() const
27 return _root->getDoubleValue("velocities/speed-east-fps", 0.0);
30 double FlightProperties::get_V_down() const
32 return _root->getDoubleValue("velocities/speed-down-fps", 0.0);
35 double FlightProperties::get_uBody () const
37 return _root->getDoubleValue("velocities/uBody-fps", 0.0);
40 double FlightProperties::get_vBody () const
42 return _root->getDoubleValue("velocities/vBody-fps", 0.0);
45 double FlightProperties::get_wBody () const
47 return _root->getDoubleValue("velocities/wBody-fps", 0.0);
50 double FlightProperties::get_A_X_pilot() const
52 return _root->getDoubleValue("accelerations/pilot/x-accel-fps_sec", 0.0);
55 double FlightProperties::get_A_Y_pilot() const
57 return _root->getDoubleValue("/accelerations/pilot/y-accel-fps_sec", 0.0);
60 double FlightProperties::get_A_Z_pilot() const
62 return _root->getDoubleValue("/accelerations/pilot/z-accel-fps_sec", 0.0);
65 SGGeod FlightProperties::getPosition() const
67 return SGGeod::fromDegFt(get_Longitude_deg(), get_Latitude_deg(), get_Altitude());
70 double FlightProperties::get_Latitude() const
72 return get_Latitude_deg() * SG_DEGREES_TO_RADIANS;
75 double FlightProperties::get_Longitude() const
77 return get_Longitude_deg() * SG_DEGREES_TO_RADIANS;
80 double FlightProperties::get_Altitude() const
82 return _root->getDoubleValue("position/altitude-ft");
85 double FlightProperties::get_Altitude_AGL(void) const
87 return _root->getDoubleValue("position/altitude-agl-ft");
90 double FlightProperties::get_Latitude_deg () const
92 return _root->getDoubleValue("position/latitude-deg");
95 double FlightProperties::get_Longitude_deg () const
97 return _root->getDoubleValue("position/longitude-deg");
100 double FlightProperties::get_Track(void) const
102 return _root->getDoubleValue("orientation/track-deg");
105 double FlightProperties::get_Phi_deg() const
107 return _root->getDoubleValue("orientation/roll-deg");
110 double FlightProperties::get_Theta_deg() const
112 return _root->getDoubleValue("orientation/pitch-deg");
115 double FlightProperties::get_Psi_deg() const
117 return _root->getDoubleValue("orientation/heading-deg");
120 double FlightProperties::get_Phi_dot() const
122 return get_Phi_dot_degps() * SG_DEGREES_TO_RADIANS;
125 double FlightProperties::get_Theta_dot() const
127 return get_Theta_dot_degps() * SG_DEGREES_TO_RADIANS;
130 double FlightProperties::get_Psi_dot() const
132 return get_Psi_dot_degps() * SG_DEGREES_TO_RADIANS;
135 double FlightProperties::get_Alpha() const
137 return _root->getDoubleValue("orientation/alpha-deg") * SG_DEGREES_TO_RADIANS;
140 double FlightProperties::get_Beta() const
142 return _root->getDoubleValue("orientation/beta-deg") * SG_DEGREES_TO_RADIANS;
145 double FlightProperties::get_Phi_dot_degps() const
147 return _root->getDoubleValue("orientation/roll-rate-degps");
150 double FlightProperties::get_Theta_dot_degps() const
152 return _root->getDoubleValue("orientation/pitch-rate-degps");
155 double FlightProperties::get_Psi_dot_degps() const
157 return _root->getDoubleValue("orientation/yaw-rate-degps");
160 double FlightProperties::get_Total_temperature() const
165 double FlightProperties::get_Total_pressure() const
170 double FlightProperties::get_Dynamic_pressure() const
175 void FlightProperties::set_Longitude(double l)
177 _root->setDoubleValue("position/longitude-deg", l * SG_RADIANS_TO_DEGREES);
180 void FlightProperties::set_Latitude(double l)
182 _root->setDoubleValue("position/latitude-deg", l * SG_RADIANS_TO_DEGREES);
185 void FlightProperties::set_Altitude(double ft)
187 _root->setDoubleValue("position/altitude-ft", ft);
190 void FlightProperties::set_Euler_Angles(double phi, double theta, double psi)
192 _root->setDoubleValue("orientation/roll-deg", phi * SG_RADIANS_TO_DEGREES);
193 _root->setDoubleValue("orientation/pitch-deg", theta * SG_RADIANS_TO_DEGREES);
194 _root->setDoubleValue("orientation/heading-deg", psi * SG_RADIANS_TO_DEGREES);
197 void FlightProperties::set_V_calibrated_kts(double kts)
199 _root->setDoubleValue("velocities/airspeed-kt", kts);
202 void FlightProperties::set_Climb_Rate(double fps)
204 _root->setDoubleValue("velocities/vertical-speed-fps", fps);
207 double FlightProperties::get_V_ground_speed() const
209 const double KNOTS_TO_FTS = (SG_NM_TO_METER * SG_METER_TO_FEET)/ 3600.0;
210 return _root->getDoubleValue("velocities/groundspeed-kt") * KNOTS_TO_FTS;
213 double FlightProperties::get_V_calibrated_kts() const
215 return _root->getDoubleValue("velocities/airspeed-kt");
218 double FlightProperties::get_V_equiv_kts() const
220 return _root->getDoubleValue("velocities/equivalent-kt");
223 double FlightProperties::get_Climb_Rate() const
225 return _root->getDoubleValue("velocities/vertical-speed-fps");
228 double FlightProperties::get_Runway_altitude_m() const
230 return _root->getDoubleValue("environment/ground-elevation-m");
233 void FlightProperties::set_Accels_Pilot_Body(double x, double y, double z)
235 _root->setDoubleValue("accelerations/pilot/x-accel-fps_sec", x);
236 _root->setDoubleValue("accelerations/pilot/y-accel-fps_sec", y);
237 _root->setDoubleValue("accelerations/pilot/z-accel-fps_sec", z);
240 void FlightProperties::set_Velocities_Local(double x, double y, double z)
242 _root->setDoubleValue("velocities/speed-north-fps", x);
243 _root->setDoubleValue("velocities/speed-east-fps", y);
244 _root->setDoubleValue("velocities/speed-down-fps", z);
247 void FlightProperties::set_Velocities_Wind_Body(double x, double y, double z)
249 _root->setDoubleValue("velocities/vBody-fps", x);
250 _root->setDoubleValue("velocities/uBody-fps", y);
251 _root->setDoubleValue("velocities/wBody-fps", z);
254 void FlightProperties::set_Euler_Rates(double x, double y, double z)
256 _root->setDoubleValue("orientation/roll-rate-degps", x * SG_RADIANS_TO_DEGREES);
257 _root->setDoubleValue("orientation/pitch-rate-degps", y * SG_RADIANS_TO_DEGREES);
258 _root->setDoubleValue("orientation/yaw-rate-degps", z * SG_RADIANS_TO_DEGREES);
261 void FlightProperties::set_Alpha(double a)
263 _root->setDoubleValue("orientation/alpha-deg", a * SG_RADIANS_TO_DEGREES);
266 void FlightProperties::set_Beta(double b)
268 _root->setDoubleValue("orientation/side-slip-rad", b);
271 void FlightProperties::set_Altitude_AGL(double ft)
273 _root->setDoubleValue("position/altitude-agl-ft", ft);
276 double FlightProperties::get_P_body() const
278 return _root->getDoubleValue("orientation/p-body", 0.0);
281 double FlightProperties::get_Q_body() const
283 return _root->getDoubleValue("orientation/q-body", 0.0);
286 double FlightProperties::get_R_body() const
288 return _root->getDoubleValue("orientation/r-body", 0.0);