Operations: links, logs, rules and fleets in service · 7 MIN READ

Radio links in operations: tested range, what the station sees, the failsafe timeline and margins

Treat the radio link as a measured range around home, show what a ground station sees while reports stop arriving, follow the link-loss failsafe second by second, predict where the vehicle reappears, and plan and fly missions that stay inside the link with margin.

The failsafes lesson treated link loss as a heartbeat timeout in code, and the ground-station lesson as a timer that every frame resets. In the field the questions are different. How far does the link reach at this site today? What does the screen show when it drops? Where will the vehicle be when its failsafe fires, and where will it come back into range? What should the operator do in the meantime, and what should they not do? This lesson answers them with the simulator's limited-range link.

drones · A MAP OF THE IDEA

  1. Range-test the site
  2. Plan inside with margin
  3. Watch age and edge time
  4. Hands off during loss

Useful when

  • The station predicts when and where the vehicle reappears.
  • Holding before the edge keeps the rest of the mission.

Watch out

  • Real links fade with terrain, antennas and interference.
  • Commands queued during an outage replay at the wrong time.

Implementation & operation cost: A range test per site, a margin in the planner and a station that tracks report age and the time to the edge.

01

Range is measured, not read off a datasheet

A radio link reaches as far as its link budget allows: transmit power, antenna gains and their orientation, a clear line of sight with room around it, the airframe shielding its own antenna in a turn, trees, terrain and whatever else transmits on the band. None of that is on the radio's datasheet, so operators range-test each site and watch the link's own health. SiK telemetry radios, for example, inject RADIO_STATUS into the MAVLink stream with local and remote RSSI, local and remote noise and a count of receive errors; RSSI falling towards the noise floor and errors rising are the early warning. The simulator reduces all of this to Config.LinkRange: a circle of that radius around each drone's home, measured horizontally. d.Link() reports whether the drone is inside it, the event log records 'link lost' and 'link restored', and with failsafes on a link lost for 5 s starts a return home. Real links fade over tens of metres instead of switching off at a line, which gives a watchful operator time the simulator does not.

02

What the ground station sees

A ground station cannot tell a fade from a crash, a flat battery or a switched-off radio: it only knows that reports have stopped. The one honest signal is the age of the last report, measured on the station's own clock. At 5 Hz, a second without a report is five missed in a row: grey the values out and say how old they are. After the same timeout the vehicle uses, declare the link lost. From then on nothing the operator sends can arrive, and status messages the vehicle sends during the outage are gone too; the vehicle's own log has them, and the station reads it after landing. In the program, the station receives d.Telemetry() only while d.Link() is true, and its commands go up only over a live link, so its view and the vehicle's log can be printed side by side.

03

The failsafe timeline

Follow a vehicle flying outwards at speed v when the link drops at the edge. It keeps flying its last command for the whole timeout T, so the failsafe fires about v times T beyond the edge. It then brakes, turns and flies back over the same distance, so the link returns roughly 2T + 2v/a after the last report, where a is the airframe's acceleration. That is the time the station can announce, and if the vehicle has not reappeared by then plus a margin, something other than the link has failed. Flight stacks make the timeout and the action parameters: PX4 triggers its data link loss failsafe after COM_DL_LOSS_T with the action in NAV_DLL_ACT (disabled, Hold, Return, Land, Disarm or Terminate), and by default holds for COM_FAIL_ACT_T seconds first so the operator can step in. ArduPilot's GCS failsafe fires after FS_GCS_TIMEOUT seconds without a ground-station heartbeat (5 by default), can be set to RTL, SmartRTL or Land, can let an Auto mission continue through FS_OPTIONS, and stays inactive if no ground station ever connected. Whatever the action, the airspace v times T past the edge and the straight line home from there must be safe to fly.

04

Three flights against a 200 m link

The tested range is 200 m and the plan keeps 40 m inside it. Check finds each plan's farthest waypoint; because distance from home is convex along a straight leg, the farthest point of any route is one of its waypoints. Flight 1 flies plan A, which the check rejects, and relies on the failsafe alone. Flight 2 flies the same plan with an operator who watches the reports: when the edge is less than 4 s away at the current outward speed, the station holds the vehicle and skips that waypoint. Flight 3 flies plan B. Lines marked station are what the ground station knows when it knows it; lines marked vehicle come from the vehicle's log.

go
package main

import (
	"fmt"
	"log"
	"math"
	"strings"

	"gopherforge.app/drone"
)

