Loading…
Loading…
Dive deeper into precision movements with this FTC simulator lesson, focusing on complex motion control using rotary encoders.

Level: Intermediate
Discover precision movement with this FTC Sim lesson, which focuses on complex movement control using rotary encoders. This lesson moves from traditional motor commands to the precise operation of rotary encoders, giving students hands-on experience programming for precision. They will learn the fundamentals of encoder integration and explore how to program these motors to control robot parts with a high degree of accuracy. Through practical exercises, students will master the art of using encoders for detailed tasks, such as precise positioning and controlled movements, thereby improving their robots’ capabilities.
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:
Understand the operating principles of rotary encoders and their advantages in robotics.
Program rotary encoders in FTC Sim to achieve precise control of robot movements.
Improve problem-solving skills by tackling real-world scenarios that require precise movement and control.
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 precise driving, use your projector or interactive whiteboard to share an engaging video showing autonomous driving robots like those used in a warehouse, which can be viewed at this link: https://youtu.be/a77XyUI-zXo?si=iDntZW7R-a3kjbZO. Online retailers use highly precise robots in their warehouses to make sorting and transporting goods easier. They use advanced navigation and handling technologies to pick, pack and sort items with remarkable speed and accuracy. In addition, a video showing a robot manoeuvring on Mars could highlight the critical importance of precise navigation in such environments: https://youtu.be/P4boyXQuUIw?si=Cd-yrCe31Ow13HO4.
After the video presentation, hand out sticky notes to your students and encourage them to brainstorm different applications for highly precise robots. Their ideas can focus on the precision of the drivetrain or the precision of a robotic arm. Ask them to write only one idea per removable 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 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 isn't posted yet, they must find an open spot to display it.
Here are some of the ideas they may come up with:
Precision-guided drones for agriculture.
Robotic surgical assistants.
Autonomous underwater exploration vehicles.
Precision-guided warehouse robots for inventory management.
Automated quality control robots in manufacturing.
Precision-guided robotic arms for 3D printing.
Self-driving cars with advanced navigation systems.
Precision-guided delivery drones.
Robotic companions for seniors or people with disabilities.
Precision-guided robots for sorting recyclable materials in waste management.
High-precision robot chefs for cooking tasks.
Automated window-cleaning robots for skyscrapers.
Landscaping robots for precise lawn and garden maintenance.
Robotic arms for assembling microelectronic products.
Autonomous robots for handling hazardous materials.
Robotic pharmacists for precise medication dispensing.
Assisting with assembly tasks in manufacturing plants
Loading and unloading cargo on ships or planes
Assisting with rescue operations in disaster zones
Assisting with space exploration missions, such as repairing satellites or spacecraft.
Lead a discussion by asking thought-provoking questions:
How does precision in robotics affect safety and efficiency in industrial environments? (e.g., precision in robotics can significantly increase safety by reducing human exposure to dangerous tasks and environments. It also improves efficiency by allowing tasks to be completed faster and with fewer errors, which can lead to cost savings and increased productivity).
How could precision robotics transform health care, particularly surgical procedures? (e.g., precision robotics could revolutionize health care by performing surgeries with a level of accuracy that minimizes risks and improves patient outcomes. They can operate in small areas without the fatigue or tremor issues that humans may experience, which could reduce recovery times and complications).
How can precision robotics advance space exploration, and what challenges need to be addressed? (e.g., precision robotics can withstand the harsh conditions of space and perform tasks accurately in environments too dangerous for humans. They can repair satellites, explore planetary surfaces for signs of life and build habitats. The main challenges are ensuring they can operate autonomously and withstand extreme temperatures and radiation).
Consider the role of precision robotics in disaster response. How could it be used, and what are its limitations? (e.g., robots can navigate through rubble, detect the heat signatures of survivors and provide assistance in disaster zones where human intervention is too risky. However, their effectiveness is limited by battery life, the need for remote control or autonomous operation, and their ability to adapt to unpredictable environments).
How could precision robotics change the future of personal transportation? (e.g., precision robotics could lead to fully autonomous vehicles, reducing accidents caused by human error and optimizing traffic flow. The challenge will be creating systems that can safely interact with human-driven vehicles and pedestrians, and resolving the legal and insurance issues related to autonomy).
Can precision robotics lead to new forms of art and creative expression? (e.g., artists can use precision robotics to explore new media and techniques, pushing the boundaries of traditional art forms. Robots can execute intricate designs with exact precision, making it possible to create complex sculptures, paintings and installations that reflect the fusion of technology and creativity).
Explain that robots and autonomous vehicles often need very precise movements when navigating complicated terrain. Mention that the next lesson will focus on coding robots in FTC Sim using encoders instead of relying on power and time.
Please encourage students to begin their hands-on learning experience with the FTC Sim platform by navigating to the link provided, https://ftcsim.org/. Ask them to log in using their username and password. Once logged in, direct them to the "Courses" section and guide them to select the course titled "FTC Movement." Explain to students that this course will help them gain the skills needed to code and effectively control autonomous robots, with a focus on using rotary encoders for movement.


