Autonomous Driving Car Simulator

Evolutionary algorithm learning process of cars in UE4 C++

Artificial Intelligence

AI is a new field that appeared a few decades ago and has seen an unprecedented growth. The AI approach has been used in numerous fields, such as finance, medicine, music, customer service, and transportation. Some of the big challenges we have to cope with are the computing power and lack of documentation. Big companies such as Google and Apple do not share advances in this field, the secretism characterizes this scientific field and thus the information we can get is very restrictive. 

In this work, we introduce a model of an autonomous car and then examine different algorithms capable of driving the car in a simulated. We also discuss the difficulties we need to deal with such as local minimums, losing diversity, fitness functions, localization, performance, and future applications.

Unreal Engine 4

For simulation, we implement a neural network in a 3D engine that simulates a car circuit as a training set to learn to drive. Then we have tested it to measure the learning rate of the cars.

UE4 is a cross-platform programming environment providing a wide range of tools to implement 3d simulations. It has an intuitive interface and can be programmed in c++, so it is faster than other environments. UE4 has tools to calculate the physics and collision, which is an advance to make this. I have used the Stick function (given a direction vector, it measures the distance to the nearest object that is pointing to, similar to a distance laser). Thus, the sensory input can be easily obtained without the need for special hardware.
This project can be easily scaled, the used of an Object Oriented Programming Language allows us to change the code and make our program more complex by using more sticks and make the capacities similar to a real Google autonomous car without any special hardware. The program has a good performance, even when using 100 car population.

The code is uploaded on a GitHub repository: AI_Car Repository

Genetic Algorithm

It is an algorithm that was inspired by the theory of evolution by Charles Darwin. It simulates the process of natural selection where the fittest individuals have higher probabilities to transfer their genes to the next generation. It is usually divided into 5 parts.

  1. Initialization

    The genes usually use booleans (0 or 1), but I have used a decimal number between -1 and 1 to depict the gene value.
    You need to design the neural net topology, for example: if I used 5 sticks to measure the distance to the nearest object and we want to return acceleration, right and left turn, this represents 5 inputs and 3 outputs, and you can change the hidden layers topology. We have used for my experiment 4 layers. Then, you need to initialize the weight values with a random number [-1..1].

  2. Selection

    This process selects the best individuals from each generation. The fitness function returns a probability to survive to the next generation. There are lots of different variant of this step, I have designed a function that uses 2 important variables: accuracy and diversity. Genetic algorithms, like others, have a paramount problem while you are trying to reach the global minimum, it usually comes to a standstill in a local minimum. To solve this problem, I have used a measure of the distance from one individual to the rest of the individuals.

        \[I_{a}=\sum_{i=1}^{n}{|x_a-x_i|}\]

    In such a way, we can get the individuals diversity.
    The accuracy can be measured using the positioning system that can tell us the percentage of the circuit traveled.
    Once we have the accuracy and the diversity of each individual, we can transform absolute data to a relative to make easier to understand for us and the machine. The results will be given with a decimal number between 0 and 1. We would create a variable that represents the importance of diversity lies in the total. Eg: impDiv=0.3, ergo impAccu=0.7
    We will do that in this way:

    Accu_{a}=\frac{ Accu_{a}}{ impAccu \cdot \sum{n}Accu_{n}}
    Div_{a}=\frac{Div_a}{impDiv \cdot \sum{n}Div_n}

    The probability to be in the next generation would be the sum of the diversity and the accuracy. We make a roulette filling with each individual and we select n-individuals from the roulette randomly.

  3. Crossover

    The elements we have chosen will experiment the crossover operation. It is the process of exchanging genes among parents to reach a new individual made by progenitors. This part can be modified to your necessities, you can design it with some hyper-parameters: crossover rate, number of progenitors.

  4. Mutation

    We change some of the genes with a random number generator. By the fact that if chosen decimal numbers, we need some hyper-parameters: mutation rate, mutation change.

  5. Termination

    This process determines whether our prototype has reached our expectations or we conform with the results.

 

17 thoughts on “Autonomous Driving Car Simulator”

  1. Wow, this was great. Keep writing this kind of texts, you will get a lot of people to this post if you continue writing this.

  2. Wow, this was awesome. Keep writing this kind of texts, you will get a lot of people to this page if you continue writing this.

  3. if our requirement is to give 1320 units good at the end of shift what would be the C.T and Takt Time. pl. Explain with calculation for better understanding pl email if possible.’ World Cup football uniform

  4. Great blog! Do you have any recommendations for aspiring writers? I’m hoping to start my own blog soon but I’m a little lost on everything. Would you recommend starting with a free platform like WordPress or go for a paid option? There are so many choices out there that I’m totally confused .. Any recommendations? Thanks a lot!

  5. whoah, this blog is great I like studying your posts. Keep up the good work! You know, a lot of individuals are hunting round for this info, you could aid them greatly.

  6. Thanks for sharing your info. I truly appreciate your efforts and I will be waiting for your
    next write ups thank you once again.

  7. Have you ever considered writing an e-book or guest authoring on other websites? I have a blog centered on the same topics you discuss and would really like to have you share some stories/information. I know my visitors would value your work. If you are even remotely interested, feel free to shoot me an email.

Leave a Reply

Your email address will not be published. Required fields are marked *