const (
	linkRange = 200.0 // m, from a range test at this site, not the radio's datasheet
	margin    = 40.0  // m the plan keeps inside it
	timeout   = 5.0   // s, the vehicle's link-loss failsafe
	speed     = 10.0  // m/s cruise
	accel     = 6.87  // m/s2, the airframe's horizontal acceleration
	lookahead = 4.0   // s, the operator holds when the edge is closer than this
)

// Station is the ground station. It sees the vehicle only through the
// reports that reach it, so it keeps its own clock on their age.
type Station struct {
	last  drone.Telemetry // latest report received
	state string          // up, stale or lost
}

func (s *Station) Receive(tel drone.Telemetry) {
	if s.state != "up" {
		fmt.Printf("  %5.1f s  station  link back after %.1f s: %s %.0f m out, %.0f m up, %.0f%%\n",
			tel.Time, tel.Time-s.last.Time, tel.Mode, tel.GPS.Horizontal().Len(), tel.BaroAlt, tel.Battery)
	}
	s.last, s.state = tel, "up"
}

// Outward is the reported speed away from home, m/s.
func (s *Station) Outward() float64 {
	p, v := s.last.GPS.Horizontal(), s.last.Velocity.Horizontal()
	if p.Len() < 1 {
		return 0
	}
	return (p.X*v.X + p.Y*v.Y) / p.Len()
}

// Tick runs on the station's own clock: stale after 1 s without a report,
// lost after the same timeout the vehicle uses.
func (s *Station) Tick(now float64) {
	age := now - s.last.Time
	p, out := s.last.GPS.Horizontal(), s.Outward()
	switch {
	case s.state == "up" && age >= 1:
		s.state = "stale"
		fmt.Printf("  %5.1f s  station  no report for 1 s: last %.0f m out, %s, moving out at %.1f m/s\n",
			now, p.Len(), s.last.Mode, out)
	case s.state == "stale" && age >= timeout:
		s.state = "lost"
		// The failsafe fires about timeout after the last report, the vehicle
		// brakes, turns and flies back over the same distance.
		back := s.last.Time + 2*timeout + 2*out/accel
		fmt.Printf("  %5.1f s  station  LINK LOST: no commands possible; expect the return near %.1f s\n", now, back)
	}
}

// Check plans against the link. Distance from home is convex along a
// straight leg, so the farthest point of a route is always a waypoint.
func Check(name string, plan []drone.Vec3) bool {
	far := 0.0
	for _, p := range plan {
		far = math.Max(far, p.Horizontal().Len())
	}
	ok := far <= linkRange-margin
	verdict := "go"
	if !ok {
		verdict = "NO-GO"
	}
	fmt.Printf("%s: farthest waypoint %.1f m from home, limit %.0f m (%.0f m range - %.0f m margin): %s\n",
		name, far, linkRange-margin, linkRange, margin, verdict)
	return ok
}

// fly flies a plan. With guard, the operator holds and skips the leg when
// the reports show the link edge less than lookahead seconds away.
func fly(plan []drone.Vec3, guard bool) *drone.Sim {
	sim := drone.New(drone.Config{LinkRange: linkRange, Wind: drone.Vec3{X: -2, Y: 1}, Gust: 1, MaxSpeed: speed, Seed: 12})
	d := sim.Drone()
	if err := d.Arm(); err != nil {
		log.Fatal(err)
	}
	d.TakeOff(30)
	st := &Station{last: d.Telemetry(), state: "up"}
	next, reached, sentAt, seenTel, seenEv, far := 0, 0, -1.0, -1.0, 0, 0.0
	sim.RunUntil(400, func(t float64) bool {
		if tel := d.Telemetry(); tel.Time != seenTel {
			seenTel = tel.Time
			if d.Link() { // the downlink works only in range
				st.Receive(tel)
			}
		}
		st.Tick(t)
		// The vehicle's own log, which the station reads after landing.
		dist := d.State().Pos.Horizontal().Len()
		far = math.Max(far, dist)
		events := sim.Events()
		for _, e := range events[seenEv:] {
			if strings.HasPrefix(e.Text, "arrived") {
				reached++
			}
			if strings.Contains(e.Text, "link") || strings.Contains(e.Text, "return") || e.Text == "landed" {
				fmt.Printf("  %5.1f s  vehicle  %-35s %5.1f m out\n", e.T, e.Text, dist)
			}
		}
		seenEv = len(events)
		if guard && st.state == "up" && st.last.Mode == drone.GoingTo && st.last.Time > sentAt {
			if r := st.last.GPS.Horizontal().Len(); r+st.Outward()*lookahead > linkRange {
				fmt.Printf("  %5.1f s  station  link edge %.1f s away (%.0f m out at %.1f m/s): hold, skip waypoint %d\n",
					t, (linkRange-r)/st.Outward(), r, st.Outward(), next)
				d.Hold()
				sentAt = t
			}
		}
		// The operator sends the next waypoint when the vehicle reports HOLD;
		// commands go up only over a live link.
		if st.state == "up" && st.last.Mode == drone.Hold && st.last.Time > sentAt && d.Link() {
			sentAt = t
			if next < len(plan) {
				d.GoTo(plan[next])
				next++
			} else {
				d.ReturnHome()
			}
		}
		return d.State().Landed
	})
	s := d.State()
	fmt.Printf("  reached %d of %d waypoints, farthest %.1f m from home, landed %.1f m from home with %.0f%%\n",
		reached, len(plan), far, s.Pos.Horizontal().Len(), s.Battery)
	return sim
}

