Mission Instructions
3. Pre-Code: A Simple Corner
Let’s try turning a simple corner first.
We need to evaluate how the robot can successfully make a turn. After all, humans have brains that auto-magically calculate how we go through an open door, but not robots.
Try the following code to go around a cardboard box:
What happened? Did the robot hit the box? Can you think of better ways to handle corners?
Here are a couple of options to try and questions to answer:
- Does turning behave better than spinning?
- Which requires a wider corridor, the spin or the turn? Will your canyon system be wide enough for either of those, or do you need to choose the tighter turn?
- Should the robot drive forward a couple of inches and then spin (or turn)?
- Maybe the side distance sensor should be moved elsewhere on the robot? Closer to the back or just above the wheel?
Try different scenarios until you are happy with the way your robot handles the corner.
Remember that robots process extremely quickly. So the moment a Distance Sensor detects an opening to the left of the robot, it will start to turn. BUT your robot might need to drive forward for a couple more inches so it doesn’t run into the wall. Since every canyon system is different, you’ll need to figure out what works for you!
Make It a Function
Once you are happy with your robot’s simple corner program, turn it into a custom function that you can use later. You’ve done this before in Mission 08, so look there if you need a reminder.