# Road Traffic Gesture Autonomous Integrity Monitoring Using Fuzzy Logic
## 5 Implementation and Evaluation  
The fuzzy location classification model created with MATLAB 2023a was converted to Arduino C++ and its fis_evaluate() function mapped into the four quadrants of the Cartesian coordinate system. Vehicles on the self-organizing network are identified as nodes which are actually ESP32-WROOM-DA microcontrollers having unique MAC addresses and assigned their hosting vehicle registration numbers with three LEDs attached to them (Table 4).  
These microcontrollers have the ability to act as senders and receivers by means of the ESPNow feature which is decoupled from the internet. The station interface of ESP-Now was chosen for sending and receiving data in the system. To effect the data exchange, eight ESP32 board peers were added via their MAC addresses, referred to as broadcast addresses.  
Relative vehicle location classification was accomplished in two steps. Step one covered left, right, and ahead positions. Step two covered cars behind and within the Back1 and Back2 locations. The various positions were identified by mapping the fuzzy logic model outputs to corresponding quadrants within the Cartesian coordinates system. The northern lane was selected for vote casting.  
A vehicle is deemed to be on the northern lane if:  
1. It is on the left of node N4.
2. It is on the right of node N2.
3. It is ahead of node N1.  
In MATLAB, the rule viewer (Figure 7) can be used to verify the output of the fuzzy location classification model. Upon adjusting the input values, it allows you to view the effect of each fuzzy rule, the aggregated output fuzzy set, and the defuzzified output value.  
As of this writeup, no simulation software exists that supports the ESP-Now data broadcast feature, and testing of the in-vehicle traffic light system is only possible on the physical ESP32-WROOM DA devices.  
The accuracy of the GPS click module was tested on the microcontroller at various locations several meters apart and at an unsignalized intersection at Zuschka in Cottbus, Germany. The readings were the same up to three decimal places. Therefore, the GPS click modules could not be relied on to produce a realistic centimeter accuracy needed for the system.  
Simulations were carried out using coordinates at Junction A, Junction B, and Junction C (Table 5). Coordinates were shifted to account for Back1 and Back2.  
A car is considered to have arrived at a junction if it turns on one of the three LED lights (Figure 8).  
\begin{table}
\begin{tabular}{c c c} \hline
**Car Node** & **MAC Address** & **Car Registration Number** \\ \hline N1 & C0:49:EF:CF:F6:AC & CB KA 1 \\ N2 & C0:49:EF:D0:26:D0 & CB AK 2 \\ N3 & C0:49:EF:CD:1D:04 & CB OA 3 \\ N4 & C0:49:EF:CD:B1:94 & CB AO 4 \\ N5 & C0:49:EF:CC:12:6C & CB KO 5 \\ N6 & 40:22:D8:5E:56:88 & CB OK 6 \\ N7 & C0:49:EF:CD:2A:0C & CB OK 7 \\ N8 & C0:49:EF:D0:1D:5C & CB OK 8 \\ \hline \end{tabular}
\end{table}
Table 4: Node, MAC address, and assigned vehicle registration number.  
The Road Traffic Gesture Autonomous Integrity Monitoring technology was evaluated based on its ability to:  
1. Identify relative vehicle positions at the junctions.
2. Vote for a single lane to disperse.
3. Adapt to changes in the arrival order.
4. Adapt to changes in the arrival direction.
5. Accommodate the removal and addition of nodes to the self-organizing network.  
The order of arrival refers to which node (vehicle) arrives at the intersection before the other. The direction of arrival means from the south, east, north, or west. These are determined by the nodes (vehicles) broadcasting different coordinates.