Project

Design of an Adaptive cruise controller for longitudinal dynamics of self driving cars and simulate impact of various parameter on it's performance by using python programming

Title:

Design of an Adaptive cruise controller for longitudinal dynamics of self driving cars and simulate impact of various parameter on it's performance by using python programming.

Objectives:

1)Develop mathematical model governing longitudinal dynamics of vehicle.

2)Solve this governing equation for initial condition of velocity over given time domain[0,2]second.

3)develop PI controller to generate input signal to accelerator pedal to maintain ego vehicle velocity constant irrespective of disturbances like slope of road,drag forces.

4)As well controller Should also adjust ego vehicle to take care of obstacle like pedestrian or static object, distance of 5 meter with another vehicle in same lane in front of vehicle to avoid collision.

5)Write python code to simulate impact of various parameters like proportional gain,integral gain, mass of vehicle, reference speed of ego vehicle, inclination of road surface, speed of vehicle in front on performance of controller by analyzing the overshoot,rise time and settling time of output;i.e. velocity of vehicle.

Significance:

This project will help in developing more robust controller for fully autonomous self driving car of level1 by integrating various sensors like RADAR to measure the relative velocity of vehicle in same lane, LIDAR to create map of road surface using camera vision to trace desired path optimally, ultrasonic sensor for parking or driving in more crowded locations, Gyroscope to find inclination of vehicle and actiive GPS for localizing vehicle. This algorithm used in python would be helpful for transiting to next level of autonomous driving that is combined logitudinal control and steering control.

Motivation:

India as a country and the world is transiting toward more advanced civilization at the same time it also begets some of lethal catastrophies as consequence of chaos generated due to oevrpopulation and that is also true for transportation. Every year increasing number of people are dying as result of road accident and in most of cases it happens as result of faulty or rash driving decisions. As well i also feel that all such decisions of driving such as acceleration,braking,lane change, steering or auxillary indication made by ego vehicle on right time by itself with the help of computers by using various sensors would save us from such fatal calamities and create more safe trasportation mode. This is the main reason for me to undertake this project as initiative to tackle this task of creating robust controller for self driving car.

Physical model:

I have assumed self driving ego vehicle as a concentrated mass which is being accelerated by pressing accelerator pedal or opening throttle valve and it also has to oppose by drag forces, rolling resistance to wheels and momentery braking action upon clutch pressing.

Mathematical Model for Adaptive crusing of vehicle:

whenever vehicle is accelereted then by de-alemberts principle we can create static model of system or ego vehicle by introducing inertia force onto system.

here by conservation of momentum or newtons second law we can convert accelarated model into static model by considering inertia forces onto vehicle,which state that resultant of all forces acting on system including inertia force is zero.

here

x1=velocity of ego vehicle

clutch1=ctutch is not being pressed and accelerator pedal held constant or pressed

clutch2=clutch is being pressed and gives input signal to brake to activate by factor between 0 to 1.
Here our target is to keep velocity as per requirement by altering input signal with help of PI controller.

Frontal_area ofvehicle=0.5 m^2
coefficient of rolling friction for wheel,mu_rolling=.06
coefficient of static friction,mu_static=0.4

inclination of vehicle with horizontal in degrees,q=10
theta=(math.pi/180)*q
density of air, rho=1.2
mass, m=1000
throttling gain in N per radian, It is force developed by engine for each radian actuation of accelerator pedal and it is given by
b=10000
gravitational acceleration, g=9.81
proportional gain, kp=1
integral gain, ke=10

Cd=0.4

time domain in which output is being integrated, t=[0,2 second] with 100 steps in between.

As per Anti braking system requirement ratio of this coefficient should be close to 0.12 to achieve perfect steering without skidding of vehicle upon braking.

here velocity x1 is output and r as reference velocity of ego vehicle which should be achieved as per prevailing condition on road surface and decided subsequentely in algorithm.

error signal =e=r-x1

whereas input signal to accelerator pedal is given by u(t) , it should maintain ego velocity as per requirement and it is as follows

u(t)=(clutch1)*(b/m)*(kp*(r-x1)+x2)

kp=proportional gain

whereas integral gain is given by following differential equation

dx2_dt=ke*(r-x1)

here input signal to accelerator pedal can be only be accessed upon confirming clutch is not being pressed and represented by first part of equation.
x3=position of ego vehicle

