Vous êtes sur la page 1sur 23

# ECE 1635H: Modern Control Theory in Special Topic

## Frances Awachie Litao Lian Nanxuan Wang

1. Introduction..pg. 03 2. Summary...pg. 03 3. Procedure..pg. 03 4. Open-Loop Design...pg. 04 a. Relationship Between and d....... pg. 04 b. Future Improvements.... pg. 06 5. Virtual Sensors.....pg. 07 a. Distance Sensor Algorithm... pg. 10 b. Sensor Readings Results....... pg. 13 c. Future Improvements.... pg. 15 6. Closed-Loop Design.pg. 16 a. Parking Environment Parameters Collection.... pg. 17 b. Closed-Loop Diagram....... pg. 19 c. Future Improvements.... pg. 21 7. Lessons Learned.......pg. 21 8. Conclusion....pg. 21 9. References....pg. 23

## Design Project: Automatic Parallel Parking System

Page 2 of 23

Introduction
Parallel parking is an acquired skill many people struggle with. Poor parallel parking skills can result in accidents, frustration of the driver and users of the road, loss of time and loss in confidence. Sometimes, drivers ignore potential parking spots due to lack of confidence and skills or require a spotter to guide them into the parking space. Due to this, vehicles with the capacity to perform automated parallel parking have become more popular and prevalent in newer vehicles especially since its an added value to the consumer.

Summary
The purpose of this project was to design a sensor-based automatic parallel parking system in via a MATLAB simulation. The project chiefly consisted of three parts: open-loop control system, creation of virtual sensors, and close-loop control system. Open-loop system was designed through calculating the optimal control path, analyzing the relationship between (car body angle) and d (distance between moving car and static car) and investigating the actual path according to data readings from sensors. Furthermore, close-loop system was completed by adding a state feedback that helped reduce errors between actual car path and designed optimal path.

Procedure
1. In open-loop system design, optimal path was designed based on idea of using a sinusoidal path created by arc tangent of two identical circles. 2. The relationship between and d was acquired through trial and error.

3. Fours sensors were decided and designed to guide the car, while car body orientation was assumed to always be known. 4. Through comparing the optimal and actual control path, a feedback was calculated to complete the close-loop system.

## Design Project: Automatic Parallel Parking System

Page 3 of 23

Open-Loop Design
The main idea of designing optimal path was originally from the paper referenced at the end of report. The path was made of arc tangent of two identical circles. However, there could be more restricted for designing There were some assumptions made: first, Car 1,2 and 3 have same sizes(see figure 1); second, Car 3 is parallel with two static cars at the beginning; in addition, long and wide enough parking space available; also R=120 was the minimum radius of two identical circles; lastly, car body angle was assumed to be known.

Relationship Between

and d

The relationship between and d was acquired by trials and errors, where car body angle was at center of arc tangent of the identical circles and d was side distance between car 1 and car 3 at ready to park state Through fixing the angles, trials and errors were performed to obtain the range of d. Table 1 illustrated the domains of d regarding to body angles chosen. In the range of distance between 0-19 units and above 62 units, there was no angle available; in other words, car was not able to park. At the beginning of design, it was struggling to look for the relationship between and d since there were plenty of variables and parameters. Nevertheless, through making some fixed parameters and assumptions, it was much easier to acquire the relationship.
Table 1: Relationship between and d

## Design Project: Automatic Parallel Parking System

Page 4 of 23

Figure 1 demonstrates the initial position of car 3 at the ready to park state.
Figure 1: Ready to park state

Figure 2 showed that car 3 was at center position of the arc tangent.
Figure 2: Center position

## Design Project: Automatic Parallel Parking System

Page 5 of 23

Future Improvement
For further design, the following improvement would be made: 1. Car 1, Car 2 and Car 3 will be in different sizes. 2. Car 3 might have certain angles with Car 2 at ready to park state 3. More sensors would be added on Car 3 so as to deal with particular cases(such as sensors on left-hand side of car to detect objects)

## Design Project: Automatic Parallel Parking System

Page 6 of 23

