1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-20 23:05:17 +03:00

configurable speed threshold to enter braking mode

This commit is contained in:
Pawel Spychalski (DzikuVx) 2018-05-05 10:15:09 +02:00
parent a13f749eb2
commit db3ddd939d
4 changed files with 20 additions and 4 deletions

View file

@ -116,6 +116,7 @@ PG_RESET_TEMPLATE(navConfig_t, navConfig,
.max_bank_angle = 30, // 30 deg
.hover_throttle = 1500,
.auto_disarm_delay = 2000,
.braking_speed_threshold = 100,
},
// Fixed wing
@ -1964,9 +1965,16 @@ static bool adjustPositionFromRCInput(void)
else {
/*
* Process states
* Process states only for POSHOLD. In any other case we go back to old routines
*/
if (navConfig()->general.flags.user_control_mode == NAV_GPS_CRUISE) {
if (
navConfig()->general.flags.user_control_mode == NAV_GPS_CRUISE &&
navConfig()->mc.braking_speed_threshold > 0 &&
(
NAV_Status.state == MW_NAV_STATE_NONE ||
NAV_Status.state == MW_NAV_STATE_HOLD_INFINIT
)
) {
const int16_t rcPitchAdjustment = applyDeadband(rcCommand[PITCH], rcControlsConfig()->pos_hold_deadband);
const int16_t rcRollAdjustment = applyDeadband(rcCommand[ROLL], rcControlsConfig()->pos_hold_deadband);
@ -1975,22 +1983,24 @@ static bool adjustPositionFromRCInput(void)
* Speed is above 1m/s and sticks are centered
*/
if (!STATE(NAV_CRUISE_BRAKING) &&
posControl.actualState.velXY > 100.0f &&
posControl.actualState.velXY > navConfig()->mc.braking_speed_threshold &&
!rcPitchAdjustment &&
!rcRollAdjustment
) {
ENABLE_STATE(NAV_CRUISE_BRAKING);
DEBUG_SET(DEBUG_BRAKING, 0, 1);
}
/*
* Case when we were braking but copter finally stopped or we started to move the sticks
*/
if (STATE(NAV_CRUISE_BRAKING) && (
posControl.actualState.velXY <= 100.0f ||
posControl.actualState.velXY <= navConfig()->mc.braking_speed_threshold ||
rcPitchAdjustment ||
rcRollAdjustment
)) {
DISABLE_STATE(NAV_CRUISE_BRAKING);
DEBUG_SET(DEBUG_BRAKING, 0, 0);
/*
* When braking is done, store current position as desired one