MAVLINKHUD

Brake Mode (Copter)

Executive Summary

Brake Mode is a dedicated safety mode designed to stop the vehicle as quickly as possible and hold its position. It is often assigned to a "Panic Switch" or triggered by the "Pause" button on GCS controllers (like the old 3DR Solo controller). Once engaged, it ignores all pilot inputs until switched out or a timeout occurs.

Theory & Concepts

1. Kinetic Energy Dissipation

Stopping a drone moving at 20 m/s requires dissipating a massive amount of kinetic energy.

  • The Problem: If you just "level" the drone, it will coast for 50 meters due to momentum.
  • The Solution: The Brake controller calculates the Deceleration Vector. It commands a negative pitch/roll to produce a horizontal thrust component that actively fights the drone's current velocity.

2. Open-Loop vs. Closed-Loop Stop

  • Manual (Open-Loop): You tilt the drone back, but you have to guess when to level it.
  • Brake (Closed-Loop): The EKF monitors the GPS velocity. As the speed reaches zero, the controller smoothly reduces the "back-angle" to exactly 0, preventing the drone from flying backwards after it stops.

Hardware Dependency Matrix

Since Brake mode relies on stopping and holding a 3D position, it has similar requirements to Loiter.

Sensor Requirement Code Implementation Notes
GPS CRITICAL Requires a valid position estimate to calculate velocity errors and hold position after stopping.
Compass CRITICAL Required for the inertial navigation system to function correctly.
Barometer REQUIRED Used for altitude hold (Z-axis stop).

Control Architecture (Engineer's View)

Brake Mode is essentially a simplified PosHold mode with hard-coded targets.

  1. Input Lockout:
    • Unlike almost every other mode, ModeBrake::run() does not read pilot sticks.
    • Throttle, Roll, Pitch, and Yaw are completely ignored.
    • Code Path: ModeBrake::run() calls pos_control->input_vel_accel_xy with zero vectors.
  2. Deceleration Logic:
    • The controller sets a Target Velocity of (0,0,0) cm/s.
    • The AC_PosControl library uses its internal PID loops to drive the vehicle to this velocity using BRAKE_MODE_DECEL_RATE (Default: 750 cm/s/s).
    • This is typically much more aggressive than a standard Loiter stop.
  3. Position Hold:
    • Once velocity reaches zero, the underlying PosControl logic automatically latches the current position and fights drift.

Timeout Behavior

Brake Mode has a unique feature: it can automatically exit itself.

  • Trigger: If timeout_to_loiter_ms() is called (usually by GCS logic), a timer starts.
  • Action: When the timer expires, the vehicle attempts to switch to Loiter mode.
  • Fallback: If Loiter fails (e.g., GPS glitch), it falls back to AltHold to at least maintain altitude.
  • Code Path: timeout_to_loiter_ms.

Failsafe Logic

  • GPS Loss: If GPS is lost while braking, the vehicle cannot determine its velocity or position. It will likely trigger a standard EKF Failsafe (switching to Land or AltHold), overriding the Brake mode.

Key Parameters

Parameter Default Description
BRAKE_MODE_DECEL_RATE 750 (cm/s/s) The deceleration aggression. Higher values stop faster but may cause pitch-up oscillations.
BRAKE_MODE_SPEED_Z 250 (cm/s) Max vertical speed allowed during the brake maneuver.

Source Code Reference

Practical Guide: The Panic Switch

You lose video. You lose orientation. The drone is flying towards a tree. You need to stop NOW.

Configuration

  1. RC Setup: Assign a momentary switch (like the "Trainer" switch) on your radio to a spare channel (e.g., Channel 8).
  2. ArduPilot: Set RC8_OPTION = 17 (Brake).
    • Note: Do not assign this to a flight mode slot. An RC Option overrides any flight mode.

Usage

  • Press and Hold: The drone slams on the brakes. It ignores all stick inputs.
  • Regain Composure: Take a breath. Look at the drone. Orient yourself.
  • Release: The drone stays in Loiter (or whatever mode you were in, usually).
  • Warning: The braking is aggressive (0.75G). Ensure your battery is secure, or it might eject through the front.