As you start building more advanced coding projects that involve robot-to-robot communication, things might not always go as planned — and that’s okay! That's where troubleshooting and error handling come in. Sometimes your robots might not respond the way you expect, or they might seem like their messages aren't getting through to each other at all.
In this lesson, you will learn the difference between troubleshooting and error handling. You will also learn some strategies for both, so you can more easily find and fix problems with your code.
Troubleshooting
Watch the video below to learn:
- That troubleshooting can help you find bugs in your project and fix them.
- Some strategies for troubleshooting robot-to-robot messaging projects, such as
- How to use a visual cue, like printing to the robot's screen, to ensure your receiving robot is getting all messages from the sending robot.
- How to use a visual cue, such as an emoji, to show if a robot is waiting for a message or working on a task after getting one.
Now that you have watched the troubleshooting video, capture your thoughts in your journal. Answer these questions to guide your thinking and help you get ready for a whole-class discussion:
- How would the strategies in the video make it easier to find and fix bugs in your projects?
- What did you see in the video that you think will help you to troubleshoot your projects?
- What questions do you have about troubleshooting your robot-to-robot messaging projects?
Watch the video below to learn:
- That troubleshooting can help you find bugs in your project and fix them.
- Some strategies for troubleshooting robot-to-robot messaging projects, such as
- How to use a visual cue, like printing to the robot's screen, to ensure your receiving robot is getting all messages from the sending robot.
- How to use a visual cue, such as an emoji, to show if a robot is waiting for a message or working on a task after getting one.
Now that you have watched the troubleshooting video, capture your thoughts in your journal. Answer these questions to guide your thinking and help you get ready for a whole-class discussion:
- How would the strategies in the video make it easier to find and fix bugs in your projects?
- What did you see in the video that you think will help you to troubleshoot your projects?
- What questions do you have about troubleshooting your robot-to-robot messaging projects?
After students watch the video and before practicing, come together for a whole-class discussion. Use student answers to the questions provided as the basis for discussion.
While the terms "bug" and "error" are often used interchangeably in casual conversation, they refer to slightly different concepts in computer science.
- A bug is an unexpected behavior or a flaw in the logic of the program that causes the robot to behave in an unexpected manner.
- An error is a problem that often prevents the code from running at all.
You may want to create a T-chart for this lesson, comparing and contrasting definitions and strategies for troubleshooting and error handling. Students can add to it as their understanding develops throughout this lesson.
Error Handling
Next, watch the video below about error handling in robot-to-robot messaging projects to learn:
- That error handling can help you to plan ahead to manage problems with your coding projects.
- How to use the if/else if/else block with a visual cue (like an emoji) to build error handling into your messaging projects.
Now that you've watched the error handling video, capture your thoughts in your journal. Answer the following questions to guide your thinking and help you get ready for a whole-class discussion.
- What differences did you notice between the strategy for error handling and the strategies for troubleshooting?
- How does adding the if/else if/else block help make the project run more smoothly?
- What questions do you have about error handling?
Next, watch the video below about error handling in robot-to-robot messaging projects to learn:
- That error handling can help you to plan ahead to manage problems with your coding projects.
- How to use the if/else if/else block with a visual cue (like an emoji) to build error handling into your messaging projects.
Now that you've watched the error handling video, capture your thoughts in your journal. Answer the following questions to guide your thinking and help you get ready for a whole-class discussion.
- What differences did you notice between the strategy for error handling and the strategies for troubleshooting?
- How does adding the if/else if/else block help make the project run more smoothly?
- What questions do you have about error handling?
After students watch the video and before practicing, come together again for a whole-class discussion. Use student answers to the questions provided as the basis for discussion.
Add students' thoughts about error handling to the T-chart for students to refer to throughout the rest of the Unit.
Guided Practice
Now that you have watched and discussed the videos, it is time to practice. You will be given several robot-to-robot messaging projects that have bugs or errors. Collaborate with your partner group to find and fix them.
- You can use the troubleshooting and error handling strategies shown in the videos, or incorporate some of your own.
- Bugs/Errors can be in the sending project, the receiving project, or both.
Use the task card (Google / .docx / .pdf) to guide your practice. For each set of projects below, collaborate to:
Step 1: Download the set of projects to each robot.
Step 2: Place the objects needed on the field as shown in the table below. If an AprilTag ID is used, ensure that it is positioned so the robot can detect it.
Step 3:
- Run the projects and observe the behavior of the robots.
- Read the project code for both projects.
- Identify and Fix the problem.
- Run the project again to test.
- Iterate as needed until the project runs as intended.
Projects for Guided Practice:
| Project | Objects Needed on Field | Robot S (Sending) | Robot R (Receiving) |
| 1 | 1 Orange Barrel 1 Blue Barrel AprilTag ID 0 | Project 1 - Sending | Project 1 - Receiving |
| 2 | 1 Sports Ball AprilTag ID 0 | Project 2 - Sending | Project 2 - Receiving |
| 3 | None | Project 3 - Sending | Project 3 - Receiving |
| 4 | 1 Blue Barrel | Project 4 - Sending | Project 4 - Receiving |
| 5 | None | Project 5 - Sending | Project 5 - Receiving |
Resources for Practice:
The resources linked here are available if you need additional support while completing the activity.
Now that you have watched and discussed the videos, it is time to practice. You will be given several robot-to-robot messaging projects that have bugs or errors. Collaborate with your partner group to find and fix them.
- You can use the troubleshooting and error handling strategies shown in the videos, or incorporate some of your own.
- Bugs/Errors can be in the sending project, the receiving project, or both.
Use the task card (Google / .docx / .pdf) to guide your practice. For each set of projects below, collaborate to:
Step 1: Download the set of projects to each robot.
Step 2: Place the objects needed on the field as shown in the table below. If an AprilTag ID is used, ensure that it is positioned so the robot can detect it.
Step 3:
- Run the projects and observe the behavior of the robots.
- Read the project code for both projects.
- Identify and Fix the problem.
- Run the project again to test.
- Iterate as needed until the project runs as intended.
Projects for Guided Practice:
| Project | Objects Needed on Field | Robot S (Sending) | Robot R (Receiving) |
| 1 | 1 Orange Barrel 1 Blue Barrel AprilTag ID 0 | Project 1 - Sending | Project 1 - Receiving |
| 2 | 1 Sports Ball AprilTag ID 0 | Project 2 - Sending | Project 2 - Receiving |
| 3 | None | Project 3 - Sending | Project 3 - Receiving |
| 4 | 1 Blue Barrel | Project 4 - Sending | Project 4 - Receiving |
| 5 | None | Project 5 - Sending | Project 5 - Receiving |
Resources for Practice:
The resources linked here are available if you need additional support while completing the activity.
Distribute the task card (Google / .docx / .pdf). As students collaborate to fix the projects with bugs or errors, observe students working and ask questions such as:
- What did you notice when you ran the project? What do you think could be causing that problem?
- Now that you have read through the code in the projects, do you see any potential issues? What makes you think that might be a problem?
- How did you identify the problem with the project?
- What troubleshooting strategy could you use to make finding and fixing problems of this kind easier?
- How are you collaborating to create solutions for the problems in this activity?
Notes:
- Projects for this activity can be downloaded using the links in the student facing section. They are also provided in the task card for students to build themselves if needed.
- The setups for each project in the activity are simple. If Barrels or Sports Balls are needed, they can be placed anywhere on the field. If an AprilTag ID is needed, students should ensure it is positioned so it can be detected by the robot's AI Vision.
Wrap-Up
Now that you have completed the activity, it is time to share what you learned about troubleshooting and error handling. Answer the following questions in your journal to help you reflect on your learning and prepare for a whole-class discussion:
Choose a bugged project from guided practice and explain in your journal how you found and fixed the bug.
- What strategy or strategies did you use to find and fix it?
- What are some other ideas you have for troubleshooting and error handling strategies?
- How might those strategies help you with future robot-to-robot communication projects?
Now that you have completed the activity, it is time to share what you learned about troubleshooting and error handling. Answer the following questions in your journal to help you reflect on your learning and prepare for a whole-class discussion:
Choose a bugged project from guided practice and explain in your journal how you found and fixed the bug.
- What strategy or strategies did you use to find and fix it?
- What are some other ideas you have for troubleshooting and error handling strategies?
- How might those strategies help you with future robot-to-robot communication projects?
Use the questions students answered in their journals as the starting point for the discussion. Ask follow up questions to guide student understanding:
- On troubleshooting:
- Think back to previous VEXcode AIM projects. Can you think of any instances where the troubleshooting strategies in this lesson could help you?
- What clues helped you identify where a bug might be in your code?
- Can you think of any other strategies you might use to help you find and fix bugs?
- On error handling:
- How do the strategies for error handling and troubleshooting differ? How are they similar?
- How do you imagine using these strategies to plan ahead to avoid errors moving forward?
As the discussion progresses, note any additional student understandings about troubleshooting and error handling on the T-chart for this lesson.
Select Next > to move on to the next lesson.