diff --git a/conf/Makefile.chibios b/conf/Makefile.chibios index ac5e72919e..0082fd8bac 100644 --- a/conf/Makefile.chibios +++ b/conf/Makefile.chibios @@ -95,7 +95,7 @@ $(TARGET).objs = $($(TARGET).objso:%.S=$(OBJDIR)/%.o) # Paparazzi options here. ifeq ($(PPRZ_DEFINITION),) - PPRZ_DEFINITION = -DUSE_CHIBIOS_RTOS -DUSE_ADC_WATCHDOG + PPRZ_DEFINITION = -DUSE_CHIBIOS_RTOS -DUSE_ADC_WATCHDOG -DPPRZLINK_UNALIGNED_ACCESS=1 endif # Compiler options here. diff --git a/conf/settings/power_switch.xml b/conf/settings/power_switch.xml index 4fce8916c0..60b34f163d 100644 --- a/conf/settings/power_switch.xml +++ b/conf/settings/power_switch.xml @@ -4,8 +4,8 @@ - - + + diff --git a/sw/airborne/boards/apogee/chibios/v1.0/board.h b/sw/airborne/boards/apogee/chibios/v1.0/board.h index d77b687614..b33270d624 100644 --- a/sw/airborne/boards/apogee/chibios/v1.0/board.h +++ b/sw/airborne/boards/apogee/chibios/v1.0/board.h @@ -149,6 +149,9 @@ #define LED_8_GPIO_ON gpio_set #define LED_8_GPIO_OFF gpio_clear +/* Power Switch, on PB12 */ +#define POWER_SWITCH_GPIO GPIOB,GPIO12 + /* Pint to set Uart2 RX polarity, on PB13, output high inverts, low doesn't */ #define RC_POLARITY_GPIO_PORT GPIOB diff --git a/sw/airborne/subsystems/navigation/common_nav.c b/sw/airborne/subsystems/navigation/common_nav.c index e50db65c80..96bd24fcc0 100644 --- a/sw/airborne/subsystems/navigation/common_nav.c +++ b/sw/airborne/subsystems/navigation/common_nav.c @@ -59,6 +59,41 @@ void compute_dist2_to_home(void) #endif } +/** Compute time to home + * use wind and airspeed when available + */ +float get_time_to_home(void) +{ + struct FloatVect2 vect_to_home; + vect_to_home.x = waypoints[WP_HOME].x - stateGetPositionEnu_f()->x; + vect_to_home.y = waypoints[WP_HOME].y - stateGetPositionEnu_f()->y; + // get distance to home + float dist_to_home = float_vect2_norm(&vect_to_home); + if (dist_to_home > 1.f) { + // get windspeed or assume no wind + struct FloatVect2 wind = { 0.f, 0.f }; + if (stateIsWindspeedValid()) { + wind = *stateGetHorizontalWindspeed_f(); + } + // compute effective windspeed when flying to home point + float wind_to_home = (wind.x * vect_to_home.x + wind.y * vect_to_home.y) / dist_to_home; + // get airspeed or assume constant nominal airspeed + float airspeed = NOMINAL_AIRSPEED; + if (stateIsAirspeedValid()) { + airspeed = stateGetAirspeed_f(); + } + // get estimated ground speed to home + float gspeed_to_home = wind_to_home + airspeed; + if (gspeed_to_home > 1.) { + return dist_to_home / gspeed_to_home; // estimated time to home in seconds + } + else { + return 999999.f; // this might take a long time to go back home + } + } + return 0.f; // too close to home point +} + static float previous_ground_alt; diff --git a/sw/airborne/subsystems/navigation/common_nav.h b/sw/airborne/subsystems/navigation/common_nav.h index ae76fb095f..63c819bfcc 100644 --- a/sw/airborne/subsystems/navigation/common_nav.h +++ b/sw/airborne/subsystems/navigation/common_nav.h @@ -68,6 +68,7 @@ extern void nav_reset_reference(void) __attribute__((unused)); extern void nav_reset_alt(void) __attribute__((unused)); extern void nav_update_waypoints_alt(void) __attribute__((unused)); extern void common_nav_periodic_task_4Hz(void); +extern float get_time_to_home(void); /* estimated time to home point in seconds */ #define NavSetGroundReferenceHere() ({ nav_reset_reference(); nav_update_waypoints_alt(); false; }) diff --git a/sw/ground_segment/cockpit/page_settings.ml b/sw/ground_segment/cockpit/page_settings.ml index 7b31cc5bee..418c7a96d9 100644 --- a/sw/ground_segment/cockpit/page_settings.ml +++ b/sw/ground_segment/cockpit/page_settings.ml @@ -231,6 +231,7 @@ let one_setting = fun (i:int) (do_change:int -> float -> unit) ac_id packing dl_ ignore (commit_but#connect#clicked ~callback); tooltips#set_tip commit_but#coerce ~text:"Commit"; tooltips#set_tip current_value#coerce ~text:"Current value, click to request update."; + tooltips#set_tip _l#coerce ~text:text; (* Undo button *) let undo_but = GButton.button ~packing:hbox#pack () in