scieee AI-readable full text Open interactive document viewer

Autonomous driving with CARLA

Martínez Martel, Enrique

Abstract

La intención de esta tesis es establecer una base en el mundo de la inteligencia artificial, específicamente en CARLA, un simulador de conducción autónoma de código abierto. El objetivo principal de este trabajo es conseguir que un coche autónomo pueda realizar una ruta cualquiera gracias a la implementación de un algoritmo de Deep Q-Network. A lo largo del documento se explica detalladamente como crear y configurar un entorno en CARLA, esto incluye un tutorial de la instalación del propio software con todas sus dependencias. Además, se intenta simular una conducción autónoma lo más cercana a la vida real en la que se utiliza un sistema de recompensas y un sistema de navegación eficiente. Cabe destacar que pese haber obtenido resultados razonables y cumplir los objetivos de la tesis, este proyecto es meramente introductorio y espero que sirva de base para futuros desarrollos.

Full text

Autonomous Driving with CARLA By Enrique Martínez Martel Departament de Ciències de la Computació Universitat Politècnica de Catalunya Director: Gerard Escudero Bakx A thesis submitted for the degree of Informatics Engineering Major in Computing Barcelona, June 1st, 2022 I This thesis is submitted to the Computer Science Department, Universitat Politècnica de Catalunya in fulfilment of the requirements for the degree in Informatics Engineering Enrique Martínez Martel, June 2022 Copyright © 2022 Enrique Martínez Martel II Acknowledgements I would like to thank my parents and brother for the immense support and help during this project. Without their help, completing this project would have been very difficult. I must also express my gratitude to my teacher, Gerard Escudero Bakx, who gave me the golden opportunity to do this wonderful project on autonomous driving. He guided me throughout all the project and helped me understand many new things. I am thankful to him. III Abstract The intention of this thesis is to establish a foundation in the world of artificial intelligence, specifically in CARLA, an open-source autonomous driving simulator. The main objective of this work is to enable an autonomous car to drive any given route thanks to the implementation of a Deep Q-Network algorithm. Throughout the document, it is explained in detail how to create and configure a CARLA environment, including a tutorial on the installation of the software itself with all its dependencies. In addition, an attempt is made to simulate autonomous driving as close to real life as possible using a reward system and an efficient navigation system. It should be noted that despite having obtained reasonable results and fulfilling the objectives of the thesis, this project is merely introductory, and I hope that it will serve as a basis for future developments. IV Resumen La intención de esta tesis es establecer una base en el mundo de la inteligencia artificial, específicamente en CARLA, un simulador de conducción autónoma de código abierto. El objetivo principal de este trabajo es conseguir que un coche autónomo pueda realizar una ruta cualquiera gracias a la implementación de un algoritmo de Deep Q-Network. A lo largo del documento se explica detalladamente como crear y configurar un entorno en CARLA, esto incluye un tutorial de la instalación del propio software con todas sus dependencias. Además, se intenta simular una conducción autónoma lo más cercana a la vida real en la que se utiliza un sistema de recompensas y un sistema de navegación eficiente. Cabe destacar que pese haber obtenido resultados razonables y cumplir los objetivos de la tesis, este proyecto es meramente introductorio y espero que sirva de base para futuros desarrollos. V Resum La intenció d'aquesta tesi és establir una base al món de la intel·ligència artificial, específicament a CARLA, un simulador de conducció autònoma de codi obert. L'objectiu principal d'aquest treball és aconseguir que un cotxe autònom pugui fer una ruta qualsevol gràcies a la implementació d'un algorisme de Deep Q-Network. Al llarg del document s'explica detalladament com crear i configurar un entorn a CARLA. Això inclou un tutorial de la instal·lació del propi programari amb totes les seves dependències. A més, s'intenta simular una conducció autònoma el més propera a la vida real on s'utilitza un sistema de recompenses i un sistema de navegació eficient. Cal destacar que malgrat haver obtingut resultats raonables i complir els objectius de la tesi, aquest projecte és merament introductori i espero que serveixi de base per a futurs desenvolupaments. VI VII Contents 1. Context ................................................................................................................................... 1 1.1 Introduction ...................................................................................................................... 1 1.2 Terms and concepts .......................................................................................................... 2 1.3 Problem to be resolved ..................................................................................................... 3 1.4 Stakeholders ..................................................................................................................... 3 2. Justification ............................................................................................................................ 5 3. Project Scope ......................................................................................................................... 6 3.1 Objectives ......................................................................................................................... 6 3.2 Sub-Objectives ................................................................................................................. 6 3.3 Requirements .................................................................................................................... 7 3.4 Obstacles and Risks .......................................................................................................... 7 3.5 Changes in Project Scope ................................................................................................. 8 4. Methodology and rigour ........................................................................................................ 9 4.1 Agile Methodology .......................................................................................................... 9 4.2 Tools and Validation ...................................................................................................... 10 5. Task Definition .................................................................................................................... 11 5.1 Tasks Description ........................................................................................................... 11 5.2 Resources ....................................................................................................................... 14 5.3 Changes in Task Definition ............................................................................................ 15 6. Estimates and the Gantt ....................................................................................................... 16 6.1 Workload estimation ...................................................................................................... 16 6.2 Gantt Chart ..................................................................................................................... 18 6.3 Changes in Estimates and Gantt Chart ........................................................................... 19 VIII 7. Risk Management ................................................................................................................ 20 7.1 Hyperparameter tuning ................................................................................................... 20 7.2 Computational power ..................................................................................................... 20 7.3 Deadline ......................................................................................................................... 20 7.4 Inexperience ................................................................................................................... 21 7.5 Incompatibilities ............................................................................................................. 21 8. Budget .................................................................................................................................. 22 8.1 Identification of costs and cost estimates ....................................................................... 22 8.2 Management control ....................................................................................................... 27 9. Sustainability report ............................................................................................................. 28 9.1 Self-assessment .............................................................................................................. 28 9.2 Economic ........................................................................................................................ 28 9.3 Environmental ................................................................................................................ 29 9.4 Social .............................................................................................................................. 29 10. Environment Setup............................................................................................................. 31 10.1 Prerequisites ................................................................................................................. 31 10.2 Environment Software.................................................................................................. 33 10.3 Environment Libraries.................................................................................................. 35 10.4 CARLA ........................................................................................................................ 36 11. Implementation .................................................................................................................. 39 10.1 The World .................................................................................................................... 39 10.2 The Car ......................................................................................................................... 40 10.3 Reinforcement Learning ............................................................................................... 42 12. Experimentation ................................................................................................................. 48 12.1 Training Model ............................................................................................................. 48 12.2 Testing Model .............................................................................................................. 66 4 1.4.2 Director My director, Gerard Escudero Bakx, is a direct stakeholder of my project because we will have an implication on the thesis as he guides me during the execution of it. 1.4.3 Myself I am a direct stakeholder of this project. The grade of this project will decide if I will turn into a computer science engineer or not. 5 2. Justification Most real-world reinforcement learning problems have an incredibly complicated state, environments, and actors. Therefore, any existing solution or study will be appreciated. That's why my director, Gerard Escudero Bakx, has provided me with two alumni theses to use in my favour. To obtain the best result for the project using and taking advantage of previous solutions will be mandatory. Adapting an existing study will help in achieving a better outcome for the thesis thanks to code reusability. Obviously, this will be a time-consuming decision due to the understanding and learning of a foreign project. Not using existing projects can be a major drawback since nothing ensures that we will achieve a significant advance in our study. 6 3. Project Scope 3.1 Objectives This thesis has two main objectives. The first goal is to create and set up an environment for CARLA. This includes installing the prerequisites, the software used for the execution of the training and the libraries. The second goal of my thesis is to try to recreate an autonomous driving simulation as close as possible to real life. Starting first with a simple scenario such as, the car must travel a route that simply follows a straight line and ending with the car travelling through a much more complex route. 3.2 Sub-Objectives All the sub-objectives come from the second goal of the thesis. 3.2.1 Waypoints Firstly, a circuit will be created where origin and destination points will be defined, and a series of waypoints will be established through which the car will have to pass. The distance between waypoints will be 1 meter. 3.2.2 Reinforcement Learning Secondly, the car will use reinforcement learning to perceive, interpret its environment, take actions and learn through trial and error. This objective will be achieved with the correct implementation of a control algorithm and a reward system which the car will use to know when a good or bad choice has been made. 7 3.3 Requirements The following requirements are needed to ensure the quality of the thesis 3.3.1 Functional requirements The functional requirements [9] for this project are: ● Setting up a proper Python3 environment on Window ● A visual demonstration of the car’s apprenticeship. ● Correct tuning of the hyper-parameters for the artificial neural network. 3.3.2 Non-functional Requirements In general, a good use of programming language to obtain the following non-functional requirements: reusability, performance, and portability 3.4 Obstacles and Risks Every project has different difficulties that must be analysed in advance to minimise their impact. Here are some of the risks that need to be aware of: ● Hyperparameters. Not tuning hyperparameters correctly is one of the biggest mistakes in hyperparameter optimization [10]. If they are not set explicitly on the model and, instead, model developer’s defaults are used, they may be inappropriate. ● Computational power - Given the high computational requirements of neural network training, it is necessary for the computer running the learning to have a high performing CPU and GPU, as this may limit the development itself. ● Deadlines - Delivery deadlines must be achieved at all costs. Lack of experience may be a drawback as I’m not familiar with this type of work. ● Inexperience - As said before, inexperience can be a major disadvantage as learning and deciding the best way to develop this project will be a time-consuming task. 8 ● Incompatibilities - Libraries incompatibilities are a big issue as some standard library interfaces may change during updates in ways that require different code than normal for example: Python3 code to achieve Python2/3 compatibility. 3.5 Changes in Project Scope During the initial planning of the project the objectives where different. At first, we only had one main objective: to recreate an autonomous driving simulation as close as possible to real life. Then during the development of project, I realised that this main goal should be split into two as setting up the environment was a bigger task than previously planned. With this objective, we also added a risk that at first, we did not think about it, library incompatibilities. 9 4. Methodology and rigour This section will justify which methodology has been chosen and the reasons for the decision, a description of the tools to be used to develop the project and how the objectives will be validated. 4.1 Agile Methodology The work methodology that will be used in this project will be agile [11]. Agile is an iterative approach to project management that helps teams deliver their product. Instead of clustering everything on a single launch the agile methodology divides the work in several sprints in which teams plan, design, develop, test, deploy and review constantly. In this case, sprints will last two weeks, starting and finishing with a meeting with the project director. Figure 2: Agile Methodology. Source: NVISIA, The Agile Process 101 [12] 10 The main reasons for choosing this methodology are: ● Project predictability - Constant meeting with the project’s director will increase transparency making it easier to predict risk and plan for a smooth project execution. ● Continuous improvements - This methodology works by iterations which means that each sprint will be better than the previous one and mistakes done in the past will not be repeated. ● Better project quality - In agile project management, testing is always present in all sprints which implies that the overall quality of the final product is greater. 4.2 Tools and Validation The tools that I’ll be using for my project development will be the open-source simulator for autonomous driving research, CARLA Simulator, Anaconda [13] and a Virtual Machine for Windows with Python 3 in which I’ll have an environment with all the libraries and dependencies needed to run de CARLA software. This environment will be set up with Anaconda. Thanks to agile methodology, every two weeks meetings with the project’s director will be arranged in which evaluation, objectives and even requirements will be discussed. 11 5. Task Definition The project will need a total of 550 hours. The work-to-begin date is on February 21st, same day as the first day of GEP, and will be delivered on June 11th. I expect an average of 5 hours of work per day among 110 days which is the time difference between the two dates. 5.1 Tasks Description In this section I will identify and describe all tasks that are involved in this study. T1 - Project Management This task includes the context and scope task, project planning task, budget and sustainability task, final project definition task and the meetings task. T1.1 - Context and Scope In this task I will contextualise the thesis and describe its scope. I estimate that this task will consume a total of 20 hours. T1.2 - Project Planning In this task I will plan the start and end date, the hours per day and a brief description of all the tasks of this project. I estimate that this task will consume a total of 10 hours. T1.3 - Budget and Sustainability In this task I will draw up the budget of the project and the initial part of the sustainability report. I estimate that this task will consume a total of 15 hours. T1.4 - Final Project Definition In this task I will integrate the previous tasks (T1.1, T1.2 and T1.3) in a final document. I estimate that this task will consume a total of 15 hours. T1.5 - Meetings This task consists of carrying out meetings with the director of the project throughout the weeks. I estimate that this task will consume a total of 20 hours. 12 T2 - Research This part includes all the research tasks needed to start the implementation of the project. T2.1 - Get familiarised with ANNs This task consists of learning and getting familiar with the concept of ANNs. I estimate that it will take a total of 25 hours to complete. T2.2 - Get familiarised with PPO This task consists of learning and getting familiar with the concept of PPO. I estimate that it will consume a total of 25 hours. T2.3 - Learn about CARLA simulator This task consists of learning and getting familiar with the CARLA simulator environment. I estimate that it will take a total of 40 hours to complete. T2.4 - Learn KERAS and TensorFlow This task consists of learning and getting familiar with the KERAS and TensorFlow. I estimate that it will take a total of 20 hours to complete. T3Pre - Setting up This part includes all the tasks that consist of preparing the environment for the CARLA simulator. T3Pre.1 - Installing prerequisites This part consists of installing all the necessary prerequisites to be able to start with the installation of the software. I estimate that this task will take a total of 10 hours. T3Pre.2 Installing software This part consists of installing all the necessary prerequisites to be able to start with the installation of the libraries. I estimate that this task will take a total of 20 hours. T3Pre.3 Installing libraries This part consists of installing all the necessary libraries. Once it’s finished, I will be able to start with the programming part. I estimate that this task will take a total of 20 hours. 13 T3 - Programming part This part includes all the tasks that consist of programming in Python3 or in the CARLA simulator. T3.1 - Designing map levels For this task I will be designing five different maps in which the autonomous car will drive and learn. This task will cost 20 hours. T3.2 - Implementation of waypoints This task consists of implementing the waypoints system that the car will use to move around the map. This task will consume 20 hours. T3.3 - Implementation of reward system This task consists of implementing the reward system that the car and the ANN will use to learn what is “right” or “wrong”. This task will cost 40 hours. T3.4 - Implementation of RL in car This task consists of implementing the reinforcement learning algorithm with the proximal policy optimization and including the waypoint and reward system. This task will cost 50 hours of work. T4 - Experiments, Analysis and Conclusion This task consists of the testing part of the project. Which includes, tuning the hyperparameters of the ANN, testing the car in different map levels, testing the car with different map difficulties, and collecting all the data from the experiments. T4.1 - Tuning hyperparameters During experiments, I will be fiddling with the hyperparameters in order to approach the best solution. I estimate that this task will consume a total of 15 hours. T4.2 - Testing in different map levels During the training of the car, I will be changing the maps to obtain the best outcome from the ANN’s. I expect that this task will consume 25 hours of work. 20 7. Risk Management It is important to predict the risks and obstacles that may emerge during the project’s development. In this section you will find a description of the problems mentioned in the first deliverable and the alternative plans to overcome them. 7.1 Hyperparameter tuning Not tuning hyperparameters correctly is one of the biggest mistakes in hyperparameter optimization. If they are not set explicitly on the model and, instead, model developer’s defaults are used, they may be inappropriate. ● Impact: Medium ● Alternative plan: To solve the problem, I could adapt the project planning and add a new task that would focus on hyperparameter tuning. I estimate that this new task will take 15 hours. 7.2 Computational power Given the high computational requirements of neural network training, it is necessary a high performing CPU and GPU, as this may limit the development itself. ● Impact: Low ● Alternative plan: To solve the problem, I will plan to use my resources wisely. I will try to train my neural network at night when I’m not working on my laptop. This alternative plan can bring problems such as: not choosing the right learning rate, not choosing the appropriate number of epochs or iterations, or not knowing when to stop the training. Nevertheless, it’s better than not doing anything. I estimate that this task will cost 10 hours. 7.3 Deadline Due to academic deadlines, the project should not be extended more than the initial time planned. ● Impact: High ● Alternative plan: To solve the problem, I could recalculate every week in the project meetings the hours of my time planning. Therefore, I could approach a more realistic and updated time schedule. I estimate that this task will cost 15 hours. 21 7.4 Inexperience Inexperience can be a major disadvantage as I have never used the CARLA simulator environment, worked with the proximal policy optimization (PPO) or even the neural networks before. Thus, this problem should be dealt with carefully. ● Impact: Medium ● Alternative plan: To solve the problem, I could adapt the project planning and extend time on the tasks that I find more difficult. I estimate that this extension would be never more than 10 hours for each task. 7.5 Incompatibilities Inexperience can be a major disadvantage as I have never used the CARLA simulator environment, worked with the proximal policy optimization (PPO) or even the neural networks before. Thus, this problem should be dealt with carefully. ● Impact: High ● Alternative plan: To solve the problem, I could extend the duration for the setting up of the environment task. I estimate that this task will cost 20 more hours. 22 8. Budget In this section I will talk about the project's budget. It will include the different types of costs associated with the personnel’s costs by activity, the hardware and software used and the workspace. In addition, to overcome the obstacles that may arise during the development, we have created a contingency plan with an estimated budget and an estimation cost for the incidents that can occur. 8.1 Identification of costs and cost estimates 8.1.1 Personnel cost per activity In this project there are 4 types of different personnel, and they all have different costs per hour. Firstly, we have the project manager, who is responsible for the planning and execution of the project. Secondly, we have the researcher, who will oversee collecting information about the project and technologies. Thirdly, we have the programmer who will be doing all the implementation of the project. Finally, we have the tester who will be responsible for the testing and reviewing the work done by the programmer. Role Cost per hour without SS Cost per hour with SS Project Manager 23,07€/hour 30 €/hour Researcher 15,38 €/hour 20 €/hour Programmer 12,30 €/hour 16 €/hour Tester 12,30 €/hour 16 €/hour Table 2: Personnel costs. Source: Hays labour market guide [14] ID Activity Cost (€) Comments T1.1 Context and Scope 600 20 hours, Project Manager T1.2 Project Planning 300 10 hours, Project Manager T1.3 Budget and Sustainability 450 15 hours, Project Manager T1.4 Final Project Definition 450 15 hours, Project Manager T1.5 Meetings 600 20 hours, Project Manager 23 T2.1 Get familiarised with ANNs 500 25 hours, Researcher T2.2 Get familiarised with PPO 500 25 hours, Researcher T2.3 Learn about CARLA simulator 360 40 hours, Researcher T2.4 Learn KERAS and TensorFlow 400 20 hours, Researcher T3Pre.1 Installing prerequisites 160 10 hours, Programmer T3Pre.2 Installing software 320 20 hours, Programmer T3Pre.3 Installing libraries 320 20 hours, Programmer T3.1 Designing map levels 320 20 hours, Programmer T3.2 Implementation of waypoints 320 20 hours, Programmer T3.3 Implementation of reward system 640 40 hours, Programmer T3.4 Implementation of RL in car 800 50 hours, Programmer T4.1 Tuning hyperparameters 240 15 hours, Tester T4.2 Testing in different map levels 400 25 hours, Tester T4.3 Testing with increased level difficulty 480 30 hours, Tester T4.4 Collecting data 600 30 hours, Researcher T5 Project Documentation 1500 50 hours, Project Manager T6 Bachelor Thesis Defence Preparation 900 30 hours, Project Manager TOTAL PERSONNEL COST BY ACTIVITY 11160 550 hours, All Roles Table 3: Total Personnel Cost. Source: Own compilation 8.1.2 Generic costs Hardware and software In this project, we only have amortisations for hardware because all the software used is open source or the UPC has given us a licence to use it. The resources will be used for a total of 550 hours. The amortisation costs are shown below: 𝐴𝑚𝑜𝑟𝑡𝑖𝑠𝑎𝑡𝑖𝑜𝑛 (€)= 𝑅𝑒𝑠𝑜𝑢𝑟𝑐𝑒𝑃𝑟𝑖𝑐𝑒 𝜒 1 4𝑦𝑒𝑎𝑟𝑠𝜒 1 100𝑑𝑎𝑦𝑠𝜒 1 5ℎ𝑜𝑢𝑟𝑠𝜒 𝐻𝑜𝑢𝑟𝑠𝑈𝑠𝑒𝑑 Hardware Price Time used(h) Amortisation (€) Laptop 1650 550 453.75 Display 110 550 30.25 24 Hardware Price Time used(h) Amortisation (€) Laptop 1650 550 453.75 Keyboard 50 550 13.75 Mouse 30 550 8.25 Microphone 50 20 0.5 TOTAL 506,5 Table 4: Hardware and Software Total Cost. Source: Own compilation Workspace In this section we will calculate the total cost for the workspace. This includes the electricity, furniture, and internet. For the furniture we used the following formula and obtained a total of 300*(¼)*(1/100) *(⅕)*550 = 82.5€. 𝑇𝑜𝑡𝑎𝑙𝐶𝑜𝑠𝑡𝑂𝑓𝐹𝑢𝑟𝑛𝑖𝑡𝑢𝑟𝑒 𝜒 1 4𝑦𝑒𝑎𝑟𝑠𝜒 1 100𝑑𝑎𝑦𝑠𝜒 1 5ℎ𝑜𝑢𝑟𝑠𝜒 𝐻𝑜𝑢𝑟𝑠𝑈𝑠𝑒𝑑 Considering that the price of the kWh in Spain is 0,3544 €/kWh [15] and the total hours of consumption will be 550, we will calculate the total cost of electricity and obtain 34,55€. Hardware Power (W) Time used (h) Consumption (kWh) Price (€) Laptop 150 550 75 26,58 Display 45 550 22,5 7,97 TOTAL 34,55 Table 5: Hardware and Software Total Cost. Source: Own compilation The internet costs 25€ per month. Considering that the project lasts 4 months (110 days) and that the working hours per day are 5 the internet cost is 4 months * (30€/month) * (5h/24h) = 25€. In conclusion, we have a total generic cost of 648,55€ and if we sum the total personnel cost by activity, we obtain a total of 648,55€+11160€= 11808,55€. 8.1.3 Contingencies During the project’s development, potentially negative events can occur. Therefore, it is always necessary to prepare a budget to reduce the impact as much as possible. In this case we have a contingency margin of 15%, 1771,28€. 25 8.1.4 Incidental costs We also need to consider the possible cost of applying alternative plans in case of unforeseen events. These plans have been discussed previously and the total cost of them are calculated in the following table. Risks Estimated hours (h) Risk (%) Cost (€) Hyperparameter tuning 15 20 90 Computational power 10 10 30 Deadline 15 15 67,5 Inexperience 10 20 60 Incompatibilities 20 20 60 TOTAL 337,5 Table 6: Incidental Costs. Source: Own compilation ID Activity Cost (€) Comments T1.1 Context and Scope 600 20 hours, Project Manager T1.2 Project Planning 300 10 hours, Project Manager T1.3 Budget and Sustainability 450 15 hours, Project Manager T1.4 Final Project Definition 450 15 hours, Project Manager T1.5 Meetings 600 20 hours, Project Manager T2.1 Get familiarised with ANNs 500 25 hours, Researcher T2.2 Get familiarised with PPO 500 25 hours, Researcher T2.3 Learn about CARLA simulator 360 40 hours, Researcher T2.4 Learn KERAS and TensorFlow 400 20 hours, Researcher T3Pre.1 Installing prerequisites 160 10 hours, Programmer T3Pre.2 Installing software 320 20 hours, Programmer T3Pre.3 Installing libraries 320 20 hours, Programmer T3.1 Designing map levels 320 20 hours, Programmer T3.2 Implementation of waypoints 320 20 hours, Programmer T3.3 Implementation of reward system 640 40 hours, Programmer T3.4 Implementation of RL in car 800 50 hours, Programmer T4.1 Tuning hyperparameters 240 15 hours, Tester T4.2 Testing in different map levels 400 25 hours, Tester T4.3 Testing with increased level difficulty 480 30 hours, Tester 26 T4.4 Collecting data 600 30 hours, Researcher T5 Project Documentation 1500 50 hours, Project Manager T6 Bachelor Thesis Defence Preparation 900 30 hours, Project Manager Total CPA 11160 Total personnel costs by activity (Gantt activities) Hardware H1 Laptop 453,75 Amortisation H2 Display 30,25 Amortisation H3 Keyboard 13,75 Amortisation H4 Mouse 8,25 Amortisation H5 Microphone 0,5 Amortisation Software S1 CARLA Software 0 Free to use S2 VisualStudio 0 Free to use S3 Python3 0 Free to use S4 Microsoft Office 0 UPC licence S5 Google Meet 0 Free to use S6 GanttProject 0 Free to use Workspace W1 Electricity 34,55 W2 Furniture 82,5 W3 Internet 25 Total GC 649,55 Total Costs imputed generically (not detailed by activity) Total CPA + Total GC 11808,05 Total Costs Contingency 1771,29 Contingency margin of 15% Total CPA + Total GC + Contingency 13579,83 Risks R1 Hyperparameter tuning 90 15 hours, risk = 20%, cost per hour = 30€ R2 Computational power 30 10 hours, risk = 10%, cost per hour = 30€ R3 Deadline 67,5 15 hours, risk 15%, cost per hour = 30€ R4 Inexperience 60 10 hours, risk 20%, cost per hour = 30€ R5 Incompatibilities 90 20 hours, risk 20%, cost per hour = 30€ Total incidentals 337,5 Total 13917,33 Total cost: CPA+CG+Contingency+Incidentals Table 7: Total Project Cost. Source: Own compilation 27 8.2 Management control In this section, we will describe the procedures and methods used to control the budget. Also, we will define the control indicators that will help us supervise the cost deviations during the development of the project. Control mechanisms are the difference between the real and estimated resource consumptions, and they are used to measure and avoid deviations. This is the formula used to obtain the personnel cost deviation: For the hardware and software deviation: Hardware Software Deviation= (EstimatedCostPerHours -RealCostPerHours)*TotalHoursConsumed For the workspace deviation: Workspace Cost Deviation = (EstimatedCostPerHours - RealCostPerHours) * TotalHoursConsumed For the incidental cost deviation: Incidental Cost Deviation =(EstimatedIncidentalHours - RealIncidentalHours)*TotalIncidentalHours Finally, we need to sum up all if we want to know the general costs deviation: Costs Deviation = Personnel Cost Deviation + Hardware Software Deviation + Workspace Cost Deviation + Incidental Cost Deviation All these indicators will help us know where the deviations in the budget are. 28 9. Sustainability report 9.1 Self-assessment After reading the first question from the pool I realised that my knowledge of sustainability was poor. Therefore, I started by looking for the definition of the word. Sustainability is a broad policy concept in the global public discourse and is often conceived of in terms of three pillars: environmental, economic, and social. The original semantic meaning of “sustainability” and “to sustain” refers to the ability to continue over a long period of time. Once I had the correct definition of sustainability, I started the poll. At first, I could not give an answer to many of the questions of the pool because I simply never thought about it. I used to think that the basics of sustainability was to reduce the CO2 emissions, but I was totally wrong. A sustainability report should consider how I will approach sustainable development, what are the social, economic, and environmental impacts of the product, the health, safety, and social justice implications of my product, how to measure it (ISO 26000, 2014/95/EU Directive), what are the methods and tools for estimating the economic feasibility of a project and the deontological principles of my product and the ethical principles of sustainability. Throughout the questionnaire, I concluded that there are many things we overlook in our day- to-day life. All businesses need to follow a sustainable report to minimise their footprint, innovate around the life cycle of a product and be transparent. This brings several benefits such as: improved brand image, increase productivity, reduce costs, attract employees and investors, reduce waste, and even make shareholders happy. To summarise the above, this self-assessment has made me understand the importance of sustainability and the little I knew about it. A project, idea or product that does not take this into account will negatively affect our society, economics and environment and probably will be doomed to failure. 9.2 Economic Regarding PPP, have you estimated the environmental impact of undertaking the project? Have you considered how to minimise the impact, for example by reusing resources? The cost of undertaking the project, human and material resources, estimation can be found in Section 8 of the document. 29 Regarding useful life, how is the problem that you wish to address resolved currently (state of the art)? In what ways will your solution environmentally improve existing solutions? Studies and research of autonomous driving are very expensive as knowledge and machinery are needed to carry them out. Therefore, for my solution I’ll be reusing and referring to another existing thesis to reduce costs. 9.3 Environmental Regarding PPP, have you estimated the cost of undertaking the project (human and material resources)? My main tool for the project will be my own PC and the estimated environmental impact will depend entirely on the energy consumption of it. Minimising this will be difficult as the learning of ANNs is very unpredictable. Regarding useful life, how is the problem that you wish to address resolved currently (state of the art)? In what ways will your solution economically improve existing solutions? In my case, an environmental improvement from existing solutions will be difficult to obtain because other projects use more efficient and specific machines for RL. Nevertheless, my tool for this project will be my PC and the resource used in it will be the electricity to power it up. To obtain a better environmentally friendly solution I will need to be using an energy efficient PC and this could be achieved with the new GPUs as I cannot afford to use other specific tools such as supercomputers. 9.4 Social Regarding PPP, what do you think undertaking the project has contributed to you personally? This project will help me expand my understanding of what I am capable of, deepen my abilities to carry out a study and develop my skills in making connections between ideas. Also, this project will help me to introduce into the autonomous industry, particularly, in the pioneering topic of driverless cars. 36 This will open a command prompt (cmd) which has our environment loaded. To install the libraries needed for the correct execution of CARLA we will simply type in the following commands in the correct order: Step 1, installing Tensorflow 1.14. Depending on this version, all the next steps will vary. If you choose a more updated version other libraries such as Keras will change. conda install tensorflow-gpu==1.14 Step 2, installing OpenCV. conda install -c conda-forge opencv Step 3, installing Keras. A compatible version for Tensorflow 1.14 is Keras 2.2.4. conda install keras==2.2.4 Step 4, installing tqdm conda install tqdm With these four steps we will be ready to execute CARLA in our machine. To check for bugs, see the Appendix B.2 for the complete list of the installed libraries. 10.4 CARLA Upon completion of the above. But first we need to understand the key concept of the software. It is composed mainly by two things: a server which is the main program (CARLA.exe) and a client. The power of CARLA simulator resides in its capacity to be controlled with scripts by this external client. It can manipulate most of the aspects of simulation, from environment to duration of each episode. It can retrieve data from different sensors and send control instructions to the player vehicle. Now we can start with the installation of CARLA. 37 10.4.1 Getting Started To download CARLA's software go to their website. This will take us to a GitHub [18] where we will find all the existing versions. Here we will select version 0.9.5 as it is the one that has been used for all the implementation and experimentation. We save the file and once downloaded we can start the software execution. 10.4.2 CARLA Server To run the CARLA server, we have two options. The first is to go to the location where we saved the file and open the directory. Inside we will find several files. Among them will be one called "CARLA.exe" and to run it, simply double click on it. The disadvantage of using this method is that it will open CARLA, specifically the server, with default options. If we want to modify these rendering options, we will have to recur to the second method of execution. To do this, we will open Anaconda Prompt (the Anaconda CMD) and go to the location of the file we downloaded earlier. After we have accessed the directory, to execute CARLA we could use the following command: ./CarlaUE4.exe -quality-level=Epic In this case we have launched the server with a different quality option. The main options that we will be using are: - Quality option, it has two different levels for graphics quality. Epic quality is the default and it’s the most detailed. Low quality disables all post-processing and shadows. Depending on the GPU card used we will use either low or epic, but to improve performance for the neural network with the Tensorflow and Keras libraries we will be using low quality. ./CarlaUE4.exe -quality-level=Low - Resolution option, the application window can be reshaped to any size, but a low resolution is recommended due to the same reason as before. ./CarlaUE4.exe -windowed -resx=800 -resy=600 -quality-level=Low 38 - World option, the world map can be changed by console or by script. Typing the map name after the main command will work. ./CarlaUE4.exe Town02 -windowed -resx=800 -resy=600 -quality- level=Low 10.4.3 CARLA Client The client provides a Python module for communicating with the CARLA server. In the folder “PythonAPI” from the downloaded file, three directories will show up with examples of scripts to be executed. In all of them, the client connects to the server through the default port “2000”. If the connection fails, code written in any of the scripts will not execute and raise an exception. To execute a client successfully you will need to run first the server and then execute the python script. For example, if we wanted to execute the “tutorial.py” from the “examples” directory we will need to navigate through with the Anaconda Prompt until we reach the following path: $\CARLA_TFG Run the server: ./CarlaUE4.exe Town02 -windowed -resx=800 -resy=600 -quality- level=Low Then, reach the next path: $\CARLA_TFG\PythonAPI\examples And execute the following python command: python tutorial.py With this last step done, we have achieved our first objective: to create and set up an environment for CARLA. Therefore, we can start the implementation and experimentation of the models. 39 11. Implementation In this section we will discuss all the elements that we need to implement to start with the experimentation. 10.1 The World The first element we need to be certain about is the world. The learning of our car can be affected by the complexity of the world itself. Having a world that is too complicated for the start of the experiments could be counterproductive due to a high number of observations it would receive. That is why in the learning process we will start with a simple world, and eventually we will scale its difficulty by changing the maps. The following figure shows a summary about each map (see Appendix C.1 for more information). Town Summary Town 01 As Town 02, a basic town layout with all "T junctions". These are the most stable. Town 02 As Town 01, a basic town layout with all "T junctions". These are the most stable. Town 03 The most complex town with a roundabout, unevenness, a tunnel. Essentially a medley. Town 04 An infinite loop in a highway. Town 05 Squared-grid town with cross junctions and a bridge. Town 06 Long highways with a lane exit. Town 07 A rural environment with narrow roads, barely non traffic lights and barns. Table 8: Town descriptions. Source: Own compilation The candidate map that we will be using in the beginning of the experiments is shown in the following Figure 9. This is because it is a small square city with several crossroads and no roundabouts. The roundabouts are usually quite tricky for autonomous vehicles. 40 Figure 9: Top view of Town02. Source: Own compilation 10.2 The Car Actors in CARLA are the elements that perform actions within the simulation, and they can affect other actors. They include vehicles, walkers, sensors, traffic signs, traffic lights and the spectator. It is crucial to have full understanding on how to operate on them. Figure 10: Tesla Model 3 model. Source: Own compilation 41 Our testing vehicle will be a Tesla Model 3 and it has several sensors that we can use as inputs for our training. These sensors can be divided into four main groups: Cameras are the first main type of sensors that we can use in or vehicle. They take a shot of the world from their point of view a can retrieve data in every simulation step. 1. Depth camera renders the depth of the elements in the field of view in a grey-scale map. 2. RGB camera provides clear vision of the surroundings. Looks like a normal photo of the scene. 3. Semantic segmentation camera renders elements in the field of view with a specific colour according to their tags. 4. Instance segmentation camera renders elements in the field of view with a specific colour according to their tags and a unique object ID. The next group of sensors are detectors, and they retrieve data when the object they are attached to registers a specific event. 1. Collision detector retrieves collisions between its parent and other actors. 2. Lane invasion detector registers when its parent crosses a lane marking. 3. Obstacle detector detects possible obstacles ahead of its parent. The third group embraces all the other sensors. They have different functionalities such as navigation, measurement of physical properties and 2D/3D point maps of the scene. 1. GNSS retrieves the geolocation of the sensor. 2. IMU comprises an accelerometer, a gyroscope, and a compass. 3. LIDAR generates a 4D point cloud with coordinates and intensity per point to model the surroundings. 4. RADAR models a 2D map and points the elements in sight regarding the sensor. The last group contains all the sensors or systems created by me and used by the car. 1. A waypoint system, it was developed to help the car reach the destination point by dividing the route into several points separated by one meter from each other. 2. An off-road detection system, it was created to detect when the car goes out of the road. During training, we will be changing the sensors to obtain the best model. 42 10.3 Reinforcement Learning Reinforcement Learning is all about learning the optimal behaviour in an environment to obtain maximum reward with an agent. 10.3.1 Introduction In RL we have two main actors: the agent and the environment, in this case CARLA, in which an agent is trained. To do this training possible we have three main interactions between them. These are the following: - State: it describes the status of the agent. This could be the current position of the car, the speed or even the orientation of the vehicle. - Action: it describes what can an agent do. Moving forward, pressing the brake, or rotating the car are different actions that can be performed. - Reward: it is the feedback on the action previously taken on a state. This could be a positive or negative reward. Figure 11: Agent-Environment Interaction Diagram. Source: Study of the implementation of an autonomous driving system, Marta Basquens [19] Maximizing the reward obtained by performing a series of actions is the main objective of the agent as we previously mentioned. Therefore, a proper reward system is very important as choosing one action or the other will be affected by it. 43 During the training process we will see two main stages: exploration and exploitation [20]. The exploration stage has a specific purpose, to visit states that you have not yet visited or to take actions you have not yet taken. When you start the first episodes you want the agent to explore and do some trial and error to find the actions that will return a positive reward. On the other hand, the exploitation stage is when you decide to use the knowledge and memory from the previous episode to maximise the rewards. This stage usually comes at the end of the training session or when you have a trained agent. The agent will require a policy to learn. The policy defines how the agent will behave at a given time and map from perceived states of the environment to actions to be taken when in those states. To store all this data the policy uses a huge table with all the information saved for each state. At the beginning, if the agent has not been trained before this table will be empty, in other words, it will have no experience. This in when the exploration stage becomes useful. After the agent has performed a series of steps, it will start leaning by adjusting its predicted rewards for specific pairs of state-actions towards the received rewards. These predicted values are known as Q-values and are used as feedback on how good a state is. The parameter that determines the probability of the agent performing a random action is the epsilon (∈). It is a real value that exists in [0, 1]. This variable introduces randomness into our training algorithm forcing the agent to try different actions. A high epsilon, for example, ∈ = 1 will result in all actions are random which means we are in the exploration stage. On the other hand, a lower epsilon such as ∈ = 0 will result in no random actions which means we are in the exploitation stage. Implementing an epsilon decay formula is very important during the training process. This is because we want to travel from the exploration stage to the exploitation to maximize learning. The formula we will be using will be the following: ∈𝑛= ∈𝑛−1 × ∈𝑑𝑒𝑐𝑎𝑦 We will need to set an ∈𝑑𝑒𝑐𝑎𝑦 that, when multiplied by the current epsilon, will give us the next epsilon value. To calculate the epsilon value in a certain number of episodes we will use the following formula: ∈ = ∈𝑖𝑛𝑖𝑡𝑖𝑎𝑙 × ∈𝑑𝑒𝑐𝑎𝑦 𝑛 Where 𝑛 is the number of episodes, ∈𝑑𝑒𝑐𝑎𝑦 the epsilon decay per episode and ∈𝑖𝑛𝑖𝑡𝑖𝑎𝑙 the epsilon used at the beginning. Another important parameter is the discount factor (𝛾). It is a real value that exists in [0, 1] and determines how the agent should care about the rewards achieved in the past, present and future. If 𝛾=0 the agent will focus on actions that produce an immediate reward whereas if 𝛾=1 the agent cares on actions that will produce a high future reward due to a sequence of actions. 44 10.3.2 DQN Agent Deep Q-Network is a reinforcement learning algorithm that combines Q-Learning with deep neural networks to let RL work for complex, high-dimensional environments, like video games, or robotics. DQN uses the Bellman’s equation to solve the problem of being unable to see future rewards. Otherwise, only immediate rewards would be shown. The formulation of the equations is as follows: 𝑄𝑛𝑒𝑤(𝑠𝑡 ,𝑎𝑡) = (1−∈)×𝑄(𝑠𝑡 ,𝑎𝑡) ⏟ 𝑜𝑙𝑑 𝑣𝑎𝑙𝑢𝑒 + ∈ × (𝑟𝑡 + γ ∗ 𝑚𝑎𝑥(𝑄𝑛𝑒𝑤(𝑠𝑡+1 ,𝑎) ) ⏟ 𝑙𝑒𝑎𝑟𝑛𝑒𝑑 𝑣𝑎𝑙𝑢𝑒 Equation 1: Bellman's equation Where: • Q is the accumulated reward value • t is the current state • s is a specific state • a is a specific action • ∈ is the epsilon, also known as learning rate. • r is the reward associated to a specific state • 𝛾 is the discount factor The agent can use this equation to link up all the information learned resulting in a batch of memory that can be used for improving the efficiency of its learning. 45 10.3.3 ANN The artificial neural network used in this project is recycled from Marta’s Thesis, Study of the implementation of an autonomous driving system. We used Marta's model because she previously carried out a study in her thesis on which artificial neural network gave the best result. In her case, she decided to use a CNN (convolutional neural network): Figure 12: Structure of the Neural Network used in this project. Source: Study of the implementation of an autonomous driving system, Marta Basquens It consists of: • 3 convolutional layers with 64 neurons each + ReLU activation function which is used for filtering information. • 3 pooling layers performed with max average. They are used to reduce the dimensions of the feature maps in this case 2x2. • 3 dropouts layers following the convolutional networks to avoid overfitting. • 1 flatten layer to convert the vector to 1D. • 1 dense layer with 64 neurons. • 1 dense layer with 4 neurons (4 actions) with linear activation function. It is used to determine the output of neural network like yes or no. 52 Training Settings Rewards Reward 1: Collision: -20 points Reward 2: Arrived at Destination: +20 points Reward 3: If distance to destination increases: -5 Reward 4: If distance to destination increases: +5 Reward 5: Short training episode (<= 20 seconds): -10 Sensors Used Semantic Segmentation camera Collision detection sensor Waypoint system Table 12: Settings for training 2. Source: Own compilation Results Figure 16: Maximum and Average Reward from Training 2. Source: Own compilation Discussion In this training we can see a great improvement in the episodes. Now we can see a big upward trend in the graph of the average reward and in the maximum reward. This indicates that the car itself is learning to get better rewards. At this point, the car has a very simple waypoint system, at each step the system returns the number of meters between the car and the destination. If the distance is reduced, a reward is given and if it is increased, a penalty is given. We will probably have to change this waypoint system as it is correct for straights but for more complex routes can be a problem. Also, the car has learnt to accelerate earlier as it has realised that if it goes in a straight line faster it gets a higher score. One problem we have found is that the car is not able to realise when it leaves the track. It only focuses on reducing the distance from the destination point and sometimes takes forbidden paths. 53 12.1.3 Training 3: Waypoint System + Off-Road Detection System For this training session we have kept the same waypoint system, although we have said that it is still quite simple, and decided to add a new sensor, the off-road detection system. Now the car will know when it goes off-road. The number of episodes was increased to 4000 as we wanted to give the car more training time. One of the biggest problems we encountered is the number of episodes and the training time. CARLA is a high demanding software, and my computer can't run two agents at the same time or even run it at a higher speed as the computer cannot handle the requirements. The reward system and actions remain the same. Training Conditions Training Settings Total Training Time 9h 25m 20s Episodes 4000 Town Town02 Seconds Per Episode 8.48 Actions Action 1: Accelerate car with throttle Action 2: Turn left at 90º Action 3: Turn right at 90º Action 4: Decelerate car with brake Rewards Reward 1: Collision: -20 points Reward 2: Arrived at destination: +20 points Reward 3: If distance to destination increases: -5 Reward 4: If distance to destination increases: +5 Reward 5: Short training episode (<= 20 seconds): -10 Sensors Used Semantic Segmentation camera Collision detection sensor Waypoint system Off-Road detection system Table 13: Settings for training 3. Source: Own compilation 54 Results Figure 17: Accuracy and Loss for Training 3. Source: Own compilation Discussion This time we decided to focus mainly on the parameters of accuracy and loss. During training, the tracking of the rewards was not saved correctly, and the rewards were only stored for episodes 0, 2000 and 4000. We decided not to repeat the training as it would be almost 10 hours wasted and you can always learn from your mistakes. In this case, this error made us look more closely at other parameters. The accuracy of the model was quite low, normally, a good model should be around 0.7. Also, the loss value was behaving incorrectly, as it should reduce as the episodes go by. Therefore, we concluded that we were not getting it right with the new modifications. We still decided to test how the car would look on a new route to confirm that this was indeed the problem. 55 12.1.4 Training 4: New Route This training had to be repeated because during the first one the laptop shut down due to temperature problems. I had run about 1000 episodes. From then on, we started to be more careful with the training sessions and the ventilation of the laptop itself was improved. The only difference in this training is that we changed the route of the car as you can see in the following figure. The car is facing its first turn. Figure 18: Route in Town07 for Training 4. Source: Own compilation Training Conditions Training Settings Total Training Time 4h 57m 39s Episodes 2000 Town Town02 Seconds Per Episode 8.93 Actions Action 1: Accelerate car with throttle Action 2: Turn left at 90º Action 3: Turn right at 90º Action 4: Decelerate car with brake 56 Training Settings Rewards Reward 1: Collision: -20 points Reward 2: Arrived at destination: +20 points Reward 3: If distance to destination increases: -5 Reward 4: If distance to destination increases: +5 Reward 5: Short training episode (<= 20 seconds): -10 Sensors Used Semantic Segmentation camera Collision detection sensor Waypoint system Off-Road detection system Table 14: Settings for training 4. Source: Own compilation Results Figure 19: Accuracy and Average Reward from Training 4. Source: Own compilation Discussion In this case we will focus on the accuracy and average reward charts. The accuracy graph shows some peaks of 0.7 of accuracy at the end of the training and a drop in the average reward which may suggest the change in the accuracy. Nevertheless, these rewards were not giving us good results so we will change the reward system again in the next training and implement a new advanced waypoint system to force the car to get the curve right. 57 12.1.5 Training 5: New Reward System + New Waypoint System In this training we added a new reward and waypoint system. For the first system we decided to implement a new formula, the multiplied centering angle and speed rewards formula (see Section 10.3.4). It will only return a value between 0 and 1 unless an infraction was committed, or the destination was reached. This normalisation of the rewards allows us to obtain more stable results. For the new waypoint system, we decided to divide the desired route into small waypoints of one meter each. This is because in old training sessions the car only focused on getting to the destination as fast as possible. This meant that the car would always try to go in a straight line and not follow the road’s path. Figure 20: Route in Town02 for Training 5. Source: Own compilation Training Conditions Training Settings Total Training Time 2h 21m 22s Episodes 1000 Town Town02 Seconds Per Episode 8.48s 58 Training Settings Actions Action 1: Accelerate car with throttle Action 2: Turn left at 90º Action 3: Turn right at 90º Action 4: Decelerate car with brake Rewards Reward 1: Infraction: -10 points Reward 2: Reached destination: 10 points Reward 3: Multiplied centering angle and speed rewards formula Sensors Used Semantic Segmentation camera Collision detection sensor Waypoint system Off-Road detection system Table 15: Settings for training 5. Source: Own compilation Results Figure 21: Minimum and Maximum Reward from Training 5. Source: Own compilation Discussion With this new reward and waypoint system we see how the car starts to improve in the episodes and especially in the last few episodes it seems to start driving better. If we focus on the minimum reward graph, we can see that there is an upward trend. But in the maximum reward graph we have a downward trend. One of the infringement conditions was to stay more than 5 seconds with the car stopped, this was a problem because to reset the environment in each episode, sometimes it took about 4 seconds and therefore if the car remained 1 second more stopped the agent detected it as an error. This had to be changed as it often didn't give the agent time to start the car. 59 12.1.6 Training 6: Update in Rewards In this training we decided to change one of the infringement conditions as previously mentioned. A total of 4000 episodes were performed and all condition settings remained the same. Training Conditions Training Settings Total Training Time 7h 09m 31s Episodes 4000 Town Town02 Seconds Per Episode 6.44 Actions Action 1: Accelerate car with throttle Action 2: Turn left at 90º Action 3: Turn right at 90º Action 4: Decelerate car with brake Rewards Reward 1: Infraction (modified): -10 points Reward 2: Reached destination: 10 points Reward 3: Multiplied centering angle and speed rewards formula Sensors Used Semantic Segmentation camera Collision detection sensor Waypoint system Off-Road detection system Table 16: Settings for training 6. Source: Own compilation Results Figure 22: Epsilon Decay from Training 6. Source: Own compilation 60 Discussion In this training I spent a lot of time carefully analysing the actions that the car was taking, since throughout the training, many actions seemed random to me. That is why after several episodes of analysis I concluded that the car still took many random actions due to the epsilon parameter. This parameter oversees determining with what probability an action will be random. During all the previous tests, the epsilon did not go below 0.4 in the last episodes. In other words, the car took 40% of random actions. Obviously, this was a problem as this parameter had not been considered due to inexperience and could be the cause of these inaccurate results. Despite all this, the car presented a curious behaviour. When arriving at the turn, the car braked drastically as it had learned to slow down in the turns. 61 12.1.7 Training 7: Epsilon Decay New Policy For this training we have decided to focus on the epsilon parameter and implement a decay formula as it will allow us to switch from the exploration stage to the exploitation stage. A total of 2000 episodes were performed while maintaining the navigation and reward system. Training Conditions Training Settings Total Training Time 3h 43m 16s Episodes 2000 Town Town02 Seconds Per Episode 6.70 Actions Action 1: Accelerate car with throttle Action 2: Turn left at 90º Action 3: Turn right at 90º Action 4: Decelerate car with brake Rewards Reward 1: Infraction (modified): -10 points Reward 2: Reached destination: 10 points Reward 3: Multiplied centering angle and speed rewards formula Sensors Used Semantic Segmentation camera Collision detection sensor Waypoint system Off-Road detection system Table 17: Settings for training 7. Source: Own compilation Results Figure 23: Epsilon decay and Maximum Reward from Training 7. Source: Own compilation 68 12.2.2 Testing 2: Town07 Longest Route This is the last test of the thesis. We switched back to map of Town07 and decided to make a new route. On this route there are different types of curves to see how the car handles itself. Figure 28: New Route on Town07. Source: Own compilation In this testing the car managed to complete 80% of the route. My guess is that the car did not know how to interpret the crossroads and therefore was not able to finish it. If we look at the rewards in Figure 18, we can see from the very beginning the results were quite good. This is due to the previous learning from other occasions. Even though he had experience he was not able to get 100% of the route completed. 69 Figure 29: Rewards from Testing 2. Source: Own compilation 70 13. Conclusions and Future Work 13.1 Conclusions In the early stages it was difficult to think that we would be able to do sufficient research on a topic like autonomous driving. In addition, inexperience, limited time, scarce resources, and constrained computational power meant that a good result would be rather challenging. Nevertheless, it was decided to go ahead. As commented on the goals of the thesis, the main objective of this project is to make an autonomous car learn how to drive any given route. To accomplish this objective, it had to be divided into two parts: to set a base on autonomous driving with CARLA by creating and setting up an environment for CARLA and to teach an artificial intelligence how to drive a car with a Deep Q-Network algorithm. This first objective was successfully achieved by creating a tutorial that explained how to replicate the development environment. The second objective was also attained as the agent was able to follow an established route while respecting basic traffic signs. This was thanks to the implementation of the waypoint and reward systems which contributed to the resolution of the problem. Although these specific objectives have been met there is still continuity and a wide range of improvement. 13.2 Future Work One of the advantages of this field is that there is always room for improvement in every aspect. In the following list you can find a couple of ideas on how our work can be broadened or improved: • Supporting an installation tutorial for Linux or other operating systems can increase accessibility and encourage the creation of more projects in the CARLA simulation software. • Using other machine learning technologies and techniques such as the Proximal Policy Optimizations instead of the Deep Q-Network algorithm would be interested to study in comparison. 71 • Changing the epsilon decay equation with an epsilon greedy strategy to improve the exploration-exploitation stages. • Adding a HUD to the car as it will look better during the training session. It could show the reward obtained at that moment, the total distance travelled, the deviation between the car itself and the centre of the road and other important information. 72 14. References [1] The 6 Levels of Vehicle Autonomy Explained | Synopsys Automotive. (s. f.). The 6 Levels of Vehicle Autonomy. Retrieved March 1, 2022, from https://www.synopsys.com/automotive/autonomous-driving-levels.html [2] Self-driving cars in the EU: from science fiction to reality | News | European Parliament. (2019, January 14). Europarl. Retrieved March 21, 2022, from https://www.europarl.europa.eu/news/en/headlines/economy/20190110STO23102/selfdriving-cars-in-the-eu-from-science-fiction-to-reality [3] Machine Learning: What it is and why it matters. (s. f.). SAS. Retrieved March 1, 2022, from https://www.sas.com/en_us/insights/analytics/machine-learning.html [4] Carew, J. M. (2021, 29 Marzo). Reinforcement Learning. SearchEnterpriseAI. Retrieved March 1, 2022, from https://www.techtarget.com/searchenterpriseai/definition/reinforcementlearning#:%7E:text=Reinforcement%20learning%20is%20a%20machine,learn%20thro ugh%20trial%20and%20error. [5] Introduction to RL and Deep Q Networks | TensorFlow Agents. (n.d.). TensorFlow. Retrieved June 22, 2022, from https://www.tensorflow.org/agents/tutorials/0_intro_rl [6] Education, I. C. (2021, 3 August). Neural Networks. Neural Networks. Retrieved March 1, 2022, from https://www.ibm.com/cloud/learn/neuralnetworks#:%7E:text=Neural%20networks%2C%20also%20known%20as,neurons%20s ignal%20to%20one%20another. [7] Wikipedia contributors. (2022, March 1). Self-driving car. Wikipedia. Retrieved March 1, 2022, from https://en.wikipedia.org/wiki/Selfdriving_car#:%7E:text=%20An%20autonomous%20vehicle%20may%20operate%20on %20a,of%20operating%20in%20compliance%20with%20the. . .%20More%20 [8] Development Team, C. A. R. L. A. (s. f.). CARLA. CARLA Simulator. Retrieved March 1, 2022, from https://carla.org/ [9] Puzhevich, V. (2021, October 27). Functional vs Non-Functional Requirements: The Definitive Guide. SCAND. Retrieved March 1, 2022, from https://scand.com/company/blog/functional-vs-non-functional-requirements/ 73 [10] SigOpt. (2021b, June 16). Common Problems in Hyperparameter Optimization. Retrieved March 1, 2022, from https://sigopt.com/blog/common-problems-in- hyperparameter-optimization/ [11] Atlassian. (n.d.). What is Agile? Retrieved March 1, 2022, from https://www.atlassian.com/agile#:%7E:text=Agile%20is%20an%20iterative%20approa ch,small%2C%20but%20consumable%2C%20increments. [12] Learn, N. (n.d.). The Agile Process 101: Understanding the Benefits of Using Agile Methodology. Nvisia. Retrieved March 21, 2022, from https://www.nvisia.com/insights/agile-methodology [13] Anaconda | Anaconda Distribution. (n.d.). Anaconda. Retrieved June 22, 2022, from https://www.anaconda.com/products/distribution [14] Hays. (n.d.). Hays Recruiting Experts Worldwide. Retrieved March 21, 2022, from https://www.hays.es/ [15] Tarifaluzhora.es. (n.d.). ¿Cuánto cuesta el kilovatio hora de luz (kWh) en España? Retrieved March 21, 2022, from https://tarifaluzhora.es/info/precio-kwh [16] NVIDIA CUDA GPUs - Compute Capability. (2022, May 31). NVIDIA Developer. Retrieved June 22, 2022, from https://developer.nvidia.com/cuda-gpus [17] Wikipedia contributors. (2022a, June 15). Visual Studio Code. Wikipedia. Retrieved June 22, 2022, from https://en.wikipedia.org/wiki/Visual_Studio_Code [18] C. (n.d.). Releases · carla-simulator/carla. GitHub. Retrieved June 22, 2022, from https://github.com/carla-simulator/carla/releases [19] Marta B. (2020, January 20) Study of the implementation of an autonomous driving system. Bachelor Thesis. Retrieve June 22, 2022, from https://upcommons.upc.edu/bitstream/handle/2117/180817/TFG_Marta_Basquens.pdf [20] M. (n.d.-b). Exploration vs. Exploitation in Reinforcement Learning. Manifold. Retrieved June 22, 2022, from https://www.manifold.ai/exploration-vs-exploitation-in- reinforcement-learning [21] Kendall, A. (2018, July 1). Learning to Drive in a Day. arXiv.Org. Retrieved June 22, 2022, from https://arxiv.org/abs/1807.00412 [22] Raffin, A. (2022, June 5). Learning to Drive Smoothly in Minutes - Towards Data Science. Medium. Retrieved June 22, 2022, from https://towardsdatascience.com/learning-to-drive-smoothly-in-minutes-450a7cdb35f4 74 A. Appendix A.1 Summary of the Tasks (First Version) 75 A.2 Gantt Chart (First Version) 76 B. Appendix B.1 Anaconda Installation Guide Step 1 Step 2 77 Step 3 Step 4 84 TOWN07 85 D. Appendix D.1 Training Case 1 Accuracy Episodes Average reward Episodes Epsilon decay Episodes Maximum reward Episodes Loss Episodes Minimum reward Episodes 86 D.2 Training Case 2 Accuracy Episodes Average reward Episodes Epsilon decay Episodes Maximum reward Episodes Loss Episodes Minimum reward Episodes 87 D.3 Training Case 3 Accuracy Episodes Average reward Episodes Epsilon decay Episodes Maximum reward Episodes Loss Episodes Minimum reward Episodes 88 D.4 Training Case 4 Accuracy Episodes Average reward Episodes Epsilon decay Episodes Maximum reward Episodes Loss Episodes Minimum reward Episodes 89 D.5 Training Case 5 Accuracy Episodes Average reward Episodes Epsilon decay Episodes Maximum reward Episodes Loss Episodes Minimum reward Episodes 90 D.6 Training Case 6 Accuracy Episodes Average reward Episodes Epsilon decay Episodes Maximum reward Episodes Loss Episodes Minimum reward Episodes 91 D.7 Training Case 7 Accuracy Episodes Average reward Episodes Epsilon decay Episodes Maximum reward Episodes Loss Episodes Minimum reward Episodes 92 D.8 Training Case 8 Accuracy Episodes Average reward Episodes Epsilon decay Episodes Maximum reward Episodes Loss Episodes Minimum reward Episodes