Autonomy: rangefinders, maps, avoidance and precision landing · 6 MIN READ
Precision landing on a beacon: centring while descending, gates, aborts and retries
Compare a GPS-only landing on a pad with a beacon-guided one in gusty wind: centre on the beacon's offset with a PI loop, descend only inside a gate that narrows with height, abort and climb back when the pad is out of view or the error jumps near the ground, and cap the retries.
GPS puts a drone within a metre or two of a point. That is fine for a field, but not for a charging pad, a box on a ship or a dock with contacts. Precision landing adds a sensor that sees the pad itself, usually a downward camera that finds a light beacon or a printed marker, and reports where the pad is relative to the drone. The control problem is then simple. The hard part is deciding when to trust the sensor, when to keep descending and when to give up and climb.
drones · A MAP OF THE IDEA
- Approach on GPS
- Centre on the beacon
- Descend inside the gate
- Abort, climb, retry
Useful when
- Touchdown error drops from metres to centimetres.
- Gates and aborts make sensor faults visible.
Watch out
- The last half metre is flown blind.
- False detections need a jump test or a marker ID.
Implementation & operation cost: A downward sensor, a 10 Hz centring loop with a gate and an abort counter, and LANDING_TARGET on the companion link.
What GPS alone can do
A GPS landing flies to the pad's coordinates and lands where the position estimate says the pad is, so the touchdown error is the estimate's error at that moment. A navigation filter smooths the receiver's jitter but not its slow wander, and the wander is the larger part. In this simulator the GPS error has a slow part of about 0.64 m per axis that wanders over about 20 s, plus 0.48 m of jitter, so averaging a few seconds of fixes removes the jitter but not the wander. One detail matters for the comparison. The simulator's autopilot flies on its true position, while a real autopilot flies on its estimate. To reproduce a real vehicle, landGPS moves the target by the estimate's error, taken as the GPS error averaged over 5 s, and then lands with the autopilot's own Land.
Seeing the pad: offsets, gates and the last metre
d.Beacon() returns the pad's offset from the drone when the pad lies within 40 degrees of straight down and the drone is between 0.5 and 30 m up, with noise of 2 cm plus 1 percent of the distance. Over MAVLink the same information travels in LANDING_TARGET, which a companion computer sends at 10 to 50 Hz, either as angles in the camera image or, in MAVLink 2, as a position. PX4 accepts the position only in MAV_FRAME_LOCAL_NED and ignores the angles; ArduPilot accepts it only in MAV_FRAME_BODY_FRD. The landing loop runs at 10 Hz. It commands a horizontal velocity of 1.2 times the offset plus 0.3 times its integral, which takes up the part of the gusts the velocity loop leaves. It descends only while the error is inside a gate of 0.2 m plus 8 percent of the height, 1.0 m at 10 m and 0.28 m at 1 m, and it slows to 0.5 m/s near the pad. Outside the gate it holds its height and centres. The camera loses the pad below 0.5 m, so the drone flies the last half metre straight down. Both flight stacks make the same choice close to the ground: PX4 keeps descending in its final approach, and ArduPilot keeps descending below PLND_ALT_MIN.
Three pads, two landings each
Three pads stand 20 to 46 m from home, in a 5.4 m/s wind with 3 m/s gusts. Over each pad the drone takes off to 10 m and lands on GPS alone, then takes off again and lands on the beacon. Two faults are injected into the beacon below 3 m, each lasting 1.5 s: over pad 2 a glint blinds the camera, and over pad 3 a reflection is detected 1.5 m beside the pad. The program prints each touchdown's distance from the pad centre, the descent time and the number of aborts.
package main
import (
"fmt"
"log"
"math"
"gopherforge.app/drone"
)
const (
approach = 10.0 // m: where a landing starts and where a retry climbs back to
timeout = 1.0 // s without the pad in view before an abort
retries = 3 // aborts before giving up on the sensor
final = 1.0 // m: below this, keep centring if the pad is in view and go down
)
var pads = []drone.Vec3{{X: 20, Y: 5}, {X: 45, Y: -10}, {X: 30, Y: 25}}
// faults are injected into the beacon over each pad: none, a glint that
// blinds the camera, a reflection detected 1.5 m beside the pad.
var faults = []struct {
blind bool
shift drone.Vec3
}{{}, {blind: true}, {shift: drone.Vec3{X: 1.5}}}
// Sensor reports the pad's horizontal offset from the drone, if it sees it.
type Sensor func() (drone.Vec3, bool)
// landGPS lands without the beacon, the way an autopilot does on GPS: it
// holds the point its estimate says is over the pad and lands there. The
// simulator's autopilot flies on the true position, so the program moves the
// target by the estimate's error: the GPS error averaged over 5 s, because a
// navigation filter removes the jitter but not the slow wander. It returns
// when the descent began.
func landGPS(sim *drone.Sim, d *drone.Drone, pad drone.Vec3) float64 {
over := drone.Vec3{X: pad.X, Y: pad.Y, Z: approach}
d.GoTo(over)
sim.RunUntil(60, func(float64) bool { return d.Arrived() })
var bias drone.Vec3
sim.Run(5, func(float64) {
bias = bias.Add(d.Telemetry().GPS.Sub(d.State().Pos).Horizontal().Scale(sim.Dt() / 5))
})
d.GoTo(over.Sub(bias))
sim.RunUntil(60, func(float64) bool { return d.Arrived() })
sim.Run(5, nil) // settle
start := sim.Time()
d.Land()
sim.RunUntil(60, func(float64) bool { return d.State().Landed })
return start
}
// land descends onto a pad while centring on what the sensor reports. It
// descends only inside a gate that narrows with height, aborts when the pad
// is out of view for longer than timeout or the error grows near the ground,
// climbs back to the approach height and tries again.
func land(sim *drone.Sim, d *drone.Drone, sense Sensor) (aborts int) {
lost, sum := 0.0, drone.Vec3{}
for !d.State().Landed && sim.Time() < 900 {
h := d.State().Pos.Z // height from a rangefinder or the barometer
off, seen := sense()
e, gate := off.Len(), 0.2+0.08*h
why := ""
switch {
case h == 0:
d.Land() // on the ground: disarm
case h < final && !seen:
d.SetVelocity(drone.Vec3{Z: -1}, 0) // under the camera's range: straight down
case !seen:
if lost += 0.1; lost >= timeout {
why = fmt.Sprintf("pad out of view for %.0f s", timeout)
} else {
d.SetVelocity(drone.Vec3{}, 0) // stop and look again
}
case h < 4 && e > 3*gate:
why = fmt.Sprintf("off by %.2f m, gate %.2f m", e, gate)
default:
lost = 0
v := off.Scale(1.2).Add(sum.Scale(0.3)) // PI: the integral takes up the gusts' push
if e < gate {
sum = sum.Add(off.Scale(0.1)) // integrate only while centred
v.Z = -math.Max(0.5, math.Min(1, 0.25*h)) // slower near the pad
}
d.SetVelocity(v, 0)
}
if why != "" {
aborts++
fmt.Printf(" %5.1f s abort %d at %.1f m: %s; climb to %.0f m, retry\n", sim.Time(), aborts, h, why, approach)
if aborts > retries {
d.Land() // give up on the sensor: land where it is
sim.RunUntil(60, func(float64) bool { return d.State().Landed })
break
}
d.SetVelocity(drone.Vec3{Z: 2}, 0) // climb straight up, then search
sim.RunUntil(10, func(float64) bool { return d.State().Pos.Z >= approach-0.5 })
lost, sum = 0, drone.Vec3{}
continue
}
sim.Run(0.1, nil)
}
return aborts
}
func main() {
sim := drone.New(drone.Config{Wind: drone.Vec3{X: 5, Y: 2}, Gust: 3, MaxSpeed: 6, Seed: 21, Pads: pads})
d := sim.Drone()
fmt.Println("three pads, 5.4 m/s wind with 3 m/s gusts; error = touchdown to pad centre")
var sums [2]float64
for i, pad := range pads {
// beacon is the downward camera with the fault this pad injects for
// 1.5 s once the drone is below 3 m.
f, began := faults[i], -1.0
beacon := func() (drone.Vec3, bool) {
off, ok := d.Beacon()
if began < 0 && d.State().Pos.Z < 3 {
began = sim.Time()
}
if began >= 0 && sim.Time() < began+1.5 {
if f.blind {
return drone.Vec3{}, false
}
off = off.Add(f.shift)
}
return off.Horizontal(), ok
}
for k, name := range []string{"GPS", "beacon"} {
if err := d.Arm(); err != nil {
log.Fatal(err)
}
d.TakeOff(approach)
sim.RunUntil(30, func(float64) bool { return d.Arrived() })
var start float64
aborts := 0
if k == 0 {
start = landGPS(sim, d, pad)
} else {
d.GoTo(drone.Vec3{X: pad.X, Y: pad.Y, Z: approach})
sim.RunUntil(60, func(float64) bool { return d.Arrived() })
start, aborts = sim.Time(), land(sim, d, beacon)
}
miss := d.State().Pos.Sub(pad).Horizontal().Len()
sums[k] += miss
fmt.Printf(" pad %d %-7s %.2f m off, descent %4.1f s, %d aborts\n", i+1, name, miss, sim.Time()-start, aborts)
}
}
fmt.Printf("mean error: GPS %.2f m, beacon %.2f m\n", sums[0]/3, sums[1]/3)
if err := sim.Save(); err != nil {
log.Fatal(err)
}
}The GPS landings miss by 1.13, 1.37 and 1.24 m, a mean of 1.25 m, each after a 9.5 s descent. The beacon lands 0.09 m off on pad 1 in 13.8 s, slower because it descends only while centred. Over pad 2 the glint hides the pad at 2.8 m. After 1 s the loop aborts and climbs back to 10 m, where the pad is in view again, and the second descent lands 0.25 m off; the whole descent takes 27.0 s. Over pad 3 the false detection makes the error jump to 1.75 m at 3.0 m, more than three times the 0.44 m gate. The loop aborts the same way and lands 0.20 m off. The mean beacon error is 0.18 m. What scatter remains comes from the gusts, which the loop cannot fully cancel in the blind last half metre.
Aborts, retries and when to give up
A landing that cannot see its target, or sees it jump away near the ground, should not continue. The gate pauses the descent for small errors; an abort climbs back to a height where the pad is easy to see. Two rules trigger an abort here: the pad out of view for 1 s, and below 4 m an error above three times the gate, which is what a false detection or a strong gust produces. After three aborts the loop gives up on the sensor and lands where it is, the safe choice over a field. Both flight stacks expose the same decisions. PX4 waits PLD_BTOUT (5 s by default) before it declares the target lost and starts descending only inside PLD_HACC_RAD (0.2 m by default). In Required mode it climbs to PLD_SRCH_ALT to search, at most PLD_MAX_SRCH times. ArduPilot does not descend while the target is more than PLND_XY_DIST_MAX away. Its PLND_STRICT chooses what follows the retries, up to PLND_RET_MAX: either a normal landing, or a hover for a deck where landing beside the pad means landing in the water. The 1 s timeout here keeps the example short; a real one weighs the camera's dropouts against the drift while blind.
Fly it in GopherForge
In GopherForge choose New project > Robotics and simulation > Drone flight, replace main.go with this program (mission.go can stay; its Square helper does not clash) and tap Run. Output replays all six landings in flight.gfflight: the pads are teal squares, and the two aborts show as climbs back to 10 m in the altitude strip. Remove the faults, or set Gust to 0 to see how small the beacon's own error is. Widen the gate to 0.5 m plus 10 percent of the height and compare the touchdowns.
TAKE THIS WITH YOU
GPS lands a drone within its estimate's slow wander, about a metre here, and a beacon that sees the pad brings that down to tens of centimetres. Centre on the beacon's offset with a PI loop, descend only inside a gate that narrows with height, and abort and climb back when the pad is out of view or the error jumps near the ground. Cap the retries, and go straight down for the part the sensor cannot see.
Check your understanding
A beacon-guided landing descends while centring on the pad. Which events should make it stop, climb back and retry?
Go to the source
Progress stays in this browser. No account needed.