In the FTC Movement section, guide students to the challenge titled "5— Options"


Before students begin coding, it is essential to clarify the movement mechanisms used in the first three lessons. These movements rely on power (or speed) and time settings. Specifically, the operation involved setting the power of both the left and right motors within a range of values from 0 to 1.0, combined with a set duration controlled by the sleep block. However, it is important to recognize a drawback of this approach to movement: external factors that influence the rotation of the wheels can cause variations in the actual distance the robot travels. For example, differences in surface conditions, such as slipperiness or the presence of dust particles, can hinder the robot's speed and cause it to travel a shorter distance than expected in the allotted time. Factors such as a low battery can also affect motor speed, further contributing to deviations from the expected distance.
Explain that this time, rotary encoders will be used instead of power and time to solve the challenge. Add that rotary encoders are sensors that track and measure the rotation of an object, generally used to determine the position, speed and direction of rotation of a shaft or wheel. Explain that by using an encoder, you can get the exact number of wheel rotations you want.
To access the coding panel, click the green computer icon on the left side of the screen. You will notice that some 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 starts its tasks.
Run blocks: Most of the code you write will be placed 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. However, for this lesson, we will only work with the initialization and run blocks. The loop section can be deleted to keep the code structure cleaner.


Explain that in this challenge, the robot's goal is to move in a straight line, then turn right 90 degrees, and finally move in a straight line to reach the final location to raise the flag. Show students how the robot will move to form an L-shaped path.

Ask students to practise using rotary encoders to move different distances. Explain to them that to use an encoder, they must first set the run mode of their wheel to "RUN_TO_POSITION." Next, they must set the target position for each wheel. Then, the robot will move to the specified position by starting the wheel at the desired speed.

Add that the wait at the end of the code gives the robot time to complete the movement, but does not affect the distance the robot travels. Ask students to describe what the robot does when the following variables are changed:

Students should reach the following conclusions:

Students should know that 1440 ticks is considered one wheel turn. Here is an example of the distance travelled with one wheel rotation, or a position of 1440 ticks.

Ask students to find the exact distance they need, through trial and error, to get to the end of the L and get ready to turn right. They should find a value between 6,000 and 6,500 ticks.


Explain that after a movement, the encoders must be reset for the next movement. Then, the code to make the robot turn 90˚ can be added. In this case, the target position of the left wheel will be positive, and the target position of the right wheel will be negative. The left wheel will move forward and the right wheel will move backward, which will cause the robot to turn right. The wheel speed will also need to be set as positive for the left wheel and negative for the right wheel.


Next, add a wait (sleep) block long enough for the robot to complete a full 90˚ turn. Students may want to adjust the first pause, because with a 5-second pause, the robot may wait too long before turning.

Encourage students to finish solving the challenge by going in a straight line. They will need to reset the encoder, set the target position to two positive values, and add two positive values for the speed of each wheel. This should allow them to reach the final location to raise the flag.

This sample code brings the robot to the final pad.

Once students have successfully completed the challenge, encourage them to add code to pick up the duck as a bonus.
Demonstrate how to create functions to break up the code. Explain that this code can be divided into three parts:
Move forward 6300 ticks
Turn right 90˚
Move forward 3500 ticks
Explain that functions are available in the "Miscellaneous" section under the name "RobotFunctions." Invite students to drag out three functions and rename them by changing the text "do something"

