Loading…
Loading…
Explore the world of self-driving robots through a hands-on experience with the FTC simulator in this lesson.

Level: Beginner
Explore the world of autonomous robots through a hands-on experience with FTC Sim in this lesson. This lesson focuses on the critical role of sensors in autonomous navigation, highlighting how robots use these tools to perceive their environment and make informed decisions. Students will be introduced to two types of sensors: a colour sensor and an ultrasonic (distance) sensor. Through engaging activities, they will learn to program a colour sensor to recognize and react to surfaces of different colours, an essential skill for following a path and making decisions based on visual cues. In addition, the lesson will cover how to use an ultrasonic sensor to detect obstacles and measure distances, which allows robots to avoid collisions and navigate efficiently in complex environments. By integrating these sensors, students will improve their robots' ability to manoeuvre autonomously with precision, highlighting the intersection of coding, robotics and sensor technology.
This lesson plan is structured according to the 5E instructional model, a widely recognized teaching model that includes five phases: engage, explore, explain, elaborate and evaluate. The 5E instructional model systematically engages students in inquiry-based learning, encouraging active exploration and understanding of complex topics.
During the lesson, students will:
learn to integrate and program a colour sensor in their robot design using FTC Sim, enabling the robot to detect and differentiate colours for path navigation and decision-making;
understand the functionality and application of an ultrasonic sensor for measuring distance, allowing their robots to avoid obstacles and navigate predetermined paths accurately and autonomously;
develop skills by synthesizing sensor data to make informed decisions in real time, thereby improving their robot's ability to perform complex tasks autonomously and respond to dynamic environments.
removable sticky notes or a collaborative brainstorming app such as Microsoft Whiteboard, Google Jamboard 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 capture your students' attention and spark their curiosity about autonomous robots, use your projector or interactive whiteboard to share an engaging video showing how LIDAR remote sensing is used in self-driving cars, which can be viewed at: https://youtu.be/JC94Y063x58?si=zIidADfpTlrc64LP. LIDAR is a kind of advanced radar for robots and vehicles that uses laser beams to measure the distances between objects. This technology creates a 3D map of the environment, which allows them to navigate safely without risk of collision.
After the video presentation, hand out removable sticky notes to your students and encourage them to take part in a brainstorming session on potential future applications of self-driving robots. Ask them to write only one idea per sticky note. Assign 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 in the shared space to post their sticky notes. If an idea has already been posted on the wall, they can place theirs on top of the existing one. If the concept is not yet displayed, they must find an available spot to post it.
Here are some of the ideas they may come up with:
Traffic signals (red, yellow, green lights)
Road signs (stop, yield, speed limit, construction ahead)
Lane markings (including lane changes and merges)
Pedestrians crossing the road
Other vehicles (ahead, behind and beside)
Cyclists and motorcyclists
Animals crossing the road
Traffic cones and temporary road closures
Potholes and road quality (to adjust speed accordingly)
Emergency vehicles and their warning lights
Railway crossings
Bridges and tunnels
Weather conditions (rain, fog, snow and ice on the road)
Traffic flow and traffic jams
Roadside obstacles (fallen trees, debris, etc.)
Parking spaces and the ability to park
Speed bumps and speed limits
Roundabouts and intersections
School zones and pedestrian crossings
Changes in elevation or steep slopes
Lead a discussion by asking thought-provoking questions:
Why does a self-driving vehicle need to recognize and respond to traffic signals and road signs? (e.g., recognizing traffic signals and road signs helps the vehicle follow traffic rules, make safe decisions and communicate with other drivers on the road).
How could a self-driving car detect and tell apart pedestrians and other objects near the road? (e.g., a self-driving car could use cameras and sensors to identify people and recognize their unique movements and shapes).
Why is it essential for self-driving vehicles to be aware of other vehicles around them? (e.g., being aware of other vehicles helps avoid collisions and maintain reasonable distances, which keeps traffic flowing smoothly).
How can self-driving cars adapt to different weather conditions while operating safely? (e.g., they can use special sensors and algorithms to detect rain, snow or fog and adjust their speed and behaviour accordingly).
What challenges might self-driving cars face when driving through construction zones or road closures? (e.g., self-driving cars have to identify cones, signs and temporary barriers to find the right path).
How do self-driving cars detect emergency vehicles such as ambulances and police cars, and how do they respond? (e.g., they can use sound and light sensors to recognize sirens and flashing lights and yield to these vehicles).
What role does recognizing lane markings play in the safety of self-driving vehicles? (e.g., lane markings allow the car to stay in its lane and change lanes safely, which reduces the risk of accidents).
Why is it essential for self-driving vehicles to recognize and respond to road hazards such as potholes? (e.g., detecting hazards such as potholes allows the car to adjust its speed or even steer around them, which prevents damage and ensures a smoother ride).
How could self-driving cars adapt their behaviour when driving through school zones or pedestrian crossings? (e.g., they can slow down and be more cautious to ensure the safety of children and pedestrians in these areas).
Let students know that recognition using LIDAR and cameras relies on complex algorithms and advanced coding skills. Explain that robots and self-driving vehicles also include sensors that are easier to program, such as colour sensors and ultrasonic (distance) sensors. Point out that while ultrasonic sensors work in the same way as LIDAR by measuring distances to obstacles, they use ultrasound rather than laser beams. Mention that the next lesson will focus on coding robots in FTC Sim using colour sensors and ultrasonic sensors.
Please encourage students to begin their hands-on learning experience with the FTC Simulator platform by navigating to the link provided, https://ftcsim.org/. Have them log in using their unique username and password. Once they are logged in, direct them to the "Courses" section and guide them to choose the course titled "FTC - Sensors." Explain to students that this course will help them gain the skills needed to code and control autonomous robots effectively, with a focus on using colour and ultrasonic sensors for navigation and decision-making.


