diff --git a/Makefile b/Makefile index f2b56eb455..da3e25973d 100644 --- a/Makefile +++ b/Makefile @@ -78,6 +78,9 @@ fbw fly_by_wire: ac_h ap autopilot: ac_h cd $(AIRBORNE); $(MAKE) TARGET=ap all +sim: ac_h + cd $(AIRBORNE); $(MAKE) TARGET=sim ARCHI=sim all + upload_fbw: fbw cd $(AIRBORNE); $(MAKE) TARGET=fbw upload diff --git a/conf/messages.xml b/conf/messages.xml index 4ff949160e..a5859f1459 100644 --- a/conf/messages.xml +++ b/conf/messages.xml @@ -66,7 +66,7 @@ - + diff --git a/sw/airborne/autopilot.h b/sw/airborne/autopilot.h index f88826604e..5ae8f77b26 100644 --- a/sw/airborne/autopilot.h +++ b/sw/airborne/autopilot.h @@ -92,7 +92,6 @@ extern bool_t rc_event_1, rc_event_2; extern float slider_1_val, slider_2_val; extern bool_t launch; -extern uint16_t cputime; /** in seconds */ #define ModeUpdate(_mode, _value) { \ diff --git a/sw/airborne/infrared.c b/sw/airborne/infrared.c index 7e72ad5e6c..c042e96a5e 100644 --- a/sw/airborne/infrared.c +++ b/sw/airborne/infrared.c @@ -33,6 +33,7 @@ #include "autopilot.h" #include "estimator.h" #include "downlink.h" +#include "sys_time.h" int16_t ir_roll; int16_t ir_pitch; @@ -125,7 +126,7 @@ uint8_t calib_status = NO_CALIB; void ground_calibrate( bool_t triggered ) { switch (calib_status) { case NO_CALIB: - if (cputime < MAX_DELAY_FOR_CALIBRATION && pprz_mode == PPRZ_MODE_AUTO1 ) { + if (cpu_time < MAX_DELAY_FOR_CALIBRATION && pprz_mode == PPRZ_MODE_AUTO1 ) { calib_status = WAITING_CALIB_CONTRAST; DOWNLINK_SEND_CALIB_START(); } diff --git a/sw/airborne/main_ap.c b/sw/airborne/main_ap.c index 975cb3e73b..c003f86c50 100644 --- a/sw/airborne/main_ap.c +++ b/sw/airborne/main_ap.c @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2003-2005 Pascal Brisset, Antoine Drouin + * Copyright (C) 2003-2005 Antoine Drouin * * This file is part of paparazzi. * @@ -21,10 +21,6 @@ * Boston, MA 02111-1307, USA. * */ -/** \file main.c - * \brief Regroup main functions - * - */ #include @@ -40,6 +36,7 @@ #include "cam.h" #include "traffic_info.h" #include "link_mcu.h" +#include "sys_time.h" #ifdef LED #include "led.h" @@ -65,10 +62,6 @@ uint8_t inflight_calib_mode = IF_CALIB_MODE_NONE; -// -// -// FIXME estimator_flight_time should not be manipuled here anymore -// /** Define minimal speed for takeoff in m/s */ #define MIN_SPEED_FOR_TAKEOFF 5. @@ -76,9 +69,6 @@ uint8_t inflight_calib_mode = IF_CALIB_MODE_NONE; uint8_t fatal_error_nb = 0; static const uint16_t version = 1; -/** in seconds */ -uint16_t cputime = 0; - uint8_t pprz_mode = PPRZ_MODE_MANUAL; uint8_t vertical_mode = VERTICAL_MODE_MANUAL; uint8_t lateral_mode = LATERAL_MODE_MANUAL; @@ -115,8 +105,8 @@ float energy; /** Fuel consumption */ static inline uint8_t pprz_mode_update( void ) { /** We remain in home mode until explicit reset from the RC */ if ((pprz_mode != PPRZ_MODE_HOME && - pprz_mode != PPRZ_MODE_GPS_OUT_OF_ORDER) - || CheckEvent(rc_event_1)) { + pprz_mode != PPRZ_MODE_GPS_OUT_OF_ORDER) + || CheckEvent(rc_event_1)) { ModeUpdate(pprz_mode, PPRZ_MODE_OF_PULSE(from_fbw.channels[RADIO_MODE], from_fbw.status)); } else return FALSE; @@ -299,7 +289,7 @@ static void navigation_task( void ) { /** Test if we lost the GPS */ if (!GPS_FIX_VALID(gps_mode) || - (cputime - last_gps_msg_t > FAILSAFE_DELAY_WITHOUT_GPS)) { + (cpu_time - last_gps_msg_t > FAILSAFE_DELAY_WITHOUT_GPS)) { /** If aircraft is launch and is in autonomus mode, go into PPRZ_MODE_GPS_OUT_OF_ORDER mode (Failsafe). */ if (launch && (pprz_mode == PPRZ_MODE_AUTO2 || @@ -398,7 +388,7 @@ inline void periodic_task( void ) { } if (!_1Hz) { if (estimator_flight_time) estimator_flight_time++; - cputime++; + cpu_time++; stage_time_ds = (int16_t)(stage_time_ds+.5); stage_time++; block_time++; @@ -431,7 +421,7 @@ inline void periodic_task( void ) { estimator_hspeed_mod > MIN_SPEED_FOR_TAKEOFF) { estimator_flight_time = 1; launch = TRUE; /* Not set in non auto launch */ - DOWNLINK_SEND_TAKEOFF(&cputime); + DOWNLINK_SEND_TAKEOFF(&cpu_time); } break; /* default: */ diff --git a/sw/ground_segment/tmtc/server.ml b/sw/ground_segment/tmtc/server.ml index 383ac97ec6..c8ae32ddb1 100644 --- a/sw/ground_segment/tmtc/server.ml +++ b/sw/ground_segment/tmtc/server.ml @@ -52,7 +52,7 @@ let rec norm_course = else c (** FIXME: Should be read from messages.xml *) -let ap_modes = [|"MANUAL";"AUTO1";"AUTO2";"HOME"|] +let ap_modes = [|"MANUAL";"AUTO1";"AUTO2";"HOME";"NOGPS"|] let gaz_modes = [|"MANUAL";"GAZ";"CLIMB";"ALT"|] let lat_modes = [|"MANUAL";"ROLL_RATE";"ROLL";"COURSE"|] let gps_modes = [|"NOFIX";"DRO";"2D";"3D";"GPSDRO"|] diff --git a/sw/simulator/Makefile b/sw/simulator/Makefile index be7b1d1d41..3fa71db10c 100644 --- a/sw/simulator/Makefile +++ b/sw/simulator/Makefile @@ -32,7 +32,7 @@ SIMHCMO=$(SIMHML:%.ml=%.cmo) SIMSML = stdlib.ml data.ml flightModel.ml gps.ml sitl.ml sim.ml SIMSCMO=$(SIMSML:%.ml=%.cmo) SIMSCMX=$(SIMSML:%.ml=%.cmx) -SIMSC = sim_ir.c sim_gps.c sim_ap.c estimator.c infrared.c gps.c pid.c nav.c main_ap.c cam.c traffic_info.c +SIMSC = sim_ir.c sim_gps.c sim_ap.c sys_time.c estimator.c infrared.c gps.c pid.c nav.c main_ap.c cam.c traffic_info.c SIMSO=$(SIMSC:%.c=$(OBJDIR)/%.o) SIMSA=sims.cma diff --git a/sw/simulator/sys_time_hw.h b/sw/simulator/sys_time_hw.h new file mode 100644 index 0000000000..e69de29bb2