final report for automatic controls
final report for automatic controls
An autonomous vehicle is capable of driving itself without human involvement and has
been a highly discussed topic of research and design. According to the World Health
Organization (WHO), more than 1.35 million people across the world die every year or
3,700+ every day because of car accidents. Others involved in road accidents who suffered
minor to serious injuries are between 20 and 50 million individuals
(didyouknowcars.com,2021). Human error is the leading cause of car related incidents,
distracted driving and reaction time of the drivers being a large factor.
In our project we will be designing a simplified version of the lane keeping assist with
assumptions and equations to model the road and the position of the car. The modeling
equation will then be added into Matlab/Simulink for the analysis.
Our Design
Dynamics:
Vehicle dynamics are very complicated, so we will use the very basic example in this report
for demonstration. Based on Linear systems ME 3010 project, tires of a moving vehicle are
complicated to say the least. For this reason, tire forces will be left as simple as possible.
For lane keeping cars, you must look at the forward, or longitudinal dynamics (velocity) as
well as the lateral dynamics (steering). The latter is the most complicated to implement,
thus a basic 2 degrees of freedom bicycle model will be used.
2
This will allow our focus to be on geometric constraints rather than torques and forces that
make this system very complicated. The equations used to model our two degrees of
freedom bicycle are:
X’ = V cos(ψ+β) (1)
Y’ = V sin(ψ+β) (2)
β = arctan(tan(δf)*[ℓr/(ℓf+ℓr)]) (4)
(Salfer-Hobbs,2019). Using X’ and Y’ we are able to integrate so we can model the position
of the car in our plant. Ψ’ is the reference angle and is used to help determine the position
of the car versus the road, and where it needs to go to correct the path. β is the slip angle,
and together with Ψ’ is used in determining if the vehicle is in the correct location in
relation to the road, and if not, what angles need to be changed to get back on path.
Assumptions needed when designing this controller were to assign constants to the
velocity and dimensions of the bike, (lf) and (li). The team decided to set the velocity of the
vehicle at 10 m/s which is an average speed in neighborhoods. (lf) and (li) were given values
of 1.5 meters because in a standard sedan the distance between the wheels is
approximately 3 meters.
We are also assuming that the velocity vectors of the front and rear tires are parallel to the
direction of the tires, meaning, no lateral forces. The second assumption is that the radius
of the vehicle path can change quickly or slowly. This will give us a basic model to use for
our PID controller.
PID controller:
For our design, we chose to use a simple PID controller. This controller type will continually
calculate an error value as the difference between the setpoint and a measured process
variable, and then apply a correction based on proportional, integrative, or derivative
terms. The PID will apply an accurate and responsive rectification to the control function
when activated. The first thing the team did when designing a Simulink control was to set
3
the inbound conditions which will represent the road. The PID controller will be a simple
box and is easy to auto tune. The next portion of the controller designed was the plant
which gives an output of the x and y position of the car. The last thing to add is the error
equation which is used in the controller to relate the position of the car versus the road.
The Plant:
Before implementing the actual PID controller and tuning it, we must first define and build
the plant of the system. The plant is the most complicated portion, in our opinion. Think of
the plant as the physical system that is being modeled, such as our bicycle design. The
plant in terms of theory is very simple; the car steers left or right along a path of different
radius of curvatures. The plant uses the equations above from the Dynamics section to
create the necessary inputs and can be viewed below in figure 2.
Now that the team had a working representation of the plant the next step was to create a
road function and error equation.
4
Road and Error function:
A simple Sin function was used to model the road for various conditions. Many different
functions were tested here but had errors or were too difficult for Matlab/Simulink to
model. One such problem was trying to use the derivative of the distance function to
optimize the shortest path from anypoint to the trig function in use. Matlab/Simulink would
process for close to an hour or more to run a basic simulation for a few seconds. Please see
the appendix for the original optimization and new error function.
The error for this model was created the same way as we learned in lecture, by finding the
difference between the input and the output. Now that we had the main parts of the
controller we were able to model the whole system as can be seen in figure 3.
The error was modeled by setting the input as the x and y position of the car and the
output as the error. The error for our systems model was defined as the shortest distance
from the vehicle's center of mass to the center of the lane. This was calculated by taking the
difference between the y position of the vehicle to the closest y position of the road.
Safety was the next consideration when designing our controller. Since we were only tasked
with designing a lane keeping assist, it was decided that safety came down to keeping the
car in its own lane. This would keep our vehicle safe from colliding with other cars or going
off the road. In Figure 4, we can see that we were able to safely model the cars position and
5
the roads position with minimal error. Any error is quickly responded to by the steering
angle which corrects any error that occurs with respect to the position of the vehicle and
the road.
Once the team was finished with designing and iterating the plant, creating a function to
model the road, and finding the error function, the last thing to do was tuning the PID
controller. This was the simplest part of the whole process and consisted of only one
function block in Matlab/Simulink. Tuning the PID block was also very simple since it has a
built-in tuning function that tunes the controller to the plant.
Results:
While working on this project the team started with a simple model of a unity feedback
loop. It was quickly discovered that the plant, the road function and the error would require
a lot more work to be able to safely design a lane keeping system. After days of work on our
design, we finally were able to come up with a model that we feel meets the requirement
given. As seen in figure 5, the vehicles position versus the cars position is very close and can
be assumed to be within safe parameters.
6
Figure 5: Cars position versus Roads position
Conclusion
In conclusion, the team was able to take what we learned in lecture and apply it to create a
controller that would assist in lane keeping and safety. By utilizing Matlab/Simulink a
controller was built to work safely under various driving conditions. The processes taken
were to build the plant, model the road conditions and error function, and then to tune the
PID controller. Building a fully capable autonomous system is a very large task that major
engineering firms are still struggling with today. Our project was a simple one in that we
were only tasked with designing a lane keeping assist controller. We are pleased with our
results based on how much we know about controllers and the limitations of our expertise
in this field. Our controller seemed to be accurate and provided results within our design
requirements, and provided safety to the rider.
7
Bibliography
1.)calculus - Shortest distance from point to curve. (n.d.). Retrieved December 3,
2022, from Mathematics Stack Exchange website:
https://math.stackexchange.com/questions/2264702/shortest-distance-from-
point-to-curve
8
Appendix
Note to the reader. Here is the original idea for calculating the error. When using this
method, Matlab/Simulink would crash and or spend an hour to process for a few seconds
of simulation time.
9
10