Merge pull request #2493 from paparazzi/small_features

Small features
This commit is contained in:
Gautier Hattenberger
2020-03-12 10:16:14 +01:00
committed by GitHub
6 changed files with 43 additions and 3 deletions
+1 -1
View File
@@ -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.
+2 -2
View File
@@ -4,8 +4,8 @@
<dl_settings NAME="Power switch control">
<dl_settings NAME="Power switch">
<dl_setting MAX="1" MIN="0" STEP="1" VAR="autopilot.power_switch" module="autopilot" handler="SetPowerSwitch">
<strip_button name="Switch on" icon="on.png" value="1"/>
<strip_button name="Switch off" icon="off.png" value="0"/>
<strip_button name="Switch on" icon="on.png" value="1" group="power_switch"/>
<strip_button name="Switch off" icon="off.png" value="0" group="power_switch"/>
</dl_setting>
</dl_settings>
</dl_settings>
@@ -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
@@ -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;
@@ -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; })
@@ -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