How to Hold a Robot Racing Event!

by TCPL in Teachers > 6

6447 Views, 64 Favorites, 0 Comments

How to Hold a Robot Racing Event!

Untitled design.png

Have you ever wanted to hold a robotics event at your library, school, and/or community center? In this instructables the Tompkins County Public Library will share how they brought robotics to their community and kept it running for half a decade. In this guide, you will find:

  • TCPL's program scaffolding
  • Links to TCPL's Instructables on how to build robot cars
  • TCPL' Lesson plans for coding and electronics
  • Tips for setting up a racetrack
  • A resource page lists all the materials used to teach robotics for youth grades 6 - 12

Some Quick History:

In 2017, TCPL opened the Makerspace and wanted to offer free coding and robotics to youth of all ages. In 2018, TCPL decided to develop in-house open-source robots using Arduino microcontrollers and hobby electronics to offer a club at the library and a local middle school. The club went through several iterations of robots: Bluetooth combat bots, RC rovers, autonomous wrestling robots, antweight, hexapods, and app development for Arduino. All of the robots worked well and were able to reach a good majority of the Ithaca and surrounding communities. The only issue was the time and complexity required for combat robotics and hobby RC. In 2021, TCPL collaborated with several outreach groups from Cornell University and team Code Red from Ithaca High School to develop an inexpensive and highly portable robotics program. The collaboration ended with developing TCPL's Autonomous Robot Racing program that could fit different age groups and be set up in virtually any space. The club moved away from using line-following tracks due to the issue of reusability with electrical tape. Drawing inspiration from Micromouse and Tamiya Mini 4wd the club went with walls to form the racetrack.

Supplies

IMG_20230621_183511249.jpg
IMG_20230621_183636381.jpg
robotA.PNG
IMG_20230812_101354261.jpg

The supplies for each robot car and the racetrack can be found in the following Instructables on TCPL's page. The car you see on the top left of the cover image will have an instructable published later in 2024.

Analog Robot Car to teach electronics

Arduino Robot Car to teach Scratch

Designing a Race That Works for You and Your Community

IMG_20230325_145128449.jpg
IMG_20230224_123847010_HDR.jpg
IMG_20230621_192707925_HDR.jpg

TCPL has used the robot cars for several kinds of events and outreach programs. If you decide to run a robot race you will have unique goals and objectives to fulfill. Attached to this step is an example of the scaffolding TCPL uses to fit this program to varying event types: outreach, school visits, demos, race days, etc.

Depending on who TCPL is collaborating with, a section for Date of Promotion from/to and List of Donors is added. We found setting up a scaffolding of the whole event gave us guidelines for us and our collaborators to use as a road map during planning.

In steps 4 and 5 you will see our exact lesson plans. One thing to consider before offering this is to understand the level of digital literacy in your community. We use demos of these robot cars to assess the potential participants' level of computer and electronics skills. At these demos, we let those watching switch out parts on the cars. We also show them how to quickly edit the code to change the speed of the car and its cornering characteristics. This allows us to see how comfortable the community is with using computers and playing with electronic components. With this hands-on approach, TCPL has been able to adjust the program to the needs of the community.

For example, it may be a challenge for beginners and those new to computers to write the robot code from beginning to end. Instead of starting from a blank sheet we pre-write several parts of the code and have them complete it with instructions. The parts we pre-write are there to teach aspects such as variables, control flow, and functions.

What If I Don't Have a 3D Printer or Laser

IMG_20221126_160304409_HDR.jpg
robotcar3.JPG
IMG_20200201_090501567.jpg

You will see in each robot car Instrucable the use of a 3D printer and a Laser are required. At TCPL we are very privileged and fortunate to have access to fabrication equipment. If you do not have access to these tools please check your public library, a local university, and the community for makerspaces. Forming makerspace collaborations in your community helps remove the barriers to information and entry. Otherwise, you can use cardboard, hot glue, and duct tape to make the chassis for the robots. The wheels you see in the pictures above can be purchased with the motors. Participants have a blast when they can design their own cars. Depending on which robot you choose, you can take its circuit and hot glue it to recycling. We've also had participants create their own wheels from lids and rubber bands.

