Paparazzi UAS  v7.0_unstable
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 extern pthread_t th_flight_gear; // sends/receives flight gear packets
25 extern pthread_t th_display_ivy; // sends Ivy messages
26 extern pthread_t th_main_loop; // handles simulation
27 
28 extern pthread_mutex_t fdm_mutex; // mutex for fdm data
29 
30 extern int pauseSignal; // for catching SIGTSTP
31 
32 extern bool nps_main_parse_options(int argc, char **argv);
33 
34 extern int nps_main_init(int argc, char **argv);
35 extern void nps_radio_and_autopilot_init(void);
36 extern void nps_main_run_sim_step(void);
37 extern void nps_set_time_factor(float time_factor);
38 
39 extern void* nps_main_loop(void* data __attribute__((unused)));
40 extern void* nps_flight_gear_loop(void* data __attribute__((unused)));
41 extern void* nps_main_display(void* data __attribute__((unused)));
42 
43 extern void tstp_hdl(int n __attribute__((unused)));
44 extern void cont_hdl(int n __attribute__((unused)));
45 
46 extern double time_to_double(struct timeval *t);
47 extern double ntime_to_double(struct timespec *t);
48 
50 
51 extern void nps_hitl_impl_init(void); // implement for HITL specific implementation
52 
53 struct NpsMain {
57  double sim_time;
58  double display_time;
59  char *fg_host;
60  unsigned int fg_port;
61  unsigned int fg_port_in;
62  unsigned int fg_time_offset;
63  int fg_fdm;
64  char *js_dev;
65  char *spektrum_dev;
66  int rc_script;
67  bool norc;
68  char *ivy_bus;
69  bool nodisplay;
70 };
71 
72 extern struct NpsMain nps_main;
73 
74 #endif /* NPS_MAIN_H */
Atmosphere model (pressure, wind) for NPS.
char * spektrum_dev
Definition: nps_main.h:65
void * nps_flight_gear_loop(void *data)
char * js_dev
Definition: nps_main.h:64
void tstp_hdl(int n)
double display_time
Definition: nps_main.h:58
int rc_script
Definition: nps_main.h:66
unsigned int fg_port_in
Definition: nps_main.h:61
#define clock_get_current_time(_x)
Definition: nps_main.h:17
pthread_t th_display_ivy
bool norc
Definition: nps_main.h:67
void cont_hdl(int n)
bool nodisplay
Definition: nps_main.h:69
double host_time_factor
Definition: nps_main.h:56
struct NpsMain nps_main
void nps_radio_and_autopilot_init(void)
Definition: nps_main_hitl.c:58
int fg_fdm
Definition: nps_main.h:63
void nps_update_launch_from_dl(uint8_t value)
Definition: nps_main_hitl.c:62
double sim_time
Definition: nps_main.h:57
char * fg_host
Definition: nps_main.h:59
int nps_main_init(int argc, char **argv)
char * ivy_bus
Definition: nps_main.h:68
void * nps_main_display(void *data)
void nps_main_run_sim_step(void)
Definition: nps_main_hitl.c:68
bool nps_main_parse_options(int argc, char **argv)
int pauseSignal
void nps_hitl_impl_init(void)
END pprzlink_dev.
void nps_set_time_factor(float time_factor)
double scaled_initial_time
Definition: nps_main.h:55
double time_to_double(struct timeval *t)
pthread_mutex_t fdm_mutex
pthread_t th_main_loop
double real_initial_time
Definition: nps_main.h:54
unsigned int fg_time_offset
Definition: nps_main.h:62
unsigned int fg_port
Definition: nps_main.h:60
pthread_t th_flight_gear
double ntime_to_double(struct timespec *t)
void * nps_main_loop(void *data)
Definition: nps_main_hitl.c:78
Architecture independent timing functions.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98