0% found this document useful (0 votes)
85 views17 pages

Final Report Automatic Brake System Using Fuzzy Logic

This document describes an automatic brake system using fuzzy logic that takes two inputs - vehicle speed and inter-vehicle distance - and outputs a brake force. It discusses designing a fuzzy logic controller with triangular and trapezoidal membership functions for the inputs and triangle membership functions for the output. The document also provides the Mamdani-style rule base and details defuzzifying the output using the centroid method. Python code is included to demonstrate the performance of the fuzzy logic system for different input values.

Uploaded by

For Books
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views17 pages

Final Report Automatic Brake System Using Fuzzy Logic

This document describes an automatic brake system using fuzzy logic that takes two inputs - vehicle speed and inter-vehicle distance - and outputs a brake force. It discusses designing a fuzzy logic controller with triangular and trapezoidal membership functions for the inputs and triangle membership functions for the output. The document also provides the Mamdani-style rule base and details defuzzifying the output using the centroid method. Python code is included to demonstrate the performance of the fuzzy logic system for different input values.

Uploaded by

For Books
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/333617977

Automatic Brake System using Fuzzy Logic Contents

Technical Report · June 2019


DOI: 10.13140/RG.2.2.14398.95043

CITATIONS READS

0 4,326

1 author:

Saif H. Alrubaee
Al-Farahidi University
12 PUBLICATIONS   6 CITATIONS   

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Filter Bank Multi-Carrier Modulation Technique for Vehicle-to-Vehicle Communication View project

LTE-V2X System Performance Based on Urban-Low Speed Environment View project

All content following this page was uploaded by Saif H. Alrubaee on 05 June 2019.

The user has requested enhancement of the downloaded file.


Automatic Brake System using Fuzzy Logic

Contents
1 OVERVIEW ...................................................................................................... 2
2 INPUT-OUTPUT OF FL SYSTEM .................................................................... 3
3 DESIGN STRUCTURE..................................................................................... 4
1 Fuzzification ................................................................................................ 4
2 Rule Base & Inference Engine ................................................................... 6
3 Defuzzification ............................................................................................. 7
4 Performance of FL system. ........................................................................ 7
5 Discussion on comparison with other FL structure .............................. 10
CONCLUSION ...................................................................................................... 10
PYTHON CODE .................................................................................................... 11
REFERENCE ........................................................................................................... 16
1 OVERVIEW
Human judgment error may cause serious accidents due to inaccurate reaction time and time
consumes to perform full braking. In many such cases, the main cause of such accidents is the
distraction through driving and failure to react in such enough time. Moreover, the fully
intelligent vehicle, which is called driverless car, will totally automate without any human
interaction. Each vehicle will utilize both its speed sensor which measures the wheel speed
and distance sensor which is based on ultrasonic waves to compute the safety distance
between the vehicle and its neighbours by controlling the brake pressure force on the brake
pedal.

The automatic brake system, which make the driving journey safer, has developed from
25 years ago, in recent years (Aras 2013), it is developed significantly utilizing the artificial
intelligent methods and algorithms, which increase the accuracy and response time. In this
project, we proposed fuzzy controller with two inputs, vehicle speed and inter-vehicle
distance, and one output, brake force, to create a safety distance between vehicles under
different circumstances which waves from too fast speed to too low speed and from a too
close distance to far distance. The main problem of this project is as follows:

• Human driving, which involves reaction times, delays, and judgment errors is not
enough to avoid emergency braking or road accidents.

• Moreover, and in many such cases, the cause of the accident is driver distraction and
failure to react in time.

• So, in this project, we design human free brake system that maintains both the vehicle
speed and inter-vehicle distance, to automatically decelerate the vehicle on urgent
demands by controlling the brake force pressure.

Figure 1 simplified explanation of our proposed fuzzy controller


2 INPUT-OUTPUT OF FL SYSTEM
We have two inputs and one output, the inter-distance is based on ultra-sonic sensor and
speed is based on Hall effect principle, as will explain later. The output of our fuzzy proposed
controller is brake force pressure.

For measuring purposes of the distance between two consequence vehicles, usually
ultra-sonic sensor is used which is considered very popular and low cost. Figure 1 shows a
type of ultra-sonic sensor. Simply, it comes with a separate transmitter, called TRIGGER and
a receiver, called ECHO. The sender sends 8 pulses of 40 kHz, which when hits an obstacle
stands at the front of the ultra-sonic module gets back and received from the receiver side. By
simple calculation on the receiver side and depending on the duration of the sum of the
travelling time, when the signal transferred until when it received back, the distance between
the vehicle and the next one could be estimated.

