Loading…
Loading…
In this lesson, students will apply their knowledge of robot vision and AprilTag data to solve a real-world challenge.

Level: Advanced
(Note: This lesson introduces the Vision Portal and is designed for advanced users in that specific topic. It also assumes prior experience with FTC Sim. Students and teachers should have already completed the standard introductory lessons and be familiar with using the platform and programming robot movement.)
In this lesson, students will apply their knowledge of robot vision and AprilTag data to solve a real-world challenge. Unlike previous lessons where the robot responded to static tag information, students will now program their robot to monitor AprilTag properties continuously while it is in motion. Using the Vision Portal, they will track changes in location and orientation data such as distance, angle, and bearing, and use this information to make real-time decisions. This dynamic approach introduces students to more advanced autonomous behaviours, where the robot adapts its actions based on live feedback from its environment.
This lesson plan is structured using the 5E framework, a widely recognized instructional model consisting of five phases: Engage, Explore, Explain, Elaborate, and Evaluate. The 5E framework systematically engages students in inquiry-based learning, encouraging active exploration and comprehension of complex topics.
In the lesson, students will:
· Monitor AprilTag properties such as location and orientation while the robot is moving.
· Use real-time data from the Vision Portal to guide robot behaviour and solve a challenge.
· Apply functions and conditional logic to create responsive, efficient, and adaptive robot code.
Post-it notes or a brainstorming collaborative app like Microsoft Whiteboard, FigJam or Apple Freeform.
Devices for your students (Windows computers, Mac computers, ChromeBook)
Google Chrome or Microsoft Edge (Chromium version) Web Browser
Access to the FTC Simulator website (https://ftcsim.org)
Students account created for each of your students
Projector or interactive whiteboard
To spark curiosity and introduce students to how robots can respond to visual data in real time, begin the lesson by showing the video of a FIRST Robotics team demonstrating AprilTag tracking, available at this link: https://youtu.be/XA15Qq2CXY0?si=DPBT4jvFr9Edxztc. In the video, a team member moves an AprilTag around a robot, and the robot actively follows the tag based on its position and orientation.
This demonstration highlights how robots can monitor AprilTag properties such as distance, angle, and bearing while moving, and adjust their behaviour accordingly. It sets the stage for students to explore how their own robot can use live AprilTag data to make decisions during movement, leading to more advanced and adaptive autonomous behaviours.
After watching the video, invite students to participate in a brainstorming session focused on how robots can use live AprilTag data such as changing distance, angle, and orientation while moving to make smarter decisions. Provide post-it notes or use a collaborative digital tool like Microsoft Whiteboard, FigJam, or Apple Freeform. Ask students to write down one idea per post-it note that answers the question:“How could a robot use live AprilTag data while moving to solve a real-world problem?” Designate a space on the classroom wall or digital board for students to place their ideas. If a similar idea is already posted, they can stack their note on top. If it is a new idea, they should find an open spot to display it.
Here are some of the ideas that they may come up with:
A robot following a person by tracking a tag on their backpack.
A warehouse robot adjusting its path in real time to avoid obstacles while tracking a moving target.
A drone keeping a camera focused on a moving object using tag orientation.
A robot navigating a maze by continuously adjusting its direction based on tag feedback.
A delivery robot aligning itself with a moving drop-off point.
A robotic arm adjusting its grip as an object shifts position.
Facilitate a discussion by raising thought-provoking questions, including:
How can a robot use live AprilTag data to adjust its movement while navigating? (e.g., it can continuously update its direction, slow down or speed up, and stay aligned with a moving target.)
Why is it important for a robot to monitor both the location and orientation of a tag while moving? (e.g., it helps the robot stay on course, avoid drifting, and respond accurately to changes in the tag’s position.)
What kinds of challenges require a robot to react to changing tag data in real time? (e.g., following a moving object, navigating dynamic environments, or adjusting to shifting obstacles.)
How does using live AprilTag data improve a robot’s ability to solve complex tasks compared to using static data? (e.g., it allows for continuous feedback and adjustment, making the robot more adaptive and precise.)
What problems might occur if a robot does not update its tag data while moving? (e.g., it could lose track of the target, misalign its path, or fail to complete the task accurately.)
In what real-world situations could this kind of responsive robot behaviour be especially useful? (e.g., delivery robots tracking moving drop-off points, rescue robots following survivors, or drones filming moving subjects.)
Can you think of any creative or unexpected ways robots could use live AprilTag data while in motion? (e.g., robots playing tag games, guiding people through crowded areas, or adjusting lighting or camera angles during a performance.)
Encourage students to start their hands-on learning experience with the FTC Simulator platform by navigating to the provided link, 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 work surface they will need for the lesson: https://ftcsim.org/puzzle/epdxxxaqbqa/

In this FTC Sim world, zoom in on the robot to clearly show students the installed camera and omni wheels.

How many AprilTags do you see? How many AprilTags do you think your robot sees right now? What could the robot do to detect more? (e.g., the robot probably sees only one tag because the other is out of view. To detect the second tag, it would need to rotate or pivot to change its camera angle.)
Ask students to create functions for each type of movement like they did in lesson #2.
Move forward in a straight line
Move backward in a straight line
Turn left
Turn right
Slide to the right
Slide to the left
This approach allows students to call a single function whenever they want the robot to perform one of these movements, instead of rewriting the motor code each time.
Slower speeds (50% or less instead of 100%) are recommended for more accuracy. Here is an example of what their code might look like.

Remind students that just creating the functions doesn’t make the code run these functions. The functions need to be called from the main code just after the Simulator.waitForStart.

Next, your students need to create the initialization to enable the Vision Portal and AprilTag recognition. They will use the same blocks they were using in lessons 1 and 2. They need to add them to the initialization section of the code, before the call to Simulator.waitForStart(). These blocks are located in the “Vision” section.\

Depending on the students’ grade level and coding experience, you may choose to walk them through what each line of the code does. If this feels too advanced for your group, you can simply provide the full initialization block and focus the lesson on how the robot recognizes AprilTags in the next step. This allows students to engage with the core concept without getting overwhelmed by setup details.
Students should now test the code by pressing “Run”. Ask students to click the small arrow in the bottom left corner of the screen. This opens the robot’s camera view.

Next, guide students to add the “turn left” function to their code to make the robot begin pivoting in place. Once the code is updated, have them run the program and observe the camera preview window. As the robot rotates, students should see it complete a full 360-degree turn (and more), revealing its surroundings. This movement should allow the robot to see both AprilTags, which were previously out of view.

Ask students: “Why do you think these two AprilTags were placed in those specific locations?” (e.g., The first tag marks the spot where the robot needs to pick up the purple block, and the second tag shows where it should be dropped off. This helps the robot locate and position itself accurately for both actions.)
Students now need to ensure that the robot continues running while the program is active. To do this, they will use a conditional block that checks if Simulator.OpModeIsActive is true. Inside this conditional, they should place a loop that will keep executing while OpModeIsActive.

Students now need to 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 only detect one tag at a time, since the other tags are positioned behind the tower and out of view. The variable will be named AllDetections, and it will help the robot keep track of which AprilTag is currently visible.

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

Now it's time for students to determine how many AprilTags the robot is currently detecting. To do this, they should check the length of the list that stores all detected tags. This list, named AllDetections, contains every AprilTag the robot can see through its camera at that moment.
By using a block that measures the length of the list, students can find out how many tags are visible. This is a useful way to confirm whether the robot is detecting just one tag, multiple tags, or none at all, especially as it moves and its view changes.

Students should press “Run” and then click “Show Telemetry” to view the robot’s sensor data. As the robot rotates, they will notice the number of visible AprilTags changing in the Telemetry display. It may go from zero to one, then back to zero, and again to one, depending on which tag is currently in the robot’s field of view. This helps students understand how the robot’s orientation affects what it can detect.

The students can add the code to display the ID. They will need to get each tag in the list by using the For each item in list AllDectections and then use the AprilTagDetection.id.

By running the code and examining the telemetry, they should see the AprilTag ID displayed every time one is detected. Students should find that the ID for the AprilTag above the purple cube is 14 and the one above the target pad is 15.

Now, students will start to explore other information they can get from the 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 information regarding the position on the bearing:

Have students run the code and observe the Telemetry display as the robot begins turning left. As it rotates, they should pay close attention to the angle value being reported. They will notice the angle gradually changing, typically ranging from around 30 degrees to -30 degrees depending on the robot’s orientation. Guide them to recognize that when the angle value is close to zero, the robot is likely facing directly toward the AprilTags. This observation helps students understand how angle data can be used to align the robot with a target during movement.

Students should now add a conditional structure to their code that checks whether the robot’s angle is less than or equal to zero. If this condition is met, the robot should stop moving. To achieve this, students will need to create a custom stop function that sets the power of all four motors to zero, effectively halting the robot’s motion. This step helps students understand how to use sensor data to control robot behaviour in real time and reinforces the importance of using functions to keep their code organized and efficient.


Students will observe that the robot stops with the AprilTag positioned directly in the center of the camera’s field of view. At that moment, the Telemetry display should show an angle value very close to zero degrees, indicating that the robot is properly aligned with the tag. Students may notice that the angle value displayed in Telemetry is slightly below zero when the robot stops. This happens because there is a brief delay between the moment the robot detects that the bearing has reached zero and the time it applies the brake. To improve accuracy and bring the robot closer to the target angle, students could adjust the code to make the robot rotate more slowly. This would give the robot more control and reduce overshooting.

Invite students to add comments to their code to explain the various coding blocks they have used. The comment blocks are blue and can be found in the “Miscellaneous” section. Explain that software engineers work in teams and need to document their code with comments to ensure that their colleagues can understand what their code means. Here is an example of part of the code with comments.

Get students to communicate their solutions to the challenges by asking probing questions such as:
What does your robot need to know in order to align itself with an AprilTag?
How does the robot’s movement affect what it can see through the camera?
What happens to the bearing value as the robot turns? How can you use that information?
Why is it useful to monitor AprilTag data while the robot is moving instead of just once at the beginning?
How did you decide when the robot should stop turning?
What does a bearing value close to zero tell you about the robot’s position?
How did you use conditional logic to make the robot respond to sensor data?
What challenges did you face when trying to stop the robot at the right moment?
How did adjusting the speed of the robot affect its accuracy?
What does the length of the AllDetections list tell you while the robot is rotating?
How did you use the AprilTag ID to decide what the robot should do?
What other tag properties could you use to improve the robot’s performance?
Encourage students to complete the challenge by adding the final steps to their code. First, they should program the robot to move closer to the purple cube by using the range property, which indicates the straight-line distance between the robot’s camera and the AprilTag. Once the robot is close enough, they should use the claw mechanism (servo motors introduced in Lesson 1) to grab the cube.
Next, students should use the second AprilTag (ID 15) to guide the robot toward the target pad and place the cube there, successfully completing the challenge. To do this effectively, students will need to monitor and respond to specific AprilTag properties that provide valuable positioning and orientation data:
range: The straight-line distance from the camera to the center of the tag, typically measured in centimetres. This is ideal for controlling forward and backward movement.
bearing: The angle between the robot’s current facing direction and the tag. A positive value means the tag is to the right; a negative value means it’s to the left. This is useful for controlling side-to-side movement.
yaw: The rotation of the tag itself, similar to turning your head left or right. This helps the robot align itself squarely in front of the tag for precise positioning.
Assessment for this lesson should be conducted through active observation and conversation with students as they engage in coding and problem-solving. Evaluating the effectiveness of the lesson involves watching how students interact with the FTC Simulator, how they apply the Vision Portal and AprilTag recognition concepts, and how they use the various properties.
Engage students in meaningful dialogue about their thought processes, challenges, and strategies. This will help you gain insight into their understanding of how camera vision and AI influence robot decision-making. These interactions also provide opportunities to offer targeted feedback and adjust instruction to support learning outcomes.
Here is a list of "look-fors" to guide your observations and your assessment:
Engagement and Curiosity: Are students actively experimenting with live AprilTag data while the robot is moving? Are they curious about how changes in distance, angle, and bearing affect robot behaviour?
Understanding of Real-Time AprilTag Data: Can students explain how properties like range, bearing, and yaw influence the robot’s movement and alignment? Do they understand how these values change as the robot moves?
Use of Conditional Logic and Functions: Are students using conditional structures to enable the robot to respond to sensor data in real-time? Are they applying functions to organize and reuse movement and control code effectively?
Problem-Solving and Adaptation: Are students adjusting their code based on what they observe in Telemetry? Are they refining movement speed, direction, or logic to improve accuracy and responsiveness?
Use of Telemetry for Live Feedback: Are students monitoring the Telemetry display to track AprilTag properties and using that data to guide robot decisions? Are they interpreting the values correctly during motion?
Precision and Control in Movement: Are students demonstrating control over the robot’s movement by using slower speeds and fine-tuned logic to align with tags and complete the challenge?
Code Documentation and Communication: Are students adding clear and meaningful comments to explain their code? Can they articulate how their robot uses AprilTag data to make decisions?
Resilience and Iteration: How do students respond when the robot overshoots, misaligns, or fails to detect a tag? Are they persistent in testing, debugging, and improving their solution?
This approach ensures that assessment is not just about the final result, but about the process of learning, experimentation, and thoughtful application of new concepts.
C3.1 solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves conditional statements and other control structures
C3.2 read and alter existing code, including code that involves conditional statements and other control structures, and describe how changes to the code affect the outcomes
C3.1 solve problems and create computational representations of mathematical situations by writing and executing efficient code, including code that involves conditional statements and other control structures
C3.2 read and alter existing code, including code that involves conditional statements and other control structures, and describe how changes to the code affect the outcomes and the efficiency of the code
C3.1 solve problems and create computational representations of mathematical situations by writing and executing efficient code, including code that involves events influenced by a defined count and/or subprogram and other control structures
C3.2 read and alter existing code, including code that involves events influenced by a defined count and/or subprogram and other control structures, and describe how changes to the code affect the outcomes and the efficiency of the code
C3.1 solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves the analysis of data in order to inform and communicate decisions
C3.2 read and alter existing code involving the analysis of data in order to inform and communicate decisions, and describe how changes to the code affect the outcomes and the efficiency of the code
C2.1 use coding to demonstrate an understanding of algebraic concepts including variables, parameters, equations, and inequalities
C2.2 create code by decomposing 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 to represent a similar or new mathematical situation
C2.1 use variables, constants, expressions, and assignment statements to store and manipulate numbers and text in a program
C2.2 write programs that use and generate data involving various sources and formats
C2.3 write programs that include single and nested conditional statements
C2.4 write programs that include sequential, selection, and repeating events
C2.5 write programs that include the use of Boolean operators, comparison operators, text operators, and arithmetic operators
C2.6 interpret program errors and implement strategies to resolve them
C2.7 write clear internal documentation and use coding standards to improve code readability