Research and Implementation of Automatic Fuzzy Garage Parking System Based on FPGA

Because of many common scenes of reverse parking in real life, this paper presents a fuzzy controller which accommodates front and back adjustment of vehicle’s body attitude, and based on chaotic-genetic arithmetic to optimize the membership function of this controller, and get a vertical parking fuzzy controller whose simulation result is good .The paper makes the hardware-software embedded design for system based on Field-Programmable Gate Array (FPGA), and set up a 1:10 verification platform of smart car to verify the fuzzy garage parking system with real car. Verification results show that, the system can complete the parking task very well.


Introduction
Automatic parking means that after reaching the parking area, according to the information returned by the external sensor and using intelligent algorithm, vehiclemounted controller guides the car go into the parking space automatically.The development of automatic parking technology can save the driver from the complex and experienced operation process effectively and improve the safety of the parking process greatly.
To improve the stability and intelligence of the automatic parking system, the researchers have proposed a variety of control strategies in recent years.Literature [1][2][3][4][5] proposed the path tracking method to guide parking, it means that the parking route is composed of the defined multistage continuous curvature curve (such as sine curve, five polynomial curve, etc.), and control the cars to drive along the reference path based on precision controller.Literature [6,7,8] use fuzzy controller to solve the problems of control decision of vertical and parallel parking process.Based on fuzzy parking system, literature [9] proposed the attitude adjustment in parking space, making the car move along the center line after drive into the parking space.Literature [10] design three fuzzy controllers which consist of attitude adjustment, steering control and parking decision, and in addition to the on-board controller it design the ground control station, achieving the auxiliary control function in large parking lot.At the same time, some studies combine the fuzzy control and other algorithms to improve the control ability, such as neural networks [11] and genetic algorithms [12].
This paper aims at the common scene of reverse parking in real life to design a fuzzy garage parking system (FGPS) which uses the fuzzy algorithm as the core strategy.The system includes the decision system which is made up of controller, the perceptual system which is made up of sensors and executive system which is made up of steering engine.Based on the coordinate of these three systems, FGPS can complete the parking action.At the same time, FPGA realize the hardware and software embedded design for FGPS, and the paper design a smart car platform to verify the system by real car.
The paper is organized as follows.The section 2 establish the vehicle kinematic equations and design the fuzzy controller of FGPS, and optimize the fuzzy controller based on chaotic-genetic arithmetic, and test the effect of fuzzy controller by MATLAB .The section 3 establish the smart car test platform.The section 4 uses FPGA to make the hardware-software embedded design for FGPS.The section 5 makes the physical verification of smart car.And the section 6 makes a conclusion for the whole passage.

The design of fuzzy controller 2.1 Vehicle kinematic equation
The paper establishes the coordinate system of parking space using the left lower corner of parking space as the original point, and determine the coverage area of the car by the coordinates of four corners of the car.The vehicle adopt the model of front-wheel steering and rear-wheel drive, it means the rear two wheels parallel with the body all the time and the front two wheels can turn left or right.Use the coordinate of the central point of the back shaft (xr,yr) on behalf of the position of the car, and I as the  From the equation we know that, we can control the next-time position coordinate and direction angle of the vehicle by controlling the speed v and angle I .In other words, it controls the vehicle's next-time position and pose.

Design the fuzzy controller
The fuzzy controller has three inputs and two outputs, the inputs are the coordinate of the central point of the back shaft (x r ,y r ) and the body direction angle θ .The outputs are steering engine corner and the speed of vehicle ν .
Using the left lower corner of parking space as the original point and thinking about the area of the parking space and the width of the carriageway, the value range of (x,y) is set in [0,10000mm] and [0,12000mm], the domain of discourse has four levels, they are {S,M,B,PB}; the value range of the body direction angle θ is set in [-20°,120°], the domain of discourse has five levels, they are {N,Z,PS,PM,PB}; the value range of steering engine corner is set in [-34°,34°] ,the domain of discourse has five levels, they are {NB,NM,Z,PM,PB}; the value range of speed ν is set in [-2000mm/s, 2000mm/s], the domain of discourse has two levels, they are {NB,PB}.Adopting the combination of trigonometric function and trapezoid function in each variable's value range, the system uses chaotic-genetic arithmetic to optimize the parameter of the membership function and get the shape of the membership function as Fig. 2.
The design of fuzzy inference rules refers to experienced drivers' operating experience,and establishes the form of fuzzy inference rules of fuzzy controller as Table 1 shown.

Simulation and verification
To verify the results of fuzzy control, the paper establishes the simulation model in MATLAB/Simulink.This model consists of four parts; they are the fuzzy controller module which makes the decision, the vehicle kinematics module which control the vehicle move, the constraint module which make the judgment of collision and stop the simulation, and the animation module which output the simulation results.To simplify the simulation, the car is set in the starting parking space.In order to obtain a complete test results, in a possible initial parking area, three points (5619,8022,2.83°),(8012, 8969,8.42°),(3566,6989,-2.5°) which are in the center, on top and on the downside, and have the different initial direction angles are set to test.The testing track figure is shown in Fig. 3. Table 1 The fuzzy inference rules after optimized.Fig. 3 is the track graphs of first, second and third test point.As can be seen from the Fig. 3, the final stop position of the vehicle is almost in an ideal location, the stop pose compared with the condition of 90° verticality has only a least difference of 0.05°, and largest difference is just 1.52°.No significant body tilt and complicated adjustment process express that the design of the fuzzy controller is reasonable and the process of control is effective.