Where to Put the Track

IMG_20230325_141300467.jpg
IMG_20230325_142547433.jpg
IMG_20230718_113521818.jpg
Fulltrack.jpg

The track can be built from almost anything and be sized to fit most rooms. The only requirement is the surface has to be light enough to reflect IR light. We tend to use cardboard and foam. Each of the robot car Instructables go into detail on how to make this track from cardboard and what lap timing apps we use. A good tip is the wider the track the more challenging it will be to set a fast lap time. TCPL has set up race tracks in offices, classrooms, and even in our main entrance hall! A good size for a smaller track is a '5 x '3 oval.

Scratch Lesson Plans

Week1code.JPG
Week_Two.JPG
Week_3.JPG

TCPL uses the Autonomous Robot Racer: Scratch Mode to teach the basics of coding in Scratch. If you go to the linked instructable you will find a premade code and instructions on how to use mBlock. We use the premade code for demos and outreach events. You can find all the code in this step here. Here is the scaffolding we use to teach coding basics through robot racing:

Title: Learn Scratch with Robot Racing

Age Range: 8 - 14

Registration Format: Series with 16 available seats

Volunteers Needed: 3 - 7

Duration: Weekly for four sessions at 1.5 hours

Location: TCPL Makerspace and Digital Lab

Equipment needed:

  • 16 robots
  • 16 laptops
  • 16 USB cables
  • Race track components
  • 32 charged batteries
  • BYOD USB storage devices
  • Dry erase/chalkboard to record times
  • Device to capture lap times

Description:

TCPL is inviting youth ages 8 - 14 to a special two-part series on learning Scratch coding through robotics. Participants will learn how to program a robot car to autonomously drive around a track. No prior experience in coding or robotics required. TCPL will provide robots and laptops for participants to borrow during the program. Registration is required to participate.

Week 1:

In the first week of the program, we start with introductions and an icebreaker. The icebreakers we usually rotate through are:

  • What do you want to make with an Arduino and code?
  • What is your favorite robot and motorsport?
  • What do you want to make someday using computer code?
  • What is your favorite book, movie, or video game robot character?

After the introductions, a demo is given of what the final script will do. We usually set up a small track and have a robot drive around it. This gives our instructors and volunteers a chance to explain how the robot works, see the link above for details. The remaining time is spent teaching variables and how to use them to make the robot drive forward. You can see this code in the first picture. Important: Before attempting to do this code make sure to set the mBlock environment to match step 8 of this instructable: link. You can find a tutorial on how to make variables in mBlock here.

Code Explanation:

  • when_Arduino_starts_up: Everything under this block will execute when the Arduino Nano is turned on.
  • ENA, ENB, IN1, IN2, IN3, IN4: These blocks are variables and each one is named after the pins on the L298N H-Bridge motor driver. The values are the digital pin numbers on the Arduino Nano. For example, ENA is set to 3 which is the D3 pin on the Arduino.
  • forever: This block is a loop and it will repeat the code inside it from top to bottom until the Arduino is powered off.
  • set_PMW_output_as: We use two of these blocks and set one to ENA and the other to ENB. These pins on the motor driver control the speed of each motor using PWM values. PWM values are any whole number between 0 and 255. 0 is off and 255 is full speed. Any value you < 255 will change the motor's speed which is important when it comes to tracks with winding turns. If you go max speed the robot will crash through the track walls. For more information PWM see this link.
  • set_digital_pin_output_as: We use four of these blocks to control the direction of each motor. The blocks set to IN1 and IN2 control the right motor. The blocks with IN3 and IN4 control the left motor. We send a signal to one if the pins and keep the other off to make the motor turn in one direction. We can then reverse this to make the motor go backward. You can find out more on how DC motors work here.

Once every participant has a robot car that drives forwards the session closes with a fun drag race. Participants can experiment by changing the PWM values and reuploading the code to see how it affects the car's speed driving forward.

