FlightGear next
flightProperties.cxx
Go to the documentation of this file.
1// flightProperties.cxx -- expose FDM properties via helper methods
2//
3// Written by James Turner, started June 2010.
4//
5// Copyright (C) 2010 Curtis L. Olson - http://www.flightgear.org/~curt
6//
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.
11//
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.
16//
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20//
21// $Id$
22
23#include "config.h"
24
26
27#include <simgear/props/props.hxx>
28#include <simgear/math/SGMath.hxx>
29
30#include <Main/globals.hxx>
31
33 _root(root)
34{
35 if (!_root) {
36 _root = globals->get_props();
37 }
38}
39
43
45{
46 return _root->getDoubleValue("velocities/speed-north-fps", 0.0);
47}
48
50{
51 return _root->getDoubleValue("velocities/speed-east-fps", 0.0);
52}
53
55{
56 return _root->getDoubleValue("velocities/speed-down-fps", 0.0);
57}
58
60{
61 return _root->getDoubleValue("velocities/uBody-fps", 0.0);
62}
63
65{
66 return _root->getDoubleValue("velocities/vBody-fps", 0.0);
67}
68
70{
71 return _root->getDoubleValue("velocities/wBody-fps", 0.0);
72}
73
75{
76 return _root->getDoubleValue("accelerations/pilot/x-accel-fps_sec", 0.0);
77}
78
80{
81 return _root->getDoubleValue("/accelerations/pilot/y-accel-fps_sec", 0.0);
82}
83
85{
86 return _root->getDoubleValue("/accelerations/pilot/z-accel-fps_sec", 0.0);
87}
88
90{
91 return SGGeod::fromDegFt(get_Longitude_deg(), get_Latitude_deg(), get_Altitude());
92}
93
95{
96 return get_Latitude_deg() * SG_DEGREES_TO_RADIANS;
97}
98
100{
101 return get_Longitude_deg() * SG_DEGREES_TO_RADIANS;
102}
103
105{
106 return _root->getDoubleValue("position/altitude-ft");
107}
108
110{
111 return _root->getDoubleValue("position/altitude-agl-ft");
112}
113
115{
116 return _root->getDoubleValue("position/latitude-deg");
117}
118
120{
121 return _root->getDoubleValue("position/longitude-deg");
122}
123
125{
126 return _root->getDoubleValue("orientation/track-deg");
127}
128
130{
131 return _root->getDoubleValue("orientation/roll-deg");
132}
133
135{
136 return _root->getDoubleValue("orientation/pitch-deg");
137}
138
140{
141 return _root->getDoubleValue("orientation/heading-deg");
142}
143
145{
146 return get_Phi_dot_degps() * SG_DEGREES_TO_RADIANS;
147}
148
150{
151 return get_Theta_dot_degps() * SG_DEGREES_TO_RADIANS;
152}
153
155{
156 return get_Psi_dot_degps() * SG_DEGREES_TO_RADIANS;
157}
158
160{
161 return _root->getDoubleValue("orientation/alpha-deg") * SG_DEGREES_TO_RADIANS;
162}
163
165{
166 return _root->getDoubleValue("orientation/beta-deg") * SG_DEGREES_TO_RADIANS;
167}
168
170{
171 return _root->getDoubleValue("orientation/roll-rate-degps");
172}
173
175{
176 return _root->getDoubleValue("orientation/pitch-rate-degps");
177}
178
180{
181 return _root->getDoubleValue("orientation/yaw-rate-degps");
182}
183
185{
186 return 0.0;
187}
188
190{
191 return 0.0;
192}
193
195{
196 return 0.0;
197}
198
200{
201 _root->setDoubleValue("position/longitude-deg", l * SG_RADIANS_TO_DEGREES);
202}
203
205{
206 _root->setDoubleValue("position/latitude-deg", l * SG_RADIANS_TO_DEGREES);
207}
208
210{
211 _root->setDoubleValue("position/altitude-ft", ft);
212}
213
214void FlightProperties::set_Euler_Angles(double phi, double theta, double psi)
215{
216 _root->setDoubleValue("orientation/roll-deg", phi * SG_RADIANS_TO_DEGREES);
217 _root->setDoubleValue("orientation/pitch-deg", theta * SG_RADIANS_TO_DEGREES);
218 _root->setDoubleValue("orientation/heading-deg", psi * SG_RADIANS_TO_DEGREES);
219}
220
222{
223 _root->setDoubleValue("velocities/airspeed-kt", kts);
224}
225
227{
228 _root->setDoubleValue("velocities/vertical-speed-fps", fps);
229}
230
232{
233 const double KNOTS_TO_FTS = (SG_NM_TO_METER * SG_METER_TO_FEET)/ 3600.0;
234 return _root->getDoubleValue("velocities/groundspeed-kt") * KNOTS_TO_FTS;
235}
236
238{
239 return _root->getDoubleValue("velocities/airspeed-kt");
240}
241
243{
244 return _root->getDoubleValue("velocities/equivalent-kt");
245}
246
248{
249 return _root->getDoubleValue("velocities/vertical-speed-fps");
250}
251
253{
254 return _root->getDoubleValue("environment/ground-elevation-m");
255}
256
257void FlightProperties::set_Accels_Pilot_Body(double x, double y, double z)
258{
259 _root->setDoubleValue("accelerations/pilot/x-accel-fps_sec", x);
260 _root->setDoubleValue("accelerations/pilot/y-accel-fps_sec", y);
261 _root->setDoubleValue("accelerations/pilot/z-accel-fps_sec", z);
262}
263
264void FlightProperties::set_Velocities_Local(double x, double y, double z)
265{
266 _root->setDoubleValue("velocities/speed-north-fps", x);
267 _root->setDoubleValue("velocities/speed-east-fps", y);
268 _root->setDoubleValue("velocities/speed-down-fps", z);
269}
270
271void FlightProperties::set_Velocities_Body(double x, double y, double z)
272{
273 _root->setDoubleValue("velocities/uBody-fps", x);
274 _root->setDoubleValue("velocities/vBody-fps", y);
275 _root->setDoubleValue("velocities/wBody-fps", z);
276}
277
278void FlightProperties::set_Euler_Rates(double x, double y, double z)
279{
280 _root->setDoubleValue("orientation/roll-rate-degps", x * SG_RADIANS_TO_DEGREES);
281 _root->setDoubleValue("orientation/pitch-rate-degps", y * SG_RADIANS_TO_DEGREES);
282 _root->setDoubleValue("orientation/yaw-rate-degps", z * SG_RADIANS_TO_DEGREES);
283}
284
286{
287 _root->setDoubleValue("orientation/alpha-deg", a * SG_RADIANS_TO_DEGREES);
288}
289
291{
292 _root->setDoubleValue("orientation/side-slip-rad", b);
293}
294
296{
297 _root->setDoubleValue("position/altitude-agl-ft", ft);
298}
299
301{
302 return _root->getDoubleValue("orientation/p-body", 0.0);
303}
304
306{
307 return _root->getDoubleValue("orientation/q-body", 0.0);
308}
309
311{
312 return _root->getDoubleValue("orientation/r-body", 0.0);
313}
double get_Phi_dot_degps() const
double get_A_X_pilot() const
void set_Euler_Angles(double phi, double theta, double psi)
double get_Phi_dot() const
void set_Velocities_Body(double x, double y, double z)
double get_Altitude_AGL(void) const
double get_wBody() const
double get_V_east() const
double get_A_Y_pilot() const
void set_Alpha(double a)
void set_Velocities_Local(double x, double y, double z)
double get_V_calibrated_kts() const
double get_Total_pressure() const
void set_Altitude(double ft)
double get_Latitude_deg() const
double get_Runway_altitude_m() const
double get_Theta_dot_degps() const
double get_uBody() const
void set_Climb_Rate(double fps)
void set_Latitude(double l)
double get_Q_body() const
double get_V_equiv_kts() const
double get_Longitude_deg() const
double get_Psi_deg() const
double get_Theta_deg() const
double get_V_down() const
double get_Track(void) const
void set_V_calibrated_kts(double kts)
double get_Latitude() const
double get_Psi_dot() const
double get_vBody() const
double get_Phi_deg() const
void set_Euler_Rates(double x, double y, double z)
double get_Total_temperature() const
double get_V_ground_speed() const
double get_Longitude() const
double get_Theta_dot() const
double get_R_body() const
FlightProperties(SGPropertyNode *aRoot=NULL)
void set_Accels_Pilot_Body(double x, double y, double z)
double get_Dynamic_pressure() const
void set_Altitude_AGL(double ft)
SGGeod getPosition() const
double get_P_body() const
double get_Alpha() const
void set_Beta(double b)
double get_V_north() const
double get_Beta() const
double get_Climb_Rate() const
double get_Altitude() const
double get_Psi_dot_degps() const
void set_Longitude(double l)
double get_A_Z_pilot() const
FGGlobals * globals
Definition globals.cxx:142