# Automatic Parking System with MATLAB

January 14, 2022

By  Abhishek Tyagi

`lang: en_US`

Parking is a real challenge in congested parking lots and for inexperienced drivers. Automatic Parking Systems are limited to premium cars across the world.

In the current situation, explore the empty parking space and get the best maneuver as the parking has become boring due to the congested parking lot. The parking skills of the expert driver are transferred to an intelligent system that can lighten the driving load and improve safety in next-generation passenger vehicles. Automatic Parking Systems comes to the aid of inexperienced drivers to avoid collisions when parking in reverse.

In automatic parking systems, radar, sonar, vision, and ultrasonic sensors are used in combination to avoid obstacles in the parking path. APAS systems are available in various models from Toyota (Advanced Guided Parking System), Lexus (Intuitive Parking Assistant), Volkswagen (Park Assist), among others. Parking assistance modules cost between \$500 and a few thousand dollars. This indicates the expensive nature of the sensors and algorithms built into the system and thus makes it inaccessible to small segment car owners. This has led to a lot of research and development in the use of ultrasonic sensor technology.

## Proposed Model

In this model, working is shown using three already parked cars and an ego vehicle that needs to be parked. The car will be parked at the nearest slot, either beside cars or in between them.

## MATLAB Implementation

Codes & Report!

An automatic parking assistance system helps the driver decide parking slot fitment and vehicle parking once the slot is confirmed. Learn APAS with MATLAB; Developed in MATLAB R2021a

Below, I am sharing some portions of the code to make the explanation part easier. It's not a complete code, and you are advised to purchase and download the entire code.

### Global Variables

We are defining global variables, which can be used by the helper function while running of code.

global wl;
global ww;
global D;
global L;
global WSeta;

### Parked cars

In next lines we are fixing coordinates of parked cars on the figure.

%% Rectangle Coordinates for Parked car 1
Parked_Car1x1=0;
Parked_Car1y1=40;
Parked_Car1x2=Parked_Car1x1;
Parked_Car1y2=75;
Parked_Car1x3=15;
Parked_Car1y3=Parked_Car1y2;
Parked_Car1x4=Parked_Car1x3;
Parked_Car1y4=Parked_Car1y1;

### Tuning Parameters

These lines are used to tune parameters to use further.

WSeta=50;
xi=Parked_Car1x2-3;
yi=Parked_Car1y2+25;
f1e=40;

### Simulation Setup

Next we prepare a figure of required dimensions as well as required parameters.

### Initialize Start Scenario

In the following lines of code, we plot all the required figures, and one function is also used to plot the ego vehicle in its turning position.

i=1;
x=Xc+Rbl*cos(seta(i)+phi);
y=Yc-Rbl*sin(seta(i)+phi);
patch([Parked_Car2x1 Parked_Car2x2 Parked_Car2x3 Parked_Car2x4],[Parked_Car2y1 Parked_Car2y2 Parked_Car2y3 Parked_Car2y4],[0 1 1]);
patch([Parked_Car1x1 Parked_Car1x2 Parked_Car1x3 Parked_Car1x4],[Parked_Car1y1 Parked_Car1y2 Parked_Car1y3 Parked_Car1y4],[1 1 0]);
patch([Parked_Car3x1 Parked_Car3x2 Parked_Car3x3 Parked_Car3x4],[Parked_Car3y1 Parked_Car3y2 Parked_Car3y3 Parked_Car3y4],[1 0 1]);
title("Automatic parking Assistance System");
text(Parked_Car1x2,Parked_Car1y2+5,"Car 1");
text(Parked_Car2x2,Parked_Car2y2+5,"Car 2");
text(Parked_Car3x2,Parked_Car3y2+5,"Car 3");
text(Parked_Car2x2,Parked_Car2y2+40,"Parking Lot",'Color','red','FontSize',16);
Turn1(x,y,A,B,seta(i));

Start Scenario

### Car Parking Scenario Simulation

Now we implement the final steps of the model where the whole simulation takes place. Using two other functions car can turn and then move back to reach the respective slot. At last, it displays the parked position of the vehicle.

### Conclusion

The average time of users parking their vehicles will be effectively reduced in this system. This intelligent parking system provides better performance, low cost, and efficient large-scale parking systems.

Did you find some helpful content from our video or article and now looking for its code, model, or application? You can purchase the specific Title, if available, and instantly get the download link.

If you are looking for free help, you can post your comment below & wait for any community member to respond, which is not guaranteed. You can book Expert Help, a paid service, and get assistance in your requirement. If your timeline allows, we recommend you book the Research Assistance plan. If you want to get trained in MATLAB or Simulink, you may join one of our training modules.

If you are ready for the paid service, share your requirement with necessary attachments & inform us about any Service preference along with the timeline. Once evaluated, we will revert to you with more details and the next suggested step.

Education is our future. MATLAB is our feature. Happy MATLABing!

#### Abhishek Tyagi

Abhishek Tyagi is an aspiring Automotive engineer who enjoys connecting the dots: be it ideas from different disciplines, people from different teams, or applications from different industries. He has strong technical skills and an academic background in engineering, statistics, and machine learning.

#### Connect with MATLAB Helper ®

Use Website Chat or WhatsApp at +91-8104622179

Watch our Latest Video

Join a Training Module