Teacher Resources - Fly with Python Mission 11

Mission 11 Lesson Plan

Reconnaissance

Students plan a navigation route for CodeAIR and use the onboard camera to document the path, combining the state estimator, waypoints, and photography into an autonomous reconnaissance run.

⏱ 60-90 min 🎯 Grades 6-12+ 💻 CodeSpace 🚁 CodeAIR 🐍 Python
View Lesson Outline
📋

Overview

Mission 11 introduces CodeAIR's onboard camera and its state estimator, then brings the two together for a full reconnaissance run. Students start by snapping and displaying bitmap images with the camera, then send those photos to the flight recorder for later review. From there they bring in the state estimator to track the drone's (X, Y, Z) position, define waypoints, and use fly.start_linear_motion() to navigate to them with precision.

By the end of the mission, students combine both skill sets: fly to a series of waypoints, snap a photo at each one, and return the drone safely to its starting position.

🎯 Mission Goal: Students will plan a navigation route for CodeAIR and use the onboard camera to document the path.

🎯

Learning Targets

  • I can understand and utilize the state estimator to track CodeAIR's (x, y, z) position relative to its starting point.
  • I can define specific target locations called waypoints.
  • I can use the fly.start_linear_motion() function for precise control over movement in all three dimensions.
  • I can program flight paths to navigate directly to waypoints.
  • I can combine navigation and camera skills to automate reconnaissance runs, capturing photos at designated waypoints and returning to base.
💡

Key Concepts

  • The image from the onboard camera can be displayed on the console using the pipe object, just like other data collected by the drone. It can also be sent to the flight recorder and viewed after flight.
  • The drone's state estimator establishes a "home base," or starting position, the moment it initializes. All position tracking after that references this home base (X, Y, Z). During Objective 6, the drone will fly this route:
Diagram of the Objective 6 waypoint route: starting at home base (0,0), the drone flies 0.5m to waypoint 2, then 0.7m to waypoint 3

Assessment Opportunities

  • Quiz after Objective 3
  • Quiz after Objective 5
  • Complete the programs FrameGrab, SelfieCam, Recon, PositionTracking, and Waypoints
  • Mission 11 Assignment
  • Mission 11 Review Questions
☑️

Success Criteria

  • Snap a photo using the onboard camera
  • Display a photo in the data panel
  • Use a countdown timer
  • Send a photo to the flight recorder
  • Create a chart that tracks the (X, Y, Z) position of the drone
  • Navigate the drone to a specific waypoint
  • Navigate the drone through a series of waypoints and return to the starting position
🧰

Classroom Materials

  • Laptop/computer with Chrome browser
  • CodeAIR drone and USB cable
  • Meter stick for measuring distance from the starting point
  • Cards or small images for the drone to take a picture of at a waypoint. You can use the images in the Aerial Images file. Tape down the images!
🌍

Real-World Applications

🛰️Surveying drones fly planned waypoint routes to map construction sites, farmland, and disaster areas, capturing photos at each stop just like CodeAIR does in this mission.
📦Warehouse delivery drones and robots rely on the same kind of position tracking to move precisely between locations without a person steering them.
🚑Search-and-rescue drones combine navigation and cameras to fly a search pattern and photograph an area for responders, the same combination students build here.
🚀

Extensions & Cross-Curricular

ExtensionTry different altitudes and speeds for the drone. What combination works best?
ExtensionDesign a more complex reconnaissance path with multiple waypoints.
ExtensionProgram CodeAIR to take pictures from different angles at each waypoint.
ExtensionUse the rangers in combination with the camera during a planned flight - for example, take a picture when close to an object, or at a specific distance.
MathThis mission uses the Pythagorean Theorem for measurement. Discuss other ways the theorem can be used, and other methods for calculating a measurement.
Visual ArtsThis mission uses the onboard camera to take low-res images. Discuss pixels and bitmaps, then have students create a bitmap image using only grid data and have another student interpret the bitmap into an actual image.
ScienceThis mission uses math to calculate a velocity for (X, Y). Discuss velocity and how it is measured, then try some experiments with objects to calculate their velocity.
Lang ArtsWrite a technical paper that describes how to navigate the drone through a series of waypoints.
🔤