(a) (b)
Figure 2 (a) Ultra-sonic sensor (b) Ultra-sonic signal radiation

The speed sensor is based on Hall effect principle which generate an electrical signal
when a magnetic field moves near a metal, these pulses are transferred to an engine electronic
control unit (ECU) which compute the relative speed of the vehicle depending on the
transferring pulse frequency. Higher frequency means high speed and low frequency means
low speed, Figure 3 shows a vehicle speed sensor installed on a wheel (crack shaft wheel),
which it rotates with vehicle engine. The speed sensor radiates a magnetic field € that cut the
cam’s wheel and then electrical pulses are generated.
Figure 3 Speed sensor principle

3 DESIGN STRUCTURE
Our fuzzy logic design is consisting of inputs, output, and Mamdani-Fuzzy inference engine.
The output is the brake force and is defuzzied using the centroid method. The block diagram
below depicts that.

Figure 4 Block diagram of our design


1 Fuzzification

We divide the distance range from 0-10 m to three sub ranges, very close(V_cls), close, and
far. The inter-vehicle distance is classified as follows:
 Very close distance (0-5 m), Triangular.
 Close distance (2-8 m), Triangular.
 Far distance (5-10 m), Triangular.
We have chosen triangle membership function since as the vehicle become close, the
value of the crisp input (V_cls) increase dramatically, at the middle membership, there are
marginal space starts from 4 and ends at 6m, after that, the distance considers far.

Then, we divide the vehicle speed from 0 to 10 m/s to 5 different ranges as follows:

 Too slow (0-2 m/s), Trapezoidal.


 Slow (1-4 m/s), Trapezoidal.
 Optimum (3-6 m/s), Trapezoidal.
 Fast (5-8 m/s), Trapezoidal.
 Too Fast (7-10 m/s), Trapezoidal.
For the speed since its relative and couldn’t rely on a specific value, we select trapezoidal
membership function. The trapezoidal shape makes the values wave with reset range.

The output of our fuzzy system is the amount of brake force and is classified as follows:

 Decrease brake force greatly (0-8 N)


 Decrease brake force slightly (4-12 N)
 No brake reaction (8-16 N)
 Increase brake force slightly (12-20 N)
 Increase brake force greatly (16 -24 N)
The output membership function consists of 5 members, triangle membership is the best
choice, since for each division range, the value increase sharply until the middle then
decrease to interfere with the adjutant membership. Figure 4 below depicts the input and
output membership functions.
Figure 5 Membership function of inputs and output

2 Rule Base & Inference Engine

Antecedent Consequent

If too close, Then increase greatly.

If close and too fast, Then increase slightly.

If close and optimum, Then increase slightly.

If far and optimum, Then no reaction.

If far and slow, Then slightly decrease.

If far or too slow, Then greatly decrease.

In the fuzzy base rules, we consider the inter-vehicle distance is the dominator since may be
the speed is too fast but the vehicle is drived far away from the targeted vehicle.
3 Defuzzification
We used Mamadni inference engine which is the simplest one and to extract the crisp output
we used a centroid method.

4 Performance of FL system.

We imply our design fuzzy controller using the python programming using the popular fuzzy
library skfuzzy version 2. After running the python code, and set the distance value of 8 m
and speed to 3 m/s, then the defuzzification figure will be as follows:

Figure 5 Defuzzied crisp output when d=8m and S= 3 m/s

Figure 6 Defuzzied crisp output value on python shell when d=8m and S= 3 m/s
Figure 7 3D projection of our proposed controller

When we adjust the inter-vehicle distance to 2m, the inter-vehicle distance is the dominator,
the brake force must increase greatly to prevent the car from accident.

Figure 8 Defuzzied crisp output when d=3m and S= 3 m/s


Figure 9 Defuzzied crisp output value on python shell when d=2m and S= 3 m/s

Figure 10 Defuzzied crisp output value on python shell when d=6m and S= 9 m/s

Figure 5 Defuzzied crisp output when d=8m and S= 9 m/s


5 Discussion on comparison with other FL structure

We compare our design with the work in (Mamat & Ghani 2009) , which it use beside fuzzy
controller, A proportional–integral–derivative (PID) controller. Our results are closed with
own improvement in the output crisp. As it’s clear, the top level of 3D plot is flat in the
targeted paper, but in our proposed design, it variates until reach the steady state. More
drawback in this work, in our opinion, is the position and velocity range, both are too wide
range and no need to consume computing effort upon them.

