## 2 Methods
### Experiments of Parking Space Detection Based on Ultrasonic Sensor
#### 2.3.2 Experiments of Parking Space Detection Based on Ultrasonic Sensor  
Ultrasonic sensor is a distance sensor based on the principle of ultrasonic reflection. The distance between the parked vehicles and the body of ego vehicle is small, so the advantages of ultrasonic sensors are fully exerted. The echo is formed by ultrasonic reflection when it touches obstacles. The transit time detection method is used to measure the distance by the parameter difference between the transmitting wave and the return wave. The intelligent minicar controlled by Arduino microcontroller is used as the experimental equipment. The simulated parking space with length of 1 m and width of 0.52 m is set up and a simulation experiment scene is built according to the parallel parking conditions. Objects 1 and 2 with certain volume and shape are used to simulate the parked vehicles 1 and 2, and object 3 is used to represent the road boundary. The experimental scene is shown in Figure 9a. The motor speed is fixed by analogWrite function, and the analog of input pin is 40 (square wave with duty cycle of 40/255 is output by PWM) to make the speed in each experiment consistent.  
Figure 8: Experimental equipment—Arduino minicar.  
Figure 9: Parking space detection experiment for parallel parking: (**a**) Experiment scene; (**b**) Experimental results of a parking space detection.  
At the beginning of the experiment, each time the car starts from the same position, the lateral distance between the ultrasonic sensor and object 1 is 25 cm. It runs straight at the set speed through the simulated parking space. In order to eliminate the chance of the experiment, 21 experiments are carried out, and the data collected by the ultrasonic sensor are analyzed. In Figure 9b, the data used in one experiment are selected for illustration. From the distance measured by the ultrasonic sensor-time curve, the experimental results are in line with expectations. In 0\(\sim\)2.16 s, the car passes through object 1, and the distance between the car and the object 1 is measured by the ultrasonic sensor. The ranging value fluctuates in a minimum range of 25 cm within the allowable error range, basically it changes into a straight line with time. When the time is 2.16 s, the ultrasonic sensor of the minicar just reaches the edge of the object 1 and the ranging value changes suddenly. The return value of the ultrasonic sensor changes into the distance between the sensor and the object 3. The ranging value changes in a small range of 67 cm from 2.16 s to 4.04 s. At 4.04 s, the ultrasonic sensor reaches the edge of the object 2, and the ranging value changes into the distance between the sensor and object 2, then mutates again, and changes within a minimum range of 25 cm until it leaves the object 2. The fluctuation of ranging value is caused by the small shaking of the minicar in the process of driving. The measured value of parking space width is basically consistent with the true value and fluctuates around the true value.  
The experimental results show that the length of the parking space can be calculated by combining the time difference between two jumps of the ultrasonic sensor ranging value under the condition of obtaining vehicle speed, and the width of the parking space can be measured by the ultrasonic sensor ranging value.