Vocabulary

Bitmap - A 2D image with a given width and height stored in a grid of pixel color values, one value per (x, y) location.
Pixel - Small dots, or tiny squares, that make up all images and text (short for "picture element").
State Estimator - CodeAIR's sensor that acts as a built-in mapping system, measuring movement along the X, Y, and Z axes.
Embedded Data Pipe - An object that sends data to the CodeSpace Data Panel, useful for visualizing sensor readings, displaying images, or sending custom text messages during program execution.
Waypoint - A specific target location defined by coordinates.
🐍

New Python Code

bitmap = camera.take()Returns a bitmap image from the camera.
pipe.image(bitmap)Displays the bitmap image to the console data panel.
trigger_beep(sm)Call a function using the state machine object as the argument.
speaker.beep(500, 0)Turn on the speaker and leave it on.
sm.schedule(speaker.off, 0.3)Schedule the speaker to turn off after 0.3 seconds.
sensor_data = get_data(STATE_EST_POS, wait=False)Uses the STATE_EST_POS sensor to get the drone's estimated position in 3D space.
fly.start_linear_motion(0.2, 0.1, 0)Fly the drone forward with specific intended velocities for x, y, and z. This enables movement in any direction.
dist = math.sqrt(x_diff**2 + y_diff**2)Calculate the distance to the next waypoint.
velocity_x_m = (x_diff/dist)*MAX_VEL
velocity_y_m = (y_diff/dist)*MAX_VEL
Shrink the triangle down to a unit vector, a single step in the right direction.
📐

Standards

CSTA Standards - Middle School

MS-ALG-PS-01 MS-ALG-PS-03 MS-PRO-PD-12 MS-PRO-PD-13 MS-PRO-VD-16 MS-PRO-RD-17 MS-PRO-TR-19 MS-SYS-HW-31 MS-SOC-CE-44

CSTA Standards - High School

HS-ALG-PS-01 HS-ALG-PS-02 HS-PRO-PD-12 HS-PRO-PD-13 HS-PRO-VD-16 HS-PRO-RD-17 HS-PRO-TR-19 HS-DAT-CD-22 HS-DAT-DI-25 HS-SYS-HW-30 HS-SOC-CE-45 HS-SOC-CD-46

CSTA Standards - Physical Computing

S1-PHY-1O-02 S1-PHY-DD-03 S2-PHY-1O-02 S2-PHY-DD-03
📝
Preparing for the Lesson
  • Reserve space with good lighting for the camera and reconnaissance activities - low light makes photos harder to see clearly.
  • Charge all CodeAIR drones fully and have spare batteries ready.
  • Print or prepare the images from the Aerial Images file and plan where you'll tape them down before class - you'll need at least two locations for the waypoint objectives.
  • Have a meter stick ready so students can measure distance from the drone's starting point.
  • Be familiar with the five programs (FrameGrab, SelfieCam, Recon, PositionTracking, Waypoints) and the assignment and review questions before class.

🧑‍🏫
Teacher Notes
  • The onboard camera isn't high resolution, but it takes fairly clear images. Students can download an image from the console and copy/paste it into the assignment document.
  • Objective 1: for best results, use good lighting with high contrast between the background and the object being photographed. For more on bitmaps, click the tool link in Objective 1. Clear the console data panel with "Clear Data" as needed.
  • Objective 3: place the drone on a picture (like the "H" image in the Aerial Images document) so it photographs something other than the floor.
  • Objective 3: the beep is very difficult to hear. Increasing altitude to 0.2 gives a little more height, but the beep is still hard to hear.
  • Objective 4: if students don't clear the data, the chart displays beneath the images. The assignment asks students to paste a snippet of their graph in the document - review how to take a screenshot if needed.
  • Objective 5: the code starts the same as Recon - students can use File > Save As instead of copying and pasting the starting code.
  • Objective 5: use the first image in the Aerial Images document as the drone's starting position, then measure half a meter forward and to the left. Tape the second image from the document at that spot. Students can try different altitudes and snap several images to get a picture of the taped image.
  • Objective 6: refer to the diagram in the Key Concepts section for positioning the navigation waypoints.
  • Extensions and cross-curricular projects are included to enhance the concepts in the mission. You can use the extensions to extend students' programming experience. A remix is planned after Mission 14.
