Paparazzi UAS  v5.15_devel-110-g5cf27ee
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
nps_main.h
Go to the documentation of this file.
1 #ifndef NPS_MAIN_H
2 #define NPS_MAIN_H
3 
4 #include <pthread.h>
5 #include <sys/time.h>
6 #include "nps_fdm.h"
7 #include "mcu_periph/sys_time.h"
8 #include "nps_atmosphere.h"
9 #include "nps_sensors.h"
10 #include "nps_autopilot.h"
11 
12 #ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
13 #include <mach/clock.h>
14 #include <mach/mach.h>
15 void clock_get_current_time(struct timespec *ts);
16 #else // Linux
17 #define clock_get_current_time(_x) clock_gettime(CLOCK_REALTIME, _x)
18 #endif // #ifdef __MACH__
19 
20 #define SIM_DT (1./SYS_TIME_FREQUENCY)
21 #define DISPLAY_DT (1./30.)
22 #define HOST_TIMEOUT_MS 40
23 
24 pthread_t th_flight_gear; // sends/receives flight gear packets
25 pthread_t th_display_ivy; // sends Ivy messages
26 pthread_t th_main_loop; // handles simulation
27 
28 pthread_mutex_t fdm_mutex; // mutex for fdm data
29 
30 int pauseSignal; // for catching SIGTSTP
31 
32 bool nps_main_parse_options(int argc, char **argv);
33 
34 int nps_main_init(int argc, char **argv);
36 void nps_main_run_sim_step(void);
37 void nps_set_time_factor(float time_factor);
38 
39 void* nps_main_loop(void* data __attribute__((unused)));
40 void* nps_flight_gear_loop(void* data __attribute__((unused)));
41 void* nps_main_display(void* data __attribute__((unused)));
42 
43 void tstp_hdl(int n __attribute__((unused)));
44 void cont_hdl(int n __attribute__((unused)));
45 
46 double time_to_double(struct timeval *t);
47 double ntime_to_double(struct timespec *t);
48 
50 
51 struct NpsMain {
55  double sim_time;
56  double display_time;
57  char *fg_host;
58  unsigned int fg_port;
59  unsigned int fg_port_in;
60  unsigned int fg_time_offset;
61  int fg_fdm;
62  char *js_dev;
63  char *spektrum_dev;
64  int rc_script;
65  bool norc;
66  char *ivy_bus;
67  bool nodisplay;
68 };
69 
71 
72 #endif /* NPS_MAIN_H */
char * fg_host
Definition: nps_main.h:57
char * ivy_bus
Definition: nps_main.h:66
void * nps_main_display(void *data)
bool norc
Definition: nps_main.h:65
double real_initial_time
Definition: nps_main.h:52
pthread_mutex_t fdm_mutex
Definition: nps_main.h:28
int nps_main_init(int argc, char **argv)
void cont_hdl(int n)
void tstp_hdl(int n)
unsigned int fg_port_in
Definition: nps_main.h:59
pthread_t th_flight_gear
Definition: nps_main.h:24
char * js_dev
Definition: nps_main.h:62
void nps_update_launch_from_dl(uint8_t value)
Definition: nps_main_hitl.c:93
int pauseSignal
Definition: nps_main.h:30
unsigned int fg_port
Definition: nps_main.h:58
struct NpsMain nps_main
Definition: nps_main.h:70
#define clock_get_current_time(_x)
Definition: nps_main.h:17
double scaled_initial_time
Definition: nps_main.h:53
void * nps_main_loop(void *data)
Architecture independent timing functions.
double time_to_double(struct timeval *t)
char * spektrum_dev
Definition: nps_main.h:63
unsigned int fg_time_offset
Definition: nps_main.h:60
void * nps_flight_gear_loop(void *data)
void nps_set_time_factor(float time_factor)
double sim_time
Definition: nps_main.h:55
double host_time_factor
Definition: nps_main.h:54
unsigned char uint8_t
Definition: types.h:14
double ntime_to_double(struct timespec *t)
bool nps_main_parse_options(int argc, char **argv)
pthread_t th_display_ivy
Definition: nps_main.h:25
bool nodisplay
Definition: nps_main.h:67
int rc_script
Definition: nps_main.h:64
void nps_radio_and_autopilot_init(void)
Definition: nps_main_hitl.c:75
int fg_fdm
Definition: nps_main.h:61
pthread_t th_main_loop
Definition: nps_main.h:26
void nps_main_run_sim_step(void)
Definition: nps_main_hitl.c:99
double display_time
Definition: nps_main.h:56
Atmosphere model (pressure, wind) for NPS.