Back-end implementation for an automatized car parking
Abstract
Grado en Ingeniería de Tecnologías de Telecomunicación
Full text
UNIVERSIDAD DE VALLADOLID ESCUELA TÉCNICA SUPERIOR DE INGENIEROS DE TELECOMUNICACIÓN TRABAJO FIN DE GRADO GRADO EN INGENIERÍA DE TECNOLOGÍAS DE TELECOMUNICACIÓN Back-end implementation for an automatized car parking Autor: D. Samuel Pilar Arnanz Tutor: Dr. D. Juan Carlos Aguado Manzano D. Daniel Castaño Navarro VALLADOLID, JULIO 2020
TRABAJO FIN DE GRADO TÍTULO: Back-end implementation for an automatized car parking. AUTOR: D. Samuel Pilar Arnanz TUTOR: Dr. D. Juan Carlos Aguado Manzano, D. Daniel Castaño Navarro DEPARTAMENTO: Teoría de la Señal y Comunicaciones e Ingeniería Telemática TRIBUNAL PRESIDENTE: Dr. D. Ignacio de Miguel Jiménez VOCAL: Dr. D. Ramón Durán Barroso SECRETARIO: Dr. D. Juan Carlos Aguado Manzano SUPLENTE: Dr. D. ª Noemí Merayo Álvarez SUPLENTE: Dr. D. Juan Blas Prieto FECHA: 13 de Julio de 2020 CALIFICACIÓN:
Resumen del Trabajo Fin de Grado El propósito de este Trabajo Fin de Grado es la implementación de un software back-end para el control de un sistema de carsharing. La característica principal de este sistema de carsharing es que consta de unos parkings donde el vehículo se aparca autónomamente. El software back-end, guardado en nuestro servidor, se encarga de gestionar el funcionamiento de los parkings, por ello, el back-end es capaz de comunicarse con toda la flota de coches. Además, también es capaz de comunicarse con la aplicación de carsharing para cuando un usuario solicita un coche. El back-end proporciona otra serie de servicios como controlar que dispositivos acceden al sistema, administración de la base de datos del sistema y gestión de fallos. Durante el desarrollo de este software, se probado su funcionamiento gracias a un simulador donde se comunicaba con otros elementos del sistema como son los coches o las aplicaciones móvil. Abstract The purpose of this Final Degree Project is the implementation of a back-end software for the control of a carsharing system. The main characteristic of this carsharing system is that it consists of parking areas where the vehicle is parked autonomously. The back-end software, stored on our server, is responsible for managing the operation of the parking areas, therefore, the back-end is able to communicate with the whole fleet of cars. In addition, it communicates with the carsharing application for when a user requests a car. The back-end provides another series of services such as controlling which devices access to the system, administration of the database and fault management. During the development of this software, its operation was tested thanks to a simulator where it communicates with other elements of the system such as cars or mobile applications. Palabras clave Back-end, Enter procedure, Exit procedure, FMEA, IoT, MariaDB, MQTT, Outside stage, parking, process architecture, relational database, RFID, Smart City, Standby stage, messaging, Twizy, TwizyLine.
Acknowledgements First of all, I would like to thank Juan Carlos Manzano Aguado, tutor of this Final Project Degree, for the opportunity to participate in the TwizyContest, and also to thank all the time and help that he has dedicated to carry out the TwizyLine project. I would like to thank my colleagues from TwizyLine, Ignacio Royuela González, Adrian Mazaira Hernández and Mario Martín Fernández, for all the endeavor made in the last 9 months. Also, I would like to thank Jairo Gurdiel González and Daniel Castaño Navarro, employees of Renault, for their involvement in the project and in the development of the Final Degree Project. Finally, I would like to thank all my family for supporting and encouraging me in these last 4 years in the degree. Special dedication to my grandparents who unfortunately passed away during this last year.
i INDEX 1 Introduction ..................................................................................... 1 1.1 Contextualization and motivation of the Final Degree Project ............................................................. 1 1.2 Objectives................................................................................................................................................... 4 1.3 Phases and methods .................................................................................................................................. 5 1.4 Means ......................................................................................................................................................... 6 2 State of the art ................................................................................. 7 2.1 Evolution of Smart cities and technologies related ................................................................................ 7 2.2 Selection of technologies ......................................................................................................................... 12 2.2.1 Messaging protocols ......................................................................................................................... 16 3 The autonomous TwizyLine parking .......................................... 17 3.1 Design of the circuit ................................................................................................................................ 17 3.2 Elements and zones of the parking ........................................................................................................ 22 3.3 Operation of the parking ........................................................................................................................ 23 3.3.1 Outside stage flow diagram ............................................................................................................. 24 3.3.2 Enter procedure flow diagram ........................................................................................................ 25 3.3.3 Standby stage flow diagram ............................................................................................................ 26 3.3.4 Exit procedure flow diagram .......................................................................................................... 27 4 Analysis of the back-end implementation .................................. 29 4.1 MQTT protocol ....................................................................................................................................... 29 4.1.1 Implementing MQTT: Eclipse Paho MQTT Python library ....................................................... 31 4.2 TwizyLine failure management ............................................................................................................. 33 4.3 Database managers and TwizyLine Database ...................................................................................... 34 4.3.1 Database managers .......................................................................................................................... 35 4.3.2 TwizyLine database ......................................................................................................................... 36 4.4 TwizyLine messages ................................................................................................................................ 37 4.4.1 Messages between the back-end and the Twizy ............................................................................. 38 4.4.2 Messages between the back-end and the application .................................................................... 39 4.4.3 Miscellaneous messages ................................................................................................................... 40 4.5 TwizyLine processing architecture ........................................................................................................ 41 4.5.1 Process diagram of the back-end implementation ........................................................................ 42 4.5.2 Miscellaneous processes ................................................................................................................... 43 4.5.3 Processes involved in the outside stage ........................................................................................... 43 4.5.4 Processes involved in the enter procedure ..................................................................................... 44 4.5.5 Processes involved in the communication with the TwizyLine applications ............................... 46 4.5.6 Processes involved in the exit procedure ........................................................................................ 47 4.6 Implementation of more functionalities for the system ....................................................................... 48
2 countries where each country assures that it will try to lower the emission of greenhouse-gasses until the previously agreed limit [5]. It is remarkable to notice that air pollution does not affect only humans. It contributes to climate change, which has multiple collateral consequences for flora and fauna, making more difficult for humans to live on Earth. One of its main effects can be seen in global warming (Figure 2) and the destruction of ecosystems. Figure 2. Global surface temperature relative to 1951-1980 average temperatures [6] According to the WHO, most of the air pollution is man-made and is produced by the inefficient combustion of fossil fuels or biomass. These combustions are produced in the industry and vehicles. New ecological policies implanted are focused on these two big groups. For example, countries are supporting renewable energies, and gasoline and diesel cars are being forbidden to drive in big cities, where the concentration of a great amount of cars produces large quantities of particular matter and NO2. So, as these pollutant vehicles could be no longer available to drive inside the cities in the future, one solution is the electric cars. The automobile sector has increased its investment in the research and development of hybrid and electric vehicles. However, their sales account for a significant percentage of the market only in some countries like Norway, Sweden or Finland [7]. Despite this, some research report states that its sales will rise in the next years, reaching 39% by 2030 (Figure 3) [8]. Figure 3. Hybrid and electric vehicle growth is expected to increase (millions of unit) [8].
3 Nowadays there are many government initiatives to fight air pollutant problem. So, many countries encourage their citizens to buy electric cars or to change their old pollutant car by a new electric one such as the plan MOVALT in Spain [9], and big cities like Madrid or Paris have launched their initiatives to regulate the traffic of polluting vehicles through the city center. For example, thanks to “Madrid central” the air pollution has been reduced by 32% [10]. Figure 4. Low-Emission Zones (LEZ) are becoming the aims of the main cities in Europe [10]. Cities are evolving to become eco-friendlier (Figure 4). They are trying to adapt to the new requirements of this ecological revolution. For example, one of the main drawbacks of electric cars is the few number of electric park stations where to charge them. So, cities are implementing steadily more of this class of service around the cities. This ecological revolution requires progress in technology. In this context of global concern about the climate change plus the need of automobile companies to reinvent themselves to offer to the market new ecological cars is based this year the contest organized by Renault, called “TwizyContest”. “TwizyContest” is a competition between team groups from nine countries around the world. The challenge aims to suggest an idea to reduce the environmental footprint of the Olympic Games of Paris 2024. So the project must be innovative, ecological, frugal, and a durable solution. In addition, it was recommendable to use the model Renault Twizy, to provide it with new functions [11] [12]. The team made up of four students of the University of Valladolid will be the Spanish representatives in this event. The project that we have proposed is called “TwizyLine” (Figure 5). It is a carsharing system, with the advantage that the vehicles involved in this system have their own autonomous parking. Clients of our system do not need to worry about park place, which is huge convenient in an event such as the Olympic Games, and also for huge cities like Paris. Users just need to reach the parking and park it on the leaving zone. Everybody with a smartphone and downloading our application can take a Twizy from the pick-up zone of the parking [13].
4 Figure 5. Logotype and symbol of TwizyLine [13] Then, the teamwork has marked four main technical goals to carry out this project: Mechanical changes in the Twizy: The mechanical structure of the Twizy must be modified to manage the longitudinal and transversal control. Its final aim is to achieve enough control over the car, to reach level 4 of autonomous driving. ECUs development: New ECUs for the Twizy, with new functionalities to process all the changes introduced to it. Back-end implementation of an autonomous parking: Enter and exit procedures must be fully controlled. Barrier and other elements of the parking are going also to be controlled. Furthermore, it must be able to manage incoming data from outside cars and smartphones. Front-end implementation in a smartphone application: Our system must have its own application. It must be available for most of the smartphones. It must be able to communicate with the server to ask for a car. This Final Degree Project is in charge of explaining how the third main goal, the back-end implementation of the autonomous parking was developed. Thanks to this implementation the parking will be an infrastructure with its own brain to make decisions, and the most relevant of all, it is a connected infrastructure. Outside elements belonging to the same system as the parking are going to be able to interact with it. It is an approach to the intelligent buildings being part of a possible smart city of the future. 1.2 Objectives The purpose of the document is to explain how the back-end implementation of the parking has been carried out. At the same time, it has also been developed by other members of the work team, the proper communication systems to connect the three main entities: car, parking, and smartphone application. On one hand, Ignacio Royuela González has developed a communication ECU, implemented in a humming board [14]. On the other hand, Adrián Mazaira Hernández has created a smartphone application, similar to the ones used for carsharing [15]. Furthermore, Mario Martín Fernández is in charge of the dissemination through social networks and the administrative management of the patent of the project [16]. The exact implementation of the software is highly dependent on the structure of the parking, this is, how the users and cars are going to interact with the infrastructure. Moreover, the back-end software must be able to control every place and event inside the parking. So, it is important to highlight that the first step was the description of the structure of the parking. Further on, it will be explained in detail.
5 The list of specific objectives included in this project is: Description of different zones and elements of the parking, such as the barrier and the turnstiles. Implementation of a server application to communicate with the parking devices, the whole fleet of cars and all smartphone application users. The software developed must be able to connect to a database, by using a standard database manager connection or implementing directly the database (being its own manager). Manager must be robust, to hold multiple connections at the same time. Design and creation of a database, where all the necessary information is stored. Design a complete control over the car, which is inside the parking. The parking system will decide which path has the car to follow to reach its park spot, or which car is the chosen to go out once a user asks for one through the application. Create a simple but effective back-up system if the software crashes. 1.3 Phases and methods The realization of the project began with an in-depth analysis of the technologies required to make it done. The whole study is included in the document “TwizyLine-Technologies” [13], written by the work team. In that document, we include our proposal to implement “TwizyLine”, such as: how to manage the transversal and longitudinal control of the autonomous car, the infrastructure of the parking, the communications between the different elements involved in the project, security measures and the planning of the project (before the coronavirus outbreak) [13]. For the development of this Final Degree Project, it is particularly important the chapters about how the parking infrastructure and the communications system are. So the next phase was to know how the parking should work and which communication protocols the system does need. This second phase can be divided into the following steps: First, it was analyzed which kind of protocols are more suitable for our project. Once MQTT protocol was chosen, due to its properties, that makes it perfect for IoT projects, it was studied how to implement MQTT. Then, it was decided which programming language to use, which libraries were going to be necessary to work with python (the chosen language), to work with MQTT and parallel processing. To practice with these libraries, a mini-project was done, which consists in controlling a temperature and humidity sensor. The next step was to design flow diagrams to determine how the parking would act in each situation. Finally, all the software's logic was programmed. The last phase was running the integration and validation tests. At this point, three members of the work team checked if the communications were well implemented. Therefore, this phase can also be divided into three parts:
6 First: Check that the exchange of messages with the car's communications module was done correctly. Second: Check the correct functionality of the application thanks to the information provided by the server. Third: Full integration of the three parts, checking that the system works properly. 1.4 Means This project has been carried out in two places, it was started in the laboratory 2L028 of the Higher Technical School of Telecommunications Engineers of the University of Valladolid. However, due to coronavirus spread across the whole country, the Spanish government decided to apply the alarm state status and the university closed. So the project had to be completed in the participants' houses, working in coordination and conducting integration tests remotely. In order to be developed, it has been used 2 Raspberry’s: a Raspberry Model B+; and another Raspberry Model B, which were placed in different locations. Furthermore, it was used a 8BitDo Zero controller.
7 2 State of the art In the introductory chapter it has been seen that the objective of this Final Degree Project is to provide intelligence to an infrastructure, such as a parking, with the final goal of being able to communicate with other devices. This is one of the bases of what is called 'Smart city'. Millions of devices distributed throughout the city connected to the same network, to obtain and analyze this data in order to take action and make the city a more sustainable and ecological site. This chapter is dedicated to study the state of the art of the current 'Smart cities'. Thus, it is required to research what technologies are behind this type of cities. Then, a selection will be made of the technologies that best fit our project to achieve its achievement. 2.1 Evolution of Smart cities and technologies related “The 19th century was a century of empires, the 20th century was a century of nation-states, the 21st century will be a century of cities” Wellington E. Webb, former mayor of Denver (Colorado, Unites States of America). In July 2007, the urban population already surpassed the rural population in the world and the forecasts point out that in 2050 it will practically reach 70% [17]. Around 600 cities together gather the fifth part of the whole population, producing 60% of the GDP worldwide. In this new situation, cities must deal with several problems. Forecasts indicate that urban spaces will become increasingly dense. They will have to face many difficulties related to the management of scarce resources, the provision of public services, the management of information, urban mobility and traffic, as well as to energy efficiency and in general to sustainability. For a sustainable ecosystem, cities must evolve to manage better the resources to afford its citizens a high living standard. To this end, the concept of smart city has grabbed the attention of many governments of large cities around the world. The definition of smart city is a bit blurry, because of no city has already reached that state and nobody knows how far the smart cities can go. A smart city integrates the ICT (information and communications technology) with the physical infrastructures in a strategic purpose to provide efficient services and guarantee an optimum living standard for the citizenry. The idea behind this does not mean just to increase the social amenities, the services and the infrastructures, but it focuses on the efficient design of methods to optimize the available resources [18]. Certainly, Smart Cities are called to become one of the most powerful tools in public policy in the coming years. Integrating the use of information and communication technologies in the evolution of a city will not only lead to notable improvements in the provision of services, but it will itself constitute a sustainable path for economic and social development in the next decades of the economy of the cities and, therefore, of the economy of the countries.
8 Some of the most remarkable benefits that a smart city can produce are [19]: Reduce public expenditures: It decreases the capital used to provision and management of public services. Increase efficiency and quality of services: It is possible to manage resources more efficiently and improve the quality of the services provided. Provide support for decision making: Facilitates the identification of the requirements of the city and the approach of new services to offer support. Real-time information: It improves citizens' awareness of the environment in which they live by providing information in real-time and, at the same time, improves the transparency of the administration. To sum up, a Smart City comes to support the development of cities, both in terms of improving their current problems and recognizing and controlling their future issues. Some towns have already started their route to reach this hopeful city. Each year there are some ‘Smart City Expo’ around the world where the innovations are presented and analyzed. The last one should have been celebrated in Brazil during the 26th and 27th of March 2020, where the latest innovations would have been presented, but it was cancelled due to the coronavirus epidemic [20]. In the world, Barcelona was considered the most advanced city inside the smart city context, before New York City (USA) or London (Great Britain), according to the Juniper Research ranking. Another European city, which is likely to appear in the top positions, is Vienna (Austria) [21]. Figure 6. Barcelona approaches to reach the stage of Smart City [22] According to Francesca Bria former CTO (Chief Technology Officer) for the city of Barcelona, the key of smart cities will be the digital democratization. So, the data coming from the devices produced by the people must be available for the people themselves and, moreover, that data should
9 not be employed for commercial goals [23]. By raising the techno-literacy of the citizens, they will be able to understand how and where technology can best serve their interests. Accordingly, Barcelona has already implemented many people-oriented initiatives like those shown in Figure 6. Another relevant idea is the creation of the “Barcelona Digital City” website where the whole project and its technological achievements are collected [24[24] P]. That website is divided into 3 parts: Digital transformation: The technology and the data obtained from IoT sensors must be employed to provide better and more affordable services to citizens. Besides, another aim is to make government more transparent, participative and effective. Digital innovation: Support the use of the digital applications to battle social challenges and to promote the digital economy. FabLabs teach the necessary skills for innovation using new technologies. Projects like ‘i.lab’ develop an area for co-creation with the general public and the confluence of new technologies, such as open data and big data, robotics, artificial intelligence and the internet of things, to ensure sustainability and to analyze the possible environmental and social impact. Digital empowerment: The technological evolution must not interfere in the digital rights, gender equality and social inclusion. There are two remarkable projects following this philosophy, ‘Vincles BCN’, which aims to strengthen the social ties of elderly people by teaching them how to use new technologies; and ‘Decidim Barcelona’ is a social platform which tries to be the voice of the people living in Barcelona to take part or to suggest ideas related to digital innovations to be implemented in the city. If we take a look at our region, there is a consulting firm located in Valladolid, called GEOCyL, which contributes to implanting territorial and environmental sustainability values, supported by the use of new geographic information technologies [25]. In 2017, they made a project called 'Mi ciudad inteligente' ('My Smart City'). This project was done by two members of GEOCyL, who travel across 30 different cities of Spain with Renault Zoe. This project had two objectives [26]: Analyze smart cities from a geographical perspective, observing how new smart policies and projects transform the habitability and morphology of our cities. Transmitting to the citizen the importance of new technological projects and social digitization, making use of the repercussion in the media, social networks. Another interesting description of a smart city is related to technology. It is considered an urban space with smart infrastructures and networks with millions of sensors and actuators (Figure 7), which must also include people and their smartphones. A city able to listen and understand what is happening in it thanks to the data collected from all the elements that compound the whole town.
10 Figure 7. IoT applications for smart cities [25] In a technological context, the smart city concept and the Internet of Things are two closely related terms. Both ideas have their basis in M2M (machine-to-machine) communications. Thanks to the applications and uses of that kind of M2M communications, IoT approaches what it is called to be the Internet of the future. Precisely, the Internet of the future will not only consist in the connection of more and more people, but ideally, everything can be connected, from devices to common objects that usually did not have this connectivity. This is the case of buildings, cars, household appliances and in general everything that could be managed or controlled. Without the slightest doubt, this new “digital reality” is going to require a new way of managing a house, a community, a city or even the economy of a country [19]. There are a wide variety of sensors to control whatever physical magnitude. Most of them already existed, but now thanks to the technological evolution, they are digitalized and connected to the Internet. So, it is possible to process all the data obtained in real-time and thus propose new services within the framework of the smart city. It is also relevant that these sensors can be reprogrammed remotely without the need for an operator to move to the place where it is installed to modified it. In this sense, for maintenance, the over the air programming (OTA) methodology is usually employed. As an example, in recent years in Spain, all traditional electric energy meters have been changed by an electronic model that allows time discrimination and that has the capacity for remote management [28]. That change to smart meters is part of the smart grid. The smart grid is an electrical grid characterized by a variety of operation and energy measurement. It includes smart meters, smart appliances and renewable energy resources (Figure 8). The name of smart grid comes from 2007, when the USA government approved the “Energy Independence and Security Act of 2007 (EISA-2007)” [29]. The act aims at renewing the electrical infrastructure of the country and trying to employ renewable resources as a powerful mean to produce electricity. As a result, this concept of smart grid is related to the smart cities; it is even a part of the smart city.
11 Figure 8. Traditional grid vs Smart Grid [30] Another technology the use of which has been common lately is the RFID technology. RFID tags contain antennas to allow us to receive and respond to radio frequency requests from an RFID transmitter-receiver. This technology is very practical in inventory management, in the secure identification of assets (documentation, equipment ...), etc. The daily use of mobile devices, such as smartphones, PDAs, tablets, etc., has aided the use of different alternatives within the mobile marketing such as NFC technology. Concerning proximity sensors, the QR codes have been familiar in the last years, to obtain information about the object where they refer to. Nowadays there is an increase in investment in research into this topic to help the society to overcome the coronavirus crisis. A clear example of an IoT which can be used soon is the product developed by Spanish company Libelium [31]. This company provides a device called the Meshlium Scanner. This device allows to detect smartphones, and in general, any gadget which works with Wi- Fi or Bluetooth interfaces (Figure 9). Thanks to this system, it can measure the number of people who are present in a defined area at a specific time, allowing the analysis of the evolution of the crowd and avoiding large gatherings. This system works also with cars. It can monitor the traffic, so it is possible to control the flow and congestion of vehicular traffic, leading to more efficient road systems in cities [32].
18 However, this simple idea does not answer to several questions, which can be critical for the viability of the project. In a big city like Paris, the land is a scarce resource, so the infrastructure should optimize the space required to build it. Another dilemma is the charging system, if an employee is hired for each parking to plug the Twizy to the energy supply, the number of employees increased significantly taking into account that: there will be several parking areas; the parking areas are open most of the day and meanwhile it is open some employee must be there, thus more than one employee is required per day; in large parking with a high number of movements more than one employee is required at the same time. So, the project costs will increase due to the payment of their wages. A better proposal that solves some of the problems of the first one is shown in Figure 15. First of all, there is an optimization of the space. In the previous proposal, the straight lines were separated exactly by the double of the turning radio of the vehicle (3,4 m, that is, 6,85 m [49]). However, in this proposal the straight lines of the circuit are only separated by the wide of a Twizy car plus the security band, that in total makes 2,4 m. In this design, there is no auxiliary path to charge the battery, because it is used an inductive charge system, which is deployed in the same path that the magnetic line. In order to know if the space is better optimized than the first design a study should be taken. However, this circuit has a great drawback, if a car breaks, it will block the whole parking. So, due to this major drawback this circuit was refused. Figure 15. Variant of the TwizyLine parking circuit, with the appropriate measures of the Twizy [13]. Finally, the chosen design implementation is represented in Figure 16. It is made up of some rows where vehicles can park, and also there are two zones where to leave and take the Twizy. The parking of Figure 16 would be an example for small or medium parking. The number of columns or rows can be modified depending on the space available. This new design allows to park or to take out any Twizy from different rows, so if one of them gets blocked, the parking can be still giving service to the clients. Furthermore, like the other two designs, it provides three different areas (leaving zone, inner circuit and pick-up zone) according to the requirements of the ODD [14], and it is implemented a charging system, which it is explained later in this section. In order to know if the capacity of this circuit is worthy we are going to make some calculations.
19 108 spots Figure 16. Final design for TwizyLine parking [13] To get the optimum design, it has been made a research considering different parameters such as the length and width of the Twizy, safety distances between cars inside the parking or the turn radio of the Twizy. The objective of that research was to compare the density of vehicles per square meter of a TwizyLine parking from a conventional parking. The parking taken as reference is design following the urbanistic rules of Madrid (Figure 17) [50]. Figure 17. Conventional parking of Madrid [13] The conventional parking shown in Figure 17 has a density of 0.0486 spot/m2. For a TwizyLine parking of 112 parking spots, the optimum distribution should be with 16 columns and 7 rows. As it can be seen in Figure 18, the density is better for that distribution, and it is achieved 0.1003 spot/m2. The density has been duplicated in our parking.
20 Figure 18. Optimization of the number of rows and columns for a TwizyLine parking 1 . To calculate that density, it has been supposed that the distance of security is 0.5 m and the distance of separation between cars of the same row is 0.3 m. These distances determine the exact density which our parking can have, however, these distances depend on how accurate our system is. The calculations made regarding the density of the parking varying these two parameters are shown in Figure 19. As it can be seen in the graph, if it is chosen 0.1 m for the distance of security and 0.2 m for the separation between cars of the same row, the density is 0.1456 spot/m2, it has been almost triplicate the density of the conventional parking. Figure 19. Densities of a TwizyLine parking depending on two parameters 2 . As this project aims at being implemented in the Olympic Games of Paris 2024, there is another design customized for big events. In this new design shown in Figure 20, there are more zones were to leave the parking and where to take the Twizy. One important advantage of this model is that if one car has any problem and stops moving, an employee can get out that Twizy from the line and once it 1 For further information about how the graphic of Figure 18 have been calculated, see Annex I. 2 For further information about how the graphic of Figure 19 have been calculated, see Annex I.
21 is repaired to introduce it on the row again without going out the parking. It can also be possible that a car can move, but it needs to be repaired some warnings, so the server can be able to send this car again to the beginning of the row, and to assign the next car to the client. Figure 20. TwizyLine design for major events [13] The chosen charging system is the same as in the previous one, it uses inductive charge. However, here each line can be designed with a different charging power. It does not matter the order, but in order to follow always the same rules, it has been defined the following assignation: the lines nearer to the entrance and exit zones should have less charge power, so, cars with high battery are going to be parked in those lines. In the other way around, those cars with lower batteries are going to be parked on the last lines, where the charge power is higher. The charge power of each line follows a staggered distribution. For example, for the design in Figure 16, as it has five rows and the maximum battery is 100%, each line is dedicated for a gap of length 20, the first line is dedicated to cars with battery between 0% and 19% (both inclusive), the next line for vehicles with 20% to 39% of battery and so on. This kind of distribution gives the parking high efficiency, to provide always the client an available Twizy with higher battery. In addition, it reduces the energy power supply it needs, if it is compared with a parking which has a high charge power in all of its rows. Renault has already carried out some research on wireless charging. Specifically, Renault, Qualcomm Technologies and Vedecom have joined to develop a charging system for electric vehicles meanwhile they are running over the circuit (Figure 21) [51]. This project is being developed in Satory (Versalles, Paris). Figure 21. Functioning of the project from Renault for wireless changing [52].
22 3.2 Elements and zones of the parking In the final design of Figure 16, it can be possible to distinguish three zones in the parking which names are: the leaving zone, the inner circuit, and the pick-up zone. It is important to highlight that the whole parking must be delimited by a fence, except the entrance and the exit zones where there are barriers. This idea of delimiting the parking is not only due to safety for the cars, but also to have under control the area where the car is in autonomous mode to meet some legal and technical requirements (for more information check the Final Degree Project of Mario Martín Fernández [16] and the Final Degree Project of Ignacio Royuela González [14]). In order to understand better the next sections, it is important to know that the Twizy can be in three different modes: autonomous, manual, and standby mode. Depending on the moment and in what place the Twizy is, it will change from one mode to another. For more details about the Twizy’s configuration check Final Degree Project of Ignacio Royuela González [14]. The leaving zone is the place where clients have to park their Twizys. It is delimited by two barriers (barrier 1 and barrier 2). There is also a unidirectional turnstile (turnstile 1) to allow users who leave there their car to go outside. In the floor, there is an RFID tag which is used to notify the parking that there is a car in that position. In Figure 22, there is a representation of the leaving zone. Figure 22. Leaving zone [13] The inner circuit is made up of the magnetic tape which indicates the available paths for the Twizys. Furthermore, as it can be seen in Figure 22 drawn in yellow points, there are some RFID tags around the circuit. There are two types of RFID: Turn RFID tags: these tags indicate the beginning of each row. They are used to order the Twizy when to turn (Figure 23). Stop RFID tags: these tags are at the end of the row. They are used to notify the car that it has arrived at the end of the line and it needs to stop.
23 Figure 23. Car turns once it detects the turn RFID of its row where it is going to be parked [13]. The pick-up zone is the place where the clients are going to take its Twizy. Users are going to be able to enter this zone just once the car has already changed to manual mode. Like the leaving zone, the pick-up zone is delimited by two barriers (barrier 3 and 4), and there is another unidirectional turnstile (turnstile 2). Similarly to the previous turnstile, turnstile 2 is critical to meet legal requirements of this kind of projects. However, in this case, the device is blocked until three conditions are met: the car is stopped on the pick-up point, it is not in autonomous mode and the user who has asked for it has passed its smartphone near to an NFC tag or a QR code that should be next to the turnstile. There is also an RFID tag on the floor, to notify the car to stop and for the system to know that the car has reached this zone (Figure 24). Figure 24. Pick-up zone [13]. 3.3 Operation of the parking This section describes how the parking must act in each situation. To help the explanation, the corresponding flow diagrams will be shown for each case. In the flow diagram appears the concrete name of the messages exchanged, which are explained in the section 4.4. Specifically, a Twizy can be involved in 4 different states, regarding the parking: outside stage, enter procedure, standby stage and exit procedure. The relationship between them is represented in Figure 25. Turn RFID detected of its row, so it turns right Barrier 3 Barrier 4 Turnstile 2
24 Figure 25. Diagram of the 4 possible states of a Twizy. 3.3.1 Outside stage flow diagram First, it is going to be tackled the entrance procedure. To start during this state, it is relevant to know that the Twizy is sending all the time its GPS position and its battery level, so, the server knows if it is near some parking. In fact, this checking that a Twizy is near to a specific parking is only done thanks to compare coordinates of both, however, this system can be reinforced by adding other technologies to verify that the car is really near it, just in case the GPS position is not too accurate. If the vehicle is close to the leaving zone, the barrier 1 elevates. This stage is called ‘Outside Stage’ and its flow diagram is in Figure 26.
25 Figure 26. Outside stage flow diagram. Once the car is over the leaving zone, the Twizy reads the RFID tag of that zone and sends a message to the server, saying that it has read that specific RFID. Now the back-end implantation must be able to process that data to know from which parking is that RFID. The barrier 1 of that parking must close, so no more Twizy enter to that zone, and thus, it is ensured that there is just one car in that place. 3.3.2 Enter procedure flow diagram Now the system has to wait until the driver, and maybe another passenger, pass through the turnstile to verify that no humans are on the leaving zone. This system can be also reinforced with the use of occupancy sensors to detect that nobody has jumped over the turnstile or has illegally passed through the barrier 1. When the car is alone in the leaving zone, barrier 2 opens, and the message to set the car in autonomous mode is sent. Once this message is acknowledged, another message with the path it needs to follow inside the parking is transmitted to the car to be parked autonomously. The battery level determines in which row the Twizy must be parked.
26 The barrier 2 closes just when the car reads the turn RFID to ensure that the barrier 2 will not collide with the vehicle. Since this point of the process, the leaving zone is enabled to service another Twizy. When the car reaches its position, the back-end sends him a message to pass to standby mode. This whole process is included in the ‘Enter procedure’ shown in the flow diagram of Figure 27. Figure 27. Enter procedure flow diagram. 3.3.3 Standby stage flow diagram Now it is going to be explained the state of ‘Standby stage’ (Figure 28). If someone wants to use our system must previously download the TwizyLine application to ask for a Twizy. Then, it is required to verify that the credentials of the user belong to the ones saves on our database. There will be a series of message exchange between the server and the application to know the client the Twizys
27 available and to select from which parking does the client want the Twizy (for more details on this procedure, see the Final Degree Project of Adrian Mazaira [13]). Figure 28. Standby stage flow diagram 3.3.4 Exit procedure flow diagram Once a Twizy has been assigned to a client, the server starts running the ‘Exit procedure’ (Figure 29). This process has two main objectives: to move the selected Twizy to the pick-up zone in order to be taken by the client, and to move forward one spot the cars behind from the same row as the selected one to make more room for incoming vehicles. Clients can enter the pick-up zone through the turnstile to take their Twizy, only when the car is in manual mode as is described in section 3.2.
34 notified to the administrator in case they decide to check the element to solve that warning. It is called ‘error’ to those failures which interrupt the element operation. This kind of failures suppose a high risk. If the error appears in a physical object, such as a car or a barrier, they must be stopped and then repaired in order to restart, once it has been reported to the administrators. Once it is defined the kind of failure, it is relevant to classify the failures depending on which element reports it. There are four elements in this system, so there will be four sorts of failures in this classification: Parking failure: Parking can report problems about barriers, turnstiles, or issues in some procedure if they are not following the correct flow. Twizy failure: Twizys notify their failures to warn about them to the administrators. The difference between warning and error is very important here because it can determine if the car must stop or not. For further information, check the Final Degree Project of Ignacio Royuela González [14]. Server failure: The server does not report itself its own failure. There is a log where all the operations done by the back-end software is saved. So, the administrator can be able to check what is happening at code level if it is noticed an anomalous behavior in some process. Application failure: Some operation asked by the application to the server can be denied, for example, because credentials of login are wrong or because the user has no permissions. For the parking and Twizy failures, the way of proceeding is similar. Any failure is reported to the server, where the back-end software saves that report into its database and sends in real-time to the administration application. Administrators can ask for the no repaired failures reports any time whenever they want, through the application (for further information check Adrian Mazaira Hernández Final Degree Project [15]). If the report notified an error the administrator must fix it. The difference of the application failures with the previous ones is that no reparation of the administrator is needed. In this case, the error does not mean to stop drastically the app [15]. The server failures are most difficult to notice. In this case, a back-up system is implemented to keep proving service to the clients if the back-end software crashed drastically (check 4.6.2 for more information about the back-up system). In Annex III, there is a table with all the failures implemented that can be managed by the back-end. 4.3 Database managers and TwizyLine Database To manage properly a large number of data simultaneously, it is required a warehouse where to store all that information. That is the aim of the database. The system has its own database, where all the relevant information about users, Twizys, parking and other elements is updated and saved. In
35 the next two sections, it is exposed the software tool used to manage the database and the composition of the TwizyLine database. 4.3.1 Database managers A Database Management System (DBMS) is a program (or set of programs) that allows users to perform the following operations on the database: specifying the structure, type and restrictions of the data; and enabling the insertion, updating, deletion and consultation of the data [58]. It is important to distinguish between the database and the DBMS. The first is the warehouse where the data is stored and the DBMS is the tool needed to access and manipulate that warehouse of information. During the development of this software, three different DBMS were tried out to manage our database, which are: SQLite, MySQL and MariaDB. At the beginning SQLite was used, however, due to the large quantity of information and simultaneous connections, sometimes it crashed. MySQL and MariaDB are very similar, in fact, MariaDB is a fork of MySQL. Both are more scalable than SQLite, so they are suitable for projects of our characteristics. Below in Table 4, there is a comparison between these three DBMSs. SQLite MySQL MariaDB Open Source Oracle Open Source RDBMS (relational DBMS) RDBMS (relational DBMS) RDBMS (relational DBMS) Low scalability High scalability High scalability No security services Authentication and codification Authentication and codification Medium performance with few simultaneous connections High performance Higher performance than MySQL under the same test conditions Installable Compatibility issues with Raspbian 10 Buster Installable No further services Database engines to provide more services to manage the database It has the same database engines as MySQL, and also, it has other ones such as Aria (make more resistant against crashes) Table 4. Comparison between three different databases [59][60][61]. Due to the research shown in Table 4, MariaDB was chosen to be our DBMS. On one hand, SQLite was replaced mainly because of the problems it has with scalability and security. In our project, a large quantity of data can be managed at the same time, and this data must be saved in a safe warehouse. On the other hand, MySQL has some problems of compatibility with the operating system installed in the server (Raspbian 10 Buster), and in addition, although MariaDB and MySQL are quite similar, MariaDB provides more services and better performance in the same network conditions [60]. It is relevant to notice that MySQL belongs to Oracle, but MariaDB is open-source 4 . 4 For further information about how the connection to the database is done with python, check Annex IV.
36 4.3.2 TwizyLine database The database model that it is going to be used is the relational model. It is based on a grouping of data into interrelated two-dimensional tables. Databases should be normalized in order to avoid integrity issues and data redundancy. The process of normalization consists in a series of steps to decompose the data in different tables, in which its structure is considered to be optimum to be implemented and manage [58]. In each table, there is at least one primary key. The primary key is the attribute which identifies a single entity (one register in the database). To create our database, it is important to identify what are: the entities, the table names; the attributes, the fields of each table; and the relations between the different entities. There are different types of relationships between tables: one to one, one to many, 0 to many… For example: a subject is taught by just one professor (relation 1 to 1), and many students attend to that subject (relation 1 to many entities). To understand better the TwizyLine database shown in Figure 34, the relationships types used are: : This symbol indicates 1 entity obligatory. : One or cero entities related. : Cero or many entities. : One or many entities. Figure 34. TwizyLine database. The entities that made up our databases are: ‘car’: The whole fleet of Twizys is here saved. For each car is possible to know: its register plate, its position, if it is parked in some TwizyLine parking or which user is driving it.
37 ‘parking’: All the parking areas are registered here. There are two GPS positions for each parking: one for the leaving zone to check the closeness of a car to it and another for the middle of the parking, to give that information to the application. ‘parking_spot’: Information related to all the parking spots from the TwizyLine parking. ‘RFID’: As RFID codes are large and sometimes difficult to deal with, the RFID tags from all the parkings are normalized to a model that can be extrapolated to any parking of any dimension. ‘id_RFID’ stores the real RFID code and the field ‘code’ stores the new codification given to deal with it. In order to differentiate between the new codes, the ‘parking_id’ is also saved. In Figure 35, there is an example of the numbering of the RFID tags (red number) for the TwizyLine parking that we will work with later on this document. Figure 35. TwizyLine with the RFID tags numbered as in the database. ‘owner’: Table to register all the users of the application, especially relevant are the fields of ‘password’ and ‘admin’. ‘historical_log’: Thanks to this table, the system knows all the movements of all the Twizys. It is possible to know: in which parking it is and it was, when it has entered or go out from any parking, or the users who has driven it. ‘failure’: All the information about types of failure are store here (in section 4.2 this topic is treated in depth). ‘fix’: In this table, it is saved all the errors or warnings from the whole fleet of cars. Furthermore, once a car is repaired, the employee who has fixed it and the time when it has been fixed is also included For further information of the TwizyLine database, such as the type of data stored in each field, the attributed length or properties of each attributed, it is provided in the Annex IV the code needed to create this database. 4.4 TwizyLine messages Messages exchanged between the different elements are defined. Each TwizyLine message has a descriptive name and some of them have some attributes. These attributes are additional information to process correctly the message received. In this chapter, messages used by the back-end are going to be split up into three groups according to the elements involved in the exchange of messages.
38 In each table from the next sections, it is shown the publisher, the subscriber, the topic and the payload of every message. It is important to highlight that those levels of topics between brackets mean that level should be replaced for the real number. For example, topic ‘(id_car)/battery’ means that this message is going to be sent in topic ‘1/battery’ or ‘2/battery’ or whatever id from any Twizy of our system next to ‘/battery’. As it was shown in chapter 4.1, when MQTT was explained, the subscriber must be listening in topic ‘+/battery’ to receive the battery information from the whole fleet of Twizys. 4.4.1 Messages between the back-end and the Twizy Mainly the back-end software sends orders to the Twizy and the messages sent by the car are information and acknowledgement to orders. Below in Table 5. Messages exchanges between the Twizy and the server., you can see the whole set of messages. Publisher Subscriber Topic Payload Twizy Server (id_car)/battery (0-100) OR -1 Twizy Server (id_car)/location (latitude,longitude) OR No signal OR GPS not connected Twizy Server (id_car)/info CONNECT regist_plate TIMEOUT RFID (ID number) WRN (error code) [attribute] ERR (error code) [attribute] AM-ON OK AM-OFF OK CONTINUE OK PAUSE OK GOTO OK STANDBY OK Server Twizy (id_car)/order CONNECTED STANDBY AM-ON AM-OFF CONTINUE PAUSE GOTO (initialSpeed) (defaultFork) [T(RFID) [newSpeed]…] [V(RFID) newSpeed…] S(RFID) RESTART Table 5. Messages exchanges between the Twizy and the server. The meaning of each of these messages are: The position and the battery are sent periodically every 2 seconds by each car. If the battery is ‘-1’, there has been some failure with the car. So, this failure is going to be notified to the administrators. The same situation happens with the value ‘No signal’ and ‘GPS not connected’, one leads to a warning and the other to an error, but both are going to be sent to the administrator. An RFID message is sent once a Twizy reads an RFID tag. This message is used by the car to send information about its position inside the parking. A ‘TIMEOUT ‘message is sent when the obstacle sensor detects that an object is in front of it. The first time a Twizy sends a ‘CONNECT (register_plate)’, its credentials are stored in the database.
39 ‘WRN’ and ‘ERR’: These messages are used to notify the server the back-end that a failure occurs in the Twizy. Depending on the type of failure, it is sent ‘WRN’ for warning or ‘ERR’ for error. The rest of the messages are going to be used to make the car move autonomously, most of them are going to be acknowledged to ensure that the car has received correctly the order, so this kind of message appears in the table with the same name but with an OK added at the end. Their meanings are: ‘AM-ON’ and ‘AM-OFF’: Autonomous mode activated or manual mode activated. ‘PAUSE’ and ‘CONTINUE’: Thanks to these orders, it is possible to stop and then to move the car whenever it is required meanwhile the car is still in autonomous mode. This gives us much flexibility, for example, to test the car the administrators or in large parking where the logic of its functioning needs these orders to provide the parking a service faster. ‘STANDBY’: The car passes to the low-cost energy status inside the parking. This low-cost energy status helps to charge faster the car, as it is almost not consuming much energy. ‘GOTO’: Once it is in autonomous mode, this message sends the route the vehicle must follow. This route is determined depending on the number of RFIDs and speed specified in this message. The speed is in km/h and the parameter “defaultFork” can be: ‘L’, which means to follow the left bifurcation by default; or ‘R’, which means to follow the right path by default. The last RFID indicated with an ‘S’means where the car must stop. For example, “GOTO 5 L T26 V27 3 S28” message, means that the Twizy start with 5 km/h as its initial speed and it follows the left bifurcation of the path by default, however, when it reaches the RFID number 26, it turns to the right bifurcation. Then, when the vehicle reaches the RFID 27 its speed is changed to 3 km/h and finally when it reads the RDIF 28 it stops. For further information and examples of this message, check the Ignacio Royuela’s Final Degree Project [14]. ‘RESTART’: This message is used to restart a car once it has been stopped due to an error. 4.4.2 Messages between the back-end and the application Depending on which kind of user access to the application some information will be restricted. Administrators have messages to ask the server for more information. That is why the messages sent between the back-end and the application is going to be divided into 3 groups. Publisher Subscriber Topic Payload Application Server log LOGIN/user/password Application Server log LOGON/user/name/surname/employment/password Server Application log CONFIRM/username Server Application log DENY/username/ErrCode Server Application (user)/app ADMIN/(0 o 1) Table 6. Message exchange between the application and the server during the log process.
40 The messages to start the session in the application are described in the table above (Table 6). ‘LOGIN’ is used for a user who has already register previously and ‘LOGON’ for a new user to create an account. ‘LOGIN’ can be denied if the credentials are wrong and the ‘LOGON’ can be denied also if the username already exists. If everything is correct and the log message is confirmed, it is sent to that specific user application a 0 if it is a normal user or a 1 if it is an admin. This information is going to be processed by the app to determine which session should start [15]. Publisher Subscriber Topic Payload Application Server (user)/server REQUEST-PARKS Server Application (user)/app NEW-PARK/id_parking/name_park/latitud/longitud/Twizys disponibles/Plazas disponibles Server Application app INFO-PARK/id_parking/Twizys disponibles/Plazas disponibles Application Server (user)/server PICK-UP/id_parking Server Application (user)/app TWIZY-OUT /id_vehicle Table 7. Message exchange between the application and the server required to take out a Twizy. The messages exchanged in a session to pick up a Twizy from our parking are described in Table 7. The user application asks the back-end for information about the status of the parking (‘REQUEST-PARKS’), and this information is periodically updated each 30 seconds (‘INFO-PARK’). Once the user wants to take a Twizy from a TwizyLine parking, a ‘PICK-UP’ message is sent. The id number of the car which is going to go out is sent to the app. So, the user knows which car has assigned to him. Publisher Subscriber Topic Payload ApplicationAdmin Server (user)/admin_server REQUEST-ERRORS Server ApplicationAdmin admin o (user)/admin ERR/id_fix/(id_vehicle o id_parking) /failure/explanation/error_date/more_info ApplicationAdmin Application (user)/admin_server ERR-FIX/id_fix ApplicationAdmin Server (user)/admin_server ASK-PARK/id_parking Server ApplicationAdmin (user)/admin PARK/num_row/num_column/ [(row_pos;column_pos;id_car)/...] Server ApplicationAdmin (user)/admin PARK-ERR ApplicationAdmin Server (user)/admin_server ASK-CAR/id_car Server ApplicationAdmin (user)/admin CAR/[enter_date;id_parking;exit_date;user/…] Server ApplicationAdmin (user)/admin CAR-ERR Table 8. Message exchange between the application of an administrator and the server. Messages shown in Table 8 are messages available just for administrators. They can ask for: the log of errors, the status of a parking or information about a Twizy. If the employee, who is log as an administrator fixes a vehicle, he must send to the back-end that it has been repaired a specific car through the app (‘ERR-FIX’). ‘PARK-ERR’ and ‘CAR-ERR’ are used to notify the application that the parking or the Twizy which is asking for information is not on the TwizyLine database. 4.4.3 Miscellaneous messages There are other messages that the back-end uses that are not sent to any application or Twizy. For example, MQTT is employed to communicate with the four barriers and with the turnstile. There are two goes down for barrier 1: ‘B_DOWN-RFID’ means that the barrier 1 must close after a car has entered the leaving zone.
41 ‘B_DOWN’ is used for barrier 1, once a Twizy passes near a parking and due to its close GPS position to the entry of the parking the barrier has to be up, but it does not go in the leaving zone, so the timer of barrier 1 expires and it closes. This differentiation is especially relevant for debugging applications, to know exactly what is happening in the parking. For the turnstile, there are two messages one to enable the turnstile 2 once the car is already in manual mode and the other to notify the back-end that the turnstile number 1 or 2 has turned. Below in Table 9, there are these messages. Publisher Subscriber Topic Payload Server Parking barrier barrier/(id_parking)/(1:4) B_UP#(id_car) Server Parking barrier barrier/(id_parking)/1 B_DOWN-RFID#(id_car) Server Parking barrier barrier/(id_parking)/ (1:4) B_DOWN#(id_car) Server Turnstile turn_enable/(id_parking/2 ENABLE_TURN_2 Turnstile Server turn/(id_parking)/(1 o 2) OK Controller Server init_remote_server INIT REMOTE SERVER MQTT process MQTT process MQTT/enter/(S oT)/(id_car) RFID (number) (id_car) (id_process) Table 9. Messages exchange between the server and other elements of the TwizyLine system. There are two more messages that they are going to be explained more in detail in the next chapters. One is used to initialize the back-end implementation remotely through a controller and the other is used to communicate inner processes of the back-end software. 4.5 TwizyLine processing architecture As it has been explaining along this document, the back-end implementation must be able to control different elements and to manage many more operations of the system simultaneously. At the software level, this parallel processing can be done in two ways: using threads or multiprocessing. It is important to differentiate both elements: Multiprocessing: It is created multiple processes. Each process provides the resources to execute a program. A process has a virtual address space, executable code, open handles to system objects, a security context, a unique process identifier, environment variables, a priority class, minimum and maximum working set sizes, and at least one thread of execution. Threading: A thread is an entity within a process that can be scheduled for execution. The program began with a main thread that later on it splits up into various threads. All threads of a process share its virtual address space and system resources. Besides, each thread maintains exception handlers, thread-local storage, a scheduling priority, a unique thread identifier, and a set of structures the system will use to save the thread context until it is scheduled [62]. It is lightweight compared with a process. They are not interruptible or killable. The back-end software implemented uses multiprocessing due to the following advantages: separate memory space, eliminates most needs for synchronization primitives, child processes are
42 killable or interruptible, it takes advantage better of multiple CPUs and python multiprocessing includes more useful abstractions than python threading [63]. One of the main advantages that we are going to take advantage of is the possibility of killing child process. This is very important to be running just the necessary processes in the system, to reduce the overall CPU memory employed. In addition, this action should be done correctly, otherwise, our system could be slowed due to the accumulation of defunct processes occupying uselessly space in memory. These defunct processes are also known as ‘zombie processes’. In the following section is shown how the processes used to control the TwizyLine system are organized in the back-end software. For further information of the code developed, it is possible to read it on the repository of GitHub from the GCO (Group of Optical Communications) from the University of Valladolid [64]. The file is called ‘hidraserverMySQL.py’ and it is inside the folder ‘Server’. The name of that file comes from: ‘hidra’, it is the name of the back-end (equivalent to ‘Sentilo’ from the Barcelona project shown in section 2.2; server, because it is where the back-end is running; and ‘MySQL’ because it uses the syntax of MySQL, which is used to work with MariaDB. 4.5.1 Process diagram of the back-end implementation To create this structure of processes the multiprocessing python library was used. This library provides a FIFO piping system to send data between two different processes. To organize the process architecture, the processes are classified depending on when they are born. Thus, the architecture is divided into levels (Figure 36). Those processes belonging to level 0 or level 1 are going to be never killed meanwhile the back-end software is running. Those processes belonging to levels below 1 are going to be killed once they finished to do their task. Figure 36. Example of the process architecture with 4 levels. At the beginning, in the back-end software developed there is just the main process (level 0) which launches other 12 processes (level 1). So, always 13 processes are running at the same time, except in the initial start-up of the software. The list of processes launched is shown in Figure 37. In the next sections, it is going to be explained the function of each process and when each message shown in section 4.4 is sent.
43 Figure 37. Main processes (level 0 and 1) from the TwizyLine architecture. 4.5.2 Miscellaneous processes There are some processes of level 1, that do not belong to any specific procedure. These processes are the following ones: ‘send_MQTT’ process is employed by all the processes which want to send a message through MQTT protocol. There is one queue called “q_sendMQTT”, which is used by other processes to send the topic and the message to ‘send_MQTT’ process. The process called ‘init_proc’ is in charge of adding to the table ‘car’ from the database new Twizys to send them the connection message (‘CONNECTED’), to acknowledge the Twizy that has been connected to the TwizyLine system. The battery level sent periodically with a message from the car is stored in the database by the process called ‘battery_proc’. The failure management is controlled by the ‘error_proc’ process. It is able to store in the database incoming failure messages (‘ERR’ or ‘WRN’) from the car in the ‘fix’ table, registering not only the type of error but also the time when that failure has appeared. Besides, it sends the failure in real-time to those administrators who are connected in that moment to the application. 4.5.3 Processes involved in the outside stage There are three main processes involved in the outside stage: ‘GPS_proc’, ‘listEnterPark’ and ‘RLZ’. Like ‘battery_proc’, the ‘GPS_proc’ is in charge of listening to the periodical message of the GPS position from the whole fleet of cars and add that information to the database to the table ‘car’. This process is also responsible to rise the barrier 1 if the car gets close to any parking. Obviously, before rising it, it is checked if the parking is full or if the barrier 1 has been already gone up to avoid repetition of messages sent.
50 Figure 44. Flow diagram of the back-up system.
51 5 Integration and test A test simulator has been created to integrate 3 different parts of the TwizyLine system. The simulator will serve first to visualize both Twizys and parking lots as in the real world thanks to Google Earth, and second, it will imitate the operation of the vehicles. For more information about the simulator and how it has been implemented, check the Final Degree Project by Ignacio Royuela González [14]. The following sections of this chapter will deal with the parking operation procedures seen in other chapters. It will also demonstrate how the failure management system works. It focuses on the physical operation, and will not go into so much detail in explaining the communication between the different elements, that is, the exchange of messages as it was already done in sections 3.3 and 4.4. 5.1 Initial conditions To know the context in which the tests are carried out in the following sections, in this section the initial conditions of both the simulator and the database will be exposed. Starting with the simulator, this represents 3 different parking areas located at: Campus Miguel Delibes, Plaza Zorrilla and Plaza. Portugalete. This information must coincide with that of the database, as it is seen in Figure 45. Figure 45. TwizyLine parking areas information in the database. In Figure 45, we see that there are 5 cars on the Miguel Delibes Campus, and that the other two parking areas are empty. Regarding the database, it is also interesting to comment that 4 users have already registered. For the following tests, the parking located in Plaza Zorrilla will be used. In Figure 46, it can be seen how the parking look like in the simulator. The four red points are the four barriers closed. If some barrier is open, it is shown a green point in later figures.
52 Figure 46. TwizyLine parking located in Plaza Zorrilla. 5.2 Outside stage Any car that is outside any parking will be on the outside stage. So, the first time a Twizy is connected, it is in this state. At the initial moment, when TwizyLine starts, a Renault operator will put the vehicles in the parking lots. The operator should only leave them in the leaving area, and then the system will already be in charge of parking them as we have already explained in previous chapters. In Figure 47, we see what the first Twizy connected to the database would be like, being outside any parking. Figure 47. Table 'car' from the TwizyLine database As we see in this Figure 47, the fields 'id_spot' and 'user' are 'NULL', because it is supposed that at the initial moment they are carried by an operator as it is said before. So, once you enter a parking lot for the first time, it will be assigned an 'id_spot', that is, the spot where it is parked, or the name of the user who drives it if it is taken out. It is talked more about this in the following sections. Returning to the outside stage and taking into account the flow diagram shown in section 3.3 (Figure 26), we will see what happens in the simulator. So, we placed in the TwizyLine parking from Plaza Zorrilla where the tests are going to be taken. As it was shown in the previous section, there are 5 vehicles in that parking. The cars have the arrangement shown in Figure 48 in that parking.
53 Figure 48. Current status of a TwizyLine parking. We will assume that car number 6 wants to park in that parking. Then, once you get close enough, barrier 1 is opened (Figure 49). Figure 49. Barrier 1 opens (green point) because a Twizy is near. As the barrier 1 is up now, it will allow the car to enter the leaving zone. When the vehicle reads the RFID of the leaving zone, it will send an RFID message (which was explained in section 4.4) and the system detects that there is a car in that zone and will close barrier 1 (Figure 50). From this point, the entry procedure would begin.
54 Figure 50. The Twizy number 6 is in the leaving zone and the system has already detected it. Regarding this point, there is a small variant. If the car wants to go in that parking but there is already one in the leaving area. To simulate this case, we have used another TwizyLine parking located in Plaza Portugalete. Figure 51. TwizyLine parking from Plaza Portugalete. Barrier 1 does not open because the leaving zone is occupied. As we see in Figure 51, barrier 1 does not open because it detects that the leaving zone is already occupied. Once this car enters and barrier 2 closes, it will enable barrier 1 to open again (Figure 52).
55 Figure 52. Barrier 1 is enabled to open now, as the leaving zone is empty and the barrier 2 is closed. 5.3 Enter procedure Continuing the previous example of Twizy number 6 from the section 5.2, now it is started the enter procedure. Now the system is waiting for the detection system to assure that the driver has gone out the leaving zone through the turnstile. To imitate this action, it is clicked on the button ‘X’ of the 8Bit Controller, which is in charge of simulating the message sent by the turnstile to the server (section 4.6.1). Now the barrier 2 is opened, and the car number 6 drives autonomously to its parking spot (Figure 53). Figure 53. Barrier 2 opens, and the Twizy moves autonomously towards its spot. Once the car has reached the turn RFID of the row of its spot, the barrier 2 closes (Figure 54). At this point, the back-end software can manage another entrance from the leaving zone.
56 Figure 54. The barrier 2 closes as the Twizy number 6 reaches the turn RFID. As Twizy number 6 has 73% of battery, the back-end software sent it to the second row, it is possible to see its battery in the table ‘car’ of the TwizyLine database (Figure 55). Figure 55. Table 'car', Twizy id equals to 6 has 73% of battery. In Figure 56 and Figure 57, it is shown how the information recorded in the database matches correctly with the status of the parking. In the Figure 56, it is the information about the spots of parking with id equals to 63002 (which is the one of Plaza Zorrilla), and it can be seen the occupied spots in the field ‘empty’. In Figure 57, it is the final result of the entrance procedure of the Twizy number 6.
57 Figure 56. Table 'parking_spot', showing just the information of those registers with id equals to 63002. Figure 57. Status of TwizyLine parking of Plaza Zorrilla. 5.4 Standby Stage Standby stage is the state in which the vehicle is inside the parking in standby mode. In this stage, the Twizy just moves if the exit procedure starts. The most important point about this stage is that the communication between the application and the server is correct, and the data shown in the application matches with the information stores in the database. First, the user must log in to the application. If it is already registered, the user and password of the client who wants to access to the system is compared with the file ‘contrasenias.txt’. Inside this file, it is the user and the password cyphered (Figure 58). It is stored in the server.
58 Figure 58. File 'contrasenias.txt' where it is the username and the password cypher of the TwizyLine clients. If the client has no account, it is checked if the username matches with any of the previous usernames used, which are stored in the database (Figure 59). If it is not equal as any other it is accepted that user, if not it is refused. Figure 59. Table 'owner' of the TwizyLine database. To continue testing the system, it is logged with the user ‘samuel’. So, in Figure 60 it is seen in the interface of the application once the user has chosen the parking from Plaza Zorrilla, that in this parking there are 6 cars available and 14 spots free. And in Figure 61, there is part of the table ‘parking’ of the TwizyLine database, showing that in the parking of Plaza Zorrilla there are 14 free spots. Figure 60. TwizyLine application, pressing the parking of Plz. Zorrilla.
59 Figure 61. 3 fields of table 'parking' of the TwizyLine database. Then the user presses the button at the bottom where it is the information of TwizyLine parking, and after the application receives the Twizy selected to that client. The chosen Twizy starts the exit procedure which is explained in the next section. This Twizy selected for the client is the number 2 (Figure 57), because according to the back-end algorithm if all the Twizys in the last column have the same battery 100%, the Twizy parked in the farthest row from the pick-up zone is chosen. Regarding these last sentence 2 relevant notes: - As it has been explained, this selection way is due to the charging system proposed in the parking explained in section 4.5.5. - Although in Figure 55 vehicles 2 and 1 has different battery levels, meanwhile testing has been waiting until both charge to the maximum battery level. 5.5 Exit procedure Continuing with the example of the previous section, now the Twizy number 2 of the parking of Plaza Zorrilla is in autonomous mode and following the orders sent by the back-end software the Twizy drives towards the leaving zone. Before this happens, the barrier 3 opens (Figure 62). Figure 62. Barrier 3 opens (green point) because the Twizy number 2 must drive to the pick-up zone. Once the car number 2 is over the RFID of the pick-up zone, barrier 3 closes, the turnstile is enabled and the vehicles parked in the same row as the number 2, Twizys number 6, 5 and 3 are going to move forward one spot (Figure 63).
66 Figure 72. Logotype of the international contest TwizyContest [11]. Furthermore, TwizyContest have been awarded with the ‘Premios Prometeo’ (Figure 73), organized by the FunGe UVa (General Foundation of the University of Valladolid). ‘Premios Prometeo’ program supports projects from students of the University of Valladolid with the aim to get a market-oriented prototype. In addition, this award helps us to file a patent application of our project. Figure 73. Logotype of the awards ‘Premios Prometeo’.
67 7 Bibliography [1] World Health Organization (WHO), “How air pollution is destroying our health“, 2018. Available online: https://www.who.int/en/air-pollution/news-and-events/how-air-pollution-is-destroying-our- health [2] World Health Organization (WHO), “Ambient air pollution: Pollutants”, 2017. Available online: https://www.who.int/airpollution/ambient/pollutants/en/ [3] Maureen L. Cropper et al, “Global estimates of mortality associated with long-term exposure to outdoor fine particulate matter”, 2018. Available online: https://www.pnas.org/content/115/38/9592 [4] World Health Organization (WHO), “Air pollution – The silent killer”, 2017. Available online: https://www.who.int/airpollution/infographics/en/ [5] World Wildlife Fund (WWF), “París: Un acuerdo histórico que necesita concentarse en acción”. Available online: https://www.wwf.es/nuestro_trabajo/clima_y_energia/cumbres_del_clima/ [6] NASA’s Goddart institute for Space Studies (GISS), “Global land-ocean temperature index”, 2020. Available online: https://climate.nasa.gov/ [7] Statista, “Los automóviles eléctricos, todavía en minoría en Europa”, 2019. Available online: https://es.statista.com/grafico/16084/proporcion-de-coches-electricos-sobre-matriculaciones-totales/ [8] Jonathan Guantt, “Global Emissions Standards Driving Hybrid and Electric Vehicle Growth”, 2019. Available online: https://www.aegonassetmanagement.com/us/thought-leadership/blog/credit-research/globalemissions-standards-driving-hybrid-and-electric-vehicle-growth/ [9] Ministerio de transición ecológica y reto de demográfico, “Plan MOVALT vehículos: Una manera de hacer Europa”, 2018. Available online: https://www.idae.es/ayudas-y-financiacion/para-movilidad-y-vehiculos/planmovalt-vehiculos [10] Transport & Environment, “Low Emission Zones are a success-but they must now move to zero-emission mobility”, 2019. Available online: https://www.transportenvironment.org/sites/te/files/publications/2019_09_Briefing_LEZ-ZEZ_final.pdf [11] Twizy Contest 2020: Off-the-Street, 2019. Available online: https://www.twizycontest.com/ [12] Twizy Contest Coordination Team, Groupe Renault, “TwizyContest2020: Rules and conditions”, 2019. [13] Adrian Mazaira Hernández, Samuel Pilar Arnanz and Ignacio Royuela González, “TwizyLine: Technologies”, version 1 2020. [14] Ignacio Royuela González, “Four level autonomous vehicle for an automatized parking”, 2020. [15] Adrian Mazaira Hernández, “Front-end implementation for an automatized car parking”, 2020. [16] Mario Martín Fernández, “Plan de Comunicación de TwizyLine: plataforma de carsharing con aparcamiento autónomo”, 2020. [17] Department of Economic and Social Affairs, United Nations, “68% of the world population projected to live in urban areas by 2050, says UN”, 2018. Available online: https://www.un.org/development/desa/en/news/population/2018-revision-of-world-urbanization-prospects.html [18] Sriharsha Mallapuram et al., “Smart City: The State of the Art, Datasets, and Evalution Platforms”, 2017. Available online:
68 https://www.researchgate.net/publication/319875757_Smart_City_The_State_of_the_Art_Datasets_and_Evalu ation_Platforms [19] Fundación Telefónica, “Smart cities: Un primer paso hacia la Internet de las cosas”, 2011. Available online: https://www.fundaciontelefonica.com/cultura-digital/publicaciones/101/ [20] Smart City Expo World Congress, “Editions abroad in 2020”, 2020. Available online: http://www.smartcityexpo.com/en/the-event/editions-abroad [21] Urban Hub, “Inteligencia: identificación de la ciudad más ‘inteligente’ ”, 2016. Available online: https://urban-hub.com/es/sustainability/identificacion-de-la-ciudad-mas-inteligente/ [22] MIMEISA Asset Management, “Impulso creative y generación de talent; el sello Barcelona”, 2020. Available online: https://mimeisa.com/blog/impulso-creativo-y-generacion-de-talento-el-sello- barcelona/ [23] Francesca Bria, former CTO of Barcelona interview at the Barcelona Smart City World Congress, 2017. Available online: https://www.youtube.com/watch?v=VAZrlVlUPwE&feature=emb_title [24] Platform Barcelona Digital City, Ajuntament de Barcelona, 2020. Available online: https://ajuntament.barcelona.cat/digital/en [25] GEOCyL Consultoría Ambiental y Territorial, 2011. Available online: https://www.geocyl.com/ [26] Mi ciudad inteligente, “Mi ciudad inteligente 2017”, 2017. Available online: https://www.miciudadinteligente.info/mi-ciudad-inteligente/ [27] Kreyon, “IoT Applications for Smart City”, 2016. Available online: https://www.kreyonsystems.com/Blog/iot-applications-for-smart-cities/ [28] Red Eléctrica de España, “Contadores inteligentes”, 2013. Available online: https://www.ree.es/es/red21/redes-inteligentes/contadores-inteligentes [29] United States Environmental Protection Agency (EPA), “Summary of the Energy Independence and Security Act”, 2007. Available online: https://www.epa.gov/laws-regulations/summary-energy-independence-and- security-act [30] Wikipedia, Smart Grid “Staying_big_or_getting_smaller.jpg”, 2018. Available online: https://en.wikipedia.org/wiki/Smart_grid#/media/File:Staying_big_or_getting_smaller.jpg [31] Innovadores by Inndux, “Covid-19: Este Sistema IoT ayuda a la política a detector movimientos de personas y vehículos.”, 2020. Available online: https://innovadores.larazon.es/es/covid-19-este-sistema-iot-ayuda-a-la- policia-a-detectar-movimientos-de-personas-y-vehiculos/ [32] Libelium, Smartphone Detection, 2020. Available online: http://www.libelium.com/products/meshlium/smartphone-detection/ [33] Amir Sinaeepourfard, Jordi García et al., “Estimating Smart City Sensors Data Generation: Current and Future Data in the City of Barcelona”, 2016. Available online: https://www.researchgate.net/figure/Barcelona- Smart-City-IT-architecture_fig1_304580274 [34] Adam Calihman, NetBurner, “Architectures in the IoT Civilization”, 2019 .Available online: https://www.netburner.com/learn/architectural-frameworks-in-the-iot-civilization/ [35] Oxford Learner’s Dictionaries. Available online: https://www.oxfordlearnersdictionaries.com/definition/english/back-end_1 [36] Fira Barcelona “firanews”, “Smart bins at the IoTSWC”, 2018. Available online: http://firanews.firabarcelona.com/en/another-look/smart-bins-at-the-iotswc/ [37] GOOD Magazine, “GOOD LOOK: Barcelona Street Lamps”, 2010. Available online: https://www.youtube.com/watch?time_continue=71&v=52YKJ31pde0&feature=emb_logo [38] Tomasz Tarczynski, “IoT backend architecture”, 2018. Available online: https://es.slideshare.net/TomaszTarczyski1/iot-backend-architecture [39] Eclipse Paho, “Eclipse Paho Downloads”, 2016. Available online: https://www.eclipse.org/paho/downloads.php
69 [40] Ruby, “Acerca de Ruby”, 2006. Available online: https://www.ruby-lang.org/es/about/ [41] Wikipedia, “Go (lenguaje de programación)”, 2009. Available online: https://golang.org/doc/ [42] Python.org, the official home of the Python Programming Language. Available online: https://www.python.org/ [43] IEEE Spectrum, “The 2018 Top Programming Languages”, 2018. Available online: https://spectrum.ieee.org/at-work/innovation/the-2018-top-programming-languages [44] IEEE Spectrum, “Top Programming Languages 2019”, 2019. Available online: https://spectrum.ieee.org/computing/software/the-top-programming-languages-2019 [45] Michael Yuan, IBM, “Conociendo MQTT”, 2017. Available online: https://www.ibm.com/developerworks/ssa/library/iot-mqtt-why-good-for-iot/index.html [46] Chris Pietschmann, Build5Nines, “Top 5 IoT Messaging Protocols”, 2020. Available online: https://build5nines.com/top-iot-messaging-protocols/ [47] Pick Data, “MQTT vs CoAP, la batalla por ser el major protocol IoT”, 2019. Available online: https://www.pickdata.net/es/noticias/mqtt-vs-coap-mejor-protocolo-iot [48] Sanjay Aiyagari et al, “AMQP Advanced Message Queuing Protocol: Protocol Specification”, 2008. Available online: https://www.rabbitmq.com/resources/specs/amqp0-9-1.pdf [49] Groupe Renault, “Renault Twizy: Plug into the positive energy”, 2018. Available online: https://renaultfuturcar.com/wp-content/uploads/2018/01/Twizy.pdf [50] Ayuntamiento de Madrid, “Compendio-2019 de las Normas Urbanísticas del Plan General de Ordenación Urbana de Madrid de 1997. (actualizado 16-12-2019)”. Available online: http://www.madrid.org/cs/Satellite?blobcol=urldata&blobheader=application%2Fpdf&blobheadername 1=Content- Disposition&blobheadervalue1=filename%3D05_Normas+Urban%C3%ADsticas.pdf&blobkey=id&blo btable=MungoBlobs&blobwhere=1352917079100&ssbinary=true [51] Groupe Renault, “Electric vehicles, towards dynamic wireless charging?”, 2017. Available online: https://group.renault.com/en/news-on-air/news/electric-vehicles-towards-dynamic-wireless-charging/ [52] Hibridos y eléctricos, “Qualcomm y Renault realizan la carga inalámbrica dinámica (de 20 kW a 100km/h) de coches eléctricos”, 2017. Available online: https://www.hibridosyelectricos.com/articulo/tecnologia/qualcomm-renault-realizan-carga-dinamica- 20-kw-100-km-h-coches-electricos-inalambricos/20170520173750014258.html [53] OASIS, “MQTT Version 5.0, OASIS Standard”, 2019. Available online: https://docs.oasisopen.org/mqtt/mqtt/v5.0/mqtt-v5.0.html [54] Eclipse Foundation, “Eclipse Mosquitto: An open source MQTT broker”. Available online: https://mosquitto.org/ [55] Eclipse, “Eclipse Paho”, 2014. Available online: https://www.eclipse.org/paho/ [56] Python Package Index, “paho-mqtt 1.5.0”, 2013. Available online: https://pypi.org/project/pahomqtt/ [57] Krzysztof Czarnecki, Waterloo Intelligent System Engineering (WISE) Lab, “On-Road Safety of Automated Driving System (ADS). Taxonomy and Safety Analysis Methods”, 2018. Available online: https://www.researchgate.net/publication/326546852_On- Road_Safety_of_Automated_Driving_System_ADS_-_Taxonomy_and_Safety_Analysis_Methods [58] Míriam Antón Rodríguez, Laboratorio de Desarrollo de Sistemas Telemáticos impartido en la E.T.S.I.T de la Universidad de Valladolid, “Base de Datos Relacionales”, 2019. [59] Digital Ocean, “SQLite vs MySQL vs PostgreSQL: A comparison of relational database management systems”, 2019. Available online: https://www.digitalocean.com/community/tutorials/sqlite-vs-mysql- vs-postgresql-a-comparison-of-relational-database-management-systems [60] Digital Guide IONOS, “MariaDB vs. MySQL”, 2020. Available online: https://www.ionos.es/digitalguide/hosting/cuestiones-tecnicas/mariadb-vs-mysql/ [61] SQLite, “Documentation”, 2020. Available online: https://www.sqlite.org/docs.html
70 [62] Stackoverflow, 2008. Available online: https://stackoverflow.com/questions/200469/what-is-the- difference-between-a-process-and-a-thread [63] Stackoverflow, 2010. Available online: https://stackoverflow.com/questions/3044580/multiprocessing-vs-threading-python [64] GCO Investigation Group – Universidad de Valladolid, repository “GCOdeveloper/Twizycontest”, 2020.
71 Annex I The objective of this annex is to explain how the graphics of Figure 18 and Figure 19 have been obtained. These graphics show how can be optimized the TwizyLine parking, in order to get a higher density of spots/m2 if it is compared with a conventional parking. The parameters used to calculate them are the ones shown in Figure 74. Figure 74. TwizyLine parking with its measurements [13]. It has been designed some MATLAB scripts to make the proper operations. The parameters shown in Figure 74 and then used in the MATLAB scripts means: 𝑙𝑡 = 𝑡𝑜𝑡𝑎𝑙 𝑠𝑖𝑡𝑒 𝑙𝑒𝑔ℎ𝑡 𝑎𝑡 = 𝑡𝑜𝑡𝑎𝑙 𝑠𝑖𝑡𝑒 𝑤𝑖𝑑𝑡ℎ 𝑑𝑠𝑒𝑐 = 𝑠𝑎𝑓𝑒𝑡𝑦 𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒 𝑑𝑠𝑒𝑝 = 𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒 𝑏𝑒𝑡𝑤𝑒𝑒𝑛 𝑝𝑎𝑟𝑘𝑒𝑑 𝑣𝑒ℎ𝑖𝑐𝑙𝑒𝑠 𝑖𝑛 𝑡ℎ𝑒 𝑠𝑎𝑚𝑒 𝑟𝑜𝑤 𝑙𝑣𝑒ℎ = 𝑣𝑒ℎ𝑖𝑐𝑙𝑒 𝑙𝑒𝑛𝑔ℎ𝑡 𝑎𝑣𝑒ℎ = 𝑣𝑒ℎ𝑖𝑐𝑙𝑒 𝑤𝑖𝑑𝑡ℎ 𝑟𝑣𝑒ℎ = 𝑣𝑒ℎ𝑖𝑐𝑙𝑒 𝑡𝑢𝑟𝑛𝑖𝑛𝑔 𝑟𝑎𝑑𝑖𝑢𝑠 𝑙𝑒 = 𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒 𝑡𝑜 𝑡ℎ𝑒 𝑓𝑖𝑟𝑠𝑡 𝑡𝑢𝑟𝑛 𝑚 = 𝑣𝑒ℎ𝑖𝑐𝑙𝑒𝑠 𝑝𝑒𝑟 𝑟𝑜𝑤 𝑛 = 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑟𝑜𝑤𝑠 The total site length and the total site width can be obtained using the following equation: 𝑎𝑡 =𝑙𝑒 + 𝑟𝑣𝑒ℎ + 𝑎𝑣𝑒ℎ 2+ 𝑑𝑠𝑒𝑐 + (𝑛 − 1) ∗ (2 ∗ 𝑑𝑠𝑒𝑐 + 𝑎𝑣𝑒ℎ) 𝑙𝑡 = 2 ∗ 𝑑𝑠𝑒𝑐 + 𝑎𝑣𝑒ℎ + 2 ∗ 𝑟𝑣𝑒ℎ + 𝑚 ∗ (𝑙𝑣𝑒ℎ + 2 ∗ 𝑑𝑠𝑒𝑝) Now it is shown the next figures the MATLAB scripts (Figure 75) used to calculate those graphics applying the notation and equation above explained.
72 Figure 75. MATLAB code required to represent graphics of Figure 18 and Figure 19.
73 Annex II In this annex, it is shown a table with the main properties of all the MQTT messages. Message Code Description CONNECT 0x10 Connect request CONNACK 0x20 Connect acknowledgement PUBLISH 0x30 Publish message PUBACK 0x40 Publish acknowledgement (QoS 1) PUBREC 0x50 Publish received (QoS 2 delivery part 1) PUBREL 0x60 Publish released (QoS 2 delivery part 2) PUBCOMP 0x70 Publish complete (Qos 2 delivery part 3) SUBSCRIBE 0x80 Subscribe request SUBACK 0x90 Subscribe acknowledgement UNSUBSCRIBE 0xA0 Unsubscribe request UNSUBACK 0xB0 Unsubscribe acknowledgement PINGREQ 0xC0 PING request PINGRESP 0xD0 PING response DISCONNECT 0xE0 Disconnect notification Table 10. MQTT type of messages [53].
74 Annex III This Final Degree Project is focused on dealing with the Twizy, application and server failures. It is relevant to highlight that this project is part of a bigger project called TwizyLine, so in the future, more failures can be added if it is needed. Below it is the Table 11 with all the failures implemented stored in the database (in section 4.3.2 is shown the full TwizyLine database). In this table, COM-MOD refers to the communications module of the Twizy and the CONMOD refers to the control module of the Twizy both implemented in the Final Degree Project of Ignacio Royuela González [14]. Source Code Hexadecimal code Failure type Failure name Explanation Twizy 1 0x001 Error CON_STATUS not received The CON_STATUS frame is not being received. Is the CON-MOD on? Is the CAN-Bus connection of both modules correct? The Twizy cannot change from one mode to another. Twizy 2 0x002 Error MODCON does not respond CON_STATUS signal CON-MOD does not change status when ordered to do so. Is the CON-MOD correctly configured? Connection failed between server and Twizy. Twizy 3 0x003 Error MOD-CON does not respond to PAUSE signal When sending a PAUSE or CONTINUE command from the COM-MOD, the CON-MOD does not respond correctly as the PAUSE signal does not change. High-risk inside the parking. Is the CONMOD correctly configured? Twizy 4 0x004 Error GOTO-ACK not received multiple times CON-MOD does not send an ACK when it has to do so. Is the CON-MOD correctly configured? Twizy 5 0x005 Warning Malformed GOTO frame received from Communication Module CON-MOD has received a GOTO message but its information is not in the proper way as described in section 4.4.
75 Twizy 6 0x006 Error Unexpected CON-MOD frame CON-MOD is sending out signals that don't make sense right now. Is CONMOD well configured? Problems in the control of the vehicle, powerful hazards that can turn into risks. Twizy 9 0x009 Error GPS not connected The GPS module is not connected to the communication module. Is the COMMOD correctly configured? Is the GPS broken? Is the GPS disconnected? Twizy can be stolen. Twizy 10 0x00A Warning GPS is not receiving signal for a long time The GPS module is connected but it is not receiving any signal from the satellites for a long time. Is the GPS broken? Is the car just in a place where there is no mobile coverage? Twizy 11 0x00B Warning Battery data not received The CAN message informing about the battery charge on the vehicle's CAN-bus is not detected. Is there a problem in the vehicle? Twizy 20 0x014 Error Connection refused - Not authorized The MQTT broker is rejecting the connection due to no authentication. Is the client sending the correct authentication data? Twizy 21 0x015 Error Connection refused - Bad username or password The MQTT broker is rejecting the connection due to a bad authentication. Is the client sending the correct username and password? Twizy 25 0x019 Error Server client is not responding The server is not responding with the message CONNECTED when called. Is the server running? Twizy 26 0x01A Warning Unexpected MQTT message The server is sending an incorrect message. Is the server well configured? Twizy 27 0x01B Error Lost connection with MQTT server Ping responses from the server are not being received. Has CON-MOD lost the