Loading…
Loading…
In this lesson, students will deepen their understanding of robot vision by discovering how AprilTags can provide precise spatial data.

Level: Intermediate
(Note: this lesson introduces the computer vision interface and is intended for beginners in this specific area. However, it assumes prior experience with FTC Sim. Students and teachers should have already completed the classic introductory lessons and be familiar with using the platform and programming robot movements.)
In this lesson, students will deepen their understanding of robotic vision by discovering how AprilTags can provide precise spatial data. Using the Vision Portal, students will learn to access data, such as the distance between the robot and a tag, as well as the angle at which the tag is seen. This information allows the robot to make smarter decisions about movement and positioning. Through hands-on coding challenges, students will begin programming their robot to react not only to the presence of a tag, but also to its location and orientation, enabling more advanced autonomous behaviours.
This lesson plan is structured according to the 5E instructional framework, a widely recognized teaching model that includes five phases: engage, explore, explain, elaborate and evaluate. The 5E instructional framework systematically engages students in inquiry-based learning, encouraging active exploration and understanding of complex topics.
During the lesson, students will:
Learn to extract and interpret distance and angle data from AprilTags using the Vision Portal.
Use mathematical reasoning and spatial awareness to guide the robot's movements based on the position of the tags.
Create and apply functions to organize their code and make it more efficient, reusable and easy to understand.
removable sticky notes or a collaborative brainstorming app such as Microsoft Whiteboard, FigJam or Apple Freeform.
devices for your students (Windows computers, Mac computers, Chromebooks)
Google Chrome or Microsoft Edge (Chromium version) web browser
access to the FTC simulator website (https://ftcsim.org)
"student" account created for each of your students
projector or interactive whiteboard
To spark students' curiosity and introduce them to how robots interpret their environment, begin the lesson by showing them the video "How Robots See the World " available at the following address: https://youtu.be/gEy91PGGLR0. This captivating video explains how different types of sensors, including cameras, LiDAR sensors, ultrasonic sensors and radar, allow robots to perceive distance, shape and movement. It offers a clear comparison of how each sensor works and explains why vision-based systems perform so well in robotics. This prepares students to discover how their own robot uses a camera and AprilTags to calculate distance and angle, which allows it to navigate and make decisions more intelligently. The video also helps students understand the advantages and limitations of camera vision compared with other technologies, giving them a broader perspective on how robots perceive the world.
After the video presentation, hand out removable sticky notes to your students and encourage them to take part in a brainstorming session on how robots can use information about distance and angle to make smarter decisions. Ask students to write one idea per sticky note that answers the question: "How can knowing the distance or angle to a target help a robot in the real world?" Give them a designated area on the classroom wall where they can post their ideas. Once they have come up with several ideas, ask them to gather at the sharing space to post their removable sticky notes. If an idea has already been posted on the wall, they can place theirs on top of the existing idea, whereas if the concept is not yet posted, they should find an available spot to post it.
Here are some of the ideas they might have:
A delivery robot that adjusts its path to avoid obstacles and reach a door precisely.
A warehouse robot that lines up with shelves to pick up or place items accurately.
A drone that lands safely by calculating its angle and distance from a landing pad.
A robotic arm that positions itself correctly to grab or place objects.
A robot that moves through tight spaces by adjusting its angle to fit through.
A self-driving car that maintains a safe distance from other vehicles.
A robot that guides a person by staying at a constant distance and angle.
A robot on a rescue mission that locates and safely approaches a person.
A robotic camera that adjusts its field of view to keep a moving object centred.
Lead a discussion by asking thought-provoking questions:
How can knowing the distance between a robot and an object help the robot make better decisions? (e.g., it can slow down before reaching a target, stop at the right spot or avoid collisions.)
Why might it be useful for a robot to know the angle at which it sees an object? (e.g., it can turn to face the object directly, line up to grab or scan it, or adjust its path.)
What types of tasks require a robot to be precise in both distance and angle? (e.g., picking up objects, docking at a station or navigating tight spaces.)
What are the advantages and disadvantages of using AprilTag data for positioning compared with using other sensors, such as laser scanners (Lidar) or ultrasonic sensors? (e.g., AprilTags can provide exact identification and location, whereas other sensors can only detect distance or shape.)
What challenges might a robot face when trying to measure distance or angle using a camera? (e.g., poor lighting, blurry images or an obstructed view.)
In what real-world situations might this kind of vision-based positioning be particularly useful? (e.g., warehouse automation, drone landings, robotic surgery or space exploration.)
Can you imagine creative or unexpected ways robots could use distance and angle data from visual markers, such as AprilTags? (e.g., guiding people through a building, adjusting camera angles for filming or helping robots play sports.)
Encourage students to begin their hands-on learning experience with the FTC Sim platform by going to the link provided, https://ftcsim.org/. Have them log in using their unique username and password. Once logged in, they will need to use the following link to load the workspace they will need for the lesson: https://ftcsim.org/puzzle/cihnekxklct/

In this FTC Sim world, zoom in on the robot to clearly show students the mounted camera and the omnidirectional wheels. Emphasize that the robot is not positioned directly in front of the AprilTag, but is angled slightly to the side.

Start the discussion by asking the following question: "What types of movements should the robot make to position itself directly in front of the AprilTag?" (e.g., it might need to turn slightly clockwise, slide to the left, then move forward.)
Explain to students that, because the robot uses omnidirectional wheels, each movement requires controlling four separate motors. This means a lot of code has to be written every time the robot needs to move, because each wheel must be programmed individually. Then ask: "Did you learn a way to simplify your code and reuse it more easily in the introductory lessons?" (e.g., yes, we learned to use functions to group blocks of code. This lets us create a movement once and reuse it whenever we need it, without rewriting everything.)
Show students how they can use what they learned in the first lesson on omnidirectional wheel movements to create functions for each type of movement. These functions will simplify their code and make it easier to reuse. Encourage them to create a separate function for each of the following actions:
Move forward in a straight line
Move backward in a straight line
Turn left
Turn right
Slide right
Slide left
This approach lets students call a single function each time they want the robot to perform one of these movements, instead of rewriting the motor code every time.
Here is an example of what their code might look like.

Remind students that they can create functions by going to the "Miscellaneous" section. They can give the function a meaningful name (e.g., move forward in a straight line). They must create a function for each type of movement. You may need to provide them with this table from the first lesson.

Remind students that simply creating the functions is not enough to run them. The functions must be called from the main code right after Simulator.waitForStart.

Next, your students must create the initialization to activate the Vision Portal and AprilTag detection. They will use the same blocks as those used in the first lesson. They must add them to the initialization section of the code, before the call to Simulator.waitForStart(). These blocks are found in the "Vision" section.

Depending on your students' grade level and coding experience, you may choose to explain the role of each line of code. If this seems too advanced for your group, you can simply provide the complete initialization sequence and focus the lesson on how the robot recognizes AprilTags in the next step. This lets students become familiar with the basic concept without being overwhelmed by the configuration details.
Students must now test the code by pressing "Run." Have students click the small arrow in the bottom left corner of the screen. This opens the robot's camera view. They should see the robot move and the AprilTag change position in the camera's field of view.

Students must now create a variable that will store a list of all the AprilTags the robot can see through its camera. In this simulation, the robot should detect only one tag at a time, because the other tags are positioned behind the tower and out of view. The variable will be named AllDetections and will help the robot keep track of the AprilTags currently visible.

Students must now assign a value to the allDetections variable by using AprilTagProcessor to get the list of detected tags. To do this, they must add blocks that call AprilTagProcessor and retrieve the current detections. The blocks they add to their code should look like the example below.

Students can now add a conditional structure to check how many AprilTags the robot can see by looking at the length of the AllDetections variable. If the length is greater than zero, it means at least one AprilTag has been detected. Students must then use the Telemetry display to show a message confirming that an AprilTag has been detected, as in the example below. Students may need to click "Show Telemetry" to see the data displayed by the robot.

The next step is for students to indicate which AprilTag ID the robot detects. To do this, they must create a new variable called detection. They must also simplify the code by removing the condition that checks whether an ID is detected. The new code should look like this:

From the telemetry, students should find that the ID of this AprilTag is 13. Students will now begin to explore other data they can get from AprilTag detection, such as ftcPose.x, ftcPose.y, ftcPose.z, ftcPose.yaw, ftcPose.pitch, ftcPose.roll, ftcPose.range, ftcPose.bearing and ftcPose.elevation.

Here is how they can display the data for the position on the x-axis:

Students must now try moving the robot to the left and observe how this affects the value of x. The "slide left" block is added right after Simulator.waitForStart and before aprilTagProcessor starts detection. Make sure a "slide left" function has been created. There should also be a "stop" function. Students should observe that the value gets closer to zero. They can change the slide duration in milliseconds to try to get as close to zero as possible.


Invite students to add comments to their code to explain the different coding blocks they used. Comment blocks are blue and are found in the "Miscellaneous" section. Explain that computer engineers work in teams and must document their code with comments to make sure their colleagues can understand what their code means. Here is an example of the second version of the code for the second challenge with comments added.

Have students share their solutions to the challenges by asking them reflection questions, such as:
What does the robot need to know before it can move precisely toward the AprilTag?
How does the robot use the camera to determine where the AprilTag is?
What do the ftcPose.x, ftcPose.y and ftcPose.z values tell you about the position of the tag?
What happens to the x value when the robot slides to the left? Why?
How can you use the range value to decide when the robot should stop moving forward?
Why is it useful to create functions for each type of movement?
How does using functions make your code easier to read and reuse?
How did you decide how long the robot should slide or turn to get closer to the tag?
What strategies did you use to test and adjust your code?
Encourage students to change the movements and update the information they receive from the AprilTag. For example, they could move closer or farther away to see how this affects the distance on the y-axis.

After running their experiments, they should arrive at the following conclusions about the different detection properties:
Relative Data
range: straight-line distance between your camera and the centre of the tag, usually expressed in inches or centimetres. This data is ideal for controlling forward/backward movement.
bearing: angle to the tag, measured left or right of the direction your robot is currently facing. A positive value means the tag is to the right; a negative value means it is to the left. Ideal for controlling sideways movement.
elevation: angle to the tag, measured up or down from the camera's level. Useful if you need to aim an arm or perform a lift.
3D Coordinates
These values tell you the position of the tag on a 3D grid.
x: lateral (horizontal) distance from the tag.
y: vertical (up-down) distance from the tag.
z: forward distance from the tag.
3D Orientation
These values describe the tilt or rotation of the tag itself in space.
yaw: rotation of the tag to the left or right, like when you turn your head. This is the most useful feature for lining up your robot directly in front of a tag.
pitch: rotation of the tag up or down, like when you nod your head.
roll: rotation of the tag from side to side, like when you tilt your head.
The assessment for this lesson should take place through observations and conversations with students while they code. To evaluate how effective the lesson is, observe how students interact with the FTC simulator, how they apply the Vision Portal and AprilTag recognition concepts, and how they use the different properties.
Engage students in meaningful dialogue about their thinking processes, challenges and strategies. This will help you better understand how they perceive the influence of camera vision and AI on robot decision-making. These interactions will also allow you to give targeted feedback and adapt your teaching to support learning.
Here is a list of "benchmarks" to guide your observations and assessment:
Engagement and curiosity: Are students actively exploring how the robot responds to AprilTag positioning? Are they experimenting with movements and observing changes in the distance and angle values?
Understanding of AprilTag spatial data: Can students explain what values such as ftcPose.x, ftcPose.range and ftcPose.bearing represent? Do they understand how these values relate to the robot's position and orientation?
Use of functions for movement: Are students creating and using functions to simplify their movement code? Do they understand how functions improve efficiency and readability?
Problem solving and debugging: Are students adjusting their code based on what they observe in the telemetry? Are they testing different movement durations or directions to improve tag alignment?
Use of telemetry for feedback: Are students using the telemetry display to monitor AprilTag data and make decisions based on what they see? Are they interpreting the values correctly?
Application of mathematical reasoning: Are students using their spatial reasoning and math skills to guide the robot's movement toward the tag? Can they describe how changes in movement affect the tag data?
Code documentation and communication: Are students adding meaningful comments to their code to explain the role of each part? Are they able to clearly communicate their coding choices and logic?
Response to failure and iteration: How do students react when the robot fails to detect a tag or behaves unexpectedly? Are they persistent, thoughtful and ready to revise their code?
This approach ensures that the assessment focuses not only on the final result, but also on the learning process, experimentation and the thoughtful application of new concepts.
C3.1 solve problems and create representations of mathematical situations using computational methods by writing and executing code, including code that involves conditional statements and other control structures.
C3.2 read and alter given code, including code that involves conditional statements and other control structures, and describe how changes in the code affect the outcomes.
C3.1 solve problems and create representations of mathematical situations using computational methods by writing and executing efficient code, including code that involves conditional statements and other control structures.
C3.2 read and alter given code, including code that involves conditional statements and other control structures, and describe how changes in the code affect the outcomes and efficiency.
C3.1 solve problems and create representations of mathematical situations using computational methods by writing and executing efficient code, including code that involves events influenced by a defined count and/or a subprogram and other control structures.
C3.2 read and alter given code, including code that involves events influenced by a defined count and/or a subprogram and other control structures, and describe how changes in the code affect the outcomes and efficiency.
C2.1 use coding to demonstrate an understanding of algebraic concepts, including variables, parameters, equations, and inequalities.
C2.2 create code to decompose situations into computational steps in order to represent mathematical concepts and relationships, and to solve problems.
C2.3 read code to predict its outcome, and alter code to adjust constraints, parameters, and outcomes for a similar situation or for a new situation.
C2.1 use variables, constants, expressions, and assignment statements to store and manipulate numbers and letters in a program.
C2.3 develop programs that include simple and nested conditional statements.
C2.4 develop programs that include sequential, selected, and repeated events efficiently.
C2.5 develop programs that include the use of Boolean operators, comparison operators, text operators, and arithmetic operators.
C2.6 interpret programming errors and implement strategies to correct them.
C2.7 write clear internal documentation and use coding standards to improve the readability of code.