Design of the smart car verification platform 3.1 Global design of hardware platform
In order to verify the design of FGPS by virtual cars, a smart car verification platform whose dimension scale is 1:10 is established, and the global hardware structure of this platform as follows: the platform of smart car ,the Nexys3 board with Xilinx Spartan-6 LX16 FPGA, logic level conversion module, ultrasonic ranging module, speed measurement module with photoelectric encoder, voltage-stabilized power supply module, motor & steering engine drive module and motor and steering engine.
In this hardware system, FPGA is the core processor, ultrasonic ranging module and speed measurement module with photoelectric encoder are sensory perceptual system, motor & steering engine drive module, motor and steering engine are execution system.The sensory perceptual system detects external environment and use logic level conversion module to translate the environment information to 3.3V logic level which can be recognized by Nexys3.This information enter FPGA via Pmods port of Nexys3, and FPGA make decisions based on arithmetic.Then the decision information is transmitted to sensory perceptual system or execution system by Pmods port and logic level conversion module in order to complete the adjustment and detection of model car.The whole parking system is provided a 5V/3.3Vvoltage by the power supply module.

The distribution of ranging sensor
The paper uses HC-SR04 ultrasonic module as the ranging sensor.In the process of parking, to get car's position and information of body pose real time, each ultrasonic module is needed to collaborate with others.The paper thinks about that the car maybe run on the left or right, so put the ultrasonic modules on car as Fig. 4 shown.18ultrasonic modules are divided into 6 groups and installed on car body.Because of the detection angle of HC-SR04 is 30°, so each group has 3 sensor and each sensor's detection angle is 30°.In this way, it is not only no mutual interference, but also ensure that the detection range is large enough in parking process.G1,G2,S8,S9 and S11, S12 are used when the car run on the right, and others are used when it runs on the left.
Supposing the parking space is on driving direction's left, when the car begins to find the parking space, it uses G1 and G2 to detect the distance between the obstacle on the right side and itself.The value of each group chooses the least among three sensors'.When start to reverse parking, because of the parking space is confirmed, so the environment map and origin of coordinates is established, and the system only need to pay attention to the position and pose of car.Supposing the value of G1 and G2 is L1 and L2, so the body can be located by Eqs.(2-4).In Eq.3 , L rw is rear track.
When the coordinate of car goes into the parking space, S8&S9 and S11&S12 are used to detect the distance between car and the bottom of parking space.By this time, the value of S8&S9 and S11&S12 get the larger one, and the positioning method is similar to the Eqs.(2-4).

The other key module
In order to make sure each module get the right voltage, 5V/3.3Vlogic level conversion module with 74LVC4245A chip is selected.And voltage-stabilized power supply which has a AMS117 chip in it is used to supply 3.3V.The actuator of automatic parking system is composed of 380 motor, MG995 steering engine and other drive modules.

The embedded design of hardware and software
The system is designed by EDK.Firstly, processor hardware platform which has a 32 bits CPU named MicroBlaze is established by XPS development environment.Then according to the process of parking, the software design is complete by SDK software development environment with C language.
About software design, Fig. 5 and Fig. 6 are the flow charts of the space search process and starting parking process.Based on these flow charts, software system is established by SDK.
In Fig. 5, PDmin is the minimum depth of the garage and PWmin is the minimum width of the garage.The system uses G1 to find parking space, and get the width of it by the product of the speed and time.Automatic parking system works as Fig. 6 shown, using G1&G2 to find parking space, and G3&G4 to determine whether the car goes into the parking space completely.

Physical verification of smart car
In this section, the parking system has been verified by smart car in a simulative garage.As shown in Fig. 7, 6 pictures in the first row from left to right show the process that the smart finds the garage.At first, the car run slowly along the carriageway and keeps a safe distance from the barrier.When it discovers the garage, keep run until arriving the site which the car must stop and get ready to reverse parking.Then the other picture in the second row from left to right show the whole process of Parking.Finally, the car enter the parking space and the distance between car and both sides of the barriers is suitable, the direction angle is almost 90°.The test shows that the parking system of this paper works in a good state, and the fuzzy control algorithm can complete the parking task perfectly.But in this environment, all the lines of barriers and parking space are totally parallel or perpendicular, so if the parking environment is more complex, the algorithm mentioned in the paper may need to have certain adjustment to adjust it.

Conclusion
The paper designs a automatic vertical parking arithmetic, consist of finding parking space automatically and selfadapting control reverse parking, and realize the arithmetic in hardware and software platform by FPGA, and establish the smart car test platform which consist of decision module, sensing module and execution module, and complete the test of this parking system.After debugging, the smart car can complete the parking task safely and efficiently.The system can adjust the body posture automatically when the car meets the barriers; it has good intelligence and security.Because of the design is based on FPGA, so it has the advantage of reconfigurable and system upgrade easily.So the paper has certain practical significance.

Figure 2 .
Figure 2. a.the membership function of the input variable x, b.the membership function of the input variable y, c.the membership function of the input variable θ , d.the membership function of the output variable v , e.the membership function of the output variable front-wheel steering angle, that means the included angle between the front wheel corner and main axis, and clockwise is positive.Use θ as the body direction angle, that means the included angle between the main axis of vehicle and the X axis of the parking space, and anticlockwise is positive.And use L as the wheelbase.The speed driving backwards is positive.Establish vehicle kinematic model as Fig. 1 and vehicle kinematic equations as Eq. 1.

Figure 4 .
Figure 4.The distribution of ultrasonic sensors.

Figure 5 .
Figure 5 .The flow chart of finding parking space.

Figure 6 .
Figure 6.The flow chart of automatic parking system.

Figure 7 .
Figure 7.The picture of parking test by smart car.