Week 2:

The program opens with a quick review of what everyone learned in week 1. Next, a talk is given on what a function is for more information on what a function is in Scratch see this link. If you are new to coding a function, is a block of code that executes when you call its name in your script. After the quick lesson, participants are shown how to make a function for driving their robot forward, left, right, and stop see the second picture. You can find out how to make function blocks in mBlock here.

Code Explanation:

  • speed_enb_ena: This block is used to control the speed of each motor using PWM values. The left input of this function controls the left motor's speed and the second the right motor's speed.
  • forward: This block makes the car drive forward.
  • left: This block makes the car turn left.
  • right: This block makes the car turn right.
  • stopped: This block stops the car.

Participants will notice if they try to use more than one of the movement functions, forward, left, right, or stop, the robot will not move. This is due to the Arduino executing each function in less than a millisecond. In week 3 the participants learn how to make their robot make decisions and use each movement separately. The session concludes with each participant testing each movement and adjusting the speed at which the robot performs it based on the PWM value.

Week 3:

The program opens with a quick review of what was covered in the last week's session. Next, a talk is given on control flow in coding. YOu can find out more info on control flow in Scratch here. If you are new to coding control flow is how we can make decisions and repeat code in our scripts. After the quick lesson participants will edit the code to read the data coming in from the two sensors and use it to make decisions. The robot cars are equipped with IR distance sensors. If the sensor sees an object it will send a 0. If the sensor does not see anything it will send a 1. This 1 and 0 value is what is called a boolean, 1 = true and 0 = false. A good way to explain this is the car's sensors answer the question of whether the path is clear or not. If both sensors send true the path is clear the robot will drive forward. You can find out more about boolean logic in coding here. After the lesson participants will add two new variables to store the pin numbers the sensors are attached to, LineL= 12 and LineR = 10. Next, participants will add four if_then blocks into the forever loop. Each input between the if an the then will receive a statement that compares the two sensors readings. Depending on the comparison the robot will perform a specific movement at a set speed. See the third picture for an example.

Code Explanation:

  • if_then: There are four of these blocks with operator statements, lime green blocks. Each operator's statement is different. this is because the if_then is used so the robot can make a decision on what to do based on what the sensors are reading. An if_then only executes the code inside of it if the statement in input is true. If the statement in the if_then block is false the code inside is skipped and the script moves to the next block outside the if_then block
  • If both sensors send a 0 it means there is an object blocking both the left and right sides of the robot so it will stop
  • If both sensors send a 1 it means there is no object blocking the left and right sides of the robot so it will move forward at the speed set by the PWM values
  • If the left sensor sends a 1 and the right a 0, the robot will turn left.
  • If the left sensor sends a 0 and the right a 1, the robot will turn right.
  • LineL: A variable set to the value of 12 which represents the pin where the left sensor is attached.
  • LineR: A variable set to the value of 10 which represents the pin where the right sensor is attached.
  • read_digital_pin: This block reads the data being sent from the Arduino pin specified in its input and returns its value.
  • _=_: This block is the equal to block that compares to values and returns true if the values are the same. Otherwise, it will return false.
  • _and_: This is the and block that compares two statements. If both statements are true the and block will return the value of true. Otherwise, it will return false.

The session concludes with setting up an oval track and having the participants test out their code.

Week 4:

The final session opens with a review of the code from last week and how to upload it to the robots. Participants then get to work together and make a large racetrack to fill the event space. Once the track is ready the instructor will lay down some blue painter's tape to denote the starting line and choose which way the cars will drive. The instructor or volunteer will set up a phone with a lap time, see the robot instructable for the link. Participants are given one practice lap and then two timed laps. Once every participant has completed all their laps the person with the fastest time wins. In between each lap, participants can adjust the code, sensors, and robot breaks.

Electronics Lesson Plan

FSR89UYLNSWO4N8.jpg

