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?
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?
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.
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?
Select Next > to move on to the next lesson.