Virtual Sensors
Setup
Figure 3 below shows the setup of the four ultrasonic distance sensors with sensors A and D fixed to the top middle and bottom middle of the car, respectively, while sensors C and D are fixed to the top and bottom right corner of the car respectively. The last item in the picture, theta, depicts the car body orientation which is determined by a gyroscope. In this case, 0 degrees is defined as when the car is facing north. Therefore theta is defined as the angle between the face of the car and the X axis.
Figure 3: Sensors

Strategy
Sensors B and C read horizontal distances while sensors A and D read vertical. Note that sensor B has a limited range compared to the other sensors. This was done intentionally in order to distinguish between the readings of a car and curb. For this simulation, the distance sensors readings are used to detect distance between the car 3 and car 1, 2 or the curb. Due to the lack of real sensors, virtual sensors were created in order to simulate the distance/intersection results. A detailed depiction of this setup can be seen in figure 4: Detailed Sensor Diagram. However, the strategy for determining the car body orientation was much simpler, since it was assumed that this was always known. This was useful since, although the output to the car is steering angle, a typical driver adjusts his/her car based on their desired resultant position or orientation of the car body. Due to this all desired movements of the car were based on the car body trajectory, then converted and output as steering angle.

Page 7 of 23

## Figure 4: Detailed Sensor Diagram

(Xcco,Yccf) (Xc2o,Yc2f) (Xc2f,Yc2f) (Xsf,Ysf)

2
SL Vertice 4 Vertice 3 (Xso,Yso) (Xsf,Ysf)

A B
L W

SLb

W (Xc2o,Yc2o) (Xc2f,Yc2o)

D C
Vertice 1 SL

SL (Xsf,Ysf)

(Xso,Yso) Vertice 2

## (Xc1o,Yc1f) (Xc1f,Yc1f) (Xsf,Ysf)

W (Xc1o,Yc1o) (Xc1f,Yc1o)

Geometry
Since the horizontal sensors B and C are always parallel to the face of the car and the car body orientation is defined as the angle between the face of the car and the X axis, then the slope found for Sensors B and C would be the car body orientation. The geometry used for this and other calculations can be seen in the Figure 5: Sensor Geometry Diagram. Note: Dx, Dy and dy, dx are different variables. The Endpoint of the sensor is based on dx and dy, while the intersection point found by the sensor is based on DX and DY. This distinction can be seen in Figure 5: Sensor Geometry Diagram and Figure 6: Sensor Scenarios and Algorithm

Curb

(Xcco,Ycco)

Page 8 of 23

## Figure 5: Sensor Geometry Diagram

V (X erti so ce ,Y 3 SL so) b