TCPL uses the Autonomous Robot Racer: Analog Mode to offer weekly robot racing for families and youth of all ages. These robots are analog and do not use a microcontroller. These robots' driving characteristics are determined by changing the wheel size, breaks, and sensor sensitivity and placement. These cars make great outreach tools with them not needing any added computer or device. Depending on your program goals you can prebuild the robots and have the participants just work on tuning or you can have them build the robot and make the circuit. There is no soldering needed with these robots.

Program Scaffolding:

Title: Autonomous Robot Racing for Everyone

Age Range: families and youth ages 8 - 18

Registration Format: open hour first-come, first-served

Volunteers Needed: 3 - 10

Duration: Weekly 1 hour sessions for three months

Location: TCPL Makerspace and Digital Lab

Equipment needed:

  • 20 robots
  • 20 sets of each type of wheel
  • 20 sets of each break type
  • Race track components
  • recycling/parts bin for participants to design their own tune-up part
  • Dry erase/chalkboard to record times
  • Device to capture lap times
  • Hot glue and duct tape

Description:

TCPL is inviting youth 8+, Teens, and families to a weekly robot race in the Makerspace! Each week participants will be challenged to tune a robot car to achieve the fastest time on the track. A new track will be available at each event to test your tinkering skills! The robots use two sensors to detect walls and navigate around the course. TCPL will provide robots, tune-up parts, and materials. This is an open-hour event and robot cars will be given out to borrow on a first-come-first-serve basis.

During the event, the participants will be introduced to the group as they show up. Volunteers are set at different stations to assist with the robots:

  • Circuitry, volunteers at this station help troubleshoot when a robot is not functioning correctly.
  • Tune-up, volunteers at this station help attach wheels and breaks to the robots.
  • Sensor, volunteers at this station assist with adjusting sensors.
  • Workshop, volunteers at this station help participants design their own tune-up parts.
  • Racetrack, when a participant is ready to run their robot a volunteer will record the time and add it to the leader board.

If there are more participants than robots the club will form teams and challenge them to work together to make the fastest robot. At the last session, the club will hand out laser-cut and/or 3D-printed trophies.

If you would like to know more about how these robots work see the following links:

Resources

Links:

  1. What is a Variable: https://en.scratch-wiki.info/wiki/Variable
  2. Make a variable in mBlock: https://education.makeblock.com/help/mblock-block-based-stage-blocks-variables/
  3. PWM and the L298n Motor Driver: https://howtomechatronics.com/tutorials/arduino/arduino-dc-motor-control-tutorial-l298n-pwm-h-bridge/
  4. How DC motors work: https://electronics.howstuffworks.com/motor.htm
  5. Scratch Functions: https://en.scratch-wiki.info/wiki/My_Blocks
  6. Making functions in mBlock: https://education.makeblock.com/help/mblock-block-based-stage-blocks-my-blocks/
  7. Boolean logic in coding: https://www.techtarget.com/whatis/definition/Boolean#:~:text=In%20computing%2C%20the%20term%20Boolean,are%20used.
  8. IR Distance Sensors: https://www.seeedstudio.com/blog/2019/12/23/distance-sensors-types-and-selection-guide/
  9. Autonomous Robot Racer: Analog Mode: https://www.instructables.com/Autonomous-Robot-Racer-Analog-Mode-no-Microcontrol/
  10. Autonomous Robot Racer: Scratch Mode: https://www.instructables.com/Autonomous-Robot-Racer-Scratch-Mode/
  11. The code from Step 4: Scratch Lesson Plans: https://drive.google.com/file/d/1BsQr3_cYnbHijji4YdwxigWALLFWfFQP/view?usp=sharing

Books:

  1. Arduino Cookbook: Recipes to Begin, Expand, and Enhance Your Projects 3rd Edition by by Michael Margolis, Brian Jepson and, Nicholas Weldin ISBN-13: 978-1491903520
  2. Scratch Programming in easy steps by Sean McManus ISBN-13: 978-1840788594
  3. JunkBots, Bugbots, and Bots on Wheels: Building Simple Robots With BEAM Technology by Dave Hrynkiw ISBN-13: 978-0072226010