Copter: add option to disable BRAKE flight mode

This commit is contained in:
Peter Barker 2018-02-23 16:40:29 +11:00 committed by Randy Mackay
parent a7fe242e31
commit 86b162e32f
5 changed files with 15 additions and 0 deletions

View File

@ -24,6 +24,7 @@
//#define SPRAYER DISABLED // disable the crop sprayer feature (two ESC controlled pumps the speed of which depends upon the vehicle's horizontal velocity)
//#define WINCH_ENABLED DISABLED // disable winch support
//#define MODE_AUTO_ENABLED DISABLED // disable auto mode support
//#define MODE_BRAKE_ENABLED DISABLED // disable brake mode support
//#define MODE_DRIFT_ENABLED DISABLED // disable drift mode support
//#define MODE_GUIDED_ENABLED DISABLED // disable guided mode support
//#define MODE_LOITER_ENABLED DISABLED // disable loiter mode support

View File

@ -962,7 +962,9 @@ private:
#if AUTOTUNE_ENABLED == ENABLED
ModeAutoTune mode_autotune;
#endif
#if MODE_BRAKE_ENABLED == ENABLED
ModeBrake mode_brake;
#endif
ModeCircle mode_circle;
#if MODE_DRIFT_ENABLED == ENABLED
ModeDrift mode_drift;

View File

@ -1303,11 +1303,15 @@ void GCS_MAVLINK_Copter::handleMessage(mavlink_message_t* msg)
bool shot_mode = (!is_zero(packet.param1) && (copter.control_mode == GUIDED || copter.control_mode == GUIDED_NOGPS));
if (!shot_mode) {
#if MODE_BRAKE_ENABLED == ENABLED
if (copter.set_mode(BRAKE, MODE_REASON_GCS_COMMAND)) {
copter.mode_brake.timeout_to_loiter_ms(2500);
} else {
copter.set_mode(ALT_HOLD, MODE_REASON_GCS_COMMAND);
}
#else
copter.set_mode(ALT_HOLD, MODE_REASON_GCS_COMMAND);
#endif
} else {
// SoloLink is expected to handle pause in shots
}

View File

@ -273,6 +273,12 @@
# define MODE_AUTO_ENABLED ENABLED
#endif
//////////////////////////////////////////////////////////////////////////////
// Brake mode - bring vehicle to stop
#ifndef MODE_BRAKE_ENABLED
# define MODE_BRAKE_ENABLED ENABLED
#endif
//////////////////////////////////////////////////////////////////////////////
// Drift - fly vehicle in altitude-held, coordinated-turn mode
#ifndef MODE_DRIFT_ENABLED

View File

@ -110,9 +110,11 @@ Copter::Mode *Copter::mode_from_mode_num(const uint8_t mode)
break;
#endif
#if MODE_BRAKE_ENABLED == ENABLED
case BRAKE:
ret = &mode_brake;
break;
#endif
case THROW:
ret = &mode_throw;