Paparazzi UAS  v6.2_unstable
Paparazzi is a free software Unmanned Aircraft System.
fg.c
Go to the documentation of this file.
1 
3 #include <string.h>
4 #include <caml/alloc.h>
5 #include <caml/mlvalues.h>
6 #include <caml/memory.h>
7 
8 #include <math.h>
9 #include <time.h>
10 
11 #include "flight_gear.h"
12 
13 value fg_sizeof(value unit) {
14  return Val_int(sizeof(struct FGNetGUI));
15 }
16 
17 value fg_msg_native(value s, value lat, value lon, value z, value phi, value theta, value psi);
18 
19 value fg_msg_bytecode(value *argv, int argc) {
20  return fg_msg_native(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
21 
22 }
23 
24 
25 value fg_msg_native(value s, value lat, value lon, value z, value phi, value theta, value psi) {
26 
27  struct FGNetGUI msg = {0};
28  msg.version = FG_NET_GUI_VERSION;
29 
30  msg.longitude = Double_val(lon);
31  msg.latitude = Double_val(lat);
32  msg.altitude = Double_val(z) + 50;
33  msg.agl = 0.;
34  msg.phi = Double_val(phi);
35  msg.theta = Double_val(theta);
36  msg.psi = - Double_val(psi) + M_PI_2;
37 
38  msg.vcas = 0.;
39  msg.climb_rate = 0.;
40 
41  msg.num_tanks = 1;
42  msg.fuel_quantity[0] = 10.;
43 
44  msg.cur_time = 3213092700ul+((uint32_t)((msg.longitude)*13578)); //time(NULL);
45  msg.warp = 0;
46  msg.ground_elev = 0.;
47 
48  msg.tuned_freq = 123.45;
49  msg.nav_radial = 123.;
50  msg.in_range = 1;
51  msg.course_deviation_deg = 12.;
52  msg.gs_deviation_deg = 123.;
53 
54  memcpy(String_val(s), (char*)&msg, sizeof(msg));
55 
56  return Val_unit;
57 }
fg_msg_native
value fg_msg_native(value s, value lat, value lon, value z, value phi, value theta, value psi)
Definition: fg.c:25
uint32_t
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78
FGNetGUI
Definition: flight_gear.h:252
s
static uint32_t s
Definition: light_scheduler.c:33
msg
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
Definition: high_speed_logger_direct_memory.c:134
FGNetGUI::phi
float phi
Definition: flight_gear.h:261
fg_sizeof
value fg_sizeof(value unit)
Values boxing for Flight Gear.
Definition: fg.c:13
FG_NET_GUI_VERSION
#define FG_NET_GUI_VERSION
Definition: flight_gear.h:231
unit
static unit_t unit
Definition: nav.c:31
FloatVect3::z
float z
Definition: pprz_algebra_float.h:57
FGNetGUI::psi
float psi
Definition: flight_gear.h:263
fg_msg_bytecode
value fg_msg_bytecode(value *argv, int argc)
Definition: fg.c:19
flight_gear.h
FGNetGUI::theta
float theta
Definition: flight_gear.h:262