For a teacher with a class? The classroom edition has the full plan, slides and standards.

Homeschooling PDF

Family edition

Drone Simulator: Program a Drone Through the Rings

Ages 9-14 ยท about 45 minutes, in one sitting

Your child runs a short program that flies a drone through six rings, then reads it block by block and finds that each block is a place in the sky, given as three numbers. They change one number at a time, say which ring the drone will miss before they press Run, and check. At the end you hide a bug in the program for them to find, and they hide one for you.

What you need

Before you start: try it once yourself

Fly the course and make the lesson's changes yourself once before you start, about ten minutes.

  1. Open the lesson. Go to mytekdev.com/try/dronesimulator?lesson=program-a-drone-through-the-rings&ref=fam-drone-1. The app opens on the Simulator with six orange rings. Press Run, the play button at the top left. Each ring turns green as the drone flies through it, and the counter at the top of the 3D view ends at Course Complete! with 6 / 6.
  2. Read the program. Open Blocks: arm drone, takeoff to 22, six fly to blocks, land. The first fly to block is x 0, y 70, alt 22.
  3. Miss ring 1. Change the first block's x from 0 to 30. Go back to Simulator, press reset, the circle arrow next to Run, then Run. Ring 1 stays orange, the other five turn green, and the counter stops at Gates: 5 / 6. Set x back to 0.
  4. Miss ring 3. Change the third block's x from 18 to -18, reset and Run. Ring 3 stays orange. Set it back to 18.
  5. Skip ring 4. Change the fourth block's alt from 30 to 60, reset and Run. The drone flies over ring 4. Set it back to 30.
The ring program in Blocks: when started, arm drone, takeoff to 22, six fly to blocks with their x, y and alt numbers, then land

The starter program. Each fly to block aims 10 past one ring: the rings are at 60, 120, 180, 240, 300 and 360 forward.

Run and reset are only on the Simulator tab, so after every change in Blocks, you have to switch back. A drone that was not reset starts where it last landed, at the far end of the course, and the result makes no sense. Typing in the Python tab brings up a warning that Python changes cannot be converted back into blocks; after that, Run uses the Python and ignores changes to the blocks.

The ideas, in plain words

A program is a sequence: the drone runs one block, finishes it, then runs the next, top to bottom. Each fly to block names a place in the sky with three numbers, the way a street address names a house: x is left and right, y is forward, and alt is the height. The block does not say how to get there; the drone works that out and flies straight to the spot.

Because each block names a place rather than a move, the blocks do not depend on each other. Change one block and the drone goes somewhere new for that one leg, then the next block sends it back to the next ring. That is why one wrong number leaves exactly one ring orange, and why your child can find a bug by reading: match each block to its ring and look for the number that does not fit.

Your child might askA good answer
Why is y forward and not up?Think of x and y as a map lying flat on the ground. Height gets its own number, alt.
Why does the block say 70 when the ring is at 60?It aims just past the ring, so the drone flies through it and out the other side instead of stopping in it.
Why does only one ring stay orange?Each fly to block aims at one ring. The next block still aims at the next ring, so the drone gets back on course.
Why are some x numbers negative?The middle of the course is x 0. Positive numbers are on one side of that line and negative numbers on the other, so 18 and -18 are the same distance from the middle on opposite sides.

Do it together

  1. Open mytekdev.com/try/dronesimulator?lesson=program-a-drone-through-the-rings&ref=fam-drone-1 together. The app opens on the Simulator with six orange rings. A short guide runs along the bottom; follow it together. It has your child press Run, the play button at the top left, then look in Blocks and come back to the Simulator. Then ask: how does the drone know where each ring is?

    You'll know it worked when: Each ring turns green as the drone flies through it, the drone lands, and the counter at the top of the 3D view ends at Course Complete! with 6 / 6.

  2. Open Blocks again and read the program from top to bottom together: arm drone, takeoff to 22, six fly to blocks, land. The steps run in order. The first fly to block says x 0, y 70, alt 22: x is left and right, y is forward, and alt is the height. Ring 1 is 60 forward and 22 high, and the block aims at 70 so the drone flies through the ring and out the other side.

    You'll know it worked when: Your child can point to a fly to block and say what each of its three numbers means.

  3. Change the first block's x from 0 to 30, and ask which ring will stay orange. Then go back to Simulator, press reset, the circle arrow next to Run, and press Run. Set x back to 0 afterward.

    If you get stuck: Run and reset are only on the Simulator tab, so after every change in Blocks, switch back. If the drone flies back down the course, it was not reset first.

    You'll know it worked when: Ring 1 stays orange, the other five turn green, and the counter stops at Gates: 5 / 6.

  4. Predict, then test. Find the third fly to block (x 18, y 190, alt 22) and change its x to -18. Before Run, your child writes or says which ring will stay orange. Then reset and Run, and set it back to 18.

    You'll know it worked when: Ring 3 stays orange, because the drone now flies to the other side of it, and the rings before and after still turn green.

  5. A challenge: make the drone skip ring 4 without deleting any blocks.

    You'll know it worked when: The drone misses ring 4 and passes the rest. Raising the fourth block's alt from 30 to 60 flies it over the ring, and other changes work too.

  6. Play the secret change game. One of you changes one number in one fly to block while the other looks away, and writes the change down. The other reads the blocks, says which ring will stay orange, then presses reset and Run, fixes the number and runs it again. Swap roles. The prediction always comes before Run.

    If you get stuck: Keep the secret change in Blocks. Typing in the Python tab brings up a warning, and after that Run ignores the blocks, so fixing the block changes nothing.

    You'll know it worked when: Your child names the ring before pressing Run, by matching each block to its ring. That means they can read a program and know what it will do before running it.

  7. Finish with one question: ring 2 stays orange. Which block would you check first, and why?

    You'll know it worked when: Your child says the second fly to block, because each block aims at one ring.

