Support » Pololu Zumo Shield for Arduino User’s Guide » 7. Example sketches »
7.b. Simple border-detecting sumo robot
Adding sensors to the Zumo allows it to sense and react to its surroundings. In a sumo competition where two robots try to push each other out of a circular ring, it is important for a robot to be able to detect the border of the ring so it can avoid driving over the edge. Since standard robot sumo rings are colored black with a white border around the edge, infrared reflectance sensors like our QTR sensors are great for this purpose. The Zumo Reflectance Sensor Array conveniently mounts six of these sensors in a module designed to plug directly into the front expansion header of the Zumo Shield (note: the pre-assembled version of the Zumo robot ships with this reflectance sensor array already installed).
This example demonstrates how to program an Arduino-controlled Zumo equipped with a reflectance sensor array to drive around and stay within a sumo ring. Note that it only uses the two outermost sensors on the array, which are sufficient for border detection. With the Zumo Shield Arduino library installed, the sketch file can be opened in Arduino by selecting File > Examples > ZumoShield > BorderDetect.
You might need to edit a few things in this sketch to make it work well with your Zumo:
- If one or both of your motors have been connected backwards, uncomment the
flipRightMotorlines to correct their directions.
- Adjust the speeds and duration definitions at the top of the sketch. Generally, lower speeds and shorter durations should work better with faster motors, while higher speeds and longer durations should be more appropriate for slower motors. We found that these default values worked well with a Zumo using 75:1 HP motors.
- Finally, the sensor reading threshold used to differentiate between black and white surfaces,
QTR_THRESHOLD, might need to be changed to suit your lighting and ring conditions.
Upload the sketch to an Arduino mounted on a Zumo, place the Zumo on a sumo ring (or a similar large dark surface with a light border), and press the user pushbutton. Be ready to catch the Zumo in case it drives off the ring! If everything works right, the Zumo should sound a countdown with its buzzer and then start driving forward until it detects the ring border; it should then back up, turn, and continue. If not, try adjusting some of the parameters as described above. Here are some specific troubleshooting tips:
- If the Zumo overshoots the ring border, try lowering
FORWARD_SPEED(especially if it is going very fast) or reducing
- If the Zumo stops at the border but turns too much or not enough before continuing, adjust
- If you do not hear any sound from the buzzer, make sure you have the buzzer control jumper configured correctly for your Arduino.
The ability to wander around while staying inside a sumo ring is enough to allow a Zumo to compete as a basic sumo robot, but a more advanced robot might be able to detect its opponent and drive toward it directly. As a next step, you might consider adding more sensors, such as range finders, to allow the Zumo to find its opponent instead of relying on luck to make contact.