(X sf

,Y sf

dy dx

## @ theta = 0: dx = SL, dy = 0 Theta - car body angle

(Angle between the front of the car and the X axis)

Ve r

tic

(X s SL Ve o,Y rti s ce o) 2 (X sf ,Y sf )
dx

W L

Ve rti c

dy

## Horizontal Sensors: cos(theta) x SL = dy sin(theta) x SL = dx @ theta = 0: dy = SL, dx = 0

The sensor readings are stored in the following format: SB = [I Ix Iy Dx Dy] SB - Sensor Reading, (A, B, C, D) I Intersection Reading, (1, 0) where: I = 1 Intersection Detected I = 0 No Intersection Detected Ix Absolute, X coordinate location of the intersection point Iy Absolute, Y coordinate location of the intersection point Dx Horizontal distance from the starting point of the sensor to the intersection point Dy Vertical distance from the starting point of the sensor to the intersection point (Xso,Yso) Coordinate of the starting point (origin) of the Sensor, i.e where the sensor is attached to the moving car. (Xsf,Ysf) Coordinate of the end point (final) of the Sensor, i.e where the sensor beam stops due to its limit or range. (Xco,Yco) Coordinate of the Vertex of the bottom left corner of the parked car. (Xcf,Ycf) Coordinate of the Vertex of the top right corner of the parked car. SL Sensor Limit (distance) SLb Restricted Sensor Limit of sensor B (distance) Design Project: Automatic Parallel Parking System Page 9 of 23

Theta Car body orientation/angle (degrees in diagrams) When there is no intersection detected, then I= 0 and the display for Dx and Dy would be N/A.

## Distance Sensors Algorithm

For the creation of the virtual ultrasonic distance sensors, the most critical attribute to calculate was the intersection point. However, this needed to be done in relative terms and not absolute. In order to do this, various assumptions had to be made and steps and calculations performed. A pictorial depiction of this can be seen in Figure 6: Sensor Scenarios and Algorithm, where the green lines are the targets and represent possible intersection points. Assumptions: 1. Car moves in a sinusoidal like path in order to parallel park 2. Car follows the right side of the road a. Parked cars are to the right b. Car parallel parks to the right 3. Car stops beside park Car 2 a. Car is parallel to Parked Car 2 b. Curb is Parallel to all three cars 4. Since car is only trying to park to the right, only sensors needed are a. Sensor to the right of vehicle to determine distance to cars and curb b. Vertical sensors to determine vertical distance to parked Car 1 and Car 2 5. Car never attempts a full body rotation when parking a. Car body angle range when parallel parking could between 0 and 70 degrees. b. Car rotates clockwise by a certain Angle and then rotates counterclockwise by same Angle. 6. Desired car trajectory is incremented or decreased by 1 degree at a time. Steps: 1. Determination of the Sensor slope and Endpoint a. This is obtained from the car body angle 2. Determination of Intersection with Vertical Side Target a. Check if Target is in Vertical Range b. Calculation of Possible Intersection Point c. Check if Possible Intersection Point is in Vertical Range d. Determination if Intersection Detected e. Output of Vertical Sensor Target Reading 3. Determination of Intersection with Horizontal Side Target a. Check if Target is in Horizontal Range Design Project: Automatic Parallel Parking System Page 10 of 23

4.

5. 6.

7.

8.

In addition to this, the actual sensor positions after each translation and rotation of the car had to also be calculated. This was based mainly on geometry and used the car body orientation intensively. The determination of the horizontal sensors and endpoint were fairly simply since the starting point of the sensors are fixed to the vertices of the moving car, which is updated after each translation or rotation. The vertical sensors, however, required more geometry since it was located on the top middle or bottom middle of the car. Since there were no vertices for these locations, the starting point of the vertical sensors had to be calculated through geometry and with the use of the car body orientation.

Page 11 of 23

## Figure 6: Sensor Scenarios and Algorithm

Possible Sensor Lines Scenarios: (Xcco,Yccf) Example for Vertical Side Target: (Xc2o,Yc2f) (Xc2f,Yc2f) Check if Target is in Horizontal Range: Sensor Algorithm:

C
(Xso,Yso)

SL (Xsf,Ysf)

if Xsf>=Xco

(Xso,Yso)

(Xc2o,Yc2o)

if Checkx==1

D
SL Curb

## Dy=tan(theta)*Dx; Iy=Yso+Dy; Ix=Xco;

Check if Possible Intersection Point is in Vertical Range:

(Xsf,Ysf)

## if (Iy>=Yco && Iy<=Ycf) &&(Ix>=Xco &&Ix<=Xcf) Checky=1

Intersection Detected:

(Xc1o,Yc1f) (Xc1f,Yc1f)

`
Determination of Sensor Slope and Endpoint

## if Checkx==1 && Checky==1

tan (theta)= m=

Y sf Y so X sf X so

## Dx=(Xco-Xso); Dy=tan(theta)*Dx; I=1; Ix=Xco; Iy=Yso+Dy;

No Intersection Detected:

## cos(theta) SL= dx s sin( theta) SL= dy s X sf = X so+ dx s Y sf = Y so+ dy s

W (Xc1o,Yc1o) (Xc1f,Yc1o)

(Xcco,Ycco)

## SBc1=[I Ix Iy Dx Dy]; SBc2=[I Ix Iy Dx Dy]; SBcc=[I Ix Iy Dx Dy]; SB=[I Ix Iy Dx Dy];

The vertical and horizontal green lines in the figure above are the targets and they represent the possible intersection points that can be found by the sensor. Design Project: Automatic Parallel Parking System Page 12 of 23

Figures 7 through 9 below show the results of several trial runs. The lines represent a sensor, in this case sensor B, that is attached the moving car. However, for testing purposes the car was neglected and the sensor lines were reproduced in various orientations/scenarios in order to confirm that algorithm worked. The blue car displayed in the picture is car 2, the top car. Each big dot is an intersection point found by the program for a particular sensor. Note that red and purple colored sensor lines in Figure 9 do not show an intersection point. This is because the sensor distance limit is reached before this can occur. For the horizontal sensors, i.e. B and C, it is possible for the sensors to obtain an intersection reading for Car1, Car 2 and the curb. This is especially true for Sensor C, due to its wider range reading. Therefore sensors B and C should always return the Car 1 or Car 2 intersection readings over that of the curb, since the curb is further away. Also because the Car 1 and Car 2 are assumed to be stationary, and the path to park in between the two is an S shape, the moving would not ever enter a situation where it is reading an intersection at both the Car 1 and Car 2. However, for the vertical sensors, due to the way the car moves in the sinusoidal like path in order parallel Park, sensors A will only obtain intersection readings from the top car or the curb, while Sensors D will only obtain readings from the bottom car (Car 1) or the curb. Once again, both sensors will take the car intersection reading over that of the curb.

Page 13 of 23

## Design Project: Automatic Parallel Parking System

Page 14 of 23

Future Improvements
If desired, the actual car body orientation can be calculated, instead of simply being known. In order for this to be done, the current and previous theta would have to be stored for comparison. In addition, the system would have to be able to distinguish between a car reading and a curb reading. This can be easily done by storing the Dx reading of the current and previous from Sensor C. Since the car is meant to have a trajectory movement of + or 1 degree, the difference between the current Dx and previous should be small. However, if the difference is large, then this means that the sensor has jumped from a car reading to a curb reading or vice versa. Therefore determining whether the car is reading the curb or the car becomes quiet simple, as long as the initial Dx reading for the curb is stored and kept static, i.e. at the point right before the car starts the parallel parking. From this and the readings of the vertical sensors, the actual car body orientation can be calculated.

## Design Project: Automatic Parallel Parking System

Page 15 of 23

Closed-Loop Design
Introduction
In the closed-loop case, the car 3 was controlled by sensors. All control algorithms were based on sensors feedback from the parking environment. In addition, the collection avoidance would use the sensors feedbacks.

Setup
Four sensors were setup on the car to measure the distances between parked cars and curb as showing on Figure 3. On the

Table ,

it shows that sensor, SB had limitations on the distance measure. All the four sensors were used for different purposes as shown on

Table .

In a real car application, ultrasonic distance sensors were used to measure the distance and avoid object (Pohl, etc., 2006, Jiang, etc., 1999). Most of those sensors were limited to 4-6 meters, but had chosen the sensors which could measure 10 meters (Pohl, etc., 2006). Our group had assumed that the car 3 would only park on the right side of the road. The sensors would be installed on the right side of the car bumper. In the real world application, there might be a case that the car would be parked on the left side of the road, so additional 2 sensors should be installed on the left side of the car body. The control algorithm would be the same.
Figure 30: Sensors setup on the car

Page 16 of 23

## Table 2: Sensors setup

SA SB SC SD

Position Top centre of the car Top right corner of the car Bottom right corner of the car Bottom centre of the car

## Range 50 unit 35 unit 50 unit 50 unit

Function Measure the distance from the front parked car Measure the distance between the parked cars and curb Only measure the distance between the parked cars Measure the distance between the behind parked car and curb

## Parking environment parameters collection

Figure 11: Parking environment parameters collection

## Design Project: Automatic Parallel Parking System

Page 17 of 23

The car 3 in Figure 11 started at the stage 0, which was the initial state. All sensors had a reading of zero. As the car 3 moving forward, sensors SB and SC started to have readings. Due to the sensor range limitation, SB did not have a reading until it intersect with car 2. An intersection flag was setup for SB, the flag would be activated when there was an intersection. SB would become inactivate after car 3 passed car 2. At the same time a timer was activated and the time would be saved for future calculation to determine the parking lot length. The timer would be stopped when the SB flag become activated again. SC would have a distance reading right after the initial state. Depends on the distance, a program would determine if the distance would be for the curb or for the car. An intersection flag was used here. The SC was also used to determine when the car 3 would be reached the ready to park state, which would be triggered by the second time flag state change from inactivate to active. There was no range limitation for the SC, so it could be used to determine the distance between the car 3 and curb. Design Project: Automatic Parallel Parking System Page 18 of 23

SA and SB did not have readings from the stage 0 to stage 3, because there were not intersections when the car 3 moving forward. A summary of the sensors readings were listed in Table .

## Stage 0 SA SA flag SB SB flag SC SC flag SD SD flag 0 0 0 0 0 0 0 0

Stage 1 0 0 d 1 dcurb 1 0 0

Stage 2 0 0 d 1 dcurb 1 0 0

Stage 3 0 0 0 0 d 1 0 0

Car 3 was moving up in a constant speed. The SB would give a time between the car 1 and car 2, so parking lot length could be calculated. In addition, the distance between the car 3 and car 2 could be calculated based on SC reading from stage 2 and stage 3. In the paper of Jiang, etc, a similar process was used to scan the parking space (Jiang, etc., 1999). According to Wangs thesis paper, the relationship between the steering angle and car body angle was described in below (Wang, 2010). Similar functions could be found in Pohls paper (Pohl, etc., 2006).

The car 3 translation was guided by the following formula according to the Wangs paper (Wang, 2010).

## The rotation formula of car 3 was use and listed in below.

Vertices of the car 3 were calculated by using the following method. The car center coordinates were known. The initial vertices of the car were known too. The calculation of the offset should be performed. The next vertices of the car could be calculated by using the Design Project: Automatic Parallel Parking System Page 19 of 23

offset and rot function. The new state would be known and would be used as the initial state. By doing this, the car 3s coordinates would be known at any time.

## Parallel parking trajectory

The parallel parking trajectory was generated by the open loop control offline. In the closed loop, the car 3 should be just following the path if there were no errors between the real path and the trajectory path. In real world application, there would be errors generated from the sensors and steering wheel. In this project, prefect sensors would be assumed. However, the steering angle and car body angle would have some errors. This error should be corrected by the controller.

## Dynamics in the parallel parking algorithm

The initial car start position was generated by using random function to simulate the real world case. It was very difficult for the driver to stop the car in a fixed spot before the parallel parking. The parallel parking algorithm should handle different start position. The algorithm should determine the car body angle needed for the car to park in the parking lot.

## Closed loop block diagram

In the closed loop, the car body angle, , was one of the input to the parallel parking system, and it was known at all time. Another input to the system was the speed of the car. In the real world, when the car was parked, the speed was normally very slow, so a constant speed was assumed. At the beginning, A and O were the same, and was equal to zero degrees. One degree increment would be applied to the O, so the algorithm would calculate the vertices of the car 3 and the centre of the car 3 should be. At the same time the actual car 3 centre would be calculated. In the simulation, a deadband of 0 to 5 degree was applied, i.e. when o is increased by less than 5 degrees the car will not move. When O reached the sixth degree, Car 3 would start to move. The sensors, SB and SC, would feedback the distance between the car 3 and car 2. Based on the feedback, a car body angle would be calculated. The controller would compare the difference between the A and O, and then a error would be generated. Any error produced would be multiplied by a proportional gaining order to obtain the new desired . The desired would be generated and then passed to the controller by using the formula stated in the Figure 12: Parallel parking block
diagram

to convert the car body angle to steering angle. This steering angle is the output to the vehicle. The generated desired angle would then be stored for the next increment and comparison. The resultant , i.e. A would be obtained and feed back into the system as an input, thereby closing the loop.
Figure 12: Parallel parking block diagram

## Design Project: Automatic Parallel Parking System

Page 20 of 23

Because this project has assumed that all the sensors would return accurate data, there was no error for the controller to correct. Even though the deadband was applied, but after the 5 degree range, it would be fine. In the real world applications, the sensors and the steering wheels would not always provide accurate data and which would therefore affect the command to the car.

Future improvement
A lot of assumptions were made before for the project. They had simplified the project, but a lot of assumptions did not truly represent the real world. In the future development, the parallel parking system should handle the following cases: 1. The cars were not parked perfectly parallel to the curb. Design Project: Automatic Parallel Parking System Page 21 of 23

2. The car 3 also should not be required to be perfectly parallel to the car 2. 3. The parking lot size should be modeled to reflect a parking lot in the real world. 4. The sensors should not be perfect. There should be noises in the sensors measurement, such as overshoot and delay.

Lessons learned
We had learned a lot of things by doing this project. The most valuable experience was to work with MATLAB to simulate a car parallel parking system. We struggle on understanding how we could only use MATLAB to do it. We had done a lot of work in the Hardware-In-theLoop. In this project, there were a lot of geometry calculations which required a lot of time to complete.

Conclusion
The open-loop system was developed successfully and the theta to d relationship obtained through trial and error worked successfully for various horizontal starting points. A number of trials were performed in order to ensure the car could successfully parallel park in the space provided without hitting any of the static cars. The major time consuming components of this section were the required geometry calculations and the MATLAB programming. The creation of virtual sensors was more complex than initially assumed. In order to obtain accurate results each time, various scenarios had to be tested and formulas adjusted to finally obtain the completed final sensor algorithm. It was due to this, the amount of geometry needed and also coding, that made this component very time intensive and as a result accounted for about 80% of the 2000 lines of code. As for the closed-loop system, the majority of the time was spent on understanding the different elements of the system. Understanding how all the components of the system were interacted together and ensuring that the steering angle and car body orientation were kept as separate variables. Also, translating and rotating the car based on actual vehicle dynamics added a complexity to this section. Although, the system has a few minor issues with the closed loop, mainly due to the incorporation of the proportional gain, it overall performs well. As was mentioned earlier, this project provided a great opportunity in learning how to program in MATLAB and has resulted in the members of the group having a deeper understanding of the MATLAB environment and simulated Hardware-In-The-Loop.

## Design Project: Automatic Parallel Parking System

Page 22 of 23

References:
1. Robust automatic parallel parking in tight spaces via fuzzy logic Robotics and Autonomous Systems (May 2005), 51 (2-3), pg. 111-127 Y. Zhao; E.G. Collins 2. Parking and the visual perception of space.Journal of Statistical Mechanics: Theory and Experiment (October 2009), 2009 (10), pg. 1-7 3. A Navigation-Field-Based Semi-Autonomous Nonholonomic Vehicle-Parking Assistant IEEE Transactions on Vehicular Technology (March 2009), 58 (3), pg. 1106-1118 4. Autonomous parallel parking of a car-like mobile robot by a neuro-fuzzy sensor-based controller Fuzzy Sets and Systems (October 2009), 160 (19), pg. 2876-2891 5. Demirli, K. and Khoshnejad, M.. Autonomous parallel parking of a car-like mobile robot by a neuro-fuzzy sensor-based controller Fuzzy Sets and Systems. October 2009. 160 (19), pg. 2876-2891. http://www.sciencedirect.com/ 6. Jiang, K., Zhang, D. Z. and Seneviratne, L. D. A parallel parking system for a car-like robot with sensor guidance. June 1999. Page 591-600. http://pid.sagepub.com 7. Liang, H.. Research of automatic parallel parking system. May 2010. http://www.docin.com/p-161114187.html 8. Oetiker, M. B., Baker, G. P. and Guzzella, L. A Navigation-Field-Based Semi-Autonomous Nonholonomic Vehicle-Parking Assistant IEEE Transactions on Vehicular Technology (March 2009), 58 (3), pg. 1106-1118 9. Parking and the visual perception of space Journal of Statistical Mechanics: Theory and Experiment (October 2009), 2009 (10), pg. 1-7 10. Pohl, J., Sethsson, M.; Degerman, P. and Larsson, J.. A semi-Automated parallel parking system for passenger cars. Jan 2006. Page 53-65. http://pid.sagepub.com/content/220/1/53 11. Zhao, Y. and Collins, E.G.. Robust automatic parallel parking in tight spaces via fuzzy logic Robotics and Autonomous Systems. May 2005, 51 (2-3), pg. 111-127

Page 23 of 23