TCPL Autonomous Robot Wrestling
Over the past several years the Tompkins County Public Library has offered learning how to code through battling Arduino-powered robots. These robots are inspired by the robotics competition in Japan known as Sumobots. TCPL's wrestling robot program has gone through several iterations. It started with robots remote-controlled through a Bluetooth app, see the last two images. Next, TCPL developed a general-purpose robotics platform that could have various attachments and introduced sensors for autonomous functions, see image 4. Later on, the club added hobby electronics found in combat robots to make non-destructive antweight bots, see image 3. This year TCPL has developed an easy-to-print modular system focused on robot wrestling, see the first two images. In this system, participants upload Scratch code through mBlock to an Arduino Nano that sets a pattern of behavior their robot will follow. The script is pre-written and covers concepts of receiving data from sensors, control flow, and how to use the internal clock for movement timing. In this Instructable, you will learn how to print, build, and code your own 3D Printed Autonomous Wrestling Robot.
Supplies
Skills
- Soldering wires together and pins to PCBs. You may be able to find the Arduino Nano and the motor driver pre-soldered.
- Using Wire strippers.
- Slicing 3D models.
- 3D printing.
- Uploading code to an Arduino. Covered in Step 9.
Tools
- Wire Stripper
- Plastic Nippers
- Phillips Head Screwdriver
- Hot Glue Gun
- Soldering Iron
- USB Mini B Cable
- 3D Printer
Parts
3D Printing
At TCPL we are privileged to have access to a Prusa Mini. You can print this model on any machine that uses PLA. Here are the settings we use on the Prusa:
- Quality 0.20mms
- Infill 15%
- Supports Build Plate Only
- Brim: Yes
The TCPL Robotics Club has also had success printing several of these robots in both PLA and ABS on the Ender 3 using Draft mode.
If you do not have access to a 3D printer please check your local library, makerspace, and/or university for services. Many public libraries have free or inexpensive 3D printing services available.
Once the parts have been printed remove the single support from the sensor connector piece, see image 3. After cleaning off the support test fit wheels and sensor. The sensor has a very loose fit on purpose to help it absorb impact when it crashes into another bot. If the wheels are a bit tight you can use a file or automotive sandpaper to remove some of the surface.
Soldering
Motors
- Take a red, black, orange, and brown wire. Snip off the end with the pin, see image 2.
- Strip the cut ends of each wire so they match the size of the motor's terminals.
- Apply solder to each stripped end of the wires.
- Apply solder to the terminals on each motor, see image 3.
- Solder a red and black wire to one motor and orange and brown to the other, see image 4.
Power Distribution
- Take a red and black wire and cut them in half.
- Strip the cut ends of each wire's halves.
- Strip the red and black wire ends coming from the 9v battery.
- Take the stripped ends of each red wire and the one coming from the battery case and twist them together.
- Do the same for the black wire.
- Solder the black wires together then the red ones, last image.
Building the Chassis
Preparing the Chassis:
- Attach the motors to the chassis by aligning the two holes and threading two 35mm M3 screws through them.
- The terminals on both motors should be facing away from the chassis. The bell of the motor, the black plastic end, should be facing the end of the chassis with the three holes on top, see the first two images.
- Screw the screws on both motors until you can just fit the bolts on, then tighten them until they can no longer rotate, see image 3.
- Using three 10mm M3 attach the sensor plate, see images 4 and 5. The smooth side of the sensor plate faces away from the chassis.
- Using plastic nippers cut off the protruding holes at the back of each motor, see image 6.
- Lace the black and red wires from the battery case through the slit closest to the rear of the chassis, see image 7.
- Using hot glue adhere the battery pack to the rear of the motors making sure to leave enough room for wires to slide between it and the chassis, see images 7 - 9.
- Lace the motor wires through the center slit in the chassis, see images 10 -14.
Attach Sensors
Ultra Sonic Sensor
- Slide the HC-SR04 sensor into the wedge with its pins facing up.
- Flip over the chassis and partially screw in two 10mm M3 screws into the left and right holes on the sensor plate.
- Slide the wedge with sensors onto the screws. Tighten the screws down, see images 1-2.
IR Sensor
- Take an orange, brown, and purple wire.
- Insert the VCC pin on the TCRT5000 sensor into the orange wire.
- Insert the GND pin on the TCRT5000 sensor into the brown wire.
- Insert the DO pin on the TCRT5000 into the purple wire, see Image 4.
- Slide the wire through the center slit in the chassis.
- Align the TCRT5000 so the sensor LEDs face the bottom of the robot and screw it into the remaining hole on the sensor plate. Do not fully tighten the screw you will want the sensor to have some movement for it to adjust to whatever surface you use it on, see images 5 - 6. Instructions on how to make an arena are discussed later in Step 10 of this instructable.
Add Arduino and Motordriver
Arduino:
- Rotate the robot so it's upright.
- The front of the robot is where the wedge and HC-SR04 are located.
- Adhere the mini breadboard to the top and front of the robot, see image 1.
- Insert the Arduino Nano so the digital pins face the front and have two sets of pin rows in their columns, see image 2.
DVR8833 Motor Driver:
- Using hot glue adhere to the DRV8833 motor driver to the chassis so it is adjacent to the rear of the mini breadboard.
- The VCC and GND pins on the motor driver should be closest to the mini breadboard, see the last image.
Note: I apply the hot glue to the DRV8833 along the solder point of each pin. You can remove this hot glue later by wetting it with rubbing alcohol. Please use safety and proper equipment when handling rubbing alcohol.
The Cricuit
Please use the images to follow along. The following steps are numbered to the images.
- Take the red wires coming from the 9v battery case. Take the end with the input and attach it to the VCC pin on the DRV8833 motor driver. Take the remaining wire with the pin and insert it into the mini breadboard adjacent to the VIN pin on the Arduino Nano.
- Take the black wires coming from the 9v battery case. Take the end with the input and attach it to the GND pin on the DRV8833 motor driver. Take the remaining wire with the pin and insert it into the mini breadboard adjacent to the GND pin on the Arduino Nano.
- Using a purple wire attach its input side to the D0 pin on the TCRT5000. Insert the pin of the attached purple wire into an input on the mini breadboard adjacent to the D12 pin on the Arduino Nano.
- Using a brown wire attach its input side to the GND pin on the TCRT5000. Insert the pin of the attached brown wire into an input on the mini breadboard adjacent to the GND pin on the Arduino Nano.
- Using an orange wire attach its input side to the VCC pin on the TCRT5000. Insert the pin of the attached orange wire into an input on the mini breadboard adjacent to the 5V pin on the Arduino Nano.
- With the front of the robot facing you take the two wires coming from the right motor, your right, not the robot's. and insert one into OUT3 and the other into OUT4. Do not worry about which right motor wire goes where, you will adjust this after uploading the script.
- With the front of the robot facing you take the two wires coming from the left motor, your left, not the robot's. and insert one into OUT1 and the other into OUT2. Do not worry about which left motor wire goes where, you will adjust this after uploading the script.
- Using a blue wire attach its input to the IN1 pin on the DRV8833 motor driver. Take the attached blue wire and insert its pin into the mini breadboard adjacent to the D10 pin on the Arduino Nano.
- Using a purple wire attach its input to the IN2 pin on the DRV8833 motor driver. Take the attached purple wire and insert its pin into the mini breadboard adjacent to the D9 pin on the Arduino Nano.
- Using a green wire attach its input to the IN3 pin on the DRV8833 motor driver. Take the attached green wire and insert its pin into the mini breadboard adjacent to the D6 pin on the Arduino Nano.
- Using a yellow wire attach its input to the IN4 pin on the DRV8833 motor driver. Take the attached yellow wire and insert its pin into the mini breadboard adjacent to the D5 pin on the Arduino Nano.
- Using an orange wire attach its input to the VCC pin on the HC-SR04 sensor. Take the attached orange wire and insert its pin into the mini breadboard adjacent to the 5V pin on the Arduino Nano.
- Using a brown wire attach its input to the GND pin on the HC-SR04 sensor. Take the attached brown wire and insert its pin into the mini breadboard adjacent to the GND pin on the Arduino Nano.
- Using a purple wire attach its input to the Trig pin on the HC-SR04 sensor. Take the attached purple wire and insert its pin into the mini breadboard adjacent to the D7 pin on the Arduino Nano.
- Using a white wire attach its input to the Echo pin on the HC-SR04 sensor. Take the attached white wire and insert its pin into the mini breadboard adjacent to the D8 pin on the Arduino Nano.
- Your circuit is complete and your robot should have a fun hairdo of wires!
Add Wheels and Traction
Slide a rubber band into each wheel. Apply a thin layer of hot glue under the rubberband to prevent it from slipping off the wheel. Slide wheels on so the protruding circle is facing the motor.
Install Mblock and Prepare Environment
In your favorite browser navigate to https://www.mblock.cc/en/. Select Download on the topmost ribbon. Navigate to your operating system and select the download option. Once downloaded open the installer and follow the prompts. At the time of writing this Instructable mBlock is in V5.4.3, this may be different for you. Install the latest version and you should be good to go. You may also want to restart your computer after the installation process.
Edit and Upload Code
SETUP:
Once mBlock has downloaded you will need the pre-written code. You can find the script here: https://drive.google.com/drive/folders/1c06kuLu3ujh788gS884428PngjDkNiKr?usp=sharing
Note: The following steps you will only need to do once.
- Download the SUMOGEN3.mblock.
- Open the mBlock application and navigate to Devices and delete the CyberPi by selecting the 'x'.
- Select the blue plus icon.
- In the popup menu locate and install the Arduino Nano by selecting the blue plus icon and then clicking 'ok'.
- Navigate back to devices and select the Add option.
- Find the Arduino Nano (old) and install it by selecting the blue plus icon and then selecting 'ok'.
- Once you have both Arduino Nanos close the program.
UPLOAD TEST CODE:
- Navigate to where you saved the SUMOGEN.mblock file.
- Open the file and the mBlock application will open showing the pre-written code.
- If the code is not visible use the zoom out button, the blue minus icon on the lower right of the screen.
- Find the stack of code that has a note saying, "Gaming Loop". The forever loop block is where you will put all your robot's code in.
- Take the forward block and attach it to the inside of the forever loop.
- Repeat these steps for the Arduino Nano(old) device too.
- Select the Arduino Nano and insert the USB cable into your device and then into the Arduino on the robot.
- Navigate to Devices, make sure Upload is selected, and then click Connect.
- Check the "Show all connectable devices".
- The Com number may be different for you, select connect.
- You will see the Device has a new option Upload Code. Select this to upload the code.
- If you get an error you will need to change to the other Arduino device. Select Disconnect from Device and then repeat the steps 8 - 11.
- Once the upload is complete and the popup leaves the screen you are ready to test.
- Remove the USB cord from the robot, insert the 9v battery, and power it on. The wheels will not start moving until after a 2-second pause.
- If both wheels are driving forward you are ready to upload more code and battle. Otherwise, locate where the motor driving in reverse is attached to the motor driver. Locate the OUT pins and swap them. For example, if the motor going in reverse is attached to OUT 3 and 4 remove them and replace them in reverse order.
- To keep the robot still while you attempt to upload more code or reverse the motor you can remove the VCC wire from the motor driver. Just make sure to replace this when you are ready to battle.
HOW TO CODE THE WRESTLING ROBOT:
- Navigate to the My Blocks tab to see all the different behaviors you can have your robot perform.
- Select any number of behavior blocks to program how your robot will move around the arena. Blocks are read top to bottom and left to right in the forever loop a.k.a the gaming loop. Once the last block is read the robot will start with the first block again until you power it off.
- Use the blocks that allow you to input a number. The number represents seconds and decimals milliseconds.
- You can also adjust the speed of each behavior block you use by placing a SpeedUp block before the action you want to adjust. The robots use PWM to control each motor's speed. PWM is a whole number between 0 and 255. 0 is off and 255 is max speed. A good range to choose from is 100, crawling, to 255, attacking.
- To adjust the range the robot sees an object using its ultrasonic input any whole number between 1 - 400 into the variable "distance". You can find all the variable blocks attached above the forever loop. These values represent centimeters.
- If you find the robot's arena edge detection movements too fast or slow you can adjust the PWM value in the variable "Esc_Speed".
- Once you have the movements you want upload your code and see how it reacts in the arena.
Note: the code for changing how the robot reacts to white and black surfaces is in the next step.
Making an Arena
There are several ways you can make and/or purchase an arena. The most budget-friendly is to use foam board and electric tape. You can also order a custom one using the PNG file included in the drive folder. There are also arenas you can purchase from robotshop.com.
Build an Arena:
Materials:
- 4x 20 x 30 Foam Board
- Roll of packing tape
- Roll of electrical tape
- Lay out foam board so they make a 40 x 60 rectangle.
- Using the packing tape, tape the boards together.
- Cover the surface with the rest of the packing tape
- Line each edge with electrical tape. The black line at the arena's edge should be two electrical tape strips thick.
Custom Order an Arena:
Links:
Amazon custom 3'x3' vinyl banner
- Navigate to the link.
- Make sure the 3'x3' option is selected.
- Select Customize Now.
- Upload PNG of the arena.
- Order arena.
How to Adjust the Robot for Black or White Surfaces:
- The robot's code is set to work with a black surface and white boundaries. To change this locate the variables "Barrier" and "surface". You can find all the robot variables attached above the forever loop.
- For a white surface and black boundaries set "Barrier" to 1 and "surface" to 0.
- For a black surface and white boundaries set "Barrier" to 0 and "surface to 1.
Running an Event
There are many different ways these wrestling robots can be used for events and STEM programming. Over the years TCPL has used these kinds of robots to teach electronics, coding, and 3D printing to patrons of all ages. Here are a few brief overviews of past library programs:
- Weekly classes where tweens learned the basics of C++ through Arduino. Each class would cover the basics of C++ syntax and how to apply it to the robot. For example, week 1 covered variables and using functions from a given library. Using the syntax learned, the participants programmed their wrestling robot to execute basic movements like forward, spin, turn, etc. The class concluded with each participant writing a script that engaged all the components attached to the wrestling robot.
- Monthly meetings where patrons of all ages learn how to edit mBlock Scratch scripts and compete in a robot fighting tournament. At TCPL, we offer this type of program to gain interest in the club and find new members while giving regular participants the chance to compete.
- In collaboration with the Girls Who Code at the Women In Computing at Cornell, we turned these robots into kits and over eight weeks had participants learn how the robot works through circuitry. We also gave participants the chance to learn Tinkercad by designing upgrade parts for their robots. The collaboration ended with a friendly double-elimination tournament.
In 2024 TCPL is using the robots to offer weekly open hours for youth aged 8 - 11, teens 12 - 19, and families. With the help of an amazing volunteer crew, we run new participants through the basics of Scratch and give regulars new challenges and resources they can pursue to further their skills in coding. The following is a seven-week breakdown of the TCPL Robotics Club Wrestling Robots program.
Program Overview
Title: TCPL Robotics Club Wrestling Robots
Location:The Makerspace and Digital Lab
Participation Level: up to 45 participants with both rooms and 20 with just the Makerspace.
Registration Type: Open Hour first-come-first-serve.
Age Range: Families with youth younger than 8, youth 8 - 11, and teens 12 - 19.
Equipment:
- 15 Windows laptops
- 20 Wrestling robots, more participants than robots form teams of 2 - 3.
- 20 USB cables
- 40 Rechargeable 9v batteries
- 5x Battery chargers
- Spare 3D printed parts
- 5 hot glue stations
- 5 soldering stations
- 10 Screwdrivers + extra screws and nuts
- 1 Large circle arena, black surface with white boundary, fits 8 robots.
- 1 Large rectangle arena, white surface with black boundaries, fits 6 robots.
- 4 Small circle arenas, black surface with white boundaries, fit 3 robots.
- 1 Large display monitor with presentation laptop.
Volunteer Participation: 4 - 8
Volunteer Skills/Interest:
- Youth Leadership
- STEM/ STEAM Education
- Engineering
- Recreation Leadership
- Technology
- Inclusivity
- Makerspaces
- Community Outreach
- Education
Duration: Weekly for 1.5 hours. The program ends after 7 weeks.
Organizational Goal: Provide youth within the FLL system with free hands-on digital literacy, coding, and engineering through open-source robotics.
Organizarional Objectives:
- Participants learn how to adjust pre-written code and successfully upload it to a robot.
- After programming the robot participants compete in at least one match against 1 - 7 opponents.
- Participants address one of several provided resources, books, online coding challenges, and video guides.
- Participants show excitement in STEM through engaging with each other, cheering on their robot, and/or seeking out further STEM-related resources.
Lesson Plan
Week 1:
- 10 min: Introductions and greetings. Icebreaker, what do want to learn about robots?
- 20 min: quick tutorial on how to edit the mBlock script to have your robot perform three different movements for 1 second each.
- 10 min: a quick hands-on tutorial on how to upload the script to a robot.
- 20 min: participants observe how their robots behave then return to edit the script. At this point another quick tutorial is given on how to make the robot perform each action for a certain amount of time.
- 20 min: free battles, participants are encouraged to test out each arena and observe how they do against varying levels of opponents.
- 10 min: water break and repairs. Instructors, volunteers, and participants interested assist with making adjustments to robots that are damaged.
- 20 min: more free battles and participants are encouraged to edit their scripts along the way.
- 10 min: Homewards bound.
Week 2:
- 10 min: Introductions and greetings. Icebreaker, what is your favorite robot from a book, movie/ show, or videogame?
- 20 min: Returning participants are given a tutorial on adjusting the speed and range of their robots by adjusting variables in the script. New participants are given the first week's tutorials to learn how to adjust their robots.
- 10 min: Participants are encouraged to experiment with their code until their robot performs the way they want it to. New participants can be introduced to adjusting speed and range during this time.
- 20 min: Participants participate in free battles.
- 10 min: water break and repairs. Participants returning from last week who did not help with repairs are encouraged to join in.
- 10 min: Battle royals, break the participants into groups of 8. Each group battles it out in the large circle arena until one remains.
- 10 min: homeward bound.
Week 3:
- 10 min: Introductions and greetings. Icebreaker, what coding language would you like to learn?
- 20 min: Returning participants are given a tutorial on how to adjust the robot to battle on an arena with a white surface and black boundaries. New participants are given the first week's tutorials to learn how to adjust their robots.
- 10 min: Participants are encouraged to experiment with their code until their robot performs the way they want it to. New participants can be introduced to adjusting their robots to work on the arenas with a white surface and black boundaries during this time.
- 20 min: Participants break into groups around the arenas they want to compete in. A large arena for battle royals, A large arena for battle royals on a different surface, and small arenas for 1-on-1 battles. Battles commence and volunteers help judge at each arena.
- 10 min: water break and repairs. Participants returning from last week who did not help with repairs are encouraged to join in.
- 10 min: Battle royals, break the participants into groups of 8. Each group battles it out in the large circle arena until one remains.
- 10 min: homeward bound.
Week 4:
- 10 min: Introductions and greetings. Icebreaker, what kind of app would you like to make someday?
- 30 min: Returning participants are introduced to how the TCRT5000 sensor works. New participants are given the first three weeks of tutorials to learn how to adjust their robots.
- 10 min: Participants are encouraged to experiment with their code until their robot performs how they want it to.
- 15 min: Participants break into groups around the arenas they want to compete in. A large arena for battle royals, A large arena for battle royals on a different surface, and small arenas for 1-on-1 battles. Battles commence and volunteers help judge at each arena.
- 10 min: water break and repairs. Participants returning from last week who did not help with repairs are encouraged to join in.
- 15 min: Participants return to their respective arenas and continue battling.
- 10 min: Battle royals, break the participants into groups of 8. Each group battles it out in the large circle arena until one remains.
- 10 min: homeward bound.
Week 5:
- 10 min: Introductions and greetings. Icebreaker, If you could make a firefighting robot what would it be?
- 30 min: Returning participants are introduced to how the HC-SR04 sensor works. New participants are given the first three weeks of tutorials to learn how to adjust their robots.
- 10 min: Participants are encouraged to experiment with their code until their robot performs how they want it to. A quick overview of how the TCRT5000 sensor can be given to participants who missed the prior week.
- 15 min: Participants break into groups around the arenas they want to compete in. A large arena for battle royals, A large arena for battle royals on a different surface, and small arenas for 1-on-1 battles. Battles commence and volunteers help judge at each arena.
- 10 min: water break and repairs. Participants returning from last week who did not help with repairs are encouraged to join in.
- 15 min: Participants return to their respective arenas and continue battling.
- 10 min: Battle royals, break the participants into groups of 8. Each group battles it out in the large circle arena until one remains.
- 10 min: homeward bound.
Week 6:
- 10 min: Introductions and greetings. Icebreaker, What would you choose if you could invent a robot that mimicked an animal?
- 30 min: Returning participants are introduced to how the DRV8833 motor driver works. New participants are given the first three weeks of tutorials to learn how to adjust their robots.
- 10 min: Participants are encouraged to experiment with their code until their robot performs how they want it to. A quick overview of how the HC-SR04 sensor can be given to participants who missed the prior week.
- 15 min: Participants break into groups around the arenas they want to compete in. A large arena for battle royals, A large arena for battle royals on a different surface, and small arenas for 1-on-1 battles. Battles commence and volunteers help judge at each arena.
- 10 min: water break and repairs. Participants returning from last week who did not help with repairs are encouraged to join in.
- 15 min: Participants return to their respective arenas and continue battling.
- 10 min: Battle royals, break the participants into groups of 8. Each group battles it out in the large circle arena until one remains.
- 10 min: homeward bound.
Week 7:
- 10 min: Introductions and greetings. Icebreaker, What kind of robots should TCPL offer next?
- 30 min: Returning participants are introduced to how the Arduino Nano works. New participants are given the first three weeks of tutorials to learn how to adjust their robots.
- 10 min: Participants are encouraged to experiment with their code until their robot performs how they want it to. A quick overview of how the DRV8833 motor driver works can be given to participants who missed the prior week.
- 15 min: Participants break into groups around the arenas they want to compete in. A large arena for battle royals, A large arena for battle royals on a different surface, and small arenas for 1-on-1 battles. Battles commence and volunteers help judge at each arena.
- 10 min: water break and repairs. Participants returning from last week who did not help with repairs are encouraged to join in.
- 15 min: Participants return to their respective arenas and continue battling.
- 10 min: Battle royals, break the participants into groups of 8. Each group battles it out in the large circle arena until one remains.
- 10 min: homeward bound and trophies.
Resources:
How a DRV8833 motor driver works.
Robot projects to make at home.
Where to get mBlock tutorials?