Next, for each function, encourage students to add the corresponding code.

Nothing will happen when students try the code because the main code is empty. Encourage students to add the three functions in order in the main code.


Encourage students to recognize that the code works the same way as the previous iterations, but with significantly improved readability and organization, which greatly simplifies debugging and modifications.

Encourage your students to move on to the next challenge in the "FTC-Movement: 6-Square" section

Explain to them that in this challenge, they will need to move the robot in the shape of a square. They should realize that this is essentially the same challenge as the L challenge, but that it must be repeated several times.

Ask students to think about the pseudocode for getting the robot to this position. Explain that pseudocode is a simplified, informal way of programming that describes an algorithm without using the syntax of a specific coding language.
Move in a straight line
Turn right 90
Move in a straight line
Turn right 90
Move in a straight line
Turn right 90°.
Move in a straight line for a shorter distance than the first three.
Ask students to recognize the patterns. They should realize that instead of coding repeatedly, they can use a loop to repeat specific steps. Ask them to do the first part, which is to move in a straight line and turn right 90 degrees. They can use what they learned in the previous challenge to solve this one more quickly. Here is an example of working code.

Students should now conclude that at this point, the robot only has to move forward a short distance. By adding this code outside the loop (because this last segment does not need to be repeated), the robot should end up on the final pad and raise the flag.


Please encourage students to begin their hands-on learning experience with the FTC Sim platform by navigating to the provided link, https://ftcsim.org/. Ask them to log in using their username and password. Once logged in, direct them to the "Courses" section and guide them to select the course titled "FTC Movement." Explain to students that this course will give them the skills they need to code and control autonomous robots effectively, with a focus on using rotary encoders for movement.


In the FTC Movement section, guide students to the challenge titled "5— Options"


Before students start coding, it is essential to clarify the movement mechanisms used in the first three lessons. These movements rely on power (or speed) and time settings. More specifically, the operation consisted of setting the power of both the left and right motors within a range of values between 0 and 1.0, combined with a designated duration controlled by the sleep block. However, it is essential to recognize a drawback of this approach to movement: external factors that affect wheel rotation can cause variations in the actual distance the robot travels. For example, differences in surface conditions, such as slipperiness or the presence of dust particles, can hinder the robot's speed and cause it to travel a shorter distance than expected in the allotted time. Factors such as a low battery can also affect motor speed, further contributing to deviations from the expected distance.
Explain that rotary encoders will be used this time instead of using power and time to solve the challenge. Add that rotary encoders are sensors that track and measure the rotation of an object, generally used to determine the position, speed and direction of rotation of a shaft or wheel. Explain that by using an encoder, you can get the exact number of wheel rotations you want.
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 starting its tasks.
Run blocks: Most of the code you write will be placed in this section, where the robot's main actions are defined.
Loop blocks: These blocks are used for tasks that need to be repeated several times. However, for this lesson, we will only work with the initialization and run blocks. The loop section can be deleted to keep the code structure cleaner.


Explain that in this challenge, the robot's goal is to move in a straight line, then turn right 90 degrees, and finally move in a straight line to reach the final location in order to raise the flag. Show students how the robot will move to form an L-shaped path.

Ask students to practise using the rotary encoders to move different distances. Explain that to use an encoder, they must first set the run mode of their wheel to "RUN_TO_POSITION." Next, they must set the target position for each wheel. Then, the robot will move to the specified position by starting the wheel at the desired speed.

Add that the wait at the end of the code gives the robot time to complete the movement, but does not affect the distance the robot travels. Ask students to describe what the robot does when the following variables are changed:

Students should reach the following conclusions:

Students should know that 1440 ticks is considered one wheel revolution. Here is an example of the distance travelled with one wheel rotation, or a position of 1440 ticks.

Ask students to find the exact distance they need, through trial and error, to reach the end of the L and get ready to turn right. They should find a value between 6,000 and 6,500 ticks.