Initial Conditions:

initial_x1=[10,0,0]
Above array represents initial velocity of vehicle x1=10 m/s, initial integral gain as 0 and position at origin or starting position.

Here second part on right side indicate drag force opposing ego vehicle,

third part on right side represents rolling resistance to vehicle

fourth part on right side shows weight opposing vehicle motion due to slope of road surface

fifth part reveals braking force acting on vehicle.

By solving above equation for various values of parameter we can judge performance of controller by observing overshoot,rise time and settling time for output velocity x1.

Python code structure:

Module used:

  1. math: to perform trignometric computation on data.
  2. matplotlib.pyplot: for plotting data to observe output signal pattern.
  3. scipy: to solve governing equation for ego vehicle, odeint library is used to integrate governing equation.
  4. numpy:to perform operations on data element in array.

Python code:

import math
import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import odeint

#let's define model for describing velocity of car by using conservation of forces by de-alemberts principle
#clutch1=ctutch is not being pressed,clutch2=clutch is being pressed
def model(x1a,t,m,b,rho,Frontal_area,mu_rolling,theta,mu_static,clutch1,clutch2):
	x1=x1a[0]
	x2=x1a[1]
	x3=x1a[2]
	dx1_dt=(clutch1)*(b/m)*(kp*(r-x1)+x2)-.5*(rho/m)*pow(x1,2)*Frontal_area*Cd - mu_rolling*g*math.cos(theta)-g*math.sin(theta)-clutch2*(mu_static*g*math.cos(theta))
	
	'''
	dx1_dt=(-a/m)*x1+(b/m)*(kp*(r-x1)+x2)
	'''
	dx2_dt=ke*(r-x1)
	dx3_dt=x1
	dxi_dt=[dx1_dt,dx2_dt,dx3_dt]
	return dxi_dt
#initial velocity of vehicle x1=10 m/s
initial_x1=[10,0,0]
#constant
Frontal_area=.5
mu_rolling=.06
mu_static=0.4
Cd=0.4
#here we can sense vehicle inclination or angle with respect to horizontal and can directly provide as theta
'''
o=np.linspace(0,1000,1000)
a1=10
a2=1
a3=10
def fun1(o,a1,a2,a3):
	return 2*o*a1+a2
q=fun1(o,a1,a2,a3)
theta=math.atan(q)
'''
#here we can sense vehicle inclination or angle with respect to horizontal and can directly provide as q

q=10
theta=(math.pi/180)*q
#density of air
rho=1.2
#mass
m=1000
#throttling gain in N per radian
b=10000
#gravitational acceleration
g=9.81
#proportional gain
kp=1
#integral gain
ke=10
#timespace
t=np.linspace(0,2,100)
#speed of front vehicle,n
#pedestrian means static object,n=0 m/s
#n=velocity of vehicle in front,need to sense through radar
n=-1
#r=velocity of ego vehicle
highway_limit_speed=30
r=initial_x1[0]
if n>0:
	#separation distance in meter
	d=5
	#separation time in sec
	time=3
	if n>r:
		d=5
		time=3
		#time=d/x1 whereas x1=current velocity of ego vehicle
		r=n-(d/time)
		clutch2=0
		clutch1=1
	elif n
 

Algorithm logic to get Output as desired:

Here main objective of our code is to calculate input signal to accelerator pedal so as maintain output velocity as per requirement on road.

here n=velocity of another vehicle in front of ego vehicle.

here n can take various values and accordingly actuate accelerator ,brake pedal and clutch pedal.

here velocity of front vehicle is assumed to be compputed by RADAR and map of road is assumed to be prepared with the help of LIDAR .

Road surface is inclined at constant angle for entire time range and can be sense by gyroscope.

output velocity of ego vehicle should be measured by odometer and send back as feedback to controller after comparing it with reference signal in various conditions as follows.

r=reference velocity of ego vehicle
highway_limit_speed=30 Assumed as 30 m/s and can be altered

  1. #pedestrian means static object,n=0 m/s

  2. if n>0: then our controller is checking for separation distance between two vehicles in same line and setting its reference speed as follows

  3. if n>r: then velocity of ego vehicle should be raised and maintain separation distance as desired by setting reference signal as follows.
    d=5
    time=3
    r=n-(d/time)
    clutch2=0
    clutch1=1
    elif n<r:
    d=5
    time=3
    r=n-(d/time)
    clutch2=0.5
    clutch1=0.5

  4. If pedestrian or static objects comes in way then ego velocity should dropped to zero by braking until road clears up as follows
    elif n==0:
    clutch2=1
    clutch1=0
    r=0

