Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
flight_gear.h
Go to the documentation of this file.
1 #ifndef FLIGHT_GEAR_H
2 #define FLIGHT_GEAR_H
3 
4 #include <stdint.h>
5 
6 #define FG_NET_CTRLS_VERSION 27
7 #define FG_NET_CTRLS_MAX_ENGINES 4
8 #define FG_NET_CTRLS_MAX_WHEELS 16
9 #define FG_NET_CTRLS_MAX_TANKS 8
10 #define FG_NET_CTRLS_RESERVED_SPACE 25
11 
12 struct FGNetCtrls {
13  uint32_t version; // increment when data values change
14 
15  // Aero controls
16  double aileron; // -1 ... 1
17  double elevator; // -1 ... 1
18  double rudder; // -1 ... 1
19  double aileron_trim; // -1 ... 1
20  double elevator_trim; // -1 ... 1
21  double rudder_trim; // -1 ... 1
22  double flaps; // 0 ... 1
23  double spoilers;
24  double speedbrake;
25 
26  // Aero control faults
27  uint32_t flaps_power; // true = power available
29 
30  // Engine controls
31  uint32_t num_engines; // number of valid engines
36  double throttle[FG_NET_CTRLS_MAX_ENGINES]; // 0 ... 1
37  double mixture[FG_NET_CTRLS_MAX_ENGINES]; // 0 ... 1
38  double condition[FG_NET_CTRLS_MAX_ENGINES]; // 0 ... 1
43 
44  // Engine faults
49  uint32_t oil_press_status[FG_NET_CTRLS_MAX_ENGINES];// 0 = normal, 1 = low, 2 = full fail
51 
52  // Fuel management
53  uint32_t num_tanks; // number of valid tanks
54  uint32_t fuel_selector[FG_NET_CTRLS_MAX_TANKS]; // false = off, true = on
55  uint32_t xfer_pump[5]; // specifies transfer from array
56  // value tank to tank specified by
57  // int value
58  uint32_t cross_feed; // false = off, true = on
59 
60  // Brake controls
61  double brake_left;
62  double brake_right;
65  double brake_parking;
66 
67  // Landing Gear
68  uint32_t gear_handle; // true=gear handle down; false= gear handle up
69 
70  // Switches
72 
73  // nav and Comm
74  double comm_1;
75  double comm_2;
76  double nav_1;
77  double nav_2;
78 
79  // wind and turbulance
80  double wind_speed_kt;
81  double wind_dir_deg;
83 
84  // temp and pressure
85  double temp_c;
86  double press_inhg;
87 
88  // other information about environment
89  double hground; // ground elevation (meters)
90  double magvar; // local magnetic variation in degs.
91 
92  // hazards
93  uint32_t icing; // icing status could me much
94  // more complex but I'm
95  // starting simple here.
96 
97  // simulation control
98  uint32_t speedup; // integer speedup multiplier
99  uint32_t freeze; // 0=normal
100  // 0x01=master
101  // 0x02=position
102  // 0x04=fuel
103 
104  // --- New since FlightGear 0.9.10 (FG_NET_CTRLS_VERSION = 27)
105 
106  // --- Add new variables just before this line.
107 
108  uint32_t reserved[FG_NET_CTRLS_RESERVED_SPACE]; // 100 bytes reserved for future use.
109 };
110 
111 
112 #define FG_NET_FDM_VERSION 24
113 #define FG_NET_FDM_MAX_ENGINES 4
114 #define FG_NET_FDM_MAX_WHEELS 3
115 #define FG_NET_FDM_MAX_TANKS 4
116 
117 #ifndef _NET_FDM_HXX
118 
119 struct FGNetFDM {
120 
121  uint32_t version; // increment when data values change
122  uint32_t padding; // padding
123 
124  // Positions
125  double longitude; // geodetic (radians)
126  double latitude; // geodetic (radians)
127  double altitude; // above sea level (meters)
128  float agl; // above ground level (meters)
129  float phi; // roll (radians)
130  float theta; // pitch (radians)
131  float psi; // yaw or true heading (radians)
132  float alpha; // angle of attack (radians)
133  float beta; // side slip angle (radians)
134 
135  // Velocities
136  float phidot; // roll rate (radians/sec)
137  float thetadot; // pitch rate (radians/sec)
138  float psidot; // yaw rate (radians/sec)
139  float vcas; // calibrated airspeed
140  float climb_rate; // feet per second
141  float v_north; // north velocity in local/body frame, fps
142  float v_east; // east velocity in local/body frame, fps
143  float v_down; // down/vertical velocity in local/body frame, fps
144  float v_body_u; // ECEF velocity in body frame
145  float v_body_v; // ECEF velocity in body frame
146  float v_body_w; // ECEF velocity in body frame
147 
148  // Accelerations
149  float A_X_pilot; // X accel in body frame ft/sec^2
150  float A_Y_pilot; // Y accel in body frame ft/sec^2
151  float A_Z_pilot; // Z accel in body frame ft/sec^2
152  // Stall
153  float stall_warning; // 0.0 - 1.0 indicating the amount of stall
154  float slip_deg; // slip ball deflection
155 
156  // Pressure
157 
158  // Engine status
159  uint32_t num_engines; // Number of valid engines
160  uint32_t eng_state[FG_NET_FDM_MAX_ENGINES]; // Engine state (off, cranking, running)
161  float rpm[FG_NET_FDM_MAX_ENGINES]; // Engine RPM rev/min
162  float fuel_flow[FG_NET_FDM_MAX_ENGINES]; // Fuel flow gallons/hr
163  float fuel_px[FG_NET_FDM_MAX_ENGINES]; // Fuel pressure psi
164  float egt[FG_NET_FDM_MAX_ENGINES]; // Exhuast gas temp deg F
165  float cht[FG_NET_FDM_MAX_ENGINES]; // Cylinder head temp deg F
166  float mp_osi[FG_NET_FDM_MAX_ENGINES]; // Manifold pressure
167  float tit[FG_NET_FDM_MAX_ENGINES]; // Turbine Inlet Temperature
168  float oil_temp[FG_NET_FDM_MAX_ENGINES]; // Oil temp deg F
169  float oil_px[FG_NET_FDM_MAX_ENGINES]; // Oil pressure psi
170 
171  // Consumables
172  uint32_t num_tanks; // Max number of fuel tanks
174 
175  // Gear status
181 
182  // Environment
183  uint32_t cur_time; // current unix time
184  // FIXME: make this uint64_t before 2038
185  int32_t warp; // offset in seconds to unix time
186  float visibility; // visibility in meters (for env. effects)
187 
188  // Control surface positions (normalized values)
189  float elevator;
191  float left_flap;
192  float right_flap;
195  float rudder;
196  float nose_wheel;
197  float speedbrake;
198  float spoilers;
199 };
200 
201 #endif
202 
203 struct FGNetMiniFDM {
204  uint32_t version; // increment when data values change
205 
206  // Positions
207  double longitude; // geodetic (radians)
208  double latitude; // geodetic (radians)
209  double altitude; // above sea level (meters)
210  double agl; // above ground level (meters)
211  double phi; // roll (radians)
212  double theta; // pitch (radians)
213  double psi; // yaw or true heading (radians)
214 
215  // Velocities
216  double vcas;
217  double climb_rate; // feet per second
218 
219  // Consumables
220  uint32_t num_tanks; // Max number of fuel tanks
222 
223  // Environment
224  uint32_t cur_time; // current unix time
225  int32_t warp; // offset in seconds to unix time
226 };
227 
228 #if FG_2_4
229 #define FG_NET_GUI_VERSION 7
230 #else
231 #define FG_NET_GUI_VERSION 8
232 #endif /*FG_2_4*/
233 
234 #define FG_NET_GUI_MAX_TANKS 4
235 
236 // Prior to FG_NET_GUI_VERSION 8, OS X needed #pragma pack(4) to
237 // properly display FG visualization data. In version 8 they added
238 // a padding1 element to ensure proper data alignment, so this is
239 // no longer required. The rest of this struct is based on FG source
240 // in src/Network/net_gui.hxx
241 
242 #if FG_2_4
243 #ifdef __x86_64__
244 #pragma pack(push)
245 #ifdef __APPLE__
246 #pragma pack(4)
247 #else
248 #pragma pack(8)
249 #endif /*__APPLE__*/
250 #endif /*__x86_64__*/
251 #endif /*FG_2_4*/
252 struct FGNetGUI {
253  uint32_t version; // increment when data values change
255 
256  // Positions
257  double longitude; // geodetic (radians)
258  double latitude; // geodetic (radians)
259  float altitude; // above sea level (meters)
260  float agl; // above ground level (meters)
261  float phi; // roll (radians)
262  float theta; // pitch (radians)
263  float psi; // yaw or true heading (radians)
264 
265  // Velocities
266  float vcas;
267  float climb_rate; // feet per second
268 
269  // Consumables
270  uint32_t num_tanks; // Max number of fuel tanks
272 
273  // Environment
274  uint32_t cur_time; // current unix time
275  // FIXME: make this uint64_t before 2038
276  uint32_t warp; // offset in seconds to unix time
277  float ground_elev; // ground elev (meters)
278 
279  // Approach
280  float tuned_freq; // currently tuned frequency
281  float nav_radial; // target nav radial
282  uint32_t in_range; // tuned navaid is in range?
283  float dist_nm; // distance to tuned navaid in nautical miles
284  float course_deviation_deg; // degrees off target course
285  float gs_deviation_deg; // degrees off target glide slope
286 };
287 #if FG_2_4
288 #ifdef __x86_64__
289 #pragma pack(push)
290 #pragma pack(pop)
291 #endif /*__x86_64__*/
292 #endif /*FG_2_4*/
293 
294 
295 #define FG_ENVIRONMENT_FOOTER_MAGIC 0x12345678
296 // described in file fg_environment.xml (generic protocol)
298  double elapsed_sec; // elapsed sim seconds
299  float wind_from_north; // wind from north in m/s
300  float wind_from_east; // wind from east in m/s
301  float wind_from_down; // wind from down in m/s
302  float wind_from_heading; // wind N-E heading in degrees
303  float wind_speed; // wind N-E speed in m/s
304  uint32_t footer_magic; // magic footer 0x12345678
305 };
306 
307 
308 
309 extern void net_fdm_dump (struct FGNetFDM* fdm);
310 extern void net_fdm_ntoh (struct FGNetFDM* fdm);
311 extern void net_fdm_init (struct FGNetFDM* fdm);
312 
313 extern void net_gui_init (struct FGNetGUI* gui);
314 extern void net_gui_hton (struct FGNetGUI* gui);
315 extern void net_gui_dump (struct FGNetGUI* gui);
316 
317 extern void net_ctrls_dump(struct FGNetCtrls* ctrls);
318 extern void net_ctrls_ntoh(struct FGNetCtrls* ctrls);
319 
320 #endif /* FLIGHT_GEAR_H */
double copilot_brake_left
Definition: flight_gear.h:63
uint32_t flaps_power
Definition: flight_gear.h:27
double latitude
Definition: flight_gear.h:258
float agl
Definition: flight_gear.h:128
float climb_rate
Definition: flight_gear.h:267
float wind_from_north
Definition: flight_gear.h:299
double brake_left
Definition: flight_gear.h:61
uint32_t freeze
Definition: flight_gear.h:99
double prop_advance[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:40
double flaps
Definition: flight_gear.h:22
uint32_t reverse[4]
Definition: flight_gear.h:42
double speedbrake
Definition: flight_gear.h:24
float v_east
Definition: flight_gear.h:142
float A_Y_pilot
Definition: flight_gear.h:150
void net_gui_dump(struct FGNetGUI *gui)
uint32_t padding
Definition: flight_gear.h:122
double latitude
Definition: flight_gear.h:208
float A_X_pilot
Definition: flight_gear.h:149
float slip_deg
Definition: flight_gear.h:154
uint32_t mag_right_ok[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:47
double copilot_brake_right
Definition: flight_gear.h:64
double theta
Definition: flight_gear.h:212
float wind_from_east
Definition: flight_gear.h:300
float gear_pos[FG_NET_FDM_MAX_WHEELS]
Definition: flight_gear.h:178
double condition[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:38
double wind_dir_deg
Definition: flight_gear.h:81
uint32_t master_bat[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:32
double longitude
Definition: flight_gear.h:125
float phi
Definition: flight_gear.h:261
float stall_warning
Definition: flight_gear.h:153
uint32_t master_avionics
Definition: flight_gear.h:71
double latitude
Definition: flight_gear.h:126
float elevator
Definition: flight_gear.h:189
#define FG_NET_CTRLS_MAX_ENGINES
Definition: flight_gear.h:7
uint32_t master_alt[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:33
float wind_speed
Definition: flight_gear.h:303
double wind_speed_kt
Definition: flight_gear.h:80
float climb_rate
Definition: flight_gear.h:140
float cht[FG_NET_FDM_MAX_ENGINES]
Definition: flight_gear.h:165
float phidot
Definition: flight_gear.h:136
float fuel_flow[FG_NET_FDM_MAX_ENGINES]
Definition: flight_gear.h:162
float course_deviation_deg
Definition: flight_gear.h:284
float left_flap
Definition: flight_gear.h:191
uint32_t cross_feed
Definition: flight_gear.h:58
double elevator_trim
Definition: flight_gear.h:20
uint32_t engine_ok[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:45
uint32_t feed_tank_to[4]
Definition: flight_gear.h:41
float v_body_v
Definition: flight_gear.h:145
double rudder
Definition: flight_gear.h:18
double aileron
Definition: flight_gear.h:16
uint32_t num_tanks
Definition: flight_gear.h:220
uint32_t flap_motor_ok
Definition: flight_gear.h:28
float vcas
Definition: flight_gear.h:139
void net_fdm_ntoh(struct FGNetFDM *fdm)
double magvar
Definition: flight_gear.h:90
void net_ctrls_ntoh(struct FGNetCtrls *ctrls)
uint32_t wow[FG_NET_FDM_MAX_WHEELS]
Definition: flight_gear.h:177
#define FG_NET_CTRLS_RESERVED_SPACE
Definition: flight_gear.h:10
float left_aileron
Definition: flight_gear.h:193
uint32_t cur_time
Definition: flight_gear.h:183
double turbulence_norm
Definition: flight_gear.h:82
uint32_t mag_left_ok[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:46
double comm_2
Definition: flight_gear.h:75
float gear_compression[FG_NET_FDM_MAX_WHEELS]
Definition: flight_gear.h:180
uint32_t warp
Definition: flight_gear.h:276
uint32_t num_engines
Definition: flight_gear.h:159
float spoilers
Definition: flight_gear.h:198
float ground_elev
Definition: flight_gear.h:277
double press_inhg
Definition: flight_gear.h:86
int32_t warp
Definition: flight_gear.h:185
void net_gui_init(struct FGNetGUI *gui)
uint32_t spark_plugs_ok[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:48
uint32_t xfer_pump[5]
Definition: flight_gear.h:55
#define FG_NET_CTRLS_MAX_TANKS
Definition: flight_gear.h:9
float right_aileron
Definition: flight_gear.h:194
uint32_t num_tanks
Definition: flight_gear.h:270
double fuel_quantity[FG_NET_FDM_MAX_TANKS]
Definition: flight_gear.h:221
uint32_t num_engines
Definition: flight_gear.h:31
float visibility
Definition: flight_gear.h:186
uint32_t version
Definition: flight_gear.h:253
double comm_1
Definition: flight_gear.h:74
float v_down
Definition: flight_gear.h:143
double temp_c
Definition: flight_gear.h:85
float alpha
Definition: flight_gear.h:132
uint32_t padding1
Definition: flight_gear.h:254
float mp_osi[FG_NET_FDM_MAX_ENGINES]
Definition: flight_gear.h:166
uint32_t fuel_selector[FG_NET_CTRLS_MAX_TANKS]
Definition: flight_gear.h:54
float rpm[FG_NET_FDM_MAX_ENGINES]
Definition: flight_gear.h:161
#define FG_NET_FDM_MAX_ENGINES
Definition: flight_gear.h:113
double hground
Definition: flight_gear.h:89
double longitude
Definition: flight_gear.h:207
uint32_t oil_press_status[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:49
double altitude
Definition: flight_gear.h:209
float beta
Definition: flight_gear.h:133
double nav_2
Definition: flight_gear.h:77
float v_north
Definition: flight_gear.h:141
uint32_t num_wheels
Definition: flight_gear.h:176
uint32_t version
Definition: flight_gear.h:204
float dist_nm
Definition: flight_gear.h:283
float nose_wheel
Definition: flight_gear.h:196
float psi
Definition: flight_gear.h:263
float theta
Definition: flight_gear.h:130
double altitude
Definition: flight_gear.h:127
float tit[FG_NET_FDM_MAX_ENGINES]
Definition: flight_gear.h:167
float altitude
Definition: flight_gear.h:259
double longitude
Definition: flight_gear.h:257
void net_fdm_dump(struct FGNetFDM *fdm)
int32_t warp
Definition: flight_gear.h:225
uint32_t starter_power[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:35
uint32_t gear_handle
Definition: flight_gear.h:68
float v_body_w
Definition: flight_gear.h:146
double spoilers
Definition: flight_gear.h:23
float elevator_trim_tab
Definition: flight_gear.h:190
uint32_t num_tanks
Definition: flight_gear.h:53
float fuel_quantity[FG_NET_FDM_MAX_TANKS]
Definition: flight_gear.h:173
float A_Z_pilot
Definition: flight_gear.h:151
uint32_t magnetos[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:34
uint32_t fuel_pump_power[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:39
double nav_1
Definition: flight_gear.h:76
float thetadot
Definition: flight_gear.h:137
uint32_t speedup
Definition: flight_gear.h:98
uint32_t num_tanks
Definition: flight_gear.h:172
float agl
Definition: flight_gear.h:260
float fuel_quantity[FG_NET_GUI_MAX_TANKS]
Definition: flight_gear.h:271
double aileron_trim
Definition: flight_gear.h:19
float phi
Definition: flight_gear.h:129
float oil_temp[FG_NET_FDM_MAX_ENGINES]
Definition: flight_gear.h:168
float theta
Definition: flight_gear.h:262
float vcas
Definition: flight_gear.h:266
#define FG_NET_FDM_MAX_WHEELS
Definition: flight_gear.h:114
#define FG_NET_FDM_MAX_TANKS
Definition: flight_gear.h:115
float right_flap
Definition: flight_gear.h:192
void net_gui_hton(struct FGNetGUI *gui)
float nav_radial
Definition: flight_gear.h:281
double climb_rate
Definition: flight_gear.h:217
void net_fdm_init(struct FGNetFDM *fdm)
float egt[FG_NET_FDM_MAX_ENGINES]
Definition: flight_gear.h:164
float oil_px[FG_NET_FDM_MAX_ENGINES]
Definition: flight_gear.h:169
double mixture[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:37
uint32_t icing
Definition: flight_gear.h:93
float fuel_px[FG_NET_FDM_MAX_ENGINES]
Definition: flight_gear.h:163
double elevator
Definition: flight_gear.h:17
uint32_t cur_time
Definition: flight_gear.h:274
double throttle[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:36
uint32_t version
Definition: flight_gear.h:13
float wind_from_down
Definition: flight_gear.h:301
double elapsed_sec
Definition: flight_gear.h:298
float rudder
Definition: flight_gear.h:195
double rudder_trim
Definition: flight_gear.h:21
float v_body_u
Definition: flight_gear.h:144
uint32_t version
Definition: flight_gear.h:121
double brake_parking
Definition: flight_gear.h:65
float gs_deviation_deg
Definition: flight_gear.h:285
float gear_steer[FG_NET_FDM_MAX_WHEELS]
Definition: flight_gear.h:179
uint32_t fuel_pump_ok[FG_NET_CTRLS_MAX_ENGINES]
Definition: flight_gear.h:50
float tuned_freq
Definition: flight_gear.h:280
float speedbrake
Definition: flight_gear.h:197
float psi
Definition: flight_gear.h:131
void net_ctrls_dump(struct FGNetCtrls *ctrls)
#define FG_NET_GUI_MAX_TANKS
Definition: flight_gear.h:234
uint32_t in_range
Definition: flight_gear.h:282
float psidot
Definition: flight_gear.h:138
uint32_t eng_state[FG_NET_FDM_MAX_ENGINES]
Definition: flight_gear.h:160
uint32_t reserved[FG_NET_CTRLS_RESERVED_SPACE]
Definition: flight_gear.h:108
float wind_from_heading
Definition: flight_gear.h:302
double brake_right
Definition: flight_gear.h:62
uint32_t footer_magic
Definition: flight_gear.h:304
uint32_t cur_time
Definition: flight_gear.h:224
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78