An autocross simulator built for the MIT FSAE team in order to validate self-driving models on virtual racetracks.
We start by implementing a simple data type for describing and rendering tracks. Every track is described by a list of cones while each cone is described by a particular (x, y) position and, optionally, an angle in the case of the directional cones which are lying on their side. And most importantly, the Track object provides a render method which compiles the track into a scene description language and renders it using POV-Ray rendering engine.
track = Track() track.add(Cone(0, 20)) # the cone is located at (0, 20) track.render((0,0), (0,1)) # you are at location (0,0), looking towards (0,1)
To make it easier to move through a track, we also implemented a driving interface which provides car-like controls and makes it easy to turn and move forwards.
drive = Drive(track) drive.forward() drive.rotate(0.1) drive.render() # the world after moving forwards and turning left
This gives us a nice base to build off of. It runs at ~8 FPS on a Core i7 machine so the performance isn't spectacular, but it's still very usable. At this point, we have implemented enough primitives to produce a synthetic dataset but it would require an absurd amount of time and effort to manually design and drive through enough tracks to train a meaningful end-to-end model.
To automate the training data collection process, we designed a parametrics API which allows us to describe our track using parametric equations. The parametrics API takes arbitrary
y(t) functions and builds tracks by randomly placing cones along the curve. Furthermore, since the parametric equations also happen to describe the optimal path, we can generate lots of training data by rendering the view from random positions/directions on the track and calculating the steering angle which will return the car to the optimal path.
After training our end-to-end model on ~16GB of synthetic data generated from training tracks
charlie, our model succesfully drove through validation track