if lane is clear then then ego vehicle should sped up as per highway limit as follows and value of n should be negative if another vehicle is not in lane . if n<0:

clutch2=0
clutch1=1
r=highway_limit_speed

Results for various condition of parameter :

1) When integral gain to PI controller is increased as ke=0,2,5,10 we get following results for output signal:

when_mass_1000kg_slope_10_degree_no_vehicle_in_path_velocity_graph

ke=0

ke=2

ke=5

ke=10

2)when mass of ego vehicle is increases as m=100 kg,500 kg, 1000 kg,5000 kg,10000 kg we get following results for output signal:

when_slope_10_degree_no_vehicle_in_path_velocity_graph

m=100 kg

m=500 kg

m=1000 kg

m=5000 kg

m=10000 kg

3) when velocity of another vehicle_n=0_m/s_pedestrian_or_obstacle_static_velocity_graph

4)when_n_5=m_s_n_less_than_referance_velocity_graph

5)when_n_15_m_s_ greater than ego velocity_graph

6)when no vehicle on highway

7)when_proportional_gain_kp_0_mass_1000_kg_slope_10_degree_no_vehicle_in_path_velocity_graph

kp=0

kp=2.5

kp=5

8)when_slope_0_degree_no_vehicle_in_path_velocity_graph

slope=0

slope=10

slope=45

9)when_throttling_gain_1000_N_rad_of_acceleration_pedal_mass_1000_kg_slope_10_degree_no_vehicle_in_path_velocity_graph

throttling gain=b=1000

throttling gain=b=5000

throttling gain=b=15000

co

co

conclusion:

1)Here performance of controlling action is judge for all this categories and aslo validated based on intuition by comparing it\'s Overshoot,Rise time and settling time with second order system and also it helps us to find natural frequency(Wn) and damping factor(Zeta) for system.

here for all the input parameter system output is stable but overshoot,rise time and settling time varies.

overshoot(Mp): percent increase in output signal above reference(steady state) signal during first oscillation.

optimally it should be minimum as possible.

Rise Time(Tr):Time require for output signal to increase from 10% to 90% of reference(steady state)signal.

optimally it should be minimum as possible.

Settling time(Ts): Time require for output signal to remain within 5% of reference(steady state)signal.

Optimally it should be minimum as possible.

2) It is observe that with increase in integral gain ke from 0 to 10, error drops to zero in output signal and reference signal but it gives rise in overshoot,faster rise time where as settling time reduced subsequently. Hence optimally Ke should be larger for better performance of system considering overshoot is limited.

3)It is observe that with increase in proportional gain kp from 0 to 5, error remains non zero in output signal and reference signal but it gives reduction in overshoot or oscillation,faster rise time where as settling time reduced subsequently. Hence optimally Kp should be larger for better performance of system.

4)It is observe that with increase in throttling gain b from 1000 to 15000, it gives reduction in overshoot or oscillation,faster rise time where as settling time reduced subsequently. Hence optimally throttling gain should be larger for better performance of system.

5)It is observe that with increase in mass of ego vehicle, m from 100 kg to 10000 kg, it gives increase in overshoot or oscillation,slower rise time where as settling time is also increased subsequently. Hence optimally mass m should be minimal for better performance of system.

6)It is observe that with increase in slope of road, q from 0 to 45 degree, it doesn\'t give evident change in overshoot or rise time where as settling time is increased very normally subsequently. Hence optimally slope should be minimal for better performance of system.

7)It is observe that with increase in velocity of another vehicle, n from 0 to 15 m/s, it gives reduction in overshoot or oscillation,faster rise time where as settling time is also reduced subsequently. Hence controller is being tested and found valid through intuition as robust for control of output signal that is velocity of ego vehicle by controlling input signal that is accelerator pedal deflection or throttle opening deflection.

In this way this adaptive cruise controller based on PI feedback control behaves robustly for cruising of self driving car irrespective of an obstacle in the path.

Project PPT

https://docs.google.com/presentation/d/17DBwBDnZKniTKkPZjBR3Ked1W70WogjQ72kwHveX8cE/edit?usp=sharing

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.