Full text
Degree Thesis Industrial Technology Engineering Autonomous guidance of a Formula Student car REPORT Author: Albert Bargalló i Sales Supervisor: Vicenç Puig Cayuela Call: 2024 January Escola Tècnica Superior d’Enginyeria Industrial de Barcelona
p. 2 Thesis
Autonomous guidance of a Formula Student car p. 3 Resum Aquesta tesi està centrada al voltant del progrés de l’enginyeria d’automoció mitjançant una exploració exhaustiva de la dinàmica de vehicles i els sistemes de control, enfocantse específicament en el cotxe de competició de l’equip BCN eMotorsport (CAT15x). L’objectiu principal és millorar les eines i els mètodes actuals de l’equip mitjançant la implementació i optimització d’un sofisticat model matemàtic de la dinàmica del vehicle. Amb aquesta finalitat s’ha realitzat una extensa revisió bibliogràfica, l’adquisició de dades reals amb el cotxe i el desenvolupament d’una eina basada en software capaç de simular diversos models de vehicle i proporcionar comparacions gràfiques i quantitatives del seu rendiment entre ells i contra dades reals. Inicialment es considera un model bàsic, seguit d’un altre una mica més complex i acabant amb el desenvolupament de dues evolucions més. Es realitzen simulacions dels diferents models considerant dades que provenen de proves reals amb el cotxe. A continuació, es duen a terme comparacions entre els resultats obtinguts, i es tria el model que ha representat millor la realitat per a ser sotmès a un procés d’optimització. Finalment, una vegada optimitzat el model, s’integra en vàries estructures de sistemes de control per a ser provat i validat. Els resultats indiquen que l’últim model plantejat, el més complex, demostra ser el que té un comportament més proper al real del CAT15x. Posteriorment, el procés d’optimització millora encara més la precisió del model. Per últim, es valida parcialment el model optimitzat en ser integrat amb sistemes de control. El projecte conclou assolint amb èxit els seus objectius, obtenint informació útil per a l’equip BCN eMotorsport i aplanant el camí per poder seguir avançant en l’ús i el desenvolupament de software per a vehicles elèctrics de Formula Student.
p. 4 Thesis Resumen Esta tesis está centrada en torno al avance de la ingeniería de automoción a través de una exploración exhaustiva de la dinámica de vehículos y los sistemas de control, enfocándose específicamente en el coche de competición del equipo BCN eMotorsport (CAT15x). El objetivo principal es mejorar las herramientas y metodologías actuales del equipo mediante la implementación y optimización de un sofisticado modelo matemático de la dinámica del vehículo, con el fin de simular el rendimiento del coche con precisión. Para ello se ha llevado a cabo una extensa revisión bibliográfica, la adquisición de datos reales con el coche y el desarrollo de una herramienta basada en software capaz de simular varios modelos de vehículo y proporcionar comparaciones gráficas y cuantitativas de su rendimiento entre ellos y frente a datos reales. Inicialmente se considera un modelo básico, seguido de otro un poco más complejo y terminando con el desarrollo de dos evoluciones más. Se realizan simulaciones de los distintos modelos considerando datos procedentes de pruebas reales con el coche. A continuación, se llevan a cabo comparaciones entre los resultados obtenidos, y se elige el modelo que ha representado mejor la realidad para ser sometido a un proceso de optimización. Finalmente, una vez optimizado el modelo, se integra en varias estructuras de sistemas de control para ser probado y validado. Los resultados indican que el último modelo propuesto, el más complejo, demuestra ser el que se acerca más al comportamiento real del CAT15x. Posteriormente, el proceso de optimización mejora aún más la precisión del modelo. Por último, el modelo optimizado se valida parcialmente al ser integrado con sistemas de control. El proyecto concluye alcanzando con éxito sus objetivos, obteniendo información útil para el equipo BCN eMotorsport, y allanando el camino para poder seguir avanzando en el uso y desarrollo de software para vehículos eléctricos de Formula Student.
Autonomous guidance of a Formula Student car p. 5 Abstract This thesis revolves around advancing automotive engineering through a comprehensive exploration of Formula Student electric vehicle dynamics and control systems, specifically focusing on the BCN eMotorsport team’s racing car (CAT15x). The primary objective is to enhance the current tools and methodologies of the team by implementing and optimising a sophisticated mathematical vehicle dynamics model, aiming to simulate the performance of the car accurately. This involved a meticulous literature review, real-world data acquisition with the car, and the development of a software-based tool able to simulate various vehicle models and provide graphical and quantitative comparisons of their performance between them and against real data. Initially a basic model is considered, followed by a bit more complex one, and ending with the development of two more evolutions. Simulations of the different models considering data coming from real tests with the car are performed. Subsequently, comparisons between its results are carried on, choosing the one that has resulted to represent better the reality to be submerged on an optimisation process. Finally, once the model is optimised, it is integrated into various control system structures to be tested and validated. Results indicate that the last model proposed, which is the most complex, demonstrates to be the closest to represent the real behaviour of the CAT15x. Then, the optimisation process further improves the overall model accuracy. At last, the Optimised Model is partially validated being integrated with control systems. The project concludes by successfully achieving its objectives, offering valuable insights for the BCN eMotorsport team, and paving the way for continued advancements in the field of the use and development of software for Formula Student electric vehicles.
p. 6 Thesis
Autonomous guidance of a Formula Student car p. 7 Contents Abbreviations and Symbols ___________________________________ 9 List of figures ______________________________________________ 10 List of tables ______________________________________________ 13 1. Preface _______________________________________________ 15 2. Introduction ___________________________________________ 16 2.1. Motivation ................................................................................................. 16 2.2. Scope ....................................................................................................... 16 2.3. Prerequisites ............................................................................................ 16 2.4. Objectives ................................................................................................ 17 2.5. Planning ................................................................................................... 18 3. Formula Student _______________________________________ 19 3.1. BCN eMotorsport ..................................................................................... 19 4. Vehicle model _________________________________________ 21 4.1. Kinematic bicycle model .......................................................................... 21 4.2. Dynamic bicycle model ............................................................................ 22 4.3. Tire modelling .......................................................................................... 24 4.4. Slip angle ................................................................................................. 27 4.5. Friction ..................................................................................................... 28 4.6. The BCN eMotorsport car: CAT15x ......................................................... 29 5. Software ______________________________________________ 31 5.1. MATLAB ................................................................................................... 31 5.2. Simulink ................................................................................................... 31 5.3. C++ .......................................................................................................... 32 5.4. Python ...................................................................................................... 33 6. Model simulation and analysis ____________________________ 34 6.1. Simulation setup ...................................................................................... 35 6.2. Simplified Model simulation ..................................................................... 38 6.3. Base Model simulation ............................................................................. 45
p. 8 Thesis 6.4. Simplified Model vs Base Model .............................................................. 55 6.5. Base Model vs More Complex Models .................................................... 59 6.6. Optimisation of the Model ........................................................................ 70 6.7. Optimised Model performance ................................................................. 71 7. Model applications _____________________________________ 77 7.1. Lane following using model predictive control ......................................... 77 7.2. Lane change assist using model predictive control ................................. 83 8. Economic assessment __________________________________ 89 9. Environmental assessment ______________________________ 90 10. Conclusions and further work ____________________________ 91 10.1. Conclusions ............................................................................................. 91 10.2. Further work ............................................................................................. 92 11. Acknowledgments ______________________________________ 93 12. Bibliography ___________________________________________ 94
Autonomous guidance of a Formula Student car p. 9 Abbreviations and Symbols BCN Barcelona CoG Centre of Gravity ETSEIB Escola Tècnica Superior d’Enginyeria de Barcelona FS Formula Student MPC Model Predictive Control MSE Mean Squared Error NLMPC Non-Linear Model Predictive Control ODE Ordinary Differential Equation RWD Rear Wheel Drive UPC Universitat Politècnica de Catalunya
p. 16 Thesis 2. Introduction 2.1. Motivation The motivation behind this thesis lies in the passionate commitment to automotive engineering and the desire to help in improving the tools and methodologies employed by the BCN eMotorsport team. By delving deeper into race vehicle modelling and simulation, the goal is to contribute to the team providing refined software-based analysis solutions, while leaving a valuable reference for future generations of members and collaborators. The elevation in these aspects could not only accelerate the learning curve but also facilitate and precise monitoring of the car’s performance, potentially reducing the time spent on extensive on-track testing and associated expenses. Therefore, this project aspires to be a catalyst for optimising resources and drive the team towards greater competitiveness and sustainability. 2.2. Scope While the ambitions outlined in the motivation are substantial, it is imperative to define the scope within which this thesis operates. Temporally, the focus is on the current Formula Student car of the BCN eMotorsport team (CAT15x), limiting the direct application to the timeframe of the existing vehicle and immediate future developments. Spatially and economically, the scope is limited to the operational environment and available resources of the team, supported by those provided by UPC (Universitat Politècnica de Catalunya). On an environmental scale, the work primarily addresses the physical aspects related to the vehicle’s performance and dynamics, as well as the impact that technologies employed may have, overlooking broader biological and social considerations. The technological focus is on developing vehicle representation tools useful for analysis and simulation, omitting high computing processes or exploration of extremely realistic scenarios. 2.3. Prerequisites For the successful realization of this project, several key prerequisites must be addressed. On a technical level, access to comprehensive literature and resources related to racing car dynamics, control systems, and Formula Student electric vehicles is essential, which mostly is facilitated by the BCN eMotorsport team. Additionally, the availability to obtain accurate real-world data from the CAT15x car is fundamental, including detailed information of its dynamic aspects. Regarding the costs derived from the software used for development, sufficient allocations for licenses are needed, which in fact are supplied directly by UPC or
Autonomous guidance of a Formula Student car p. 17 sponsors of the team. Establishing these prerequisites creates a solid foundation for a satisfactory execution of the proposed work, ensuring a well-prepared environment aligned with the objectives. 2.4. Objectives The overall aim of this thesis is to implement and optimise an effective model of the current electric Formula Student race car of the BCN eMotorsport team (CAT15x) in order to carry out accurate simulations and analysis based on data acquired from real life testing with the car. The specific objectives of this work are as follows: • Conduct a comprehensive literature review to identify and understand the principles of racing car dynamics and control systems, and more specifically of Formula Student electric vehicles. • Acquire and process real-world data from the BCN eMotorsport team’s racing car, including information on vehicle dynamics and control systems performance. • Develop a useful software-based analysis tool able to simulate the performance of mathematical models and compare their outcomes to real data, both graphically and quantitatively. • Test and compare the accuracy of several vehicle models proposed by analysing results obtained from simulations carried out through personally developed software and contrasting with real-world data. • Calibrate and validate the model considered that offers better precision through optimisation methods and real track testing, adjusting its parameters to obtain results as close to the reality as possible. • Integrate the car model into control systems and conduct simulations facing real based scenarios, to validate its utility in complex situations. • Document and present the results of this work in a comprehensive and accessible thesis report, serving as a useful reference for future BCN eMotorsport team members and other engineering students with a keen interest in the use of simulation, benchmarking and data acquisition and analysis methods in the development of racing cars.
p. 18 Thesis 2.5. Planning To effectively manage and schedule the tasks that need to be undertaken during the duration of this project, from October 2023 to January 2023, a system based on a Gantt chart is employed. In it, a visual representation of the planned tasks with the ideal time allocated for them is displayed, allowing an overview of the project timeline and ensuring a structured workflow through the stages of the thesis. Figure 1. Gantt chart of the thesis
Autonomous guidance of a Formula Student car p. 19 3. Formula Student Formula Student is a prestigious and recognized engineering competition since 1981, which brings together students from all over the world in designing and building a Formula style car to compete during summer. The popularity of the event has grown significantly, with over 20 Spanish teams, including 8 from Catalonia with various of them coming from faculties of Universitat Politècnica de Catalunya (UPC). The competition features combustion and electric categories, allowing teams to choose whether competing with a vehicle powered by petrol or electricity. In addition, for some years now teams can also participate in a driverless discipline, where the car is driven autonomously. As it is an engineering focused competition, the participating vehicles are subject to several static and dynamic tests, thus the winning team is determined by the highest overall score across these. 3.1. BCN eMotorsport This thesis is realized in collaboration with BCN eMotorsport team, which is formed by undergraduate engineering students from UPC Barcelona with the aim of developing a Formula Student vehicle capable of competing and obtaining good records in the national and international competitions in which it participates. History The first Formula Student team in Spain was created in 2007 under the name ETSEIB Motorsport by a small group of industrial engineering students from the ETSEIB (Escola Tècnica Superior d’Enginyeria Industrial de Barcelona) [1]. This team would become BCN eMotorsport a few years later. That first year, they developed a combustion engine car able to compete in Formula Student competitions, which received the name CAT01. During the following years, significant steps in terms of knowledge and recognition were made. In 2012, a radical change in direction was made, as electric mobility was embraced by creating the CAT05e, the first electric single-seater among all the Spanish Formula Student teams. In 2018, Driverless UPC, a parallel team from the same university, was established, and they were focused on the autonomous electric racing discipline. From 2018 to 2020, both ETSEIB Motorsport and Driverless UPC progressed independently. Later, in 2020, a pivotal moment took place, as the two teams of UPC merged to become BCN eMotorsport. This crucial decision was made in order to join forces and knowledge, as well as to meet new regulations requiring a single car for both manual and autonomous modes. During that season and the following one, fusion vehicles CAT14x and CAT15x respectively, were developed and employed in national and international competitions,
p. 20 Thesis obtaining successful results. In this moment, the team is already thinking in new improvements for the next car to come, the CAT16x, the one that will be used to participate in 2024 season. However, to this end, the CAT15x continues to be tested and studied, as it is the most cutting-edge car built to date by BCN eMotorsport team, and it continues fully operational. That is the main reason why this thesis is based on CAT15x car. Figure 2. Visual timeline of remarkable team events [1] Vehicle Controls This work is closely related to the vehicle controls section, where all the control systems for autonomous and manual architectures of the car are built, tested and implemented. The members of this section are responsible for the lower-level layers like torque vectoring, traction control and power management, as well as the path planning, state estimation and autonomous controller algorithms. The main objective is bridging the gap between planning and control, unlocking superior automobile behaviour on the track performances.
Autonomous guidance of a Formula Student car p. 21 4. Vehicle model To be able to accurately simulate the behaviour of the car without spending so much money, time and effort in specific testing with the real car, it is necessary to have a model that represents the car and as close to the reality as possible. 4.1. Kinematic bicycle model To get used to a simple initial model to afterwards try to improve it and optimise it to a more realistic one, a good idea is to start with a kinematic bicycle model. It consists of a simplified version of the kinematic four-wheel model, where it just has one rear and front wheel (imaginaries) replacing both rear and front wheels in the middle of them, respectively. This well-known model, which is quite appropriate for representing car motion under typical driving circumstances, also receives the name front wheel steering model, as the direction of the rear wheels is static whilst the front wheel orientation in relation to the direction of the vehicle can be adjusted. The inputs of the model are the velocity (v) and the steering angle (δ), and there is a constant variable, which is the length of the wheelbase (L). The distance reference is composed of two dimensions (x, y), which in this case is located in the centre of the rear axle. The ICR illustrated in the following figure is the Instantaneous Centre of Rotation. Figure 3. Representation of the kinematic bicycle model
p. 22 Thesis Making the necessary relations through trigonometry the following equations to compute the state change rate are obtained: [𝑥𝑦𝜃]=[𝑣∙𝑐𝑜𝑠𝜃 𝑣∙𝑠𝑖𝑛𝜃 𝑣𝐿∙𝑡𝑎𝑛𝜃](1) To get the final state, it is commonly used the forward Euler method by solving the ordinary differential equations after stating an initial state, as it is one of the basic but efficient methods to use when calculating by hand. Moreover, these types of calculus are often done through computer software, where other more advanced methods can be easily used. [𝑥𝑡+1 𝑦𝑡+1 𝜃𝑡+1]=[𝑥𝑡+𝑣∙𝑐𝑜𝑠𝜃∙∆𝑡 𝑦𝑡+𝑣∙𝑠𝑖𝑛𝜃∙∆𝑡 𝜃𝑡+𝑣𝐿∙𝑡𝑎𝑛𝜃∙∆𝑡](2) 4.2. Dynamic bicycle model In order to obtain a more accurate representation of car dynamics it is crucial to work with a more complex and sophisticated model than the kinematic bicycle model. As a natural evolution from it, the dynamic bicycle model appears. In contrast to the kinematic one, which assumes that a vehicle’s motion can be described solely by its position and orientation, the dynamic bicycle model considers the distribution of the mass of the vehicle and some essential forces that are involved during motion. For these reasons, this more complex model is far more adequate when dealing with scenarios involving simulations and analyses. The model considers the longitudinal velocity (Vx), as well as the lateral (Vy) and rotational (r) ones. The force provided by the motors (Fm), the steering angle (δ) and the yaw angle (θ) are also reflected, and the same goes for the constant variables noting the distance from front and rear wheels to the CoG (Centre of Gravity), which are Lf and Lr, respectively. Additionally, the forces regarding friction and the interactions on the tires, alongside the slip angle for front and rear axles (all of them detailed in the following sections), are regarded.
Autonomous guidance of a Formula Student car p. 23 Figure 4. Representation of the dynamic bicycle model The kinematic part of the model is defined by the equations: [𝑥𝑦𝜃]=[𝑣𝑥∙cos𝜃−𝑣𝑦∙sin𝜃 𝑣𝑥∙sin𝜃+𝑣𝑦∙cos𝜃 𝑟](3) The dynamics of the vehicle are represented through: [𝑣𝑥 𝑣𝑦 𝑟]= [ 1 𝑚(𝐹𝑚(1+cos𝛿)−𝐹𝑦,𝐹sin𝛿+𝑚 𝑣𝑦 𝑟 −𝐹𝑓) 1 𝑚(𝐹𝑚sin𝛿+𝐹𝑦,𝑅+𝐹𝑦,𝐹cos𝛿+𝑚 𝑣𝑥 𝑟) 1 𝐼𝑧(𝐿𝐹(𝐹𝑚sin𝛿+𝐹𝑦,𝐹cos𝛿)−𝐹𝑦,𝑅 𝐿𝑅 ] (4) Regarding the particular case of the CAT15x, it boasts a powerful rear wheel drive system (RWD) system, a feature that significantly influences its handling dynamics. Unlike front wheel drive (FWD) vehicles, where the engine’s force propels the car through the front wheels, or all-wheel drive (AWD) vehicles, where that force is propelled through all wheels,
p. 24 Thesis the car built by BCN eMotorsport students channels its power to the rear wheels. This configuration requires some modifications in the general dynamic bicycle model stated above (4), as the absence of engine force acting directly on the front tires impacts the overall behaviour of the vehicle. The adapted dynamic equations to represent a RWD car are: [𝑣𝑥 𝑣𝑦 𝑟]= [ 1 𝑚(𝐹𝑚(1−𝐹𝑦,𝐹sin𝛿+𝑚 𝑣𝑦 𝑟 −𝐹𝑓) 1 𝑚(𝐹𝑦,𝑅+𝐹𝑦,𝐹cos𝛿𝑚− 𝑣𝑥 𝑟) 1 𝐼𝑧(𝐿𝐹 𝐹𝑦,𝐹cos𝛿−𝐿𝑅 𝐹𝑦,𝑅) ] (5) 4.3. Tire modelling Tires play a crucial role in automotive vehicles, as the performance, efficiency and safety of vehicles depend largely on how the tires interact with the road or surface they are on. However, modelling this interaction is a very complex work because many factors must be considered, such as camber (the angle at which the tire contacts the road), load (weight placed on the tire) and various external conditions depending on the environment. The goal is to develop a model that accurately represents the behaviour of the tires of a vehicle across a wide range of operating conditions. The most common model used to represent the tires is the Pacejka tire model, which in practice is known for its accuracy in terms of emulating reality [14]. To be able to calculate the lateral force (it is customary to only consider the lateral force as it provides suitable results for not extremely advanced studies) using the Pacejka magic formula, it is needed to consider the vertical load on the tire (Fz) several constant parameters such as the stiffness factor (B), the shape factor (C) and the peak value (D). To obtain its values, the following formulas are applied: We define C as a constant value between 1 and 1,8. 𝐷=𝐹𝑧(𝑎1 𝐹𝑧+𝑎2)(1−𝑎15 γ2) (6) BCD=𝑎3sin(arctan(𝐹𝑧 𝑎4)2)(1−𝑎5 |γ|) (7) 𝐵=𝐵𝐶𝐷 𝐶𝐷 (8)
Autonomous guidance of a Formula Student car p. 25 𝐸=(𝑎6 𝐹𝑧+𝑎7)+(1−(𝑎16 γ+𝑎17)𝑠𝑖𝑔𝑛(α+𝐻))(9) The vertical load (Fz) comprises the gravity (g) and the mass of the vehicle and the driver (m): 𝐹𝑧=𝑔⋅𝑚 (10) It is also crucial to consider the horizontal shift (H), the vertical shift (V) and the slip angle (α), which are calculated as follows: H=a8 Fz+a9+a10𝛾(11) V=𝑎11 𝐹𝑧+𝑎12+(𝑎13 𝐹𝑧+𝑎14) γ 𝐹𝑧(12) Bx1=B(α+𝐻) (13) With all the previous parameters defined, it is possible to obtain the lateral force generated by the tires through the magic formula, which is stated as follows: Fy=Fz⋅D⋅sin[C⋅arctan(Bx1−E⋅(Bx1−arctan(Bx1)))]+V (14) As a car has two front and two rear wheels, to obtain more realistic results it is necessary to use different Pacejka constant values for front and rear tires, as the behaviour of them is usually quite different. Therefore, two different lateral forces are obtained, Fy,F for the front axle and Fy,R for the rear one. Simplified Magic Formula (constant coefficients) To facilitate the analysis and computation of tire behaviour, it is often employed a simplified approach of the Pacejka magic formula that relies on using the four dimensionless B, C, D and E coefficients as constant values. These, they do not depend on load, camber or further
p. 32 Thesis control systems and algorithms, and that is one of the main reasons why it is widely used in this particular project. By the usage of several blocks and subsystems in the Simulink environment, as well as some built-in tools, the team is able to represent the system dynamics of the car and the control systems and algorithms that act upon it. For all the things stated above, Simulink complements MATLAB as the essential computational and simulation engine driving the success of this project and the team. Figure 7. Simulink scheme used by BCN eMotorsport for traction control 5.3. C++ C++ is a programming language that offers high performance, flexibility and control over hardware and software resources. It is extensively used for software development and scientific applications that require speed, efficiency and reliability. For Formula Student projects, C++ is particularly useful when it comes to the implementation of complex control algorithms and data structures, as well as to interact with the hardware and sensors of the vehicle. Also, it can be used to integrate the system with a commonly used framework for developing and running software for robots called ROS (Robot Operating System), which is a feature that makes it really interesting when working with a race car. For the purposes of this thesis, C++ is used in the background for certain control systems and algorithms related to the car, as well as code that is generated in that language through the schemes and simulations carried out in Simulink, usually to make it more appropriate when implementing them in real life, but it is not used directly to develop the modelling, analyses and simulations done.
Autonomous guidance of a Formula Student car p. 33 5.4. Python Python is one of the most versatile open-source programming languages. It is renowned for its simplicity and readability, while excelling in importing, processing and analysing data, which makes it an interesting option for comprehensive vehicle modelling and real data analysis tasks. Its wide ecosystem of libraries such as Pandas, NumPy, Matplotlib, or SciPy, as well as all the existing forums and documentation about Python given the strong community that surrounds it, allows engineers and scientists an efficient handling of datadriven projects. First preliminary analyses and simulations in this thesis were done through the development of various notebooks and scripts based on Python. However, after those initial approaches, a strategic decision was made to consolidate virtually all software usage to MATLAB as the project evolved. This shift was motivated by the superior suitability of MATLAB for handling complex mathematical modelling and calculations, in addition to its extensive included toolboxes specifically built for vehicle modelling and simulation (and given that UPC provides licenses to the students). Furthermore, it was taken under consideration that MATLAB is the main tool used by the BCN eMotorsport team in aspects closely related to vehicle control and dynamics, so working with the same tools facilitates smooth integration and collaboration within the team.
p. 34 Thesis 6. Model simulation and analysis Comprehensive analyses of several models are undertaken through simulation to delve into their complexities. The simulation section constitutes a pilar model of this thesis. Four distinct bicycle models are employed to evaluate their capacity in representing the realworld dynamics of the vehicle CAT15x. The accuracy of the various models is tested and analysed by subjecting them to comparisons with real data derived from trial runs with the actual car. In the simulations, the models are fed with torque values for both front and rear axles, and steering angle values, obtained from the sensors of the car during the trial runs. The outputs generated by the models are meticulously examined, focusing on key parameters such as the lateral, the longitudinal and the rotational velocities. The comparison is conducted by visualizing these simulated velocity values over time through graphs and quantitatively analysing the MSE (Mean Squared Error) against the velocities directly captured by sensors during real-life runs, which provides the average squared differences between the model's predictions and the actual values. This approach enables a detailed assessment of each model’s behaviour (visually through graphs and quantitively through the error) in response to the exact same real-world inputs, clarifying their capabilities and limitations in accurately replicating the dynamics of the vehicle. Real-life testing data To execute the simulations and subsequent analyses, real-life data from tests conducted by the BCN eMotorsport team with the CAT15x car is used. These tests are mainly conducted to see where is room for improvement in order to obtain better results in competitions, either by increasing reliability or by trying to reduce lap times. Three distinct datasets are employed, each extracted from a singular run conducted on different days during 2023 year. In the runs considered the car is driven in autonomous mode around different track layouts, which are designed following similar scenarios to those of the competitions. Specifically, a first analysis and simulation are carried on with data captured on October 19, followed by a second one using information from December 17, and a final analysis based on data acquired on December 29. These selection of datasets from diverse days is rooted in the intention to capture the model’s behaviour under varying weather conditions and diverse track scenarios. This multifaceted approach ensures a robust evaluation, enhancing the reliability and applicability of the models across a range of dynamic driving environments.
Autonomous guidance of a Formula Student car p. 35 Figure 8. CAT15x undergoing autonomous dynamic tests Vehicle models The first model proposed (Simplified Model) encompass a simplified dynamic bicycle model version with a lateral velocity that is considered as an input, taken directly from real-data. The second model considered (Base Model) it is also a dynamic bicycle model, but this one comprehends both lateral and longitudinal velocity as variables, therefore making it much more complete. This both models, the Simplified and the Base one, use some constant parameters approximated by the team considering the Pacejka magic formula with some given parameters by the tire manufacturer, in order to calculate the forces that represent the interaction of the vehicle tires with the road. The next models of the vehicle presented are two intricate variants derived from the Base one, as they also contemplate a fundamental dynamic bicycle model. The main differences with the Base Model are in how the forces that act on the tires are calculated, since here an auxiliary function is used in order to theoretically obtain more precise values than when calculating it through some approximated coefficients for the Pacejka magic formula. Regarding these last two, they are practically identical, but one of them (Calc Fy Model) considers the vertical load of the tires as if the car has the weight perfectly distributed between both axes, and the other one (Calc Fz & Fy Model) pretends to be more realistic taking into account the real position of the CoG (Centre of Gravity). 6.1. Simulation setup The structure of the simulation is organized comprising some fundamental MATLAB functions and scripts (Solver, Simulator and Comparator, Vehicle Model Definer, Data Preparation and Model Optimiser), while calling some other auxiliary functions (Forces Calculator and MSE Calculator) and built-in tools (ODE Solver and Pattern Search). The principal functions are responsible for defining the vehicle models and its differential equations that will be considered during the concrete simulation. In tandem, the whole
p. 36 Thesis simulation is run from a main script that is formulated to function as a solver, simulator and comparator. It is built to orchestrate the simulation process through loading real test data, calling and executing the mode functions, and finally comparing them graphically and quantitatively. This organizational setup ensures clarity and efficiency in the exploration of the accuracy of different car models and provides the user visual representations as well as quantitative results in order to be able to analyse the results. Figure 9. Conceptual map of the simulation structure Solver, Simulator and Comparator This is the main script of the simulation structure, as it solves the vehicle models, performs simulations with them considering real-data, and provides a graphical and quantitative display of their outcomes. It begins with the establishment of some constant parameters, as well as with the usage of the Data Preparation function to prepare the real testing data. Subsequently, the built-in function ODE45 is used to solve each of the vehicle models to be considered in a concrete simulation. After the simulations are completed, it follows with plotting the estimated values obtained for all models and the real ones, displaying them side by side in three distinct graphs (for lateral, longitudinal, and rotational velocity against time). These visualizations provide a comprehensive overview of the variations between the different models considered, and against the reality. Additionally, mean squared error values are calculated using the MSE Calculator function, displaying them to offer a quantitative evaluation. Finally, the script saves the charts in a specific folder chosen by the user. In brief, this script serves as the primary pilar of the simulation and analysis setup, serving as the main tool for running all simulations and providing all needed valuable insights for analysing and comparing different vehicle models accuracy.
Autonomous guidance of a Formula Student car p. 37 Vehicle Model Definer It defines the vehicle model used in the simulation and computes the differential equations governing its motion. First, it states several constants defining the physical properties of the car, such as aerodynamic parameters, tire characteristics, mass or the inertial moment. Additionally, a condition based on time is defined to ignore some extremely small input steering values. Then, it describes the equations of the bicycle model and the ones defining the forces that are considered during the simulation, like the vertical load on the tires, slip angles or friction forces (in some of the models, few of these equations are defined through calling some auxiliary functions, which are stated separately in order to maintain a more clean and optimised script). Finally, the code incorporates an order reduction process, which provides a set of ODEs (Ordinary Differential Equations) that represent the lateral and longitudinal dynamics of the car. In summary, this script is where the vehicle model is defined, facilitating the subsequent simulation and analysis of its dynamic behaviour under various inputs and conditions. Model Optimiser This script is designed to enhance the accuracy of a vehicle model by iteratively optimising some of its parameters based on real data inputs. First, it defines the parameters subjected to optimisation and pre-processes the data using the Data Preparation function, following with a simulation process of the model. In addition, lower and upper bounds for the parameters to optimise are set to avoid obtaining unrealistic results. Then, the script employs the Pattern Search function to refine the parameters iteratively, which uses the MSE Calculator one to evaluate the error for each iteration. The outcome of the optimisation process is the determination of the optimal parameters that result in the minimum MSE for the model estimations against the reality. Finally, the obtained values are displayed, alongside insights into the runtime and iterations of the optimisation. Data Preparation It is used for preparing and processing the data obtained from the real tests done with the car. First, this function loads all the data coming from the tests, which is saved in a csv file that consists of a table with an innumerable number of columns representing different information measured by the sensors mounted on the car. Then, it selects from that file just the parameters that are used in the other scripts and functions during the simulation process, and it removes some of the first and some of the last values of the data collected that are not useful for the analysis (mainly because in the very first and last moments of the test runs, the car is not moving) and it filters out some other values that are extremely low and could cause problems. In addition, through some equations it calculates the force applied by the motors. Finally, it returns the outputs of this MATLAB code function, which are a table with the data that is useful and ready to be used in the analyses and simulations,
p. 38 Thesis and the force provided by the engines. MSE (Mean Squared Error) Calculator This function is essentially designed to facilitate quantitative analysis of simulation outcomes through computing their mean squared error values with respect to the real data. It serves as a fundamental tool within the Model Optimiser script, as its primary function is to gauge the error by comparing simulation results against real data. Additionally, it plays a main role in the Solver, Simulator and Comparator script, in order to display the MSE values for all simulations carried on each time. Forces Calculator The role of this function is to precisely compute the values for the interaction forces exerted on the tires of the vehicle. It takes some parameters coming from real data as inputs, which are processed through some sophisticated operations calibrated with corrector coefficients, to finally deliver accurate values for the force in question. These obtained outcomes are dependent on a functional relationship with slip angle. It is specifically used in the Vehicle Model Definer script when considering one of the more complex models (Calc Fz & Fy). Built-in Functions (ODE45, Pattern Search) Two pivotal MATLAB built-in functions are employed within the simulation setup. ODE45, short for Ordinary Differential Equation 45, stands as a robust solver used for solving differential equations. In this context, it is used to numerically solve the ODEs of the models that describe their evolution over time, making it a relevant component for conducting the simulations, providing precise solutions. On the other hand, the Pattern Search function essentially works an optimisation algorithm that explores a parameter space, iteratively adjusting values to find the minimum of a function. Regarding this project, it is called within the Model Optimiser script to adjust some parameters of the model minimizing the discrepancies between simulated outcomes and real data. 6.2. Simplified Model simulation The model used in this simulation employs a simplified dynamic bicycle model composed of the equations detailed in Section 4.2 in combination with the equations for calculating the slip angle, the friction (drag force and rolling resistance), and the tire interactions with the surface through the Pacejka magic formula. Notably, it considers the lateral velocity (Vx) as an input, directly extracted from real data from the tests. This simplification allows working with a more basic representation of the model while providing foundational understanding of the vehicle dynamics. This serves as a valuable initial small-scale demonstration to assess whether the model behaves in a way that appears to start from an appropriate basis.
Autonomous guidance of a Formula Student car p. 39 Such insights are particularly helpful in determining if further development in this direction is worthwhile or if some adjustments are needed. As detailed before, the data used to carry on the simulations is obtained from BCN eMotorsport’s CAT15x tests on October 19, December 17 and December 29, in order to get a realistic and reliable evaluation of the model’s performance. As in the case of this Simplified Model the longitudinal velocity (Vx) is an input coming from real data, it makes no sense to study it, and that’s why only lateral and rotational velocity are considered. October 19, 2023 Test Figure 10. Lateral velocity obtained for the Simplified Model under October 19 data Regarding the Figure 10 it can be said that both the Simplified Model and real data show a similar trend for the lateral velocity: an initial spike around the 14 second mark followed by a gradual decrease, which reflects an initial fast move from the car and more stables moves after that. However, there is a remarkable difference between both lines as the real data has far more pronounced fluctuations than the Simplified Model, meaning that in this case the model is not that effective in predicting the reality as it ignores some of the factors that affect the vehicle’s lateral velocity.
p. 40 Thesis Figure 11. Rotational velocity obtained for the Simplified Model under October 19 data For the rotational velocity, the simulated one obtains similar values as the real values among all the run, closely following the same path over time and presenting the same frequency of oscillation. Therefore, it can be said that in this case the Simplified Model presents a really accurate approximation. However, the Simplified Model slightly smoothens some fluctuations that appear in the reality. Simplified Model MSE Lateral Velocity 0,4809 MSE Rotational Velocity 0,0372 Table 1. Mean Squared Error in velocities for the Simplified Model under October 19 data Quantitatively analysing the Simplified Model MSE for both lateral and rotational velocities among this first run, it is quite apparent that it presents a fairly good approximation. Nonetheless, it reveals distinct performance characteristics for lateral and rotational velocity, as the MSE is notably lower for the rotational velocity, suggesting that regarding this first test the model has better accuracy in predicting the rotational values of the velocity.
Autonomous guidance of a Formula Student car p. 41 December 17, 2023 Test Figure 12. Lateral velocity obtained for the Simplified Model under December 17 data The prediction of the lateral velocity in this precise run follows the same overall trend as the real one, but seems markedly deviated when the values are low. For example, it can be seen that the Simplified Model tends to underestimate the lateral velocity when it is positive and overestimate it when it is negative, and at the top of the first velocity peak that appears from the second 15 to 18, the model presents some misleading values. Moreover, these differences are not that remarkable in absolute terms, as in this run the speeds are generally low (-2 to 3,5 km/h), and this visually makes the deviation appear larger than it is.
p. 48 Thesis Figure 18. Rotational velocity obtained for the Base Model under October 19 data In this case, the simulated values of rotational velocity for the Base Model closely mirrors the reality throughout most of the run. The trajectory followed is softer in the peaks, but the oscillation frequency and values obtained are similar to the ones from real data. Moreover, during the last 10 seconds of the simulation some notable deviation appears. Base Model MSE Longitudinal Velocity 1,2871 MSE Lateral Velocity 0,5276 MSE Rotational Velocity 0,0474 Table 5. Mean Squared Error in velocities for the Base Model under October 19 data Considering the MSE values obtained during this first dataset for the Base Model, it appears that there is a considerable disparity between the predicted and actual values in the longitudinal velocity. Anyway, checking the corresponding graph (Figure 16) it seems that the higher error value could be probably caused because the longitudinal velocities reach higher values than the lateral or rotational ones, and in a short amount of time (fast accelerations), which might be an influential factor. Meanwhile, the Base Model exhibits relatively better accuracy in predicting lateral velocity, and suggests considerably great precision in predicting rotational motion, as reflected by its low MSE.
Autonomous guidance of a Formula Student car p. 49 December 17, 2023 Test Figure 19. Longitudinal velocity obtained for the Base Model under December 17 data On Figure 19 it is can be observed that the simulated longitudinal velocity for the Base Model presents the same fluctuations over time as the real data from the test, though there is a significant offset during almost all the run. The actual data has two more extreme peaks during the first 20 seconds in comparison to the simulated one where are softened.
p. 50 Thesis Figure 20. Lateral velocity obtained for the Base Model under December 17 data Observing the diagram, it is clear that there are some existent discrepancies between the Base Model predicted results and the reality in terms especially in terms of the amplitude and frequency of the lateral velocity changes. In particular, the Base Model often provides lower values when the velocity is positive and higher ones when it is negative, and there also are some inaccurate appearances at the top of the first velocity peak. However, the trend that follows the Base Model is almost identical to the real data, and the differences named are don’t seem much significant considering that the speeds in this run are generally low, which could make them look bigger than really are.
Autonomous guidance of a Formula Student car p. 51 Figure 21. Rotational velocity obtained for the Base Model under December 17 data The rotational velocity obtained from the simulation of the Base Model in this case mostly matches the real data obtained from the trial. In any event, some inaccurate values are given particularly at the highest points of the first apex, whilst in the last part of the run (from the second 30 to the end) more extreme values are obtained in the highest and lowest points. Base Model MSE Longitudinal Velocity 3,8851 MSE Lateral Velocity 0,0817 MSE Rotational Velocity 0,0947 Table 6. Mean Squared Error in velocities for the Base Model under December 17 data Comparing quantitatively the differences between the velocities predicted by the Base Model and the reality, it can be said that in terms of lateral and rotational velocities the model offers reasonable precision. Besides, the MSE for the longitudinal velocity is relatively elevated, and from having a look at the corresponding chart (Figure 19), it can be deduced that this difference could be mainly due to the fact that the longitudinal speeds are high and the existing offset during almost all the run has a significant effect.
p. 52 Thesis December 29, 2023 Test Figure 22. Longitudinal velocity obtained for the Base Model under December 17 data In the figure above it is showed that the simulated longitudinal velocity by the model follows the same path as the data coming from the test. Even though, the accuracy drops in the extreme values, as the simulated values are slightly flattened, and during the latest 5 seconds of the run where the Base Model fails to be precise slowing down less than expected.
Autonomous guidance of a Formula Student car p. 53 Figure 23. Lateral velocity obtained for the Base Model under December 17 data Visualizing the lateral velocity against time during this particular run, it can be stated that the general course of both data obtained by the simulation through the model and the real data is alike. There are still some discrepancies in the magnitude and frequency of the fluctuations, where are more pronounced and abrupt in the reality than in the lateral velocity the model provides.
p. 54 Thesis Figure 24. Rotational velocity obtained for the Base Model under December 29 data With respect to Figure 24, it is clear that the rotational velocity obtained by the Base Model has a very close resemblance to the trial data. Despite a slight existent discrepancy in the first 12 seconds of the run and in some of the maximum and minimum values, the rotational velocity provided by the Base Model matches constantly the actual values. Base Model MSE Longitudinal Velocity 3,9182 MSE Lateral Velocity 0,1828 MSE Rotational Velocity 0,0316 Table 7. Mean Squared Error in velocities for the Base Model under December 29 data Regarding the MSE values for the velocities obtained with this particular set of data, the less accurate prediction is clearly for the longitudinal velocity, as its value is relatively high. By checking its graph (Figure 22), it doesn’t seem to be that inaccurate except for the last 5 seconds, so it might be the cause of that final values. In contrast, the Base Model presents a better performance in predicting lateral velocity, and even more in the rotational velocity case, where the value of mean squared error found is minimal, stating its reliability.
Autonomous guidance of a Formula Student car p. 55 Average results Considering each run of the three different sets of data used for the simulations, the following averages for the MSE values are obtained: Base Model Avg MSE Longitudinal Velocity 3,0301 Avg MSE Lateral Velocity 0,2640 Avg MSE Rotational Velocity 0,0579 Table 8. Average Mean Squared Error in velocities for the Base Model Analysing the average of the MSE for the longitudinal, lateral and rotational velocities among the three sets of real data chosen, it can be generally affirmed that the Base Model offers a very decent performance. Comparing the averages to the individual test results, it can be seen that the simulation carried on with the test data from October 17 differs from the other two, as it obtains the lower error value for longitudinal velocity but higher values for both lateral and rotational velocities. The best prediction for lateral velocity is obtained with the dataset from December 19, and for longitudinal velocity with the last simulation, involving data from December 29. Despite these variations across the different runs, the average relatively low MSE values demonstrate that the Base Model manages to predict the velocities effectively in all the situations presented, especially the lateral and rotational ones. Regarding the average MSE obtained for the longitudinal velocity, it is clear that it is a bit high, but analysing the diagrams against time (Figures 16, 19 and 22) it can be concluded that the cause of this is due to the higher values of velocity reached, as the simulated data follows almost exactly the same pattern as the real data but with some offset or a located mistake on the last few seconds. 6.4. Simplified Model vs Base Model An in-depth comparison of the simulation results obtained for the Simplified Model and the Base Model is conducted. By juxtaposing the predicted lateral and rotational velocities from both models in the same graphs, as well as the values from real data, the results are examined both visually and quantitatively thus providing valuable insights into the effectiveness and limitations of each model.
p. 56 Thesis October 19, 2023 Test Figure 25. Lateral and rotational velocities comparison under October 19 data Regarding the velocity predictions of the Simplified and Base models, it can be seen that they are really similar between them in terms of accuracy against real data. The Simplified Model, however, performs better specifically during the very last seconds of the run, where the Base Model tends to deviate by showing more extreme values. Simplified Model Base Model MSE Lateral Velocity 0,4809 0,5276 MSE Rotational Velocity 0,0372 0,0474 Table 9. Mean Squared Error in velocities under October 19 data by vehicle model In terms of the error observed for each model, the Simplified Model is slightly more precise in predicting the velocities than the Base Model. Nevertheless, both are quite similar, and the difference is not very pronounced.
Autonomous guidance of a Formula Student car p. 57 December 17, 2023 Test Figure 26. Lateral and rotational velocities comparison under December 17 data Comparing the lateral and longitudinal velocities obtained for the Simplified and Base models among data obtained at December 17 test, it is plain that both models provide similar outcomes. Even so, some differences can be spotted, as the Simplified Model is closer to the reality in the peak values, where the Base Model deliver anomalies particularly during the last part of the run. Simplified Model Base Model MSE Lateral Velocity 0,0750 0,0817 MSE Rotational Velocity 0,0454 0,0947 Table 10. Mean Squared Error in velocities under December 17 data by vehicle model In relation to the MSE values, there is no doubt that the Simplified Model performs better, particularly in estimating rotational velocity. Yet, the performances for the lateral velocity are near.
p. 64 Thesis Figure 32. Lateral velocity comparison under December 17 data In relation to the results for the lateral velocity displayed on the figure above, it can be stated that both two more complex models behave really similar, following the same steps as reality but with some remarkable uniform deviation, whilst the Base Model has a clearly different behaviour. It starts reflecting a comparable deviation but then more pronounced extreme values, making it more precise in some cases like around the second 36, but penalizing it in other moments.
Autonomous guidance of a Formula Student car p. 65 Figure 33. Rotational velocity comparison under December 17 data All three models considered mostly obtain the same estimated rotational velocity values in this simulation, with no significant differences between them, and are quite in line with reality. However, some values are inaccurate especially at the first peak and around the highest and lowest points in the final part of the run. Base Model Fy Model Fz & Fy Model MSE Longitudinal Velocity 3,8851 3,2510 3,2710 MSE Lateral Velocity 0,0817 0,0576 0,0563 MSE Rotational Velocity 0,0947 0,0907 0,0933 Table 14. Mean Squared Error in velocities under December 17 data by vehicle model Considering the errors calculated for the simulated velocities in this run, it can be claimed that both the Calc Fy and the Calc Fz & Fy models outperform the Base Model in all three velocities. Moreover, the two more complex models receive practically identical MSE values, slightly better for the Fy Model in longitudinal and rotational velocity, but with no significant differences. It is worth noting that the error for the longitudinal velocity for all the models is relatively elevated, yet it might be due to the fact that the longitudinal speeds reached are high and some offset appears having a significant effect.
p. 66 Thesis December 29, 2023 Test Figure 34. Longitudinal velocity comparison under December 29 data The graph shows that in terms of simulating the longitudinal velocity for this specific run, the three models contemplated follow more or less the same trajectory, which clearly looks like the one from real data as they fluctuate in the same points, but in a smoothed way. In addition, none of the models predicts in an accurate manner the final deceleration which takes place in the last 5 seconds. Between the Base Model and the more complex models, the principal variations reside in the higher values that obtains the Base Model during almost all the run.
Autonomous guidance of a Formula Student car p. 67 Figure 35. Lateral velocity comparison under December 29 data For the lateral velocity simulation, it can be seen that the overall trend of the data estimated by the models and the real data looks similar, although there are some discrepancies in the size and rate of the variations. Comparing the values of the velocity obtained for each model, it seems that both Calc Fy and Calc Fz & Fy have a better behaviour specifically when the values are small, while the Base Model tends to be imprecise there.
p. 68 Thesis Figure 36. Rotational velocity comparison under December 29 data As for the simulation results illustrated in Figure 36, the rotational velocities estimated by the models are really close to reality for all of them. Taking a deep look into each model, the Base one is more exact, because in the extreme low values the Calc Fy Model tends to overestimate them, and so does it the Calc Fz & Fy Model, but to a lesser extent. Base Model Fy Model Fz & Fy Model MSE Longitudinal Velocity 3,9182 3,5664 3,4725 MSE Lateral Velocity 0,1828 0,1923 0,1845 MSE Rotational Velocity 0,0316 0,0533 0,0464 Table 15. Mean Squared Error in velocities under December 29 data by vehicle model With regard to the MSE values obtained for the velocities during this simulation, the Base Model offers a more accurate precision in predicting lateral and rotational velocity. However, the errors obtained by the Fz & Fy Model are similar in magnitude, and the ones from the Fy Model are not so far. For the longitudinal velocity, in all cases is relatively elevated, but as stated in the previous simulation, it might be related with an existent offset when high speeds are involved.
Autonomous guidance of a Formula Student car p. 69 Average results Considering each run of the three different sets of data used for the simulations, the following averages for the MSE values are obtained: Base Model Fy Model Fz & Fy Model Avg MSE Longitudinal Velocity 3,0301 2,9109 2,7960 Avg MSE Lateral Velocity 0,2640 0,2181 0,2115 Avg MSE Rotational Velocity 0,0579 0,0693 0,0641 Table 16. Average Mean Squared Error in velocities by vehicle model Examining the average MSE values obtained for each model across the three different simulations, it is notable that for lateral and rotational velocities the predictions are fairly precise for all three models. Regarding the average error obtained for the longitudinal velocity, it is undeniable that it is a bit high, but going through its charts (Figures 28, 31 and 34) it can be concluded that it is caused by the high lateral velocity the car reaches, as the simulated data follows almost exactly the same pattern as the data from the tests, but with some offset or located missteps on fast speed changes. Taking a deeper look at the error values, the lowest one for the rotational velocity is obtained by a small margin by the Base Model, whilst for the longitudinal and lateral velocities it goes for the Calc Fz & Fy Model. As for Fy Model, there is not much to highlight, as its MSE values fluctuate in between the others and do not stand out either positively or negatively. Then, it can be stated that the overall performance of the Calc Fz & Fy Model is slightly better than the Base Model in almost all situations, the one from which it is derived. While it is true that in predicting rotational velocity the Base Model is somewhat superior, in terms of longitudinal and lateral velocity, where the accuracy obtained through the simulations is notably lower, the Calc Fz & Fy Model unquestionably prevails. It is also important to highlight that within the BCN eMotorsport team, some inaccuracies have been identified in specific sensor calibrations in the CAT15x. Consequently, potential for errors might have been manifested in the raw data obtained directly from the tests, particularly in relation to lateral velocity (Vy). Additionally, reviewing all the graphs obtained during the simulations, it becomes apparent that the displayed real data exhibits a considerable amount of noise, which is attributed to the absence of robust noise filtering in the current data acquisition process.
p. 70 Thesis 6.6. Optimisation of the Model In pursuit of enhancing the predictive capabilities of the vehicle model, an optimisation strategy is explored to try to refine its performance across longitudinal, lateral and rotational velocities. The previous evaluations, as detailed in the preceding sections, pointed out the strengths and weaknesses of different models. Notably, the Calc Fz & Fy Model demonstrated a slightly superior overall performance compared to the other models studied. However, through the analysis of mean squared error values it was clear that there still exists room for improvement, specifically in addressing anomalies during rapid speed changes and mitigating observed offsets. The optimisation process is centred on reducing the error in estimating longitudinal velocity, given its considerable deviation obtained in comparison to lateral and rotational velocity. The strategy is to fine-tune the parameters related with friction, the drag coefficient (Cd), and the rolling coefficient (Cr). These crucial constants used in the models are currently provided by the team, and are said to come from tests carried out with the CAT15x car. However, the origin of these values remains unclear, and as their precision is subject to question, the main aim is to potentially recalibrate them. As a reminder, the values of the coefficients used on the previous simulations, as detailed on the Friction section, were the following: 𝐶𝑑=1,793 𝐶𝑟=0,0045 Optimisation method The process is executed using the Pattern Search function in MATLAB, a greatly effective tool for finding optimal points by iteratively exploring the parameter space [16]. Specifically, Pattern Search operates by establishing a sequence of points (x0, x1, x2, …) that converge toward an optimal point, ensuring that the objective function decreases or at least remains constant during the progression. The procedure is conducted across the same three datasets collected from the real tests performed with the car in the previous simulations, as it enables to replicate the exact same simulations facilitating a consistent comparison of the model’s performance before and after the optimisation. In this particular case, the function is set to find the best combination of Cd and Cr values in a maximum of 50 iterations, in order to obtain the minimum longitudinal velocity MSE when running simulations with the model. To ensure that the obtained values for the coefficients are realistic and applicable, specific ranges based on typical values observed in formula cars are established. These aim to comprise values that are both practical and reflective of the dynamics commonly
Autonomous guidance of a Formula Student car p. 71 encountered in motorsport scenarios. The range assigned for the drag coefficient (Cd) is [0,6; 1,8] and for the rolling coefficient (Cr) is [0,0045; 0,003]. Optimisation results After executing the optimisation process three times, each employing the data collected from one of the real-life tests as done before with the simulations, the resulting optimised values for the coefficients are detailed in the next table: Cd Cr Test 19 October 2023 0,7930 0,0199 Test 17 December 2023 1,7928 0,0228 Test 29 December 2023 1,7930 0,0050 Average 1,4596 0,0159 Table 17. Optimised drag and rolling coefficients for each test data The optimised coefficient values exhibit some variability across the different tests involved. For the drag parameter, the obtained value derived from the inputs of the real data obtained in October is considerably lower than the original one, whilst the ones involving the tests done in December are pretty close to it. On the other hand, in the case of the rolling resistance, the optimised coefficient nearer to the original one is the corresponding to the December 29 test, whereas regarding the values achieved with the other two tests are significantly higher. Moreover, the Cd average value obtained is inferior than the one used before, but for the Cr is the opposite case. As declared, the ultimate objective of the optimisation is to enhance a model that demonstrates an overall improved performance. So even though there is variability between the obtained coefficients, the average values of them will be considered in all subsequent simulations and analyses, with the intention to achieve generalized better outcomes. With this approach, the focus is centred in evaluating the new model’s efficacy in delivering consistent upgrades in estimating velocities across diverse scenarios. 6.7. Optimised Model performance With the intention of analysing the behaviour of the Optimised Model (which is, in fact, the Calc Fz & Fy Model with the friction coefficient values derived from the optimisation process), a comprehensive comparison with the original model (Calc Fz & Fy Model) is conducted. To this end, the simulations carried out earlier with all the other models are mirrored, but in this case displaying the predicted longitudinal, lateral and rotational velocities from both models on the same graph, alongside the real data values. Therefore, a comparative analysis can be conducted both visually and quantitatively with the aim to
p. 72 Thesis determine the extent of improvement achieved throughout the optimisation process. October 19, 2023 Test Figure 37. Longitudinal and lateral velocity comparison under October 19 data Figure 38. Rotational velocity comparison under October 19 data Regarding the figures above it seems that the Optimised Model draws practically an identical pattern as the original one for all three velocities, there are no visually appreciable major differences for any of them. In any case, it does appear to be some small dissimilarities at certain points in the final part of the run, but not enough significant to form conclusions. Original Model Optimised Model Improvement MSE Longitudinal Velocity 1,6444 1,6599 -0,94% MSE Lateral Velocity 0,3937 0,4116 -4,55% MSE Rotational Velocity 0,0526 0,0517 1,71% Table 18. Mean Squared Error in velocities under October 19 data for the original and Optimised Model, and percentage of improvement
Autonomous guidance of a Formula Student car p. 73 Considering the MSE values obtained, it is clear that in this particular case the Optimised Model does a worse job in predicting the longitudinal and lateral velocity, which, as shown in Table 18, there is no improvement but the opposite, especially for the lateral velocity where the setback is close to a 5%. In contrary, it does provide a slightly better estimation of the rotational velocity, representing a 1,71% refinement. However, it can be concluded that involving the data collected from October 19, the model does not improve with the proposed optimisation. December 17, 2023 Test Figure 39. Longitudinal and lateral velocity comparison under December 17 data Figure 40. Rotational velocity comparison under December 17 data It can clearly be seen that the Optimised Model is much more accurate in predicting the longitudinal velocity than the original one, as its values are aligned more closely with the real data. For the rotational velocity also seems to perform way better with the optimised parameters, specifically in the extremes, where it is less deviated. Whereas, the values projected in the lateral velocity diagram are more or less the same for both models, maybe even a bit better for the original model, but without notable differences.
p. 80 Thesis but despite this it is certain that the overall precision of the adapted lane-following system is rather respectable. Figure 46. Lateral and longitudinal velocity comparison for the simple lane-following system adaptation Taking a closer look at the deviations through the visual comparison of the expected values with the simulated ones, it seems that the accuracy is really high for both lateral and longitudinal velocity during the first 7 seconds. Whereas, it is not that decent for the last part of the simulation, as the precision decreases, especially for rotational velocity where some fluctuations appear in the final seconds. In summary, the analysis of both lateral deviation and relative yaw angle reveals that the adapted system, incorporating the Simplified Model presented in this project, generally behaves appropriately in maintaining the vehicle within the desired lane. Although, towards some specific moments, some minor deviations exist. Optimised Model adaptation The process of adapting the Optimised Model to the lane-following system in the example requires way more changes than the first approach done. Here, the model continues to take the same inputs as the simplified version, which include the force provided by the engines located to the rear axis (Fm) (instead of the acceleration in the example), and the steering angle (δ). But the complexity comes because the Optimised Model considers all the states employed by the lane-following controller.
Autonomous guidance of a Formula Student car p. 81 Therefore, in this case the need for a sensor dynamics block is eliminated, as the outputs of predicted by the Optimised Model directly provides the information needed to obtain the values for the relative yaw angle (e1) and lateral deviation (e2). Another notable modification involves the curvature previewer, which now transfers the information straight to the car model, allowing it to incorporate curvature in real-time as no sensors are used. All these changes underscore the sophisticated integration of the Optimised Model with the lane-following system from the example, aiming to reflect a more realistic approach capturing the dynamics of the scenario. Figure 47. Overview of the Simulink scheme with the Optimised Model adapted The performance of the Optimised Model adapted to the lane-following system is analysed mirroring the same approach used with the first simple adaptation. Lateral deviation (e1) and relative yaw angle (e2), which in practice are the errors in predicting lateral and rotational velocity, are examined. In addition, charted comparisons of simulated and expected for both velocities against time are displayed for complementary interpretation. Hence, insights into the system’s accuracy in keeping the car within the desired trajectory can be studied. As before, the scenario replicates the CAT15x on a 10 second drive around a curved twolane highway.
p. 82 Thesis Figure 48. Lateral deviation and relative yaw angle for the lane-following system Optimised Model adaptation Observing the results obtained for the lateral deviation and relative yaw angle, it is undeniable that in this case the precision of the lane-following system is far from being perfect. Despite the errors being big, it seems that the intention of the system in all times is to minimize them, as they fluctuate around zero (with remarked outliers). Moreover, the system appears to follow the centre-line during the first part of the simulated curved highway, but then in the middle and last section of it, the accuracy decreases in a considerable way. Figure 49. Lateral and rotational velocity accuracy comparison for the lane-following system Optimised Model adaptation
Autonomous guidance of a Formula Student car p. 83 Through the comparison of both lateral and rotational velocity simulated values with the expected ones, it looks like that until half the time elapsed, the simulated values are pretty much right on target. Nonetheless, from the middle to the end of the run the accuracy decreases drastically, as extreme values without any reasonable sense appear. To conclude, considering the analysis of the simulation results for the adaptation of the lane-following system with the Optimised Model studied in this thesis, it can be stated that it does not excel in terms of performance. Despite the fact that in the first half of the proposed scenario the system is effective in keeping the car around the centre-line as desired, from that moment onwards it seems to collapse causing the car to follow a completely wrong trajectory. The observed significant errors in the lane-following system with the Optimised Model adapted may be due to several factors, including potential issues such as imperfect calibration, or not having achieved a perfect fit between the model and the example considered. Despite these pronounced discrepancies, it is worth noting that from the results obtained the system appears to be on a consistent effort to minimize the errors, indicating its intention to adhere to the objective. This suggests that the vehicle model employed might not be the main issue. Recommended next steps involve following up with further studies focused on the connection and adaptation of the example with the Optimised Model, as well as on calibration and refining of the system itself. These aspects are of strong importance in trying to increase the existent potential to deliver accurate performance, aligning the car more closely with the intended trajectory. 7.2. Lane change assist using model predictive control In a second application scenario, the Optimised Model that represents the CAT15x car developed throughout this thesis is adapted as a NMPC similarly as done above, but in this case, it is integrated into a lane-change assist controller. Following the same way as before, due to the design of the lane-change system being beyond the scope of this thesis, an example from MathWorks is employed as a foundation [18]. Then, the Optimised Model is adapted to the example structure and simulations are performed to examine the results. Example description A lane change assist control system autonomously steers an ego vehicle to an adjacent lane when there is another vehicle moving slower in front of it, as shown in the following figure.
p. 84 Thesis Figure 50. Representation of the lane-change scenario [18] The lane change controller in this example is designed to work when the ego vehicle is driving on a straight road at a constant velocity, though it can be extended to other driving scenarios with appropriate modifications. In this example: • A driving scenario is used to model the environment such that a situation requiring a lane change arises. The scenario was created and exported using the Driving Scenario Designer app from the Automated Driving Toolbox. • Based on this scenario, a discrete occupancy grid is populated, which is then used by the path planner to plan a collision-free reference path for the ego vehicle. • Once the reference path is generated, the controller performs the autonomous lane change maneuver by controlling the steering angle of the ego vehicle to track the lateral position of the planned path. Figure 51. Overview of the Simulink model from the pre-built example [18]
Autonomous guidance of a Formula Student car p. 85 The Simulink model contains four main components: • Nonlinear MPC — Lane change controller, which controls the front steering angle of the ego vehicle • Vehicle and Environment — Models the motion of the ego vehicle and models the environment • Occupancy Grid Generator — Generates a discrete grid that contains information about the environment and cars surrounding the ego vehicle • AStar Path Planner — Plans a collision-free path for the ego vehicle considering the dynamic behavior of other cars Inside the Vehicle and Environment subsystem, the Vehicle Dynamics subsystem models the vehicle dynamics using the Bicycle Model - Velocity Input block from the Automated Driving Toolbox. Summarising, the example represents a scenario where a car (represented with a bicycle model) changes from its lane to another autonomously by making use of its lane change controller, without hitting any other existent vehicle on the road. Optimised Model adaptation To be able to integrate the Optimised Model into the complex control system structure of the lane change assist example, few adjustments need to be made given that the vehicle model considered there is way simpler. The most noticeable distinctions lie in how the Optimised Model represents the dynamics compared to the example. However, no major changes are needed as the example does not incorporate sensors for measuring vehicle dynamics. Consequently, the model just executes iterations to generate the information required by the controller, allowing its proper functioning. Despite these variations, the Simulink scheme is maintained the same because the main input considered is the steering angle (δ), and the outputs can easily be adapted, considering the absence of direct vehicle dynamics data obtained from sensors in this case. Therefore, concerning the Simulink scheme, the only block modified is the “Velocity and Environment”, accompanied by the script defining the model. In that new script, a substantial modification is made, replacing the initial considerations from the example with more complex ones that represent the Optimised Model. In contrast to the previous application example based on a lane following controller, in this case the results displayed are more visual. Apart from an individual plots showing the lateral position throughout the course of the simulation and the error of this position with respect to the expected one (lateral deviation), a representation of the scenario is displayed, where
p. 86 Thesis it can be seen the car in question driving around the highway and how it performs the lane changes while avoiding other vehicles. The simulation conducted involves the car driving through a road during 10 seconds. It starts its journey from one lane, then changes to another where it remains some seconds, and subsequently it maneuvers back to the initial lane. Throughout this simulated driving, the vehicle also focuses on avoiding collision with other virtual vehicles. Figure 52. Visual sequence of the lane change simulation with the Optimised Model integrated In Figure 52 a visual sequence of the performed simulation is represented (order from left to right, up to bottom), where it can clearly be seen how the car (represented in dark blue) makes a first lane change followed by a second one back to the initial lane. The lane change system with the Optimised Model does a really good job, as the vehicle performs the two lane changes maintaining the car within the delimited lines, and without hitting any other vehicle on the road. Anyway, it is true that it does appear to behave a bit abruptly when changing lanes, and as can be seen in the fourth photo of the sequence, the car is close to crash into another car.
Autonomous guidance of a Formula Student car p. 87 Figure 53. Lateral deviation for the lane change system Optimised Model adaptation Regarding the figure above, where the error in the lateral position of the car is displayed, it can be seen that it fluctuates around zero during all time. While it is undeniable that at the beginning and at the end of the run the deviation is considerably bigger, this is justified because this is when lane changes are made. Thus, it can be said that the performance of the controller is very accurate, although as been before, in certain moments it seems to be a bit abrupt. Figure 54. Lateral position accuracy comparison for the lane change system For the lateral position results obtained from the simulation of the Optimised Model integrated with the lane change system, it is plain that the overall accuracy is really high in terms of lateral position. This means that the car drives around where it is supposed to throughout all the simulated scenario, approaching closely the expected values. Whereas, after moving from one lane to another, slightly more extreme values for its position are obtained, which seems to be caused by a brusquer behaviour when changing lanes. In addition, the ideally expected is that after changing from one lane to another, the car stays
p. 88 Thesis immediately completely straight in the same position, but regarding the chart it is noticeable that this is not exactly the case, as there exist some minimum fluctuations for a short amount time before remaining stable. In conclusion, through the analysis of the simulation results obtained for the lateral position and its deviation from the planned values, it can be stated that the lane change adapted system, incorporating the Optimised Model developed in this project, presents an overall high precision in guiding the car autonomously executing lane changes without crashing into others. The notable success in applying the model within a control system structure stands as a valuable validation of its accuracy in representing vehicle dynamics. Furthermore, this accomplishment contributes as well to the overall confidence in the model’s utility when considering it alongside complex control structures.
Autonomous guidance of a Formula Student car p. 89 8. Economic assessment The costs involved during the development of the project are detailed in this section to reflect its financial implications. MATLAB and Simulink licenses were indispensable tools in the simulation and modelling processes, and the same applies to Microsoft Office, that facilitated the comprehensive documentation of it. Regarding the hardware setup needed to be able to run the processing of data, perform development tasks, and run simulations, computer and several peripherals were employed. In any case, the big money is involved in the testing phases with the car and the cost of personnel. 30 hours of testing were conducted, which led to significant costs, as they include the wage of all the engineers that work in it (usually 6 or 7), costs for running the car itself, and the ones regarding the renting of the test track and the transfers of both the engineers and the car to it. Moreover, the average salary of a junior engineer in Barcelona is considered to determine what cost it represents in relation to the hours spent working in this thesis. Concept Quantity Cost per unit Cost MATLAB License 1 900,00 € 900,00 € Simulink License 1 1.360,00 € 1.360,00 € Microsoft Office License 1 150,00 € 150,00 € Computer and peripherals 1 1.000,00 € 1.000,00 € Testing with the car 30 h 114,00 € 3.420,00 € Junior Engineer 700 14,00 € 9.800,00 € Total 16.630,00 € Table 22. Summary of the costs involved in the project This comprehensive economic assessment, totalling 16.630 € encompasses all expenses incurred. However, it is crucial to note that the execution of this work did not directly incur all the outlined above, as several resources were generously provided by the university and sponsors of the BCN eMotorsport team. Specifically, all licenses of the software used were supplied by the UPC because of the enrolled student status, reducing the software-related expenses to zero. Additionally, a substantial portion of the testing costs were sponsored by external entities in the form of letting the team rent the track free of charge, and also should be noted that the engineers working there were from the team, further easing the financial burden of the thesis. Therefore, the actual direct cost of the project has been as detailed in the table below: Concept Quantity Cost per unit Real Cost Computer and peripherals 1 1.000,00 € 1.000,00 € Testing with the car 30 h 30,00 € 900,00 € Total 1.900,00 € Table 23. Summary of the real costs involved in the project