ArduPilot Plane Automatic Landing with Rangefinder

ArduPilot Plane Automatic Landing with Rangefinder

Understanding Barometer Drift Problem

During flight, the barometer altitude can drift due to: - Temperature changes inside the vehicle (battery heat, video transmitter heat, etc.) - Atmospheric pressure changes during flight - Temperature differences between takeoff location and flying site

Result: The barometer can report altitude errors of ±5 to ±20 meters (or more) on long flights, even though most barometers are temperature compensated.

How Rangefinder Corrects Altitude During Landing

The Key Formula

When the rangefinder is in range (typically ≤6-12m for cheap sensors), the autopilot calculates:

correction = baro_altitude - rangefinder_altitude
landing_height = baro_altitude - correction
               = baro_altitude - (baro_altitude - rangefinder_altitude)
               = rangefinder_altitude  ✓

Once rangefinder is in range, it directly overrides the barometer for landing altitude!

Code Evidence

From ArduPlane/altitude.cpp:

float Plane::get_landing_height(bool &rangefinder_active)
{
    // get basic height above target
    height = height_above_target();  // Barometer-based
    
    // possibly correct with rangefinder
    height -= rangefinder_correction();  // Subtract correction
    rangefinder_active = rangefinder_state.in_range;
    
    return height;  // = rangefinder altitude when in range!
}

Landing Sequence Order

1. Approach Phase

2. Flare Trigger (first condition met)

3. Flare Execution

4. Final Phase

5. Touchdown and Rollout

Two Critical Scenarios with 6m Rangefinder

Scenario 1: Baro Drift -20m (reads LOW)

Situation: - Actual altitude at ground level: 0m - Barometer reports: -20m (thinks it’s 20m underground)

What Happens:

Actual Alt Baro Reading Rangefinder What Happens
30m 10m No signal (too high) LAND_FLARE_ALT=10m triggers flare! ❌
20m 0m No signal Gliding in flare mode
10m -10m No signal Still gliding
6m -14m 6m detected Rangefinder correction active! ✓
0m -20m 0m Lands safely

Result: - ❌ Flare starts 20m too high (at 30m instead of 10m) - ✅ Rangefinder prevents crash after 6m detection - ⚠️ Landing is LONG (overshoots touchdown point by ~100-200m) - ✅ Safe if runway is long enough - ❌ Cannot fix on first approach (baro error > rangefinder range)

Solution: Use the “dry run calibration” LUA script: 1. Descend until rangefinder triggers 2. Pull up immediately 3. Recalibrate baro to known rangefinder altitude 4. Execute actual landing with corrected baro


Scenario 2: Baro Drift +20m (reads HIGH)

Situation: - Actual altitude at ground level: 0m - Barometer reports: +20m (thinks it’s 20m high)

What Happens:

Actual Alt Baro Reading Rangefinder What Happens
30m 50m No signal Normal descent at TECS_LAND_THR
20m 40m No signal Still descending (no flare yet)
15m 35m No signal Still descending with power! ⚠️
10m 30m No signal Getting dangerous…
6m 26m 6m detected RANGEFINDER SAVES THE DAY!
6m 26m 6m Correction: 20m applied → height = 6m
6m 26m 6m FLARE TRIGGERS (even though baro > 10m)
0m 20m 0m Lands safely ✓

Result: - ⚠️ Plane continues powered descent past intended flare altitude - ✅ Rangefinder detects ground at 6m actual altitude - ✅ Flare triggers immediately based on rangefinder - ✅ Prevents powered crash into ground! - ✅ Landing point is approximately correct (maybe slightly short)

Safety Mechanism from Code:

// AP_Landing_Slope.cpp line 103
if ((on_approach_stage && below_flare_alt) ||
    (on_approach_stage && below_flare_sec) ||
    (!rangefinder_state_in_range && wp_proportion >= 1) ||  // Safety catch!
    probably_crashed)

Even if rangefinder fails, flare triggers when plane passes the landing point.


Key Insights

Rangefinder Limitations

With a 6m range rangefinder: - ❌ Cannot prevent early flare (when you’re too high to detect ground) - ✅ CAN prevent late/no flare (detects ground and forces correction)

Critical Parameters for Your Setup

RNGFND_LANDING = 1 or 3     # Enable rangefinder for landing
LAND_FLARE_ALT = 10         # Flare altitude (meters) - conservative value
LAND_FLARE_SEC = 2.0        # Flare time (seconds)
TECS_LAND_SINK = 0.25       # Final descent rate (m/s)
LAND_SLOPE_RCALC = 2.0      # Allow slope recalc for rangefinder bumps

Best Practices

  1. Use shallow glide slopes (3-6 degrees) to minimize overshoot in Scenario 1
  2. Space waypoints adequately to allow turns to complete before final approach
  3. Set conservative LAND_FLARE_ALT (10-15m) to ensure rangefinder engagement
  4. Ensure long runway to handle potential overshoot from early flare
  5. Calibrate barometer just before landing if possible (arm at ground level)
  6. Consider dry-run calibration script for long-range missions

Why Documentation Emphasizes Shallow Slopes

The documentation recommends shallow glide slopes and conservative flare altitudes because: - Minimizes overshoot distance in Scenario 1 (early flare) - Gives more time for rangefinder to engage and correct - Reduces approach speed and energy at touchdown - Makes landing more survivable if things go wrong

Conclusion

Your cheap 6m rangefinder is highly effective at preventing the dangerous Scenario 2 (powered descent into ground). For Scenario 1, you need either: - A long runway to handle overshoot, OR - A pre-landing baro calibration routine (custom LUA script)

The rangefinder’s limited range makes it asymmetric in protection: excellent crash prevention, limited overshoot prevention.