🗺️

Lesson Outline

🗣️Warm-up / Hook

Students access prior knowledge by answering questions in the pre-mission section of the assignment doc.

  • Ask: "If you wanted to give someone directions using only distances and directions from a starting point, what information would you need?"
  • Ask: "How is taking a photo with your phone similar to what CodeAIR's onboard camera does?"
Teaching tip: Frame the mission as a "flying spy game" - reconnaissance means gathering information (photos) while flying a planned route, not just flying for its own sake.
📖Introduce the Mission

Front-load the key new programming concepts before students start coding.

  • Introduce camera.take() and pipe.image() - snapping and displaying a bitmap image on the console.
  • Introduce the state estimator and the "home base" concept - explain that all (X, Y, Z) position tracking is relative to where the drone starts.
  • Introduce waypoints and fly.start_linear_motion() for controlled movement toward a target.
  • Preview the math in Objective 6 - using the Pythagorean Theorem to find distance, then shrinking that direction down to a unit vector to set a steady velocity.
  • Set expectations: five programs across six objectives, with quizzes after Objective 3 and Objective 5.
Teaching tip: The unit-vector math in Objective 6 can be a stretch for some students. Focus on the concept, shrinking a direction down to a fixed speed, rather than the derivation, unless you want to go deeper with a higher-level class.
💻Coding Time

Students build five programs that progress from camera basics to full waypoint navigation. As they work through the objectives, they should take notes and answer questions in their assignment doc.

  1. FrameGrab - snap a photo with camera.take(), display it with pipe.image(), and use a countdown timer before the photo.
  2. SelfieCam - send the photo to the flight recorder so it can be reviewed after the flight.
  3. Recon (quiz after Objective 3) - combine the camera with a beep alert into a simple reconnaissance routine.
  4. PositionTracking - use get_data(STATE_EST_POS) to chart the drone's live (X, Y, Z) position.
  5. Waypoints (quiz after Objective 5) - define a waypoint and use fly.start_linear_motion() to navigate directly to it.
  6. Waypoints, continued - extend the program to fly through a series of waypoints, snap a photo at each one, and return to home base.
Teaching tip: Warn students ahead of time that the Objective 3 beep is quiet, so they don't think their code failed.
Teaching tip: Have students test each waypoint objective in a clear, consistent space so their distance measurements stay accurate from run to run.
🧑‍🤝‍🧑Class Debrief

Bring the class together to connect the camera and navigation skills from this mission.

  • Ask: "What does the state estimator's 'home base' actually track, and why does it matter for navigation?"
  • Ask: "Why do we need to shrink our direction down to a unit vector before setting the drone's velocity toward a waypoint?"
  • Ask: "What real-world jobs need both navigation and photography skills, like this mission combines?"
Teaching tip: Connect back to the Real-World Applications section - surveying and search-and-rescue drones use this exact combination of navigation and photography.
✏️Wrap-up & Review

Students answer the reflection question in the assignment doc and then submit.

Use the Mission 11 Review Questions through a preferred method - class discussion, Kahoot!, or LMS quiz.

Teaching tip: Waypoint navigation is the foundation for Missions 12 and 13, where the drone starts navigating using the camera instead of coordinates. Make sure the "fly toward a target" concept sticks before moving on.