← Drones with Go

GO DRONE PROGRAMMING · FLIGHT SIMULATOR · 10 LESSONS

Autonomy: rangefinders, maps, avoidance and precision landing

Rangefinders and lidar scans, reactive avoidance and braking distance, potential fields and gap following, orbiting a structure, occupancy grids, planning in configuration space, behaviour trees, beacon landing and flying without GPS.

  1. Rangefinders and lidar scans: rays, maximum range, noise and what a horizontal scan misses

    Model a rangefinder as a ray with a maximum range and noise, turn a lidar scan into clustered obstacle points in local coordinates, reject dropouts and spurious returns with a median, pack the result as MAVLink OBSTACLE_DISTANCE, and name what a horizontal scan cannot see.

    7 min · Worked lesson

  2. Reactive avoidance: corridors, slow-down zones and stop-and-sidestep

    Check the corridor a drone sweeps instead of a single ray, limit speed in proportion to the free distance with a gain that is provably safe for a measured reaction time and braking, and get past a building with stop-and-sidestep, without a map.

    6 min · Worked lesson

  3. Potential fields: attraction, repulsion from a scan, and the local-minimum trap

    Build an artificial potential field from a goal and rangefinder readings, fly its negative gradient as a velocity command, watch it stall inside a U-shaped obstacle, detect the stall, and escape by wall following, with an honest account of what fields cannot guarantee.

    6 min · Worked lesson

  4. Gap following with a polar histogram: VFH-style sectors, widening and heading choice

    Bin a lidar scan into a polar histogram, threshold it with hysteresis into blocked and free sectors, widen every reading by the vehicle radius, choose the free direction with a VFH+ style cost, smooth heading and speed, and fly through a cluttered field.

    7 min · Worked lesson

  5. Inspecting a structure: a constant-standoff orbit from rangefinder feedback

    Orbit a mast at a constant distance from its surface with a radial PI loop on the rangefinder and a tangential speed, count laps, and compare per-lap standoff statistics with a GPS-only orbit around a mapped position that is a few metres off.

    6 min · Worked lesson

  6. Occupancy grids from rangefinder scans: log-odds, Bresenham rays and clamping

    Build a 2D occupancy grid in local metres from rangefinder scans: add log-odds evidence along each beam traced with Bresenham's line, mark nothing for readings without a return, clamp every cell so the map can change, and compare the built map with the true obstacles after a survey flight.

    7 min · Worked lesson

  7. Configuration space: inflating your own map, deciding about unknown cells and flying the plan

    Turn a self-built occupancy grid into a configuration space by growing occupied cells by the airframe radius, a margin and half a cell, decide whether unknown cells count as free or blocked, plan on the result with A*, fly the plan and check the clearance with the rangefinder.

    6 min · Worked lesson

  8. Behaviour trees for autonomy: sequences, fallbacks, conditions and actions ticked every step

    Build a behaviour tree from Sequence, Fallback, Condition and Action nodes that return Success, Failure or Running, tick it at 10 Hz to fly 'inspect then return; on low battery return; on obstacle hold', trace its ticks deterministically and compare it with the flight-modes lesson's state machine.

    7 min · Worked lesson

  9. 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.

    6 min · Worked lesson

  10. Flying without GPS: frozen telemetry, drift, the landing failsafe and your own policy

    Detect a GPS outage at the ground station from the fix flag and repeated positions rather than message age, measure how far a drone drifts in wind when its autopilot can only keep level, watch the 'no GPS for 3 s: landing' failsafe act, and compare hold, land and climb policies in an urban canyon with the failsafe on and off.

    6 min · Worked lesson