func main() {
	planA := []drone.Vec3{{X: 100, Y: 100, Z: 30}, {X: 240, Y: 60, Z: 30}, {X: 100, Y: -40, Z: 30}}
	planB := []drone.Vec3{{X: 100, Y: 100, Z: 30}, {X: 150, Y: 40, Z: 30}, {X: 100, Y: -40, Z: 30}}
	Check("plan A", planA)
	Check("plan B", planB)

	fmt.Println("\nflight 1: plan A anyway, the failsafe alone")
	if err := fly(planA, false).SaveAs("failsafe"); err != nil {
		log.Fatal(err)
	}
	fmt.Println("\nflight 2: plan A, the operator watching the edge")
	if err := fly(planA, true).SaveAs("operator"); err != nil {
		log.Fatal(err)
	}
	fmt.Println("\nflight 3: plan B")
	if err := fly(planB, true).Save(); err != nil {
		log.Fatal(err)
	}
}
Read the code

Plan A's farthest waypoint is 247.4 m from home against a 160 m limit, NO-GO; plan B's is 155.2 m. In flight 1 the vehicle logs 'link lost' at 38.0 s, 200.3 m out. The station learns nothing until 38.8 s (no report for 1 s, last seen 199 m out in GOTO, moving out at 7.8 m/s) and declares LINK LOST at 42.8 s, expecting the return near 50.1 s. The failsafe fires at 43.0 s, 241.3 m out; the link is restored at 49.5 s and the station sees RTL 198 m out at 49.6 s, 11.8 s after the last report. The drone reached 245.3 m, 1 of 3 waypoints, and landed at home with 74%. In flight 2 the station holds at 34.4 s, 172 m out with the edge 3.9 s away, skips waypoint 2 and finishes the rest: 2 of 3 waypoints, never beyond 176.4 m, 77%. Plan B reaches all 3, at most 155.6 m out, and lands with 78%.

05

What operators do that the failsafe cannot

The failsafe is the last line, and it ends the mission. Operators work earlier. They plan inside the tested range with a margin that covers fading and the failsafe's overshoot. They watch the trend (report age, RSSI against noise, distance and time to the edge) and pull back before the edge, as flight 2 did, keeping the rest of the mission. When the link does drop, they take their hands off: commands cannot arrive, and commands queued during the outage replay later into a situation that has changed. They note the last position, heading and time, keep visual contact where the rules require it, and announce when and where the vehicle should reappear. If it has not by then, they start the lost-aircraft procedure. When the link returns, they confirm the mode and the battery before sending anything, because the vehicle may be on its way home. And they choose the failsafe action and return altitude per site: Return over open ground, Hold or Land where the way home crosses something.

06

Fly it in GopherForge

In GopherForge choose New project > Robotics and simulation > Drone flight, replace main.go with this program and keep mission.go, then tap Run. Output lists three recordings: failsafe.gfflight crosses the dashed link circle, carries on for 5 s and turns home; operator.gfflight stops short of the circle and goes on to the last waypoint; flight.gfflight stays well inside it. Change lookahead to 1 s, or the margin to 0, and watch where the station stops the drone and how close it comes to the edge.

TAKE THIS WITH YOU

Measure the link range at each site and plan inside it with a margin for fading and for the overshoot of speed times the failsafe timeout. Let the station judge the link by the age of the last report, predict when the vehicle should reappear, send nothing while the link is down, and pull back before the edge rather than waiting for the failsafe to end the mission.

Check your understanding

A drone flies away from home at 8 m/s, loses its link 200 m out, and its failsafe returns home after 5 s without a link. Where does it start to turn back?

Go to the source

Progress stays in this browser. No account needed.