MAVLINKHUD

Drift Mode (Copter)

Executive Summary

Drift Mode completely reimagines the control scheme of a multicopter to mimic the behavior of a fixed-wing aircraft or a car. It provides "coordinated turns" where rolling the vehicle automatically induces a yaw rotation, allowing for smooth, banking turns without needing manual yaw input. It also features automatic braking when the sticks are released.

Theory & Concepts

1. Coordinated vs. Uncoordinated Flight

In traditional aviation, a "Coordinated" turn is one where the plane doesn't slip sideways through the air.

  • The Drone Problem: Drones are inherently uncoordinated. They can fly sideways just as easily as forwards.
  • The Drift Mode Solution: ArduPilot forces coordination by Linking Yaw to Roll. By automatically yawing the drone into the direction of the roll, it creates a bank-and-turn feel similar to a fixed-wing airplane.

2. Relative Momentum

Drift mode uses Velocity Control for its horizontal axes.

  • The Feel: Because the Pitch stick controls speed, and the Roll stick controls turn rate, flying Drift mode feels like "Driving a car in 3D space." It removes the complexity of managing the drone's heading separately from its movement vector.

Hardware Dependency Matrix

Drift Mode relies on velocity estimation to perform its coordinated turns and braking.

Sensor Requirement Code Implementation Notes
GPS CRITICAL Required for inertial velocity calculations. Without a position estimate, the braking and roll-assist logic cannot function.
Compass CRITICAL Required for heading and velocity frame transformation.
Barometer REQUIRED Used for altitude hold (Z-axis).

Control Architecture (Engineer's View)

Drift Mode uses a custom "remap" of the pilot inputs that exists nowhere else in the codebase.

  1. Stick Remapping:
    • Roll Stick (Right Stick X): Commands Yaw Rate (Turn rate). It also commands a coordinated bank angle.
    • Pitch Stick (Right Stick Y): Commands Pitch Angle (Acceleration/Deceleration).
    • Yaw Stick (Left Stick X): Commands Lateral Velocity (Side-slip).
    • Throttle Stick: Standard Altitude Hold (Climb Rate).
  2. Coordinated Turn Logic:
    • The controller calculates a target yaw rate based on the Roll Stick input.
    • Equation: Yaw_Rate = Roll_Input * (1.0 - (Forward_Speed / 50m/s)).
    • Effect: At low speeds, the yaw response is sharp. At high speeds, the yaw response is dampened to prevent spinning out, creating a smooth banking curve.
  3. Velocity Controller (Roll Axis):
    • The roll axis runs a P-loop (DRIFT_SPEEDGAIN) to minimize lateral velocity.
    • This acts like the "keel" of a boat or the vertical stabilizer of a plane, fighting side-slip and forcing the drone to fly nose-first.

Pilot Interaction

  • Flying Forward: Push Pitch stick forward.
  • Turning: Push Roll stick Left/Right. The drone banks and turns. No rudder (Yaw stick) required.
  • Stopping: Release the Pitch stick. The drone automatically pitches back to brake (using DRIFT_SPEED logic).

Failsafe Logic

  • GPS Loss: The mode relies on inertial_nav.get_velocity_neu_cms(). If GPS fails, the velocity estimate becomes invalid. The behavior will likely degrade to a drift-prone Stabilize-like feel or trigger an EKF failsafe.

Key Parameters

Parameter Default Description
DRIFT_SPEED 500 Max speed (cm/s). Also used to calculate braking aggression.
DRIFT_SPEEDGAIN 14 Gain for the side-slip controller. Higher values make the "virtual keel" stronger, forcing nose-forward flight more aggressively.
DRIFT_COORD 0 (Boolean) If enabled, allows manual yaw input to override the coordinated turn logic.

Source Code Reference