Delivery Ops guide

A route, a clock, and a city in the way.

Multi-stop runs where the plan is the score. The individual manoeuvres are ones you already know; what these missions test is whether you sequence them without wasting altitude, distance or time.

What you will learn

  • Fly a stop list with a service pause at each one.
  • Cruise above the rooftops and descend only over a stop.
  • Spend the clock deliberately with `setSpeed()`.
  • Factor a route into functions you can reuse across missions.

Commands

Flight

await drone.moveTo(x, y, z)
Fly to an absolute point in the world, in one straight line.
await drone.setAltitude(altitude)
Climb or descend to an absolute height, holding position over the ground.
drone.setSpeed(speed)
Set the cruise speed used by every move that follows.
await drone.hover(seconds)
Hold station for a fixed time.
await drone.takeoff(altitude?)
Spool the motors and climb straight up from the pad.
await drone.land()
Descend straight down from wherever the drone currently is and settle on its landing gear.

Sensors

await drone.getBattery()
Charge remaining, as a whole percent.
await drone.getPosition()
Where the drone is now, in world coordinates.

Worked examples

A delivery run as a stop list

Every stop is the same four moves, so it is written once as a function and called per entry. The cruise altitude sits above the tallest thing on the route, and the drone only comes down when it is over a drop.

async function main(drone) {
    const CRUISE = 12;      // above the rooftops
    const DROP = 2;         // hand-off height
    const SERVICE = 1.5;    // seconds on station per stop

    const stops = [
        { name: 'depot-north', x: 10, z: -8 },
        { name: 'tower-west', x: -6, z: -20 },
        { name: 'market', x: 14, z: -26 },
    ];

    async function deliver(stop) {
        await drone.moveTo(stop.x, CRUISE, stop.z);
        await drone.setAltitude(DROP);
        await drone.hover(SERVICE);
        await drone.setAltitude(CRUISE);

        console.log('delivered', stop.name);
    }

    await drone.takeoff(CRUISE);
    drone.setSpeed(7);

    for (const stop of stops) {
        await deliver(stop);
    }

    await drone.moveTo(0, CRUISE, 0);
    await drone.land();
}

Climbing once instead of per leg

The commonest way to lose a timed route is to yo-yo: descending to each stop and climbing back to cruise between every pair. Sorting the stops so the route does not double back costs nothing and is usually worth more than raising the speed.

async function main(drone) {
    const CRUISE = 14;

    const stops = [
        { name: 'market', x: 14, z: -26 },
        { name: 'depot-north', x: 10, z: -8 },
        { name: 'tower-west', x: -6, z: -20 },
    ];

    // Nearest-first from the pad. Not the shortest possible
    // tour, but it is one line and it beats the order the
    // briefing happened to list them in.
    const ordered = [...stops].sort(
        (a, b) => Math.hypot(a.x, a.z) - Math.hypot(b.x, b.z),
    );

    await drone.takeoff(CRUISE);
    drone.setSpeed(8);

    for (const stop of ordered) {
        await drone.moveTo(stop.x, CRUISE, stop.z);
        await drone.hover(1);
    }

    await drone.moveTo(0, CRUISE, 0);
    await drone.land();
}

Checking you can finish

Charge drains faster under throttle than in a hover, and the rate belongs to the airframe you picked. Reading it between stops turns a run that dies on the last leg into one that comes home early and lands.

async function main(drone) {
    const CRUISE = 12;
    const RESERVE = 25; // percent kept back for the trip home

    const stops = [
        { x: 10, z: -8 },
        { x: -6, z: -20 },
        { x: 14, z: -26 },
    ];

    await drone.takeoff(CRUISE);
    drone.setSpeed(7);

    for (const stop of stops) {
        const charge = await drone.getBattery();

        if (charge < RESERVE) {
            console.warn('breaking off at', charge, '%');
            break;
        }

        await drone.moveTo(stop.x, CRUISE, stop.z);
        await drone.hover(1);
    }

    await drone.moveTo(0, CRUISE, 0);
    await drone.land();
}

Common mistakes

Cruise under the rooftops and the straight line finds them
`moveTo()` does not route around anything. Pick a cruise altitude above the tallest obstacle on the route and only leave it over a stop.
Hovers are on the clock
A one-second service pause at six stops is six seconds. On a timed mission that is often the whole margin.

Fly the Delivery Ops missions