PosHold Mode (Copter)
Executive Summary
PosHold (Position Hold) is a hybrid flight mode that attempts to offer the best of both worlds: the direct, responsive feel of Stabilize when the pilot is flying, and the GPS-locked position holding of Loiter when the pilot releases the sticks. It is often preferred by FPV pilots who want GPS safety without the "heavy" feeling of Loiter.
Theory & Concepts
1. Direct Pilot Link
The key difference between PosHold and Loiter is the Stick-to-Angle Mapping.
- Loiter: Stick = Requested Velocity.
- PosHold: Stick = Requested Lean Angle.
- The Difference: In PosHold, if you tilt the stick 10 degrees, the drone tilts 10 degrees immediately. It feels "Crisp" like Stabilize mode, but it won't drift when you let go.
2. Wind Correction Memory
Holding position in wind requires leaning into the wind.
- The Problem: If you are hovering in a 10 m/s wind, the drone might need a 5-degree lean just to stay still.
- The Trick: When you are in the "Hold" phase of PosHold, the EKF learns this Wind Lean Angle. When you start flying again, it adds that 5-degree lean as an offset to your stick input, so you don't have to fight the wind yourself.
Hardware Dependency Matrix
Like Loiter, PosHold relies on GPS for the braking and holding phases.
| Sensor | Requirement | Code Implementation Notes |
|---|---|---|
| GPS | CRITICAL | Required for the "Hold" phase and braking logic. Without GPS, the mode cannot stop the vehicle automatically. |
| Compass | CRITICAL | Required for heading and wind compensation logic. |
| Barometer | REQUIRED | Used for altitude hold (Z-axis). |
Control Architecture (Engineer's View)
PosHold implements a custom State Machine in ModePosHold::run() that switches behavior based on pilot input.
- Phase 1: Pilot Override (Stick Input)
- Behavior: The pilot controls the Lean Angle directly (like Stabilize/AltHold).
- Difference from Loiter: In Loiter, you command Acceleration/Velocity. In PosHold, you command the angle. This feels much more "connected."
- Wind Compensation: The controller injects a "Wind Lean Angle" estimate (learned during the hold phase) so you don't have to constantly lean into the wind manually.
- Phase 2: Braking (Sticks Released)
- Trigger: When pilot sticks return to center.
- Behavior: The controller calculates a "Back Angle" to arrest velocity.
- Math: It measures the current velocity vector and leans the opposite way.
- Phase 3: Loiter (Stopped)
- Trigger: When velocity drops near zero.
- Behavior: It engages the full Loiter controller to lock the 3D position and compensate for drift.
Pilot Interaction
- Flying: Feels crisp like Stabilize. The drone tilts exactly as much as you move the stick.
- Stopping: When you let go, the drone will pitch back aggressively to stop (Braking).
- Note: The transition can sometimes feel "jerky" if the braking rate is high.
- Throttle: Standard Altitude Hold (Climb Rate control).
Failsafe Logic
- GPS Loss: If GPS fails, the vehicle cannot perform the Braking or Loiter phases.
- Reaction: It typically triggers an EKF failsafe (Land/AltHold).
- Danger: If it degrades to AltHold, the "Braking" behavior disappears. The drone will just drift with its momentum when you let go.
Key Parameters
| Parameter | Default | Description |
|---|---|---|
PHLD_BRAKE_RATE |
8 | (deg/s) Max angle rate for braking. Higher = harder stop. |
PHLD_BRAKE_ANGLE |
3000 | (centi-deg) Max lean angle (30 deg) allowed during braking. |
PSC_POSXY_P |
1.0 | Position controller P-gain (used during the Hold phase). |
Source Code Reference
- Mode Logic:
ardupilot/ArduCopter/mode_poshold.cpp - Stick Smoothing:
ModePosHold::update_pilot_lean_angle()
Practical Guide: Tuning the "Brake"
Many pilots find the default braking in PosHold too aggressive, causing the drone to pitch back violently when sticks are released.
The Goal
Make the braking transition smoother without sacrificing stopping power.
The Parameters
PHLD_BRAKE_RATE(Default: 8 deg/s): This controls how fast the drone pitches back to stop.- To Smooth it Out: Reduce this value to 4 - 6 deg/s. This makes the braking pitch-back slower and less "jerky," preventing the drone from violently bucking when you let go of the sticks.
- To Stop Faster: Increase this value, but be aware that it may cause oscillation if the PID tune is not perfect.
PHLD_BRAKE_ANGLE(Default: 3000 cdeg = 30 deg): This limits the maximum lean angle the drone will use to stop.- To Limit Speed: If your drone brakes too hard from high speed, reduce this to 2000 (20 deg). This forces a longer stopping distance but keeps the airframe more stable.
Troubleshooting: "Toilet Bowling"
If the drone stops but then starts swirling in a circle (toilet bowling) during the "Hold" phase, this is not a PID issue.
- Cause: Almost always Compass interference or Mag calibration.
- Fix: Re-calibrate compass and check
COMPASS_MOT_x(Compass Motor Compensation).
For full parameter details, see the ArduPilot Wiki: PosHold Mode.