In the "FTC-Sensors" section, guide students to the first challenge, titled "1- Color Sense." After they open this puzzle, prompt them to engage with the story involving Lisa and her dog, Dozer. They will be introduced to the concept of telemetry. Explain to students that telemetry in robotics is the way a robot shares data about itself, such as its position, speed and status, with its operator or a computer, just as a smartwatch tells you your heart rate or your steps.



To access the coding panel, click the green computer icon on the left side of the screen. You will notice that sample code is already there. It is essential to let your students know that this code is divided into three main sections, each marked by blue comment blocks:
Initialization blocks: This section contains the information the robot needs before it begins its tasks.
Run blocks: Most of the code you write will go in this section, where the robot's main actions are defined.
Loop blocks: These blocks are used for tasks that need to be repeated many times. The code will be placed in a loop because the robot must constantly check for colours here.


Explain that in this challenge, the robot's goal is to move until it reaches a colour code, where it must interpret the colour to decide which way to turn next. If the code is red, the robot will turn left, and if it is blue, it will turn right. Encourage students to run the code several times at first, even without adding any additional instructions, to observe how the simulator randomly selects a colour and activates the corresponding gate.

Have students begin the code to make the robot move forward, as they learned in the first lesson. Remind them to keep the loop block here.

Explain to students that they will now add telemetry to measure colours as the robot moves, using the colour sensor. Explain that the colour sensor can detect the three primary colours of light: red, green and blue. Add that these colours may differ from the ones they learned about in art class, when they learned that the primary colours of paint or ink are cyan, magenta and yellow. They should see the three primary colours of light when they open the colour sensor menu:

Explain to them that for this challenge, they need to detect the red and blue values. Since the robot must constantly look for the colour code and start turning when it reaches one of the two colours, the colour reading from the sensor must be placed in the loop. To add this, they need to go to the "utilities" section to get two "telemetry-addData" blocks. For the key, they can write a label such as "Red Value" or simply "Red" that will be displayed in the telemetry panel. Students must then add the sensor's red value as the first number and the sensor's blue value as the second number. Finally, they must update "telemetry" on each pass. Have students run the code several times and check the colour values in the telemetry panel. They may need to click "Show Telemetry" to display the values.

They should understand that when the code is red, they get a value of 255 for red and about 10 for blue. When the code is blue, they get a value of about 10 for red and 255 for blue.

To better understand sensors and colour theory, encourage students to visit the website: https://colordesigner.io/color-mixer. By pressing the (+) button, students can create their own colour mixes by changing the red, green and blue (RGB) values. They can ignore the HSL (hue, saturation, lightness) values and focus only on the RGB values. Invite students to fill in a table like this one, in which they find a colour combination that produces each of these colours. They can also create their own colours. They may be surprised that red light and green light combined produce yellow light. Point out that the minimum value is 0 and the maximum value of each colour is 255. If students want to know why 255, explain that the values 0 to 255 represent a total of 256 values, or 28. Add that values in computer science are often binary (base 2).

