35int main(
int argc,
char **argv)
91 struct timespec requestStart;
92 struct timespec requestEnd;
93 struct timespec waitFor;
97 struct timeval tv_now;
110 gettimeofday(&tv_now, NULL);
115 printf(
"Press <enter> to continue (or CTRL-Z to suspend).\nEnter a new time factor if needed (current: %f): ",
118 if (fgets(line, 127, stdin)) {
119 if ((sscanf(line,
" %le ", &tf) == 1)) {
120 if (tf > 0 && tf < 1000) {
124 printf(
"Time factor is %f\n",
nps_main.host_time_factor);
126 gettimeofday(&tv_now, NULL);
138 gettimeofday(&tv_now, NULL);
140 double host_time_elapsed =
nps_main.host_time_factor * (host_time_now -
nps_main.scaled_initial_time);
143 printf(
"%f,%f,%f,%f,%f,%f,",
nps_main.host_time_factor, host_time_elapsed, host_time_now,
nps_main.scaled_initial_time,
148 static int prev_cnt = 0;
149 static int grow_cnt = 0;
150 while (
nps_main.sim_time <= host_time_elapsed) {
159 if (cnt > (prev_cnt)) {grow_cnt++;}
161 if (grow_cnt < 0) {grow_cnt = 0;}
165 printf(
"Warning: The time factor is too large for efficient operation! Please reduce the time factor.\n");
175 task_ns = (requestEnd.tv_sec - requestStart.tv_sec) * 1000000000L + (requestEnd.tv_nsec - requestStart.tv_nsec);
179 waitFor.tv_nsec = period_ns - task_ns;
180 nanosleep(&waitFor, NULL);
184 printf(
"MAIN THREAD: task took longer than one period, exactly %f [ms], but the period is %f [ms]\n",
185 (
double)task_ns / 1
E6, (
double)period_ns / 1
E6);
void nps_atmosphere_update(double dt)
struct NpsAutopilot nps_autopilot
ifndef NPS_NO_MOTOR_MIXING include "modules/actuators/motor_mixing.h"
void nps_autopilot_run_step(double time)
#define NPS_COMMANDS_NB
Number of commands sent to the FDM of NPS.
void nps_autopilot_run_systime_step(void)
void nps_autopilot_init(enum NpsRadioControlType type, int num_script, char *js_dev)
void nps_fdm_run_step(bool launch, double *commands, int commands_nb)
Minimum complexity flight dynamic model In legacy Paparazzi simulator, was implemented in OCaml and c...
void nps_fdm_run_init_step(void)
void * nps_main_loop(void *data)
#define clock_get_current_time(_x)
int nps_main_init(int argc, char **argv)
void * nps_main_display(void *data)
void * nps_flight_gear_loop(void *data)
double time_to_double(struct timeval *t)
pthread_mutex_t fdm_mutex
void * nps_main_loop(void *data)
void nps_radio_and_autopilot_init(void)
void nps_update_launch_from_dl(uint8_t value)
void nps_main_run_sim_step(void)
void nps_sensors_run_step(double time)
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.