Explain that after a movement, the encoders must be reset for the next movement. Then, the code to make the robot turn 90˚ can be added. In this case, the target position of the left wheel will be positive, and the target position of the right wheel will be negative. The left wheel will move forward and the right wheel will move backward, which will make the robot turn right. The wheel speed will also need to be set as positive for the left wheel and negative for the right wheel.


After adding a wait (sleep) block long enough for the robot to complete a full 90˚ turn. Students may want to adjust the first pause, because with a 5-second pause, the robot may wait too long before turning.

Encourage students to finish solving the challenge by going in a straight line. They will need to reset the encoder, set the target position to two positive values, and add two positive values for the speed of each wheel. This should allow them to reach the final location to raise the flag.

This sample code brings the robot to the final pad.

Once students have successfully completed the challenge, encourage them to add code to pick up the duck as a bonus.
Demonstrate how to create functions to segment the code. Explain that this code can be divided into three parts:
Move forward 6300 ticks
Turn right 90˚
Move forward 3500 ticks
Explain that functions are available in the "Miscellaneous" section under the name "RobotFunctions." Invite students to drag out three functions and rename them by changing the text "do something"

Next, for each function, encourage students to add the corresponding code.

Nothing will happen when students try the code because the main code is empty. Encourage students to add the three functions in order in the main code.


Encourage students to recognize that the code works the same way as the previous iterations, but with significantly improved readability and organization, which greatly simplifies debugging and modifications.

Encourage your students to move on to the next challenge in the "FTC-Movement: 6-Square" section

Explain to them that in this challenge, they will need to move the robot in a square shape. They should realize that it is essentially the same challenge as the L challenge, but it must be repeated several times.

Ask students to think about the pseudocode needed to bring the robot to this position. Explain that pseudocode is a simplified, informal programming method that describes an algorithm without using the syntax of a specific coding language.
Move in a straight line
Turn right 90
Move in a straight line
Turn right 90
Move in a straight line
Turn right 90°.
Move in a straight line for a shorter distance than the first three.
Ask students to recognize the patterns. They should realize that instead of coding repeatedly, they can use a loop to repeat specific steps. Ask them to do the first part, which involves moving in a straight line and turning right 90 degrees. They can use what they learned in the previous challenge to solve this one more quickly. Here is an example of working code.

Students should now conclude that at this point, the robot only needs to move forward a short distance. By adding this code outside the loop (because this last segment does not need to be repeated), the robot should end up on the final pad and raise the flag.


Invite students to add comments to their code to explain the different coding blocks they used. Comment blocks are blue and are available 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 6 — Square) with comments added.

Have students share the solutions they found for the first two challenges by asking them reflection questions, such as:
What is the benefit of using rotary encoders? (e.g., Rotary encoders track and measure rotation, which allows precise control of the robot's position, speed and direction of movement).
Why is code organization important when coding? (e.g., Organized code improves readability and makes it easier for programmers to debug and modify the code).
How do external factors affect the movement of robots, and how can rotary encoders address these challenges? (e.g., External factors such as surface conditions and battery levels can affect the robot's movements. Using tools such as rotary encoders helps ensure accurate navigation despite these challenges).
What is the role of functions in coding? (e.g., Functions break code into reusable blocks, which promotes modularity and simplifies complex tasks into manageable components).
Encourage students to put the skills they have just learned into practice by tackling FTC Movement Challenges #7 and #8. In these challenges, they must deepen their understanding of coding operations and robot movements. Although Challenges #7 (Turn Test) and #8 (Helix) are similar to the two puzzles solved in this lesson, they involve harder angles than a 90˚ turn. They will also involve moving in a straight line over different distances.

The lesson should be assessed through observations and conversations with students while they code. Assessing the effectiveness of the lesson should include observing students as they code and engaging in constructive dialogue with them about their thought process, challenges and 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 movement 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 "benchmarks" 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 might 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 rotary encoders: Assess students' proficiency in using rotary encoders to achieve precise movement control, including setting target positions, adjusting speed and resetting encoders for subsequent movements.
Use of functions: Assess students' ability to effectively implement functions to segment code, promote code reuse and improve code readability, demonstrating an understanding of the principles of modular programming.
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.