Explain that the next part of the code must contain a conditional statement. Add that a conditional statement is an instruction that runs a block of code only if a specified condition is true. It generally uses "if" statements (and sometimes "else" and "else if") to control the flow of a program based on Boolean expressions (true or false conditions).
Demonstrate how conditional statements are used here. The robot must turn left IF the colour sensor detects a maximum red value (255). The robot must turn right IF the colour sensor detects a maximum blue value (255). To code these conditional statements, students will need to get an "if" block and a "comparison" block from the "conditional" section. In the first part of the comparison, they must insert the colour sensor value, and in the second part, they must insert a value (from the "math" section) and type it in. In this case, they will use the maximum value of 255.
Inside each condition, they must make the robot turn left (counterclockwise) if red equals 255 or right (clockwise) if blue equals 255. The code with the two conditional structures should look like the following example:

Encourage students to try this code. They should realize that the problem now is that the robot turns in the right direction but keeps turning instead of stopping after 90°. Now that the robot turns in the right direction, the same code can be applied regardless of which condition is triggered. Explain to students that the code will now run outside the loop. This is why it is essential to exit the loop at this point. A "break out of loop" block is found in the "Loops" section and must be added to both conditions.

Explain that the next step is to add a pause long enough to let the robot complete a 90° turn. This will also depend on the speed they chose. They must find the right value through experimentation. In the following example, a 300 ms pause with a speed of 50% and -50% works. Encourage students to find the best value, either by changing the speed or by changing the pause.

All that is left is to move in a straight line to reach the flag.

Have students modify the code so that the robot stops on the mat instead of pushing against the wall.

Tell students that they will now focus on a different sensor, called the distance sensor. Encourage them to go to Challenge 7 — Distance Sensor in the sensor lessons. Show the image of a bat on the screen at the front of the class.

