Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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 */
fdm_mutex
pthread_mutex_t fdm_mutex
Definition: nps_main.h:28
NpsMain::real_initial_time
double real_initial_time
Definition: nps_main.h:52
nps_main_init
int nps_main_init(int argc, char **argv)
Definition: nps_main_common.c:79
NpsMain::spektrum_dev
char * spektrum_dev
Definition: nps_main.h:63
ntime_to_double
double ntime_to_double(struct timespec *t)
Definition: nps_main_common.c:74
NpsMain::fg_fdm
int fg_fdm
Definition: nps_main.h:61
nps_radio_and_autopilot_init
void nps_radio_and_autopilot_init(void)
Definition: nps_main_hitl.c:75
nps_flight_gear_loop
void * nps_flight_gear_loop(void *data)
Definition: nps_main_common.c:258
NpsMain::fg_port
unsigned int fg_port
Definition: nps_main.h:58
nps_fdm.h
NpsMain::host_time_factor
double host_time_factor
Definition: nps_main.h:54
NpsMain::fg_port_in
unsigned int fg_port_in
Definition: nps_main.h:59
nps_autopilot.h
NpsMain::fg_time_offset
unsigned int fg_time_offset
Definition: nps_main.h:60
time_to_double
double time_to_double(struct timeval *t)
Definition: nps_main_common.c:69
NpsMain::ivy_bus
char * ivy_bus
Definition: nps_main.h:66
cont_hdl
void cont_hdl(int n)
Definition: nps_main_common.c:61
nps_main_parse_options
bool nps_main_parse_options(int argc, char **argv)
Definition: nps_main_common.c:147
nps_main_run_sim_step
void nps_main_run_sim_step(void)
Definition: nps_main_hitl.c:99
pauseSignal
int pauseSignal
Definition: nps_main.h:30
nps_main_loop
void * nps_main_loop(void *data)
Definition: nps_main_hitl.c:305
tstp_hdl
void tstp_hdl(int n)
Definition: nps_main_common.c:49
nps_main_display
void * nps_main_display(void *data)
Definition: nps_main_common.c:306
clock_get_current_time
#define clock_get_current_time(_x)
Definition: nps_main.h:17
NpsMain::display_time
double display_time
Definition: nps_main.h:56
nps_atmosphere.h
NpsMain::sim_time
double sim_time
Definition: nps_main.h:55
sys_time.h
Architecture independent timing functions.
uint8_t
unsigned char uint8_t
Definition: types.h:14
nps_sensors.h
NpsMain::norc
bool norc
Definition: nps_main.h:65
nps_main
struct NpsMain nps_main
Definition: nps_main.h:70
th_main_loop
pthread_t th_main_loop
Definition: nps_main.h:26
nps_set_time_factor
void nps_set_time_factor(float time_factor)
Definition: nps_main_common.c:119
th_flight_gear
pthread_t th_flight_gear
Definition: nps_main.h:24
NpsMain
Definition: nps_main.h:51
nps_update_launch_from_dl
void nps_update_launch_from_dl(uint8_t value)
Definition: nps_main_hitl.c:93
th_display_ivy
pthread_t th_display_ivy
Definition: nps_main.h:25
NpsMain::scaled_initial_time
double scaled_initial_time
Definition: nps_main.h:53
NpsMain::fg_host
char * fg_host
Definition: nps_main.h:57
NpsMain::js_dev
char * js_dev
Definition: nps_main.h:62
NpsMain::rc_script
int rc_script
Definition: nps_main.h:64
NpsMain::nodisplay
bool nodisplay
Definition: nps_main.h:67