Third Place Solution in Summer 2022 ROAR S1/S2 Series
Written by Vivian Zhu, a student from Vista del Lago High School, describing her experience and solution for her third place solution in Summer 2022 ROAR S1/S2 Series Competition.
Table of Contents
Introduction:
This report summarizes the experience of my work in the Berkeley Robot Open Autonomous Racing (ROAR) competition. The ROAR Competition S1/S2 is an autonomous racing competition hosted by University of California, Berkeley where high school and college students build and code simulated car models in a virtual Berkeley campus track built by the Berkeley FHL Vive Center for Enhanced Reality. The goal of the competition is to learn and race these cars for maximum speed without collisions. In the future, the learnings from this competition could be beneficial in real life to control electric cars like Teslas to automatically drive in the streets. During the competition and the study in ROAR academy, I learned the AI and autonomous car driving that inspired me to participate in this event and also introduced it to my high school’s machine learning club.
The map used in this competition is the Berkely Major map which has many sharp turns, bumps, and hilly areas likely to cause crashes. Before this competition, I was familiar with python coding and some machine learning concepts. Originally, I wanted to attempt the machine learning way, however, later I realized that it was too difficult to finish it in time. Therefore I decided to learn the existing PID control method from the baseline and hopefully improve it a little. I cloned the ROAR Github and studied the PID Controller code. I also learned from the blogs of previous winners and their githubs which are very helpful.
My approach to the competition stemmed from a series of trials and errors to optimize throttle control based on the roadmap factors, add a gradual speeding up method, and a location based hard coded speed control based on test run feedback. My code is open sourced and published in github https://github.com/vivianzhu2/ROAR.
The test run video can be found below: https://www.youtube.com/watch?v=F2xxvhO6YVw .
Strategy and Design
The code was based around the PID controller in the baseline code https://github.com/augcog/ROAR. The PID controller works like the following image: It is a negative feedback loop where the error is the new input into the system and triggers the alter control and motor (including throttle and steering).
The first step of the process was gathering information on the racing track to see where exactly in the map would cause possible collisions such as sharp turns or skinny narrow areas. The first diagram plots the path of the waypoints on the track from the sample code.
From here, I observed and noted down the areas where the car model might need to slow down to avoid collision. There are three separate types of obstacles the car model might face: sharp turns, big bumps in the mountains, and the winding roads. Each of the dots present a possible collision spot.
The following gif is a demonstration of a sharp turn that the car must anticipate in order to avoid collision and lower throttle to de-accelerate.
The following gif showed a bumpy area in the track, which I also reduced the throttle in the controller.
To further shorten the time yet be cautious of collisions, I did more careful analysis on the throttle in the previous blog’s sample code by capturing the throttle values along the whole track as shown in the diagram below. The diagram compares my model with the sample model in terms of throttle and speed. As shown in the diagram, the new model reduced the throttle to a less degree when hitting a risky area so that the car does not de-accelerate too much. It leads to an increase in speed consecutively overall along the track.
When I was gathering data from the diagram, I also had one observation that when the car model makes a big turn in a dangerous area, the previous code reduces the throttle to a very low value and the throttle stays in low value for a very long time. Maybe the long duration is not necessary which could reduce the speed too much. In order to save some time, I thought maybe after a sharp throttle decrease, I may increase the throttle little by little instead of staying at the low time for a long time. The throttle now balances between collision avoidance and speed optimization. As a result, the running time is decreased by several seconds with this gradual speed up method.
In order to achieve this, I built a series of if statements in the control that help control the throttle using a gradual method of speeding up. When the car model encountered the sharp turns, the gradualness of the method worked by recovering the throttle incrementally after a sharp decrease in a risky area. The increment is set to 0.3 per step (a value achieved after much testing and error).
Testing
Now that the design guideline was established, I ran the program multiple times to test for collisions and time to optimize the program even more. During the test run with Mr. Tianlun Zhang, he helped me notice that around some specific coordinates, collisions were very likely to occur. He gave me a great idea to box those collision spots and reduce the speed in those areas. An example of a crashing place is shown in the gif below. Since it included both bumps and winding roads, the car would frequently crash at this location.
To address this, I recorded the x,y, z coordinates of the collisions. Using those coordinates, I hard coded these areas using the if statements to box these locations. In the dangerous boxes, I made the throttle equal to 0 to avoid the potential collisions.
Conclusions and Next Steps
The ROAR Competition was overall very fulfilling and fun to participate in. Based on the trends in the previous test runs, I optimized the throttle to gradually increase and used a boxing method where frequent collisions occurred. Some advantages of the code are that it has a high speed with minimal collisions, and accounted for the difficult exceptions, which were very likely to crash, without sacrificing too much in speed. Some disadvantages of the code were that the design process was very time consuming to keep running and testing the car model in order to optimize the throttle duration and to determine the dangerous boxes. In addition, it would not be as flexible to another map. In the future, I would like to try incorporating some reinforcement learning into the algorithm so it can have more applications towards different maps by machine learning.
A special thanks to Dr. Allen Yang for the inspiring course of ROAR Academy and for all his support throughout the event and to Mr. Tianlun Zhang for helping with test running the initial code and suggesting boxing the dangerous areas of the map which improved the speed further without collisions.