CONCLUSION
Safe driving is essential for both community and automotive manufactures since it reduces
the human death numbers and accidents cost. Many modules and applications are developed
recently to increase the safety factor through driving. An automatic brake system that adapts
the brake pressure based on inter-vehicle distance and speed is proposed in this project. The
proposed fuzzy control performs significantly as the distance decrease reaching the dead
zone. We consider the too close distance is the dominator in our design. Finally, comparing
our design with another one in the literature shows that they are close together.
PYTHON CODE
import numpy as np

import skfuzzy as fuzz

import matplotlib.pyplot as plt

import matplotlib.pyplot as plt2

from skfuzzy import control as ctrl

# Generate universe variables

# * distanceance is on subjective ranges [0, 10] in units of m.

# *Speed is on subjective ranges [0, 10] in units of m/s.

# * Brake pedal force (deaccelaration) has a range of [0, 24] in units of N.

dist = np.arange(0, 11, 1)

speed = np.arange(0, 11, 1)

Brake_F = np.arange(0, 25, 1)

# Generate fuzzy membership functions

Dist_V_cls = fuzz.trimf(dist, [0, 0, 4])

Dist_cls = fuzz.trapmf(dist, [2, 4, 6, 8])

Dist_far = fuzz.trimf(dist, [6, 10, 10])

####################################################

speed_2_slow = fuzz.trapmf(speed, [0, 0, 1, 2])

speed_slow = fuzz.trapmf(speed, [1, 2, 3, 4])

speed_op = fuzz.trapmf(speed, [3, 4, 5, 6])

speed_fast = fuzz.trapmf(speed, [5, 6, 7, 8])

speed_2_fast = fuzz.trapmf(speed, [7, 8, 10,10])

####################################################

Dec_brake_greatly = fuzz.trimf(Brake_F, [0, 4, 8])

Dec_brake_slightly = fuzz.trimf(Brake_F, [4, 8, 12])

11
No_brake = fuzz.trimf(Brake_F, [8, 12, 16])

Inc_brake_slightly = fuzz.trimf(Brake_F, [12, 16, 20])

Inc_brake_greatly = fuzz.trimf(Brake_F, [16, 20, 24])

# Visualize these universes and membership functions

fig, (ax0, ax1, ax2) = plt.subplots(nrows=3, figsize=(10, 10))

ax0.plot(dist, Dist_V_cls, 'b', linewidth=1.5, label='Very-Close')

ax0.plot(dist, Dist_cls, 'g', linewidth=1.5, label='Close')

ax0.plot(dist, Dist_far, 'r', linewidth=1.5, label='Far')

ax0.set_title('Inter-vehicle distance')

ax0.legend()

ax1.plot(speed, speed_2_slow, 'b', linewidth=1.5, label='Too Slow')

ax1.plot(speed, speed_slow, 'y', linewidth=1.5, label='Slow')

ax1.plot(speed, speed_op, 'g', linewidth=1.5, label='optimun')

ax1.plot(speed, speed_fast, 'r', linewidth=1.5, label='Fast')

ax1.plot(speed, speed_2_fast, 'k', linewidth=1.5, label='Too Fast')

ax1.set_title('Speed')

ax1.legend()

ax2.plot(Brake_F, Dec_brake_slightly, 'b', linewidth=1.5, label='Dec-Slightly')

ax2.plot(Brake_F, Dec_brake_greatly, 'y', linewidth=1.5, label='Dec-Greatly')

ax2.plot(Brake_F, No_brake, 'g', linewidth=1.5, label='No_brake')

ax2.plot(Brake_F, Inc_brake_slightly, 'r', linewidth=1.5, label='Inc_Slightly')

ax2.plot(Brake_F, Inc_brake_greatly, 'k', linewidth=1.5, label='Inc_Greatly')

ax2.set_title('Brake_Force_Amount')

ax2.legend()

# Turn off top/right axes

for ax in (ax0, ax1, ax2):

ax.spines['top'].set_visible(False)

ax.spines['right'].set_visible(False)

12
ax.get_xaxis().tick_bottom()

ax.get_yaxis().tick_left()

plt.tight_layout()

plt.show() # To show the membership inputs

#dis=np.arange(0, 11, 1)

distance = ctrl.Antecedent(dist, 'distance')

speed = ctrl.Antecedent(speed, 'speed')

Brake_F = ctrl.Consequent(Brake_F,'Brake_F')

###################################################

