Deakin University SIT215 - PBL Task 1: Fuzzy Logic ABS Project

Verified

Added on  2022/09/18

|10
|2000
|29
Project
AI Summary
This project focuses on the design and implementation of an Anti-braking System (ABS) using fuzzy logic. The project utilizes a fuzzy controller with two inputs: car speed and the distance between vehicles. The output of the controller is the braking force applied. The system uses speed and ultrasonic sensors to gather input data. The design includes fuzzification, a rule-based inference engine, and defuzzification using the Mamdani inference engine. The Python library skfuzzy is used for the fuzzy logic controller design, and the code includes membership function visualizations and the definition of rules. The project demonstrates how the fuzzy logic system calculates the braking force based on the distance and speed of the vehicle, including the application of rules such as greater force applied when the vehicle is too close or slightly decreasing speed when the vehicle is too far. The project showcases the entire fuzzy logic ABS system and its functionality, with detailed explanations of each component and the underlying logic.
Document Page
Automatic Breaking
System(ABS)
Fuzzy Logic PBL 1
Group Assignment Members:
Ramneet:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
OVERVIEW
Serious accidents has been caused due to inaccurate reaction time and also
due to time consumed for performing full braking because of human
judgement error.
The main reason for these crash instances is due to distraction while driving
or not able to respond during such moment. So abs (Anti-braking system)
overcomes this inaccuracy by using the smart artificial intelligence
techniques and algorithm. ABS improves the precision and response time
during those conditions.
INPUT-OUTPUT OF FUZZY LOGIC SYSTEM
This project is based on fuzzy controller having two inputs, car speed and
distance between vehicles and provides output as brake force which
generates distance which is safe between the two vehicles and also it waves
the speed from too fast to slow under distinct conditions.
In order to get the input for Fuzzy controller, speed sensor and ultrasonic
sensor is used. The ultrasonic sensor on certain frequency will give signals
and echo will be received. Then by doing some simple calculation on
receiver side of the time duration of the echo received would suggest how
far is the vehicle and making decision based on the rules which are specified
in the logic. Also the speed sensor will make use of frequency for making
decision as per the specified rules.
DESIGN SHAPE/STRUCTURE:
The Fuzzy logic has two inputs, one output and one Mamdani inference
engine. The inputs for the fuzzy logic are speed and distance between the
vehicle and the output is the braking force. Below diagram shows the design
of the fuzzy logic:
PAGE 1
Document Page
1: Fuzzification:
The range is classified as between 0-15 Meters. It has been divided into
three as specified below:
In this we have used triangle membership function as when vehicle comes
close then the estimation of fresh info (V_cls) will increment drastically, at
center participation, where negligible space starts from 4m and ends at 6m,
hence from that point the separation is considered as far.
Input speed is divided into five from 0-10 m/s as shown below:
The amount of force of brake applied in defined in below categorization as
output as shown below:
PAGE 2
Document Page
In this we have used triangle membership function as when vehicle comes
close then the estimation of fresh info (V_cls) will increment drastically, at
center participation, where negligible space starts from 4m and ends at 6m,
hence from that point the separation is considered as far.
The output capacity of membership is comprised of 5 individual, triangle
participation is considered as best decision as for each and every decision
run, the worth increment as the center at that point decreases to meddle
with aid membership. Following shows the output participation and
information membership.
2. Rule-based inference engine:
Below are the rules which are considered for the inter-vehicle distance in
the fuzzy logic:
Rule set
Greater force is applied when the vehicle is too close to the controller.
Slight force is applied when the vehicle is close but vehicle is moving
with medium speed.
Greater force is applied when the vehicle is close but vehicle is
moving too fast.
Decrease speed when the vehicle is slowly moving and far away.
Decrease the speed slowly when the vehicle is moving too slowly and
too far.
Slightly decrease the speed when the vehicle is too far.
3. Defuzzification: The mamdani inference uses the centroid
method and provides the crisp output.
Mamdani inference engine: In order to make decision the
inference make use of below 6 steps which are as follows:
PAGE 3
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
4. Performance of Fuzzy logic system:
For fuzzy logic controller design the library used in python programming is
skfuzzy and its version is 0.3. Following diagram shows the figures for the
fuzzy system for ABS.
The Python code used is as follows:
"""
Author : Ramneet
Date: 18.08.2019
PAGE 4
Document Page
"""
import numpy as np
import skfuzzy as fuzz
import matplotlib.pyplot as plot
from skfuzzy import control as ctrl
# Generate universe variables
# all distance will be in range of [0, 10] in units of m.
# all Speed will be in range of [0, 10] in units of m/s.
# all Brake pedal force (deaccelaration) will be in range of [0, 24] in units of
N. dist = np.arange(0, 11, 1)
dist = np.arange(0, 11, 1)
speed = np.arange(0, 11, 1)
Break_Force = np.arange(0, 25, 1)
# Methods for fuzzy members
Distance_V_cls = fuzz.trimf(dist, [0, 0, 4])
Distance_cls = fuzz.trapmf(dist, [2, 4, 6, 8])
far_distance = fuzz.trimf(dist, [6, 10, 10])
slow_2_speed = fuzz.trapmf(speed, [0, 0, 1, 2])
slow_speed = fuzz.trapmf(speed, [1, 2, 3, 4])
op_speed = fuzz.trapmf(speed, [3, 4, 5, 6])
fast_speed = fuzz.trapmf(speed, [5, 6, 7, 8])
fast_2_speed = fuzz.trapmf(speed, [7, 8, 10,10])
greatly_dec_brake = fuzz.trimf(Break_Force, [0, 4, 8])
slightly_dec_brake = fuzz.trimf(Break_Force, [4, 8, 12])
PAGE 5
Document Page
No_brake = fuzz.trimf(Break_Force, [8, 12, 16])
slightly_Inc_brake = fuzz.trimf(Break_Force, [12, 16, 20])
greatly_Inc_brake = fuzz.trimf(Break_Force, [16, 20, 24])
# Visualize these universes and member methods
fig, (ax0, ax1, ax2) = plot.subplots(nrows=3, figsize=(10, 10))
ax0.plot(dist, Distance_V_cls, 'b', linewidth=1.5, label='Very-Close')
ax0.plot(dist, Distance_cls, 'g', linewidth=1.5, label='Close')
ax0.plot(dist, far_distance, 'r', linewidth=1.5, label='Far')
ax0.set_title('Distance Between Two vehicles')
ax0.legend()
ax1.plot(speed, slow_2_speed, 'b', linewidth=1.5, label='Too Slow')
ax1.plot(speed, slow_speed, 'y', linewidth=1.5, label='Slow')
ax1.plot(speed, op_speed, 'g', linewidth=1.5, label='optimun')
ax1.plot(speed, fast_speed, 'r', linewidth=1.5, label='Fast')
ax1.plot(speed, fast_2_speed, 'k', linewidth=1.5, label='Too Fast')
ax1.set_title('Speed')
ax1.legend()
ax2.plot(Break_Force, slightly_dec_brake, 'b', linewidth=1.5, label='Dec-
Slightly')
ax2.plot(Break_Force, greatly_dec_brake, 'y', linewidth=1.5, label='Dec-
Greatly')
ax2.plot(Break_Force, No_brake, 'g', linewidth=1.5, label='No_brake')
ax2.plot(Break_Force, slightly_Inc_brake, 'r', linewidth=1.5,
label='Inc_Slightly')
ax2.plot(Break_Force, greatly_Inc_brake, 'k', linewidth=1.5,
label='Inc_Greatly')
ax2.set_title('Break Force Amount')
PAGE 6
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
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)
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
plot.tight_layout()
plot.show() # To show the membership inputs
distance = ctrl.Antecedent(dist, 'distance')
speed = ctrl.Antecedent(speed, 'speed')
Break_Force = ctrl.Consequent(Break_Force,'Break_Force')
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])
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])
Break_Force['DG'] = fuzz.trimf(Break_Force.universe, [0, 4, 8])
PAGE 7
Document Page
Break_Force['DS'] = fuzz.trimf(Break_Force.universe, [4, 8, 12])
Break_Force['NF'] = fuzz.trimf(Break_Force.universe, [8, 12, 16])
Break_Force['IS'] = fuzz.trimf(Break_Force.universe, [12, 16, 20])
Break_Force['IG'] = fuzz.trapmf(Break_Force.universe, [16, 20, 24, 24])
rule1 = ctrl.Rule(distance['V_cls'] , Break_Force['IG'])
rule2 = ctrl.Rule(distance['cls'] & speed['2_fast'] , Break_Force['IS'])
rule3 = ctrl.Rule(distance['cls'] & speed['op'] , Break_Force['IS'])
rule4 = ctrl.Rule(distance['far'] & speed['op'] , Break_Force['NF'])
rule5 = ctrl.Rule(distance['far'] & speed['op'] , Break_Force['DS'])
rule6 = ctrl.Rule(distance['far'] & speed['2_slow'] , Break_Force['DG'])
control_brake = ctrl.ControlSystem([rule1, rule2, rule3, rule4, rule5, rule6])
braking = ctrl.ControlSystemSimulation(control_brake)
braking.input['speed'] = 3
# Crunch the numbers
braking.compute()
print (braking.output['Break_Force'])
Break_Force.view(sim=braking)
sim = ctrl.ControlSystemSimulation(control_brake, flush_after_run=24 * 24
+ 1)
upsampled = np.linspace(0, 10, 25)
x, y = np.meshgrid(upsampled, upsampled)
z = np.zeros_like(x)
# Loop through the system to collect the control surface
for p in range(10):
PAGE 8
Document Page
for k in range(10):
sim.input['distance'] = x[p, k]
sim.input['speed'] = y[p, k]
sim.compute()
z[p, k] = sim.output['Break_Force']
fig = plot.figure(figsize=(8, 8))
ax = fig.add_subplot(111, projection='3d')
surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap='viridis',
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)
plot.show()
PAGE 9
chevron_up_icon
1 out of 10
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]