Skip to content
UAVProg
Languageen
Blocks

Blocks

When it does not work

The handful of things that actually go wrong, what each one looks like from the pilot's seat, and how to fix it.

Almost everything that goes wrong with a block program is one of about eight things, and each has a signature: the aircraft does something specific and recognisable. This page is organised by what you saw, not by what the fault is called.

In the simulator, all of it costs nothing. A student who has watched each of these happen on purpose will diagnose the next one in about four seconds.

Nothing happened at all

The most likely cause is a missing active fly. It is the block that arms the motors, and until it has run every other flight block is ignored. No error appears, because nothing has gone wrong — you asked an unarmed aircraft to move and it declined.

Three blue blocks stacked: active fly, take off, land

active fly goes first. Always. It is the only block with a fixed position.

Two other things produce the same symptom:

  • The program is empty as far as the editor is concerned. Press the <> button on the right edge and read the code. If your blocks are not in there, they are not connected to anything (see below).
  • The program already ran. The Run button turns into Stop while a program is going, and back to Run when it finishes. A three-block flight is over in a couple of seconds.

It flew off and kept going

fly and rotate are switches, not steps. They start a movement and hand straight on to the next block; the aircraft keeps doing it until something stops it. If the next block is land, the drone is still travelling sideways when it touches down.

The fix is the start · wait · stop pattern:

Three blocks: fly Front speed 1, wait 2 seconds, fly Front speed Stop

The wait block is in Timing. It is what turns a switch into a step.

It moved, but only for an instant — or all at once

A stack of fly blocks with no wait between them is not four movements. Each one replaces the last, immediately, so only the final one has any duration — and it lasts until the landing.

A program with four fly blocks in a row — Front, Right, Back and Left — and no wait blocks between them

The shape almost every first attempt at a square takes. It generates four fly calls without giving each movement time. Do not expect four sides.

Generated by Blocks
drone.active_fly()
drone.takeoff()
drone.fly('forward', 1)
drone.fly('right', 1)
drone.fly('backward', 1)
drone.fly('left', 1)
drone.land()

Read those four middle lines as four instructions given in the same instant, because that is what they are. Every side needs its own wait.

It ended up somewhere strange, or would not stop turning

The two Stops do different jobs. fly with Stop stops travelling and leaves any rotation running; rotate with Stop stops the rotation and leaves any travel running. A program that starts both and stops one keeps doing the other.

A forward movement with its wait and stop, followed by a turn with its wait and stop

A movement and a rotation each have their own wait and stop.

Check movement and rotation separately. In the current simulator, yaw does not rotate the world-frame axes of the next fly command.

The Stop blocks are there but the drone still overshoots

A stop changes the requested velocity; it does not erase actual velocity immediately. Add time to slow down before the next direction or landing. A half-second pause is an example to try, not a universal braking time. Check height, wind, load and the observed movement.

The route does not close

Check both timing and coordinate frame. rotate sets a rate rather than a measured final angle. The current simulator uses world-frame fly directions, so a forward-and-turn loop does not automatically draw a square. Choose directions explicitly or use the available navigation blocks. See Turning.

A block is sitting on its own

Blocks connect by touching: the bump under one drops into the notch on top of the next, and they click together. A block dropped a few pixels clear does not click, and it stays where it is — a small separate program on the same canvas.

Active fly and take off connected, with land left unconnected beside them

Two programs, not one. The editor is perfectly happy with this.

It is worse than it looks, because a loose block does not get ignored. The editor generates code for every separate stack on the canvas, roughly top-left to bottom-right, and runs them one after another — so the loose block above runs after land:

Generated by Blocks
drone.active_fly()
drone.takeoff()
drone.land()

drone.fly('forward', 1)

Those blank lines are the giveaway. If the code pane has gaps in it, the canvas has stacks in it, and the program is not the one you drew.

To fix it: drag the loose block by its own left edge and drop it so it overlaps the block it should follow. Overlapping slightly is better than placing it neatly underneath — the editor snaps generously to an overlap and stingily to a near-miss.

The program finished and the drone is still in the air

Reaching the end of a program does not guarantee a landing. Include a landing command and observe the result; do not rely on a session timeout.

End every program with land. If one is already flying and you have no intention of editing it mid-flight, the toolbar’s Land button does the same job immediately — it stops the program and commands a landing.

It sank instead of climbing

A fresh throttle block arrives set to 0, and in this simulator adapter 0 requests descent. The value 3 requests zero vertical velocity; 6 requests climb. These are not calibrated motor-power settings for a physical drone.

throttle 4, wait 1 second, throttle 3

Climb, then hold. Throttle is a switch too — the wait is what gives it a duration.

The battery number never changes

get battery level reads the charge at the instant it runs. A loop that reads it once, before the loop, is looking at the same number on every pass forever. Put the reading inside the loop.

The same is true of every value block, and it is the one rule that catches people who already know how to program.

Still stuck?

Two tools, both already on screen.

The terminal is the black strip along the bottom. Anything the program prints goes there, and so does anything that went wrong. A print block from the Text category, dropped between two flight blocks, tells you how far the program got — which is usually all you need to know.

A print block containing the battery reading

print is the debugging block. Put one anywhere you are not sure about.

The code pane is the <> button on the right edge. One block makes one line, in the same order, so reading down the Python and reading down the stack should tell the same story. Where they stop agreeing is where the problem is.