# Generate fuzzy membership functions

distance['V_cls'] = fuzz.trimf(distance.universe, [0, 0, 4])

distance['cls'] = fuzz.trapmf(distance.universe, [2, 4, 6, 8])

distance['far'] = fuzz.trimf(distance.universe, [6, 10, 10])

#distance.view()

####################################################

speed['2_slow'] = fuzz.trapmf(speed.universe, [0, 0, 1, 2])

speed['slow'] = fuzz.trapmf(speed.universe, [1, 2, 3, 4])

speed['op'] = fuzz.trapmf(speed.universe, [3, 4, 5, 6])

speed['fast'] = fuzz.trapmf(speed.universe, [5, 6, 7, 8])

speed['2_fast'] = fuzz.trapmf(speed.universe, [7, 8, 10,10])

#speed.view()

####################################################

Brake_F['DG'] = fuzz.trimf(Brake_F.universe, [0, 4, 8])

Brake_F['DS'] = fuzz.trimf(Brake_F.universe, [4, 8, 12])

Brake_F['NF'] = fuzz.trimf(Brake_F.universe, [8, 12, 16])

Brake_F['IS'] = fuzz.trimf(Brake_F.universe, [12, 16, 20])

13
Brake_F['IG'] = fuzz.trapmf(Brake_F.universe, [16, 20, 24, 24])

#Brake_F.view()

# Visualize these universes and membership functions

#distance.view()

"""

The Fuzzy design rules

rule1= If too close , then increase greatly.

rule2= If close and too fast , then increase slightly.

rule3= If close and optimum, then increase slightly.

rule4= If far and optimum, then no reaction.

If far and slow , then slightly decrease.

If far or too slow, then greatly decrease.

"""

rule1 = ctrl.Rule(distance['V_cls'] , Brake_F['IG'])

rule2 = ctrl.Rule(distance['cls'] & speed['2_fast'] , Brake_F['IS'])

rule3 = ctrl.Rule(distance['cls'] & speed['op'] , Brake_F['IS'])

rule4 = ctrl.Rule(distance['far'] & speed['op'] , Brake_F['NF'])

rule5 = ctrl.Rule(distance['far'] & speed['slow'] , Brake_F['DS'])

rule6 = ctrl.Rule(distance['far'] & speed['2_slow'] , Brake_F['DG'])

brake_ctrl = ctrl.ControlSystem([rule1, rule2, rule3, rule4, rule5, rule6])

braking = ctrl.ControlSystemSimulation(brake_ctrl)

# Pass inputs to the ControlSystem using Antecedent labels with Pythonic API

# Note: if you like passing many inputs all at once, use .inputs(dict_of_data)

braking.input['distance'] = 8

braking.input['speed'] = 3

14
# Crunch the numbers

braking.compute()

print (braking.output['Brake_F'])

Brake_F.view(sim=braking)

""""""

sim = ctrl.ControlSystemSimulation(brake_ctrl, flush_after_run=24 * 24 + 1)

# We can simulate at higher resolution with full accuracy

upsampled = np.linspace(0, 10, 25)

x, y = np.meshgrid(upsampled, upsampled)

z = np.zeros_like(x)

# Loop through the system 21*21 times to collect the control surface

for i in range(10):

for j in range(10):

sim.input['distance'] = x[i, j]

sim.input['speed'] = y[i, j]

sim.compute()

z[i, j] = sim.output['Brake_F']

# Plot the result in pretty 3D with alpha blending

import matplotlib.pyplot as plt

from mpl_toolkits.mplot3d import Axes3D # Required for 3D plotting

fig = plt.figure(figsize=(8, 8))

ax = fig.add_subplot(111, projection='3d')

surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap='viridis',

15
linewidth=0.4, antialiased=True)

cset = ax.contourf(x, y, z, zdir='z', offset=-2.5, cmap='viridis', alpha=0.5)

cset = ax.contourf(x, y, z, zdir='x', offset=3, cmap='viridis', alpha=0.5)

cset = ax.contourf(x, y, z, zdir='y', offset=3, cmap='viridis', alpha=0.5)

ax.view_init(10, 20)

plt.show()

REFERENCE
Aras, A. A. 2013. Design of a Controller for Abs Anti Lock Breaking System Using Fuzzy Logic
Control. California State University, Northridge,

Mamat, M. & Ghani, N. 2009. Fuzzy Logic Controller on Automated Car Braking System. 2009
IEEE International Conference on Control and Automation, pp. 2371-2375.

16

View publication stats

You might also like