Talk about it

Ask these while you work together. A child who has understood the lesson can answer them without help:

The last one is the real test. A child who can read a program and predict what it will do, before running it, understands that the drone does exactly what the blocks say.

For younger and older kids

Younger: For ages 7 and 8, do the ring 3 test side by side and the ring 4 challenge together, and save the secret change game for another day.

Older: For teens, work in the Python tab and write the secret change as a line of Python. Then explain in a few sentences why each fly to aims 10 past its ring, and what would happen if it aimed at the ring's center.

Keep going

Bring it into other subjects

For your records

Ready to copy into an hour log, a portfolio or a transcript.

LessonDrone Simulator: Program a Drone Through the Rings
SubjectsComputer science, Math
Time45 minutes
What we didRead a block program that flies a drone through six rings and learned that each block names a place with three coordinates. Predicted which ring each change would make the drone miss, tested every prediction, and found and fixed a hidden bug by reading the program.
Skills practicedsequences in a program; 3D coordinates (x, y and height); predicting before running; debugging by reading code

Drone Simulator: Program a Drone Through the Rings

Activity sheet (optional)

Name: ______________________________ Date: ______________

Open the app: scan the QR code, or go to mytekdev.com/try/dronesimulator?lesson=program-a-drone-through-the-rings

Essential question: How does a program tell a drone where to fly?

  1. Run it. Press Run, the play button. Watch the six rings turn green.
  2. Read a block. Open Blocks. The first fly to block says x ____ y ____ alt ____. x is left and right, y is forward, alt is height.
  3. Reset first. Before every Run, press reset, the circle arrow, so the drone starts over.
  4. Predict, then test. For each change, write your prediction first. Then reset, Run, and write what happened. Change it back after.
ChangeI predict this ring stays orangeWhat happened
3rd fly to: x 18 to -18
My change to skip ring 4:
The secret change I found

1. How did you make the drone skip ring 4 without deleting a block?

2. Which prediction surprised you most, or was wrong? Why?

Quick check

Name: ______________________________

1. In the block fly to x 0 y 70 alt 22, what does 22 tell the drone? (A) how far forward to go, (B) how high to fly, (C) how fast to fly.

2. You change the x of the fifth fly to block and press reset and Run. What is most likely to happen? (A) the drone misses ring 5 and passes the others, (B) the drone misses every ring, (C) nothing changes.

3. Ring 2 stays orange in someone else's program. Which block would you check first, and what would you look for?

Answers

Measured in the app: changing one number in one fly to block makes the drone miss that block's ring only, and it still passes the others and lands. The first block's x changed to 30 misses ring 1; the third block's x changed to -18 misses ring 3; the fourth block's alt changed to 60 skips ring 4.

QuestionAnswerWhy
1Balt is the altitude, the height. The other two numbers are x, left and right, and y, forward.
2AEach fly to block aims at one ring. Moving that block's x sends the drone beside ring 5, and the other blocks still aim at their rings.
3The second fly to block. Look for a number that does not match ring 2: its x, its y or its altA good answer names the second fly to block and one of its numbers to check.

If your state or umbrella school asks, this lesson covers CSTA 2017 1B-AP-10, CSTA 2017 1B-AP-15, CSTA 2017 2-AP-17, Common Core Math 5.G.A.1.

The Drone Simulator is built on GEARS (GearsBot) by Cort Wee, open source under the GNU General Public License 3.0. Its blocks are Blockly, its 3D view is Babylon.js and its Python runs in Skulpt.