Use the following questions to start a class discussion.
How do bats use sound to navigate and locate objects in their environment? Describe this process in your own words and compare it to how an ultrasonic sensor works. Explain the principle of echolocation used by bats. (e.g., Bats emit high-frequency sound waves that come back to them when they hit an object. The bat then interprets these echoes to understand its surroundings, including the distance, size and even texture of the object. An ultrasonic sensor works in the same way by sending out ultrasonic sound waves and measuring the time it takes for the echoes to return, which lets it determine the distance of an object. Both systems use sound waves to map the environment without relying on light.)
Discuss the role of the delay between the emission of sound waves and their return after bouncing off objects in determining distance. How is this concept applied in ultrasonic sensor technology? (e.g., The delay between the emission of sound waves and their return is crucial for determining the distance of an object. This delay makes it possible to calculate distance based on the speed of sound. Ultrasonic sensors apply this concept by using the time interval between the emission and reception of ultrasonic waves to accurately measure an object's distance, in the same way that bats assess the distance of an object based on the time it takes for the echo to return.)
Examine the limitations and challenges bats may face when using echolocation. How can these challenges be compared to the limitations engineers encounter when designing and implementing ultrasonic sensors in devices? (e.g., One limitation of echolocation is that it can be less effective over long distances or in noisy environments, because echoes can weaken or be lost. Similarly, ultrasonic sensors may lack accuracy over long distances or in noisy environments. Both systems also have difficulty telling apart several objects that are close to one another. Engineers who design ultrasonic sensors must take these limitations into account, just as bats have evolved to optimize their echolocation abilities within these constraints.)
Bats can determine not only distance but also the size, shape and texture of objects through echolocation. Discuss how advanced ultrasonic sensors try to imitate this ability and the potential applications of this technology. (e.g., Advanced ultrasonic sensors are being developed to detect the distance of an object and gather detailed data on its size, shape and texture by analyzing the quality of the returning echo. This is how bats can discern the different features of objects through echolocation. These advanced sensors could have many applications, including in robotics for more nuanced navigation and interaction with objects, in security systems for better monitoring and in health care for non-invasive diagnostics, imitating the versatile use of echolocation by bats.)
Help students understand that in this challenge, their robot must determine the distance to the fence, which can move one way or the other. Have them run the simulation before they even start coding to see whether the fence opens or closes.

Invite students to discuss the pseudocode for this challenge:
Move the robot forward in a straight line
If the wall is less than 40 cm in front of the robot, turn left 90°.
Move forward in a straight line to reach the flag.
Students should be able to create the first part of the code (moving forward in a straight line) without difficulty. It is recommended to move forward slowly (10%) to give the fence time to open or close. They should also add telemetry to display the distance in front of the robot. A common mistake students make is using the "distance cm" block instead of the "call distance1-get distance" block. The latter is the one they should use. Their initial code should look like this:

Encourage students to run the code and show the telemetry. They should notice that the displayed distance decreases as the robot gets closer to the wall. Ask the following question:
Why doesn't the telemetry show a distance of 0 cm when the robot touches the wall? (e.g., the sensor is not located at the very front of the robot. It is about 13 cm behind the front of the robot.)
They must then add a condition. In this case, they will not need two conditional statements as with the colour sensor. They only need to determine whether the distance is less than 40 cm. The code with the condition should look like this:

Explain that the robot must now start turning left and exit the loop to complete the course. They must add a block to move at -30%/+30%, then exit the loop.

When students run this code, the robot starts turning indefinitely. They should try it several times to see the results of both scenarios.
To keep the robot from turning indefinitely, they must add a pause, then go in a straight line. They must experiment to get the right timing for a 90° angle. The following code should work for a speed of -30% and +30% and a pause of 400 ms.

Challenge your students to go get the duck for bonus points.
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 (Challenge 7 — Distance Sense) with comments added.

Have students share the solutions they found to the first two challenges by asking them reflection questions, such as:
What is the purpose of using telemetry in our robot's program? (e.g., telemetry lets our robot share data with us about its status or surroundings, such as the colours it detects, in real time. It's as if the robot is telling us what it "sees" as it moves).
Why do we place the code that reads the colour sensor values inside a loop? (e.g., the robot has to constantly check for colours while it moves. By placing the code in a loop, we make sure it keeps looking for red or blue colours until it finds them).
How does the robot decide which direction to go based on the colour it detects? (e.g., The robot uses a conditional structure to check the colour sensor values. If it detects the maximum value for red, it turns left. If it detects the maximum value for blue, it turns right).
Why is it necessary to use a "break out of loop" block after the robot has started to turn? (e.g., without the "break out of loop" block, the robot would keep checking the colour and might turn indefinitely. Breaking out of the loop lets it move on to the next part of the program after making the right turn).
How does an ultrasonic sensor determine the distance of an object? (e.g., It sends out ultrasonic waves and measures the time it takes for them to bounce back. The sensor uses that time to calculate the object's distance, much like echolocation in bats).
What is the purpose of setting a condition for the robot to turn if the distance is less than 40 cm? (e.g., this condition ensures that the robot turns to avoid hitting the wall if it is within 40 cm, which lets it navigate to the flag without crashing).
How do you determine the right pause length for the robot to make a 90-degree turn? (e.g., By experimenting. I adjust the length of the pause, keeping the robot's speed in mind, to find the right timing that lets the robot make a 90-degree turn accurately).
Why is it essential to add comments to your code? (e.g., Comments help others understand what our code does, which makes collaboration easier among team members and lets them make changes or improvements. They document our thought process and the purpose of the different parts of the code).
How can experimenting with different values in your code help improve the robot's performance on its tasks? (e.g., Experimenting with different values, such as turning speed or pause length, lets us fine-tune the robot's movements and actions, making it more efficient and more accurate in completing its tasks).
Encourage students to put the skills they have just learned into practice by solving FTC Sensors Challenges #2 and #8. In these challenges, they must deepen their understanding of how sensors work. The second challenge is similar to the first, but it involves more complex movements after reading the colour code. Challenge #8 is similar to Challenge #7, but the movement after detecting the wall is a little more complicated. Students should have all the skills required to solve this new challenge.

Assessment of the lesson should be done through observations and conversations with students as they code. Evaluating the effectiveness of the lesson should include observing students as they code and engaging in constructive dialogue with them about their thought process, their challenges and their strategies. This approach provides a better understanding of their comprehension and application of the concepts taught, including how they solve problems and refine their code to achieve the desired movements and navigation with the virtual robot. Through these interactions, educators can assess each student's understanding of the concepts, provide targeted feedback and adjust instruction as needed to support learning outcomes. Here is a list of "look-fors" to guide your observations and assessment:
Engagement and participation: Observe whether students are actively engaged in the task, experimenting with the code, taking part in discussions or asking questions.
Problem-solving skills: Note students' ability to identify problems in their code, debug errors and apply logical reasoning to overcome difficulties.
Application of instructions: Check whether students correctly apply the instructions and guidelines provided for the lesson, for example by using the right blocks or the right code syntax for movement and navigation.
Creativity and innovation: Look for creative approaches or innovative solutions that students may apply in their coding strategies, beyond the basic requirements of the lesson.
Understanding of motor commands: Observe students' understanding of how motor commands affect the robot's movement, including speed, direction and the execution of specific turns or manoeuvres.
Use of sensors: Assess how effectively students integrate and use sensors in their coding projects. This involves observing their ability to incorporate sensors for collecting environmental data (colour), detecting objects and navigating. Observe their understanding of sensor capabilities, the accuracy with which they read and interpret sensor data, and how they use it to make decisions or adjust the robot's behaviour.
Response to failure: Pay attention to how students react to failure or unexpected results, looking for resilience, persistence and a willingness to experiment and learn from mistakes.