Are you sure?
This action might not be possible to undo. Are you sure you want to continue?
Department of Electrical Engineering
Examensarbete
Observer for a vehicle longitudinal controller
Examensarbete utfört i Reglerteknik
vid Tekniska högskolan i Linköping
av
Peter Rytterstedt
LiTHISYEX2007/3950SE
Linköping 2007
Department of Electrical Engineering Linköpings tekniska högskola
Linköpings universitet Linköpings universitet
SE581 83 Linköping, Sweden 581 83 Linköping
Observer for a vehicle longitudinal controller
Examensarbete utfört i Reglerteknik
vid Tekniska högskolan i Linköping
av
Peter Rytterstedt
LiTHISYEX2007/3950SE
Handledare: Johanna Wallén
isy, Linköpings universitet
Volker Maaß
Mercedes Benz Technology Center, DaimlerChrysler AG
Examinator: Thomas Schön
isy, Linköpings universitet
Linköping, 1 April, 2007
Avdelning, Institution
Division, Department
Division of Automatic Control
Department of Electrical Engineering
Linköpings universitet
SE581 83 Linköping, Sweden
Datum
Date
20070401
Språk
Language
Svenska/Swedish
Engelska/English
Rapporttyp
Report category
Licentiatavhandling
Examensarbete
Cuppsats
Duppsats
Övrig rapport
URL för elektronisk version
http://www.control.isy.liu.se
http://www.ep.liu.se/2007/3950
ISBN
—
ISRN
LiTHISYEX2007/3950SE
Serietitel och serienummer
Title of series, numbering
ISSN
—
Titel
Title
Observatör för en längsregulator i fordon
Observer for a vehicle longitudinal controller
Författare
Author
Peter Rytterstedt
Sammanfattning
Abstract
The longitudinal controller at DaimlerChrysler AG consists of two cascade
controllers. The outer control loop contains the driver assistance functions such
as speed limiter, cruise control, etc. The inner control loop consists of a PID
controller and an observer. The task of the observer is to estimate the part of
the vehicle’s acceleration caused by large disturbances, for example by a changed
vehicle mass or the slope of the road.
As observer the Kalman ﬁlter is selected. It is the optimal ﬁlter when the
process model is linear and the process noise and measurement noise can be mod
eled as Gaussian noise. In this Master’s thesis the theory for the Kalman ﬁlter
is presented and it is shown how to choose the ﬁlter parameters. Simulated an
nealing is a global optimization technique which can be used when autotuning,
i.e., automatically ﬁnd the optimal parameter settings. To be able to perform
autotuning for the longitudinal controller one has to model the environment and
driving situations.
In this Master’s thesis it is veriﬁed that the parameter choice is a compromise
between a fast but jerky, or a slow but smooth estimate. As the output from
the Kalman ﬁlter is directly added to the control value for the engine and brakes,
it is important that the output is smooth. It is shown that the Kalman ﬁlter
implemented in the test vehicles today can be exchanged with a ﬁrstorder lag
function, without loss in performance. This makes the ﬁlter tuning easier, as
there is only one parameter to choose.
Change detection is a method that can be used to detect large changes in the
signal, and react accordingly – for example by making the ﬁlter faster. A ﬁlter
using change detection is implemented and simulations show that it is possible to
improve the estimate using this method. It is suggested to implement the change
detection algorithm in a test vehicle and evaluate it further.
Nyckelord
Keywords Kalman ﬁlter, longitudinal controller, ﬁlter tuning, simulated annealing, change
detection
Abstract
The longitudinal controller at DaimlerChrysler AG consists of two cascade
controllers. The outer control loop contains the driver assistance functions such
as speed limiter, cruise control, etc. The inner control loop consists of a PID
controller and an observer. The task of the observer is to estimate the part of
the vehicle’s acceleration caused by large disturbances, for example by a changed
vehicle mass or the slope of the road.
As observer the Kalman ﬁlter is selected. It is the optimal ﬁlter when the
process model is linear and the process noise and measurement noise can be mod
eled as Gaussian noise. In this Master’s thesis the theory for the Kalman ﬁlter
is presented and it is shown how to choose the ﬁlter parameters. Simulated an
nealing is a global optimization technique which can be used when autotuning,
i.e., automatically ﬁnd the optimal parameter settings. To be able to perform
autotuning for the longitudinal controller one has to model the environment and
driving situations.
In this Master’s thesis it is veriﬁed that the parameter choice is a compromise
between a fast but jerky, or a slow but smooth estimate. As the output from
the Kalman ﬁlter is directly added to the control value for the engine and brakes,
it is important that the output is smooth. It is shown that the Kalman ﬁlter
implemented in the test vehicles today can be exchanged with a ﬁrstorder lag
function, without loss in performance. This makes the ﬁlter tuning easier, as
there is only one parameter to choose.
Change detection is a method that can be used to detect large changes in the
signal, and react accordingly – for example by making the ﬁlter faster. A ﬁlter
using change detection is implemented and simulations show that it is possible to
improve the estimate using this method. It is suggested to implement the change
detection algorithm in a test vehicle and evaluate it further.
v
Acknowledgments
This Master’s thesis has been performed between October 2006 and March 2007 at
the Mercedes Technology Center, DaimlerChrysler AG in Sindelﬁngen, Germany.
It completes my international studies for a Master of Science degree in Applied
Physics and Electrical Engineering at Linköpings Universitet, Sweden.
I would like to express my greatest gratitude to my supervisor at DaimlerChrysler,
Volker Maaß, who has always had time for my questions and helped me in any way
possible. The teams EP/ERW and GR/EAT deserve many thanks for welcoming
me at the department, and for answering questions about the cars and develop
ment tools that have come up during this thesis. My supervisor Johanna Wallén
and examiner Thomas Schön at Linköpings Universitet, who have given insightful
comments and tips, also have a part in this thesis.
Finally I would like to thank Marie Rytterstedt, Peter JuhlinDannfelt and Erik
Almgren for proofreading, and my girlfriend for her support and encouragement.
Sindelﬁngen, March 2007
Peter Rytterstedt
vii
Contents
1 Introduction 1
1.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Problem Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 DaimlerChrysler AG . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5 Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.6 Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.7 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Driver Assistance Systems 5
2.1 Antilock Braking System . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Traction Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Stability Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.4 Speed Limiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.5 Cruise Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.6 Hill Descent Control . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.7 Forward Collision Mitigation System . . . . . . . . . . . . . . . . . 6
2.7.1 Distance Warning . . . . . . . . . . . . . . . . . . . . . . . 7
2.7.2 Brake Assist System . . . . . . . . . . . . . . . . . . . . . . 7
2.8 Adaptive Cruise Control . . . . . . . . . . . . . . . . . . . . . . . . 7
2.9 Lane Guidance System . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.10 Blindspot Warning . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.11 Systems Supported by the Controller . . . . . . . . . . . . . . . . . 8
3 Basic Filter Theory 11
3.1 StateSpace Models . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Discretization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3 Observer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.4 Observability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.5 Kalman Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.5.1 Process and Measurement Model . . . . . . . . . . . . . . . 15
3.5.2 Discrete Time Kalman Filter Equations . . . . . . . . . . . 15
3.5.3 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.5.4 Steady State . . . . . . . . . . . . . . . . . . . . . . . . . . 17
ix
x Contents
3.5.5 Block Diagram of the Stationary Kalman Filter . . . . . . . 17
3.5.6 Design Parameters . . . . . . . . . . . . . . . . . . . . . . . 17
3.6 Shaping Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.6.1 Shaping Filters for NonGaussian Process Noise . . . . . . . 19
3.6.2 Shaping Filters for NonGaussian Measurement Noise . . . 19
4 Choosing the Kalman Filter Parameters 21
4.1 Estimating the Covariances . . . . . . . . . . . . . . . . . . . . . . 21
4.2 Choosing Q and R Manually . . . . . . . . . . . . . . . . . . . . . 22
4.3 Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.3.1 OpenLoop Simulation . . . . . . . . . . . . . . . . . . . . . 23
4.3.2 ClosedLoop Simulation . . . . . . . . . . . . . . . . . . . . 24
4.4 Autotuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.4.1 Evaluation Using RMSE . . . . . . . . . . . . . . . . . . . . 25
4.4.2 Autotuning Using Matlab . . . . . . . . . . . . . . . . . . . 25
4.4.3 Simulated Annealing . . . . . . . . . . . . . . . . . . . . . . 26
5 Kalman Filter Implementation 33
5.1 Overview of the Inner Control Loop . . . . . . . . . . . . . . . . . 33
5.2 Modeling the Acceleration . . . . . . . . . . . . . . . . . . . . . . . 35
5.3 Errors in the Acceleration Model . . . . . . . . . . . . . . . . . . . 38
5.4 Kalman Filter Model . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.5 Choosing the Filter Parameters . . . . . . . . . . . . . . . . . . . . 44
6 Alternative Kalman Filter Models 49
6.1 Vehicle Speed as Feedback . . . . . . . . . . . . . . . . . . . . . . . 49
6.2 Modeling the Disturbance a
z
. . . . . . . . . . . . . . . . . . . . . 50
6.2.1 FirstOrder Lag Function . . . . . . . . . . . . . . . . . . . 50
6.2.2 FirstOrder GaussMarkov Process . . . . . . . . . . . . . . 52
6.2.3 Identifying the Time Constant . . . . . . . . . . . . . . . . 53
6.2.4 Testing the Model of a
z
. . . . . . . . . . . . . . . . . . . . 55
6.2.5 HigherOrder Derivative of a
z
. . . . . . . . . . . . . . . . . 56
6.3 Implementation and Testing in Arjeplog . . . . . . . . . . . . . . . 59
6.4 Comparing the Kalman Filter Models . . . . . . . . . . . . . . . . 60
6.5 Comparing the Kalman Filter with a FirstOrder Lag Function . . 61
7 Change Detection 67
7.1 Idea of Change Detection . . . . . . . . . . . . . . . . . . . . . . . 67
7.2 One Kalman Filter with WhitenessTest . . . . . . . . . . . . . . . 68
7.3 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
7.4 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
8 Conclusions and Future Work 75
8.1 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
8.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
List of Notations 77
Bibliography 79
A Matlab Implementation of “lsqnonlin” 81
B Matlab Implementation of Simulated Annealing 83
C Time Constant Identiﬁcation 88
xii Contents
Chapter 1
Introduction
This chapter wil l give an introduction to the problem investigated in this Master’s
thesis. DaimlerChrysler AG, where the thesis project has been performed, wil l be
presented, as wel l as an outline for the thesis.
1.1 Background
Driver assistance systems are more and more becoming standard in the new vehi
cles built today. The tasks for these systems are to support and relieve the driver,
but not to take the driving task from him or her. By vehicle longitudinal regula
tion, one understands the inﬂuence of the vehicle in its driving direction by means
of a controller. In this Master’s thesis the focus will be on the driver assistance
systems supported by the longitudinal controller at DaimlerChrysler AG.
The longitudinal controller can be thought of as two cascade controllers, see
Figure 1.1. The outer controller contains the driver assistance functions (such as
Speedtronic, Distronic, DSR, etc  for further information see Chapter 2). v is here
the actual vehicle speed. a
d1
, a
d2
, . . ., a
dn
are the desired accelerations calculated
by the assistance functions. The block called “Coord.” (coordinator) in the ﬁgure
chooses which of the functions that should have aﬀect, depending on the driver’s
choice. It also contains a jerk damper, so that the vehicle is traveling smoothly,
even when switching between the diﬀerent assistance functions.
The resulting calculated acceleration a
d
is delivered to the inner control loop,
whose task is to make the vehicle have the same acceleration as the desired value.
The inner controller delivers a desired torque T to the actuators engine, brake and
gearbox, which are aﬀecting the vehicle. The current speed v and acceleration a
are measured and used as feedback signals by the controllers.
The inner controller contains a PIDcontroller and an observer. The task of the
observer is to estimate the part of the vehicle’s acceleration caused by disturbances
not included in the vehicle model. A Kalman ﬁlter is chosen as observer, and this
Master’s thesis will explain the function and implementation of the Kalman ﬁlter
in more detail.
1
2 Introduction
... 
a
dn

v
DSR

a
d3

v
Distronic

a
d2

v
Speedtronic

a
d1
Coord.

a
d
PID
Observer

T
Vehicle
6
v, a
Outer controller Inner controller
Figure 1.1. Overview of the longitudinal controller in the vehicle. The driver assis
tance functions in the outer control loop calculates accelerations a
di
. The coordinator
(“Coord”) chooses which of the functions that should have aﬀect and delivers a desired ac
celeration a
d
to the inner control loop. The inner control loop consists of a PIDcontroller
and an observer. They deliver a desired torque T to the engine, brake and gearbox which
are aﬀecting the vehicle. The speed v and acceleration a are used as feedback signals.
1.2 Problem Formulation
The Kalman ﬁlter attached parallel to the PIDcontroller should estimate the part
of the vehicle’s acceleration caused by large disturbances (for example a changed
mass or slope of the road). The ﬁlter is directly attached to the engine and brakes,
and it is therefore important that the output from the ﬁlter is smooth. Otherwise
the comfort is negatively aﬀected.
The Kalman ﬁlter has to be tuned to work optimally. For this purpose the
theory behind the ﬁlter and the methods for ﬁlter tuning had to be better inves
tigated.
1.3 Objective
The goal of this thesis is to explain the function of the Kalman ﬁlter, describe
methods for choosing the parameters, and to ﬁnd good parameter settings justiﬁed
by theoretical and practical methods. It should also be examined if the structure
of the ﬁlter can be improved.
1.4 DaimlerChrysler AG 3
1.4 DaimlerChrysler AG
DaimlerChrysler AG is a major automobile and truck manufacturer formed in 1998
by the merge of DaimlerBenz in Germany (the manufacturer of MercedesBenz)
and the Chrysler Corporation in USA. The company produces cars, trucks, vans
and busses under the brands Chrysler, Dodge, Jeep, MercedesBenz, Smart and
Maybach, among others. In January 2007 the company was the second largest
auto manufacturer.
At Mercedes Technology Center in Sindelﬁngen, Germany, over 35000 employ
ees are producing the CClass, EClass, SClass, CLSClass, CLClass and May
bach cars. 9500 persons are working with development. The team working with
driving assistance systems is developing control systems such as adaptive cruise
control and hill descent control.
1.5 Method
The necessary theory describing the Kalman ﬁlter will be presented using literature
studies. Diﬀerent methods for choosing the ﬁlter parameters will be explained
and implemented. Using previous Master’s theses at DaimlerChrysler the process
model for the vehicle’s longitudinal dynamics will be developed. The model of the
disturbance used in the existing Kalman ﬁlter will be examined. Then a stationary
Kalman ﬁlter is designed for the model and good working parameters will be found
using simulation. The development of the observer is performed in Matlab and
Simulink, and simulations are made oﬀline. The ﬁlter will then be extended with
an algorithm for change detection. It will be examined if this makes the ﬁlter both
work properly in case of small noise as well as respond quickly in case of sudden
larger changes (as is two competitive goals with the Kalman ﬁlter).
1.6 Outline
In the introductory chapter the purpose and method of the thesis is presented. An
overview of the diﬀerent driver assistance systems supported by the longitudinal
controller is given in the second chapter. Chapter three discusses some basic esti
mation ﬁlter theory needed to implement an observer in the controller. Diﬀerent
possibilities to choose and tune the ﬁlter parameters are presented in chapter four.
In chapter ﬁve the model for the longitudinal dynamics of the vehicle is derived,
and an initial version of the Kalman ﬁlter is implemented and tested. Chapter
six starts with a presentation of some more complex models used to model the
estimated parameter, and continues with a discussion of the advantages and dis
advantages of using these models. At the end of chapter six a comparison between
the developed Kalman ﬁlter and a standard lowpass ﬁlter is made. Chapter seven
discusses the possibilities given by some ideas picked up from the area of “Change
Detection”, and an algorithm that uses this theory is simulated and evaluated.
Finally, in the last chapter, conclusions are drawn and some extensions for the
thesis are presented.
4 Introduction
1.7 Limitations
The use of an observer in an inner controlloop to estimate the model errors was
suggested in [1]. A comparison between this method and the use of a PIDcontroller
was made in [19]. However, the advantages and disadvantages of attaching an
observer in parallel to a PIDcontroller (as described in this Master’s thesis) have
not been examined. It is a method used for about a year in test vehicles at
DaimlerChrysler and accepted as a basis for this thesis.
The sensors used in this Master’s thesis to measure the speed and acceleration
of the vehicle use Kalman ﬁlters and sensor fusion techniques to obtain stable
measurements. It has not been examined if the ﬁlter described in this thesis
would make better estimates by using unﬁltered data.
Chapter 2
Driver Assistance Systems
To better understand the task of the control ler discussed in this thesis, an intro
duction to driver assistance systems is given in this chapter. Among the driver
assistance systems there are comfort functions, which relieve the driver in his/her
tasks, passive safety functions, which reduce the consequence of an accident, and
active safety functions which help the driver to avoid accidents.
2.1 Antilock Braking System
Antilock braking system (ABS) prevents the wheels from locking and maintains the
steering ability of the vehicle during hard braking. During bad road conditions,
ABS will also reduce the stopping distance. The system measures the velocity
of all four wheels, and if one of the sensors reports an abnormal deceleration it
concludes that the wheel is about to lock and the pressure in the braking system
is reduced. [7]
2.2 Traction Control
The functioning of the traction control system is very similar to that of the ABS.
The system prevents the wheels from slipping during acceleration by using the
same velocity sensors as the ABS. If the vehicle starts to slip, the engine power is
reduced in order to maintain control of the vehicle. [7]
2.3 Stability Control
A stability control system basically measures the yaw rate of the vehicle, i.e., the
rotation in the ground plane, and compares it with the desired trajectory. If the
deviation is greater than a certain threshold, the system will activate the brakes
on one side of the vehicle to correct this. When the German automotive supplier
Bosch launched their stability control system they called it “electronic stability
program” (ESP). [7]
5
6 Driver Assistance Systems
2.4 Speed Limiter
The speed limitation function is used to make sure that the driver does not ex
ceed a set speed. The driver can set a variable or permanent limit speed. The
variable limit can easily be set and changed during driving. It is automatically
deactivated if the driver pushes down the accelerator pedal beyond the pressure
point, often referred to as “kickdown”. This is useful when overtaking. The per
manent limit is used for permanent longterm speed restrictions, such as driving
on winter tires. The permanent limit speed is set using the onboard computer,
and it cannot be exceeded by kickdown. This function is called “Speedtronic” by
DaimlerChrysler. [25]
2.5 Cruise Control
The cruise control, sometimes called “speed control” or “autocruise”, automatically
controls the speed of the vehicle. The driver can easily set and change the desired
speed during driving, and cruise control maintains the set speed and accelerates
and brakes the vehicle automatically if necessary. If the driver pushes down the
accelerator pedal to temporarily drive faster, the cruise control adjusts the vehicle’s
speed to the last stored speed when he/she again releases the accelerator pedal.
This is useful when overtaking. [25]
2.6 Hill Descent Control
The hill descent control system is essentially a lowspeed cruise control system for
steep descents. It uses the ABS brake system to control each wheel’s speed and
keeps the speed of travel to the speed set in the operating system. It is possible to
drive at a higher or a lower speed than that set in the operating system at any time
by manually braking or accelerating. The driver will be able to maintain control of
the vehicle when driving down hills with slippery or rough terrain and the system is
therefore especially helpful in oﬀroad conditions. The hill descent control system
used in DaimlerChrysler vehicles is called “Downhill Speed Regulation” (DSR). [26]
2.7 Forward Collision Mitigation System
Col lision mitigation system (CMS) uses radar sensors to detect obstacles which
are in the path of the vehicle. Most manufacturers have a similar functionality
when it comes to the intervention strategy. They use increasing warning levels as
the threat approaches. If the driver does not brake himself, the CMS will reduce
the impact speed by applying the brakes when a collision with the leading vehicle
appears to be unavoidable. [7]
2.8 Adaptive Cruise Control 7
2.7.1 Distance Warning
This function warns the driver when the distance to the vehicle in front is too
small. A message or a warning lamp in the instrument cluster then lights up. If
the driver is approaching the vehicle in front at high speed, he/she will also hear a
signal. The driver has to apply the brakes in order to maintain the correct distance
and avoid a collision. [25]
If the system has detected a risk of collision and the driver does not brake
or steer himself/herself, the vehicle is automatically braked gently and the seat
belts are retracted gently two or three times to warn the driver. This helps to
reduce the consequence of an accident, but the driver has to apply the brakes
himself/herself in order to avoid a collision. This system is called “presafe brake”
in DaimlerChrysler vehicles. [25]. At this point, if the driver applies the brakes,
the system interprets this action as emergency braking, and activates the brake
assist system to reduce impact speed. [7]
2.7.2 Brake Assist System
Brake assist system (BAS) operates in emergency braking situations. If the driver
pushes down the brake pedal quickly, BAS automatically boosts the braking force
and thus shortens the stopping distance. If the vehicle is equipped with radar
sensors, the system calculates the brake pressure necessary to avoid a collision.
When the driver pushes down the brake pedal forcefully, the system automatically
boosts the braking force to a level appropriate to the traﬃc situation. The brake
assist system is deactivated and the brakes will function as normal when the driver
releases the brake pedal, there are no obstacles detected in the path of the vehicle
and there is no longer a risk of collision. In DaimlerChrysler vehicles this function
is called “BAS Plus”. [25]
2.8 Adaptive Cruise Control
Adaptive cruise control (ACC) is also known as “active cruise control” or “intelli
gent cruise control”. ACC uses a forward looking sensor, usually radar or laser, to
monitor the distance to leading vehicles. If the system is active and the time gap
to the leading vehicle falls below a certain threshold, the vehicle will automatically
brake in order to maintain distance. In Europe there are government restrictions
which limit the permitted braking rate. If the vehicle detects that a higher decel
eration is required to avoid colliding with the leading vehicle, an audible warning
is given to the driver. If there is no vehicle in front, ACC operates in the same
way as cruise control. [7]
DaimlerChrysler oﬀers adaptive cruise control under the name “Distronic”. It
functions at speeds between 30 and 200 km/h. With the Distronic system, the
distance to the leading vehicle is set as a time between one and two seconds. The
system uses radar sensors to measure the distance to the vehicle in front. [25]
Some DaimlerChrysler vehicles are equipped with a system called Distronic
Plus, which functions at speeds between 0 and 200 km/h. If Distronic Plus detects
8 Driver Assistance Systems
that the vehicle in front has stopped, it will cause the vehicle to brake and come to
a halt. Once the vehicle is stationary, it will remain so without the driver having to
push down the brake pedal. If the vehicle in front pulls away, and the driver pulls
the cruise control lever or brieﬂy pushes down the accelerator pedal, the vehicle
automatically pulls away and adapts its speed to the vehicle in front. [25]
2.9 Lane Guidance System
Lane guidance system refers to systems that try to help the driver stay in the lane.
Systems typically use an audible warning or a steering wheel torque to alert the
driver if the vehicle is approaching the lane markings. The steering wheel torque
used by some of the systems will automatically steer the vehicle back into the
center of the lane, thus working almost like an autopilot. Another idea is to try
to mimic the sounds and vibrations that are generated by rumble strips, i.e., the
grooved lane markings that are sometimes used on motorways to indicate lane
departure. [7]
2.10 Blindspot Warning
The general idea behind a blindspot warning system is to lower the risk of lane
change accidents by warning the driver about vehicles in the blind spot. There are
diﬀerent techniques for achieving this but usually ocular vision or radar is used. [7]
2.11 Systems Supported by the Controller
In this Master’s thesis, the focus will be on those driver assistance systems that
are supported by the longitudinal controller at DaimlerChrysler AG. These are
• Speed limiter
• Cruise control
• Adaptive cruise control
• Collision mitigation system
• Brake assist system
• Hill descent control
Figure 2.1 gives an overview of the vehicles sold by DaimlerChrysler. The vehicles
are listed together with the driver assistance systems that are used in the vehicles.
2.11 Systems Supported by the Controller 9
Speed
tronic
Cruise
Control
Distance
Warning
Distronic
Distronic
Plus
DSR
Pre
Safe
Brake
BAS
Plus
C  Class WS203
x x
C  Class CL203
x x
CL  Class 215
x x x x
CL  Class 216
x x x x x x x
CLK  Class 209
x x x x
CLS  Class 219
x x x x
E  Class 211
x x x x
R  Class 251
x x x x
S  Class 221
x x x x x x x
SL  Class 230
x x x x
SLK  Class 171
x x
M  Class 164
x x x x x
G  Class 463
x x
GL  Class X164
x x x x x
Sprinter
x x
Viano 639
x x
Vito 639
x x
Crafter (VW)
x x
Figure 2.1. Driver assistance systems supported by the vehicle longitudinal controller
at DaimlerChrysler. The ﬁgure shows which DaimlerChrysler vehicles are using the
systems. The names that are used in the ﬁgure are the names used by DaimlerChrysler.
10 Driver Assistance Systems
Chapter 3
Basic Filter Theory
This chapter starts with an introduction to statespace models often used when
working with control systems. It is shown how to transform a continuous time
model into a time discrete model. Then some basic theory for observers is pre
sented. One popular observer is the Kalman ﬁlter. The Kalman ﬁlter is “certainly
one of the greater discoveries in the history of statistical estimation theory and
possibly the greatest discovery in the twentieth century” [11]. The equations for
this ﬁlter are presented and the function of the stationary Kalman ﬁlter is ex
plained. In the end of this chapter it is described how to construct shaping ﬁlters
for nonGaussian process noise and nonGaussian measurement noise.
3.1 StateSpace Models
To design an estimation ﬁlter one ﬁrst needs a mathematical model of the con
trolled process. Sir Isaac Newton (16421727) discovered that the sun and its
planets are governed by laws of motion that depend only upon their current rel
ative positions and current velocities. By expressing these laws as a system of
diﬀerential equations and feed them with the current positions and velocities he
could uniquely determine the positions and velocities of the planets for all times.
Almost every physical system can in the same way be described using diﬀerential
equations. [11]
The order of a diﬀerential equation is equal to the order of the highest deriva
tive. When doing control design it is preferable to have all equations of ﬁrst order.
One can reduce the form of any system of higher order diﬀerential equations to
an equivalent system of ﬁrstorder diﬀerential equations by introducing new vari
ables. [9]
In this Master’s thesis a special type of diﬀerential equations will be used,
called ordinary diﬀerential equations (ODE). This model is also referred to as the
continuoustime statespace model. When the equations describing a system are
11
12 Basic Filter Theory
linear, the model can be written as the linear statespace model [3]
˙ x(t) = Ax(t) +Bu(t) +Gw(t) (3.1)
y(t) = Cx(t) +e(t) (3.2)
The variables x = [x
1
, x
2
, ..., x
n
]
T
in (3.1) and (3.2) are commonly called “state
variables” (or “states”) and they represent all important characteristics of the sys
tem at the current time. The “process model” (3.1) describes the dynamics of the
system. The variable u represents a known external signal, typically available to or
controlled by the system. The variable w is used to model unknown disturbances
or model uncertainties, which cannot be directly measured. They can only be
observed through their inﬂuence on the output. The “measurement model” (3.2)
describes how the noisy measurements y are related to the internal variables. e is
here some noise added to the measurement. [3]
Usually e and w are modeled as unpredictable random processes with null as
mean value and a known variance, often referred to as Gaussian noise. It can
be shown that a system described by (3.1) and (3.2) with e and w modeled as
Gaussian noise is a Markov Process. This means that it satisﬁes the Markov
Property [3]
p[x(t)x(τ), τ < t
1
] = p[x(t)x(t
1
)], ∀t > t
1
(3.3)
The construction p[AB] in this statement should be read “the probability of A
given B”. In words this means that the past up to any time t
1
is fully characterized
by the value of the process at t
1
, or “The future is independent of the past if the
present is known”. This is an important property, because when trying to predict
future states of the system with a good model, one only needs to know the current
state. [3]
3.2 Discretization
Almost every physical system is best described using a continuoustime model, but
the controller is often implemented in a computer using discrete methods. The
model therefore has to be sampled and changed into a discrete time statespace
model. How this is done is explained in this section, based on [10] and [13].
The continuous dynamic system described by (3.1) and (3.2) can be trans
formed into a discrete statespace system, assuming that the input signal u is
piecewise constant during the sampling interval T. This is usually the case when
the input u is generated by a computer. This gives the linear discrete time
invariant statespace model
x(kT +T) = A
d
x(kT) +B
d
u(kT) +G
d
w(kT) (3.4)
y(kT) = C
d
x(kT) +e(kT) (3.5)
The index d is referring to the discrete form of the matrices. Often an easier and
more compact form of (3.4) and (3.5) is being used
x
k+1
= A
d
x
k
+B
d
u
k
+G
d
w
k
(3.6)
y
k
= C
d
x
k
+e
k
(3.7)
3.3 Observer 13
In this Master’s thesis the indices d will be left out, when there is no risk of
confusion.
The discrete form of the matrices are calculated using the matrices in (3.1)
and (3.2) as
A
d
= e
AT
(3.8)
B
d
=
T
_
0
e
AT
Bdt (3.9)
C
d
= C (3.10)
There are several ways to calculate e
AT
. One of them is
e
AT
= L
−1
(sI −A)
−1
(3.11)
where L
−1
is the inverse Laplace transform. Other methods are using Taylor series
approximation or the Padé approximation, see [11] for a more detailed description.
There are several possibilities to calculate the matrix G
d
. Assuming that the
stochastic input e also is constant during the sampling intervals, the same method
can be used as for the matrix B
d
. G
d
is then calculated using A and G from (3.1)
giving [13]
G
d
=
T
_
0
e
AT
Gdt (3.12)
This method, called “zeroorder hold”, is used by the command “c2d” (=con
tinuous to discrete) in Matlab when nothing else is speciﬁed [24].
It is seldom the case that e is constant during the sampling intervals [13].
Another alternative is “triangle approximation”, where the input e is assumed
piecewise linear over the sampling period. This method is generally more accurate
than zeroorder hold when the input e is assumed to be smooth [24]. Other meth
ods include “impulseinvariant discretization” (where the impulse response of the
discretized system is matched with that of the continuous system) and “Tustin
approximation” (which instead matches the frequency response of the systems).
3.3 Observer
When designing a controller it is important to have information about the states
of the system. Normally all states cannot be measured. An observer may be used
to estimate the unknown states with help from the available measured states and
the measured signals y and u. In this section some basic theory about the observer
is discussed, based on parts from [9] and [3].
Consider the discrete time system described by (3.6) and (3.7). The matrices A,
B and C are time invariant and known, and the signals u and y can be measured.
The states x cannot be measured but are needed for controlling purposes. An
14 Basic Filter Theory
initial approach to estimate the states would be to simulate the system using only
the known input values u
ˆ x
k+1
= Aˆ x
k
+Bu
k
(3.13)
where ˆ x
k
is the estimated value of x at time step k. To measure the quality of the
estimation, the diﬀerence y
k
− Cˆ x
k
can be used. This diﬀerence should be null
if the estimate ˆ x
k
is equal to the real state x
k
, and will also be so in absence of
errors. This will in practice, however, never be the case, since there are always
model errors and disturbances w as well as measurement noise e. A good way to
improve the estimates is to use y
k
−Cˆ x
k
as a feedback, such that
ˆ x
k+1
= Aˆ x
k
+Bu
k
+L(y
k
−Cˆ x
k
) (3.14)
In words this can be written as
“Estimated state” = “Predicted state” + L · “Correction term”
The correction term reﬂects the diﬀerence between the predicted measurement
and the actual measurement as explained above. In the context of ﬁlters this term
is often called the measurement “innovation” or the “residual”.
The matrix L is here a design parameter and it adjusts how much the residuals
should aﬀect the estimated states. It is a trade oﬀ between how fast the estima
tions converge toward the measurement (high L gives a fast convergence) and how
sensitive the estimate is to measurement noise (high L gives a more noise sensitive
estimate).
The optimal value of L can be calculated in diﬀerent ways, resulting in diﬀerent
types of observers. One type of observer is the Kalman ﬁlter, described in detail
in Section 3.5.
3.4 Observability
The observer estimates the states x with the help of measurements y. Therefore,
there has to be a connection between the states and the measurement, the states x
has to be “seen” in the output y. This limitation is formulated with the help of
the observability matrix O, described in [9] as
O =
_
_
_
_
_
_
_
C
CA
CA
2
.
.
.
CA
n−1
_
_
_
_
_
_
_
(3.15)
All states are observable if and only if O has full rank. This criteria does
however not give any information about how good the estimate will be. When a
matrix has full rank, none of the rows can be written as a linear combination of
3.5 Kalman Filter 15
the other rows. If the matrix does not have full rank, then there is one or more
rows that are “unnecessary”. The easiest way to compute the rank of a matrix is
given by the Gauss elimination algorithm. In Matlab this is calculated with the
command “rank”.
3.5 Kalman Filter
The Kalman ﬁlter is very powerful in several aspects. It supports estimates of
past, present, and future states, and it can do so even when the precise nature of
the modeled system is unknown [11]. In the following sections the basic theory of
the Kalman ﬁlter is presented, based on parts from [23], [12] and [13].
3.5.1 Process and Measurement Model
The Kalman ﬁlter is a set of equations that calculates the optimal L, given a linear
model of the system and statistical information about the process noise w and
measurement noise e. When the system and noise are modeled in the way described
in this section, the Kalman ﬁlter will compute the value of L that minimizes the
variance of the state estimation error, i.e., x
k
− ˆ x
k
. [23]
The Kalman ﬁlter estimates the states of a discrete time controlled process
described in the form of (3.6) and (3.7), repeated below
x
k+1
= Ax
k
+Bu
k
+Gw
k
y
k
= Cx
k
+e
k
The random variables w and e are assumed to be independent of each other,
Gaussian, and with normal probability distributions according to
p(w) ∼ N(0, Q) (3.16)
p(e) ∼ N(0, R) (3.17)
The covariance matrices are thus deﬁned R = E{e
k
e
T
k
} and Q = E{w
k
w
T
k
}
with E{e
k
} = E{w
k
} = 0. The process noise covariance matrix Q, measurement
noise covariance matrix R and the matrices A, B, C and G might change with
each time step or measurement, but in this Master’s thesis they will be assumed
stationary and known.
3.5.2 Discrete Time Kalman Filter Equations
In this section the Kalman ﬁlter equations will be presented to give an overview
of how the ﬁlter works, following the presentation in [23] and [12]. Note that
the equations can be algebraically manipulated into several forms. Therefore the
equations presented here might diﬀer from those found in other literature. For
more information, for example on how to derive the equations, see [3], [11] or [12].
The Kalman ﬁlter estimates a process by using a feedback control. The ﬁlter
estimates the process state at some time and then obtains feedback in the form
16 Basic Filter Theory
of (noisy) measurements. As such, the equations for the Kalman ﬁlter are divided
into two groups; predictor equations and measurement update equations.
The discrete Kalman ﬁlter predictor equations are [13]
ˆ x
tt−1
= Aˆ x
t−1t−1
+Bu
t
(3.18)
P
tt−1
= AP
t−1t−1
A
T
+GQG
T
(3.19)
which translates the estimate from the last time step ˆ x
t−1t−1
to obtain the esti
mate for the current time step. ˆ x
tt−1
refers to the estimate of x at the current
time step t given all the measurements prior to this time step, also referred to as
the “a priori” state estimate. P
tt−1
in (3.19) is deﬁned
P
tt−1
= E[(x
t
− ˆ x
tt−1
)(x
t
− ˆ x
tt−1
)
T
] (3.20)
and is the estimation error covariance given measurements prior to this time step,
also referred to as the “a priori” estimate error. Note that P
tt−1
is calculated using
the estimate error from the last time step, P
t−1t−1
, and the process noise covari
ance (or “model uncertainties”), Q. P
tt−1
can be thought of as the uncertainties
of how the states x are evolving.
The discrete Kalman ﬁlter measurement update equations are [13]
L
t
= P
tt−1
C
T
(CP
tt−1
C
T
+R)
−1
(3.21)
ˆ x
tt
= ˆ x
tt−1
+L
t
(y
t
−Cˆ x
tt−1
) (3.22)
P
tt
= (I −L
t
C)
−1
P
tt−1
(3.23)
The measurement update equations are responsible for the feedback, i.e., for im
proving the estimate incorporating a new measurement. They can also be thought
of as corrector equations. (3.21) computes the Kalman gain L
t
that minimizes the
estimation error covariance P
tt
= E[(x
t
− ˆ x
tt
)(x
t
− ˆ x
tt
)
T
]. The correction (3.22)
generates the state estimate by incorporating the new measurement y
t
. Together
are (3.18) and (3.22) forming (3.14) in Section 3.3. The ﬁnal step (3.23) is to
obtain the estimate error covariance P
tt
, which is needed in the next time step.
After each predictor and measurement update pair, the calculated values x
tt
and P
tt
are saved so they can be used in the next time step. This update is
performed with the time update equations
ˆ x
t−1t−1
= ˆ x
tt
(3.24)
P
t−1t−1
= P
tt
(3.25)
The process is then repeated using these values in the algorithms for the next
time step. This recursive nature of the Kalman ﬁlter is practical when doing the
implementation. [23]
3.5.3 Initialization
The initial values ˆ x
−1
and P
−1
have to be chosen before starting the ﬁlter. ˆ x
−1
is
chosen with knowledge about the state x. For example, if x is a random constant
3.6 Shaping Filter 17
with normal probability distribution, the best choice is ˆ x
−1
= 0. P
−1
is the
uncertainty in the initial estimate ˆ x
−1
. When one is absolutely certain that the
initial state estimate is correct, then P
−1
should be set to 0. Otherwise the best
choice is the variance of x. However, the choice is not critical. [12],[23]
3.5.4 Steady State
If the matrices A, C, Q and R are timeinvariant, both the estimation error covari
ance P
k
and the Kalman gain L
k
will converge to a stationary value. If this is the
case, these parameters can be precomputed by either running the ﬁlter oﬀline,
or by calculating the stationary value P as described in [12] and [19]
P = APA
T
+GQG
T
−APC
T
(CPC
T
+R)
−1
CPA
T
(3.26)
This equation is referred to as the algebraic Riccati equation. The stationary value
of L can then be calculated as
L = APC
T
(CPC
T
+R)
−1
(3.27)
3.5.5 Block Diagram of the Stationary Kalman Filter
The computational procedure and the relation of the ﬁlter to the system is illus
trated as a block diagram in Figure 3.1. The Kalman ﬁlter recursively computes
values of ˆ x using the precalculated stationary values of P and L, the initial esti
mate ˆ x
t−1t−1
and the input data y
t
. [23]
3.5.6 Design Parameters
Design parameters for an observer are the matrices A, B, C and L. If the Kalman
ﬁlter equations (3.26) and (3.27) are used to calculate L, the design parameters
are Q, R and G instead of L. If the matrices are time dependent, the functionality
to calculate new values for L also has to be implemented, but in this Master’s
thesis they will be assumed stationary. In Chapter 4 it will be discussed how
to choose the parameters Q and R. The model used in this Master’s thesis is
developed in Chapter 5.
3.6 Shaping Filter
When implementing a Kalman ﬁlter, it is necessary to have all disturbances acting
as Gaussian noise, i.e., a random signal with null as mean value. For many physical
systems encountered in practice, it may not be justiﬁed to assume that all noises
are Gaussian. If the spectrum of a signal is known, the signal can be described
as the output of a ﬁlter driven by Gaussian noise. Using this, a model with
nonGaussian noise can be extended to a ﬁlter driven by Gaussian noise. These
ﬁlters are called shaping ﬁlters, and they shape the Gaussian noise to represent
the spectrum of the actual system. The ﬁlter can be included in the original state
space system, giving a new linear statespace model driven by Gaussian noise.
18 Basic Filter Theory
u
t

B

+
f
x
t
delay
x
t−1
A
6
+
?
w
t
+

C

+
f
?
e
t
+
y
t
+
f
L
+
f
ˆ x
tt
ˆ x
tt
?
delay

ˆ x
t−1t−1
A

+
f
u
t
6
B
6
+
ˆ x
tt−1
6
+

C
6
−
Discrete System
Measurement
Discrete Kalman Filter
Figure 3.1. Kalman ﬁlter block diagram. This ﬁgure shows the computational pro
cedure of the Kalman ﬁlter, and its relation to the system. The blocks “Discrete Sys
tem” and “Measurement” are a graphically representation of the statespace model (3.6)
and (3.7). The Kalman ﬁlter recursively computes values of ˆ x using the precalculated
stationary values of P and L, and the input signals y and u. It can here be seen how the
estimate ˆ x
tt
delivered from the Kalman ﬁlter is saved in the delay block, so that it can be
used in the next time step. The variable ˆ x
tt−1
is calculated Aˆ x
t−1t−1
+Bu
t
as in (3.18).
The estimate for the current time step ˆ x
tt
is calculated ˆ x
tt−1
+ L(y
t
− Cˆ xtt − 1) as
in (3.22). [11]
3.6 Shaping Filter 19
This is done for systems with nonGaussian process noise and nonGaussian
measurement noise in the next two sections, following the theory in [11].
3.6.1 Shaping Filters for NonGaussian Process Noise
Consider a system given on the form
˙ x
1
= A
1
x
1
+G
1
w
1
(3.28)
y = C
1
x
1
+e (3.29)
where w
1
is nongaussian noise and e is zeromean Gaussian noise. Suppose w
1
can be modeled by a linear shaping ﬁlter according to
˙ x
SF
= A
SF
x
SF
+G
SF
w (3.30)
w
1
= C
SF
x
SF
(3.31)
where w is Gaussian noise. Then the ﬁlter can be included in the original state
space system, giving the new statespace system
˙ x = Ax +Gw (3.32)
y = Cx +e (3.33)
where
x =
_
x
1
x
SF
_
(3.34)
A =
_
A
1
G
1
C
SF
0 A
SF
_
(3.35)
G =
_
0
G
SF
_
(3.36)
C =
_
C
1
0
¸
(3.37)
3.6.2 Shaping Filters for NonGaussian Measurement Noise
Consider a system given on the form
˙ x
1
= A
1
x
1
+G
1
w (3.38)
y = C
1
x
1
+e
1
(3.39)
In this case, e
1
is nonGaussian noise and w is Gaussian noise. Suppose e
1
can be
modeled by a linear shaping ﬁlter according to
˙ x
SF
= A
SF
x
SF
+G
SF
e (3.40)
e
1
= C
SF
x
SF
(3.41)
where e is Gaussian noise. In this case the new statespace system becomes
˙ x = Ax +GW (3.42)
y = Cx (3.43)
20 Basic Filter Theory
where
x =
_
x
1
x
SF
_
(3.44)
A =
_
A
1
0
0 A
SF
_
(3.45)
G =
_
G
1
0
0 G
SF
_
(3.46)
C =
_
C
1
C
SF
¸
(3.47)
W =
_
w
v
_
(3.48)
Chapter 4
Choosing the Kalman Filter
Parameters
In this chapter diﬀerent possibilities on how to choose and tune the Kalman ﬁlter
parameters are presented. First it wil l be shown how to estimate the parameters
using information about the process and measurement noise. Then it wil l be de
scribed how to tune the parameters using knowledge about the parameters’ inﬂuence
on the behavior of the ﬁlter, using openloop or closedloop simulation, and ﬁnal ly
using autotuning. A global optimization technique cal led simulated annealing is
implemented for autotuning in Matlab and Simulink.
4.1 Estimating the Covariances
The Kalman ﬁlter assumes that all disturbances are stochastic variables known in
advance. If the system is linear and both the process noise w and measurement
noise e have a normal distribution, it can be shown that the Kalman ﬁlter is the
optimal ﬁlter (in the sense of minimizing the variance of the estimate error). In
this case the covariance matrices Q and R should be estimated using measures of
the noises e and w. [12]
Each element of R is deﬁned as [3]
R
ij
= E[(e
i
− ¯ e
i
)(e
j
− ¯ e
j
)
T
] (4.1)
where ¯ e
i
is the mean value of e
i
, and the formulation E[ζ] means the statistical
expected value of ζ. The matrix R is a symmetric n × n matrix, where n is the
number of elements in e. The diagonal elements of the covariance matrix are the
variances of the components of e, while the oﬀdiagonal elements are the scalar
covariances between its components. If the components of e is independent of each
other, the oﬀdiagonal elements of R should be set to 0.
By investigating the measured signals, it is possible to obtain an estimation of
the covariance matrix R. Assume that the information in the measured signal y
21
22 Choosing the Kalman Filter Parameters
is constant. The elements of R can then be estimated as in [4] and [2] using
R
i
=
1
N −1
N
t=1
(y
i
(t) − ¯ y
i
)
2
(4.2)
where i is the i:th measured signal, ¯ y
i
is the mean value of y
i
, and N is the number
of samples used for the estimation. The uncertainties of the measured signals are
here assumed to be independent, which results in a diagonal R matrix.
Now assume that the necessary information in the measured signal is of low
frequency, for example the speed of the vehicle. The measurement noise e can
then be estimated by lowpass ﬁltering the signal y as [2]
e = y(t) −y (4.3)
where y is the lowpass ﬁltered signal. The elements of R can then be calculated
as
ˆ
R
ij
=
1
N
N
t=1
e
i
(t)e
j
(t) (4.4)
where i and j are the index of the measured signals and N is the number of samples
used for the estimation. The estimation of the covariance matrix can be performed
in Matlab using the command “covf” [18].
The deﬁnition of the covariance matrix for the process noise Q is similar as
for R and it can also be estimated using a similar method. The problem that
might arise is the fact that not all states in the state vector are measurable.
4.2 Choosing Q and R Manually
A drawback of the Kalman ﬁlter is that knowledge about process and measurement
noise statistics is required. It may be possible to determine the measurement noise
covariance from measurements, but determining the process noise covariance is
more diﬃcult, for example when not all the states are measurable. Instead, a
common approach is to test diﬀerent choices of Q and R until the Kalman ﬁlter
shows acceptable behavior. To understand how the parameter choice aﬀects the
ﬁlter, a discussion of the function of the parameter will now be held based on parts
from [12] and [11].
L is calculated using A, C, Q and R, and will therefore depend on which char
acteristics the process noise and the measurement noise are given in the model.
The inﬂuence on L from diﬀerent choices of R and Q can be understood by insert
ing (3.7) in (3.22), which gives
ˆ x
k
= ˆ x
−
k
+L
k
(y
k
−Cˆ x
−
k
)
= ˆ x
−
k
+L
k
Cx
k
+L
k
e
k
−L
k
Cˆ x
−
k
= ˆ x
−
k
+L
k
C(x
k
− ˆ x
−
k
) +L
k
e
k
(4.5)
4.3 Simulation 23
This shows that the state estimate ˆ x
k
is adjusted using the diﬀerence between the
estimate ˆ x and the real state x, as well as the measurement noise e. Both terms
are multiplied with the gain L. A large Q results in a large L, which means a fast
ﬁlter with good trust in the measurements, but it also makes the observer more
sensitive to the measurement noise e. A large R results in a small L, which means
that the measurements are not reliable. This demands good thrust in the model,
which makes the observer sensitive to errors in the model.
Assume that the parameters are chosen as Q = Q
1
and R = R
1
. Then the
stationary values of P and L can be calculated using (3.26) and (3.27). Assume
that the calculated values are P
1
and L
1
.
If Q and R is both multiplied with the same value λ, the resulting P in (3.26)
is according to [12] also multiplied with λ. This gives P = λP
1
. The calculation
of L in (3.27) then becomes
L = APC
T
(CPC
T
+R)
−1
= A(λP
1
)C
T
(C(λP
1
)C
T
+ (λR
1
))
−1
= λAP
1
C
T
λ
−1
(CP
1
C
T
+R
1
)
−1
= AP
1
C
T
(CP
1
C
T
+R
1
)
−1
= L
1
(4.6)
In other words, L remains the same when Q and R is multiplied with the
same value. The quotient between Q and R is therefore the design parameter; the
absolute values do not matter. When choosing the parameters, R can be set to a
constant value and Q adjusted until the ﬁlter gets acceptable behavior.
4.3 Simulation
Using simulation in Simulink diﬀerent parameter choices can be evaluated without
having to make a test drive in a real vehicle. Here two diﬀerent simulation methods
will be explained, openloop and closedloop.
4.3.1 OpenLoop Simulation
One method is openloop simulation. With this method, measurements done in a
test car can be recorded and given as input back to the model in Simulink. It is
now possible to simulate the Kalman ﬁlter with diﬀerent parameters and compare
the outputs. The reason why this simulation method is called openloop is that
the diﬀerent parameter choices does not aﬀect the behavior of the vehicle. The
ﬁlter is fed with the recorded measurements, but the output from the ﬁlter is not
connected to the controller run in the simulation. This type of simulation is used
to produce all the diagrams presented in the next chapters.
24 Choosing the Kalman Filter Parameters
4.3.2 ClosedLoop Simulation
The other type of simulation used is closedloop simulation. With this method
a scenario including the vehicle and the road is simulated. The output from the
ﬁlter is attached to the controller and the behavior of the vehicle is aﬀected by how
well the ﬁlter is performing. Figure 4.1 shows the Simulink model used by the
closedloop simulation. The model consists of several subsystems, all developed by
DaimlerChrysler, and one of them is the controller containing the Kalman ﬁlter.
Figure 4.1. Closedloop simulation. The vehicle, it’s controller and the environment are
simulated together. The output of the ﬁlter will here aﬀect the behavior of the vehicle.
The environment and the actions of the driver are speciﬁed using simulation scenarios. It
is also possible to specify another vehicle which is traveling in front, a socalled “rabbit”.
Simulation Scenarios
For the closedloop simulation two diﬀerent scenarios are prepared. The ﬁrst
scenario represents the vehicle driven up and down a hill. The vehicle is unloaded
and the driver has activated the cruise control with a set speed of 120 km/h. The
ﬁrst part of the hill has a slope of 10% (meaning “uphill”), and the second part
has a slope of −15% (meaning “downhill”).
The second scenario represents the vehicle driven on a straight road. The
vehicle is heavy loaded. Total mass of the vehicle is 1.8 times the normal mass.
The vehicle is driven at 80 km/h and the driver has activated the cruise control.
The driver adjusts the speed by using the cruise control lever, ﬁrst by increasing
the set speed to 120 km/h and then by decreasing it again to 80 km/h.
4.4 Autotuning 25
4.4 Autotuning
Tuning the ﬁlter, i.e., choosing the values of the process noise covariance Q and
measurement noise covariance R so that the ﬁlter performance is optimized with
respect to some performance measure, is a challenging task. Performing it manu
ally is timeconsuming with no guarantee for optimality. Poor tuning may result
in unsatisfactory performance of an otherwise powerful algorithm. It is there
fore often desirable to develop automated systematic procedures for Kalman ﬁlter
tuning.
A systematic method of choosing Q and R is to perform many simulations using
diﬀerent parameters and evaluate the performance. A performance evaluation
variable may be the variance of the state estimation error, x
k
− ˆ x
k
(which is also
minimized with the Kalman ﬁlter). [12]
4.4.1 Evaluation Using RMSE
The observer gives a so called point estimate ˆ x of the state vector x using the
inputs u and measurements of the output y. Suppose that it is possible to gener
ate M realizations of the data u and y and apply the same estimator to all of them.
For evaluation it is necessary to measure the performance of this estimation. One
such performance measure is the root mean square error (RMSE) described in [13]
RMSE(k) =
¸
¸
¸
_
1
M
M
j=1
x
k
− ˆ x
(j)
k

2
2
(4.7)
where the subindex 2 stands for the 2norm, also called the euclidean norm. (The
euclidean norm is deﬁned x
2
=
_
x
2
1
+· · · +x
2
n
.) This is an estimate of the
standard deviation of the estimation error norm at each time instant. A scalar
measure for the whole data sequence is
RMSE =
¸
¸
¸
_
1
k
k
i=1
1
M
M
j=1
x
k
− ˆ x
(j)
k

2
2
(4.8)
The scalar performance measure can be used for autotuning, as long as it is
possible to generate several data sets under the same premises. Optimally this
should be done using reallife testing (instead of simulation), but this might not
be possible, for instance when it is too expensive to repeat the same experiment
many times. [12]
4.4.2 Autotuning Using Matlab
To automatically ﬁnd the optimal parameters for the Kalman ﬁlter implemented
at DaimlerChrysler, an optimization algorithm is developed in Matlab. The
algorithm starts with some parameter values, then simulates the system using
these values for the Kalman ﬁlter and calculates a cost function based on RMSE
explained in the previous section. The cost function measures how good the actual
26 Choosing the Kalman Filter Parameters
parameters are working. The optimization algorithm then changes the values,
simulates again and calculates a new value for the cost function. The algorithm
continues until optimal values for the parameters are found.
The source code for the script implementing this optimization technique is
found in Appendix A. The code is a modiﬁed example from the Optimization
Toolbox [6], and it uses a function called “lsqnonlin”.
Using this optimization technique does not give a satisfactory result. After sev
eral (about 100) restarts with diﬀerent starting parameters the script each time
ends up giving almost the same parameters back to the user. The optimization
function does not vary the parameters enough to see if there are any better solu
tions.
One reason is that Matlab’s optimization functions are designed to ﬁnd local
minima and they can be fooled, especially by oscillatory functions. They will only
ﬁnd a global minimum if it is the only minimum and the function is continuous.
Global optimization problems are typically quite diﬃcult to solve. Methods for
global optimization problems can be categorized based on the properties of the
problem that are used and the types of guarantees that the methods provide for
the ﬁnal solution. “Simulated annealing” is a popular approach for the global
optimization of continuous functions when derivatives of the objective functions
are not available. [21]
4.4.3 Simulated Annealing
The rest of this chapter will be used to present an algorithm implementing the
theory of simulated annealing. More theory of the algorithm can be found in [15],
and the implementation in Matlab developed to do optimization with Simulink
is found in Appendix B.
Simulated annealing (SA) is a stochastic global minimization technique. Given
a function E(s) depending on some parameter vector s = [s
1
, ...s
n
], the SA al
gorithm attempts to locate a good approximation to the global minimum of the
function.
The name and inspiration come from annealing in metallurgy, a technique in
volving heating and controlled cooling of a material to increase the size of its
crystals and reduce their defects. The heat causes the atoms to become unstuck
from their initial positions (a local minimum of the internal energy) and the slow
cooling gives them more chances of ﬁnding conﬁgurations with lower internal en
ergy than the initial one.
By analogy with this physical process, each step of the SA algorithm considers
some random neighbor ˜ s of the current parameter state s, and probabilistically
decides between moving the system to state ˜ s or staying in s. This probability is a
function P(E(s), E(˜ s), T) depending on the corresponding values of the function
for the states s and ˜ s, and on a parameter T (called the temperature), that is
gradually decreased during the process. There are diﬀerent possibilities to choose
the function P, as long as some constraints are fulﬁlled. This will be explained
later.
Another explanation of the simulated annealing algorithm goes as follows. Con
4.4 Autotuning 27
sider a man running in the mountains. His task is to ﬁnd the place with the lowest
altitude. The cost function that should be minimized is in this case the man’s
altitude, and the variable T is his current strength. To ﬁnd the place with the
lowest altitude (the global minimum) he sometimes has to try running up the hills,
otherwise he may be stuck in a valley (local minimum) not knowing that a better
solution is hiding in another valley behind the next hill. The man’s will to go
“uphill” is larger at the beginning, when his strength T is large. When T tends to
zero the man will only has the strength to run “downhill”.
PseudoCode
The following pseudocode describes the simulated annealing algorithm. It starts
at a state s
0
and recursively explores the search space using the method described
above. The algorithm continues until a maximum number of evaluations k
max
has been reached, or until a state with the target function value e
target
or less
is found. The function call “neighbor(s)” should generate a randomly chosen
neighbor of a given state s. The function call “random()” should return a random
value in the range [0, 1]. The annealing schedule is deﬁned by “tempfunction()”,
which should yield the temperature to use, given the fraction r of the time that
has passed so far.
s = s0; // Initial state
e = E(s); // Initial function value
s_best = s; // Initial best parameters
e_best = e; // Initial function minimum
T = initialtemperature(k_max); // Initial temperature
k = 0; // Evaluation count
while k < k_max and e > e_target // While not good enough
s_neighbor = neighbor(s); // Pick some neighbor
e_neighbor = E(s_neighbor) // Compute its function value
if e_neighbor < e_{best} then // Is this a new best?
s_best = s_neighbor; // Yes, save it
e_best = e_neighbor;
end if
if random() < P(e, e_neighbor, T) // Move to the neighbor state?
s = s_neighbor; // Yes, change state
e = e_neighbor;
end if
T = tempfunction(T,k/k_max); // Calculate new temperature
k = k + 1; // Count evaluations
end while
return s_best; // Return best solution found
Implementation of the SAAlgorithm
In order to apply the SA method to a speciﬁc problem, one must specify the
parameter search space, the neighbor selection method, the probability transition
28 Choosing the Kalman Filter Parameters
function, and the annealing schedule (temperature function). These choices can
have a signiﬁcant impact on the eﬀectiveness of the method. Unfortunately, there
are no choices that will be good for all problems, and there is no general way to
ﬁnd the best choices for a given problem. It has therefore been observed that
applying the SA method is more an art than a science.
In the following subsections it is explained how the algorithm is implemented.
The general demands and calculations are described here, and the complete imple
mentation of the algorithm in Matlab can be found in Appendix B. The script
can be used to perform autotuning on the ﬁlter.
Choosing the Neighbors
The neighbors of the current state have to be chosen so that the function values of
the neighboring states are not too far away from the function value of the current
state. This makes the probability of moving to the new state higher, and in this
way the algorithm can move on ﬁnding a good solution. It is true that choosing
a neighbor far away from the current state could lead to ﬁnding the best solution
faster, but this also leads to a low probability of moving to the new solution and
the risk of getting stuck in a nonoptimal solution is higher.
In the Matlab implementation found in Appendix B, the neighbors ˜ s to the
current state s are found by moving a random distance from s in a random direc
tion. The distance has been chosen as a value between −0.5 and +0.5 times the
current parameter vector s. The Matlabcode is as follows
move = (rand(1,3)0.5).*s; % Randomize between 0.5 and +0.5
s_neigbour = s + move; % Calculate new parameters
Transition Probability Function P
The function P calculates the probability of making the transition from the current
state s to a candidate new state ˜ s. The function depends on the corresponding
function values E(s) and E(˜ s), and the temperature T. The probability (a number
between 0 and 1) should be greater than 0 when E(˜ s) > E(s). This is an essential
requirement meaning that the system may move to the new state even when its
solution is worse than the current one. It is this feature that prevents the method
from becoming stuck in a local minimum. As the algorithm evolves and T goes to
zero, the probability P must tend to zero if E(˜ s) > E(s) and to a value greater
than zero if E(˜ s) < E(s). This makes the system favor moves that go “downhill”
and avoid those that go “uphill”. When T is zero the algorithm will fall down to
the nearest local minimum.
In the implementation found in Appendix B the probability is calculated as
P =
_
1 if E(˜ s) < E(s)
e
E(s)−E(˜ s)
T
otherwise
(4.9)
This is the method used in [21] and [15]. However, there is no mathematical
justiﬁcation for using this particular formula in SA, other than the fact that it
corresponds to the requirements explained above. The Matlabcode is as follows
4.4 Autotuning 29
function P = transition_P(E, E_neighbor, T)
if E_neighbor < E
P = 1; % Always go down the hill
else
P = exp((EE_neighbor)/T); % Move if temperature is high
end
end
Annealing Schedule
The annealing schedule must be chosen with care. The initial temperature must be
large enough to make the “uphill” and “downhill” transition probabilities nearly
the same. To do that, one must have an estimate of the diﬀerence E(˜ s) −E(s) for
a random state and its neighbors. The temperature must then decrease so that it
is zero, or nearly zero, when the algorithm is supposed to ﬁnish. For this thesis
an exponential schedule has been chosen, where the temperature decreases by a
ﬁxed cooling factor 0 < α < 1 at each step. The temperature T
k
for the current
time step k is calculated using the cooling factor α and the temperature from the
previous time step, T
k−1
, as
T
k
= αT
k−1
(4.10)
The initial temperature T
0
and the cooling factor α now have to be chosen.
Typically they are obtained by trial and error and tuned to the function E, which
should be minimized. In the problem at hand, this function depends on the simu
lated model, and as the evaluation of this function involves running a simulation
in Simulink, such tuning procedures are impractical. What is needed is an au
tomatic and reasonable way of setting these parameters based on some initial
information obtained by the algorithm. Such a method is presented in [21] and
used in this Master’s thesis.
Let s
0
be the initial state of the system. To pick the initial temperature T
0
,
generate a set of solutions that lies in the neighborhood of s
0
. Let s
bestn
and s
worstn
be the best and worst among the neighbor solutions. If E(s
worstn
) > E(s
0
), deﬁne
the maximum uphill move as maxmove = E(s
worstn
) −E(s
0
). Otherwise, deﬁne
maxmove = E(s
0
) −E(s
bestn
).
It is now reasonable to assume that the initial temperature T
0
is high enough
if an “uphill” move maxmove will be accepted with a relatively high probability,
say 0.9. Setting P = 0.9 for an “uphill” move of maxmove, (4.9) gives
0.9 = e
−
maxmove
T
(4.11)
and T = T
0
can be calculated.
Next, the cooling parameter α is calculated. To do this, assume that the ﬁnal
acceptance probability for an “uphill” maxmove should be very low, say 10
−6
. If
the ﬁnal probability is too high, the algorithm still behaves like a random search.
As k
max
is the maximum number of function evaluations allowed, this is also the
number of times the temperature is reduced. (4.9) now gives
10
−6
= e
−maxmove
T
0
α
k
max
(4.12)
30 Choosing the Kalman Filter Parameters
and α can be obtained.
Restarting
The SAalgorithm uses a random method to ﬁnd the solution, which means that
several executions may give diﬀerent outputs. When a better solution is needed,
and more computer time is available, instead of justifying the maximum number
of iterations allowed (k
max
), it is sometimes better to start the algorithm over
with a new initial state s
0
. Moving back to a solution that was signiﬁcantly better
rather than always moving from the current state is called restarting. The decision
to restart could be based on a ﬁxed number of evaluation steps, or based on the
current function value being too high from the best value so far. The Matlab
implementation found in Appendix B can be executed recursively and the starting
parameter state s
0
for the next iteration is set to the best solution found in the
previous iteration. In this way the algorithm can be left running for a long time,
restarting over and over again using the previous best solution found as the new
initial solution.
Results
Figure 4.2 shows one execution of the SA script with 200 closedloop simulations
in the ﬁrst scenario (the hill) described in Section 4.3.2. The upper diagram is the
cost function described in Section 4.4.1, calculated by using the diﬀerence between
the ﬁlter estimate and the “real” value. The diagram shows that the SAalgorithm
is trying to ﬁnd the global minimum of the cost function, but does not get stuck in
local minima. The allowance for parameter changes causing a higher value of the
cost function is high in the beginning, but decreases together with the temperature
shown in the lower diagram.
4.4 Autotuning 31
Figure 4.2. One execution of the simulated annealing (SA) algorithm using 200 evalu
ations. By analogy with the physical process, each step of the SA algorithm probabilis
tically decides between moving the system to the new state or staying in the old state.
The probability depends on the parameter T (called the temperature). The top diagram
shows the RMSE costfunction for all the states evaluated. The bottom diagram shows
the temperature that is gradually decreasing during the process. As can be seen, the
current solution changes almost randomly when T is large. This allowance for “uphill”
moves saves the method from becoming stuck at local minima.
32 Choosing the Kalman Filter Parameters
Chapter 5
Kalman Filter
Implementation
In this chapter the model for the longitudinal dynamics of the vehicle is derived,
and an initial version of the Kalman ﬁlter is implemented and tested. First the
function of the observer in the context of the inner control loop wil l be explained
and then a model for the expected acceleration of the vehicle wil l be derived. It
wil l be shown that this model cannot take al l driving situations into consideration,
resulting in a large error in the calculated acceleration. To deal with this error, a
Kalman ﬁlter is implemented. In the end of this chapter a discussion wil l be held
on how to best choose the ﬁlter parameters.
5.1 Overview of the Inner Control Loop
Before implementing the Kalman ﬁlter, a short explanation of its surroundings,
the inner control loop of the vehicle longitudinal controller, is needed.
An overview of the inner control loop is given in Figure 5.1. (For a complete
diagram of the outer and inner control loop, refer to Figure 1.1.) The controlled
system is the vehicle with its actuators engine, brake and gearbox. The desired
engine torque T
e
and the desired brake torque T
b
are calculated and given as input
to the actuators. The output from the controlled system is the actual motion
of the vehicle and can be thought of as the actual speed v
real
and the actual
acceleration a
real
.
The block “Sensors” in the ﬁgure contains signal processing software which
analyzes the motion of the vehicle and gives information back to the controller.
The measured speed v
m
and acceleration a
m
are derived from wheel speed sensors.
Input to the controller is the desired acceleration a
des
. The momentary devi
ation a
dev
from the desired value is calculated as
a
dev
= a
des
−a
m
(5.1)
This deviation is fed into a PIDcontroller which calculates a control value to the
33
34 Kalman Filter Implementation

a
des
+
f 
a
dev
PID

+
f 
a
c
F
1

T
F
2
T
e
, T
b
q
Vehicle
v
real
, a
real
Sensors
v
m
Observer
a
z
6
−
6
−
a
m
Figure 5.1. Inner control loop of the longitudinal controller. Input to the controller
is the desired acceleration a
des
. Sensors are measuring the real speed v
real
and accel
eration a
real
of the vehicle, and the task is to get a
real
= a
des
. The deviation a
dev
is
given as input to a PIDcontroller. The control value a
c
is converted by two conver
sion functions F
1
and F
2
into the torques T
e
and T
b
, which are given as input to the
vehicle’s actuators engine and brake, respectively. The observer looks at the torques T
e
and T
b
and calculates the expected acceleration of the vehicle. The output a
z
from the
observer is the estimated diﬀerence between the expected acceleration and the measured
acceleration. This is summarized with the output from the PIDcontroller, forming a
c
.
actuators which minimizes the deviation. The output from the PIDcontroller will
form the variables T
e
and T
b
described above, after passing through two conversion
steps F
1
and F
2
.
The block F
1
calculates the needed torque T on the wheel axis from the corre
sponding acceleration a
c
, using the equation
T = r
w
(a
c
˜ m+F
resistance
) (5.2)
Since ˜ m is the standard mass of the vehicle plus the moments of inertia of the
wheel axis and other rotating parts, then a
c
˜ m is the force needed to get the desired
acceleration a
c
. The other force taken into consideration here, F
resistance
, is acting
on the vehicle in its opposite direction of travel and is called “drive resistance”.
It consists of the force due to air resistance, losses due to tire deﬂection, etc, and
will be described in detail in Section 5.2. By adding F
resistance
to a
c
˜ m and then
multiplying with the wheel radius r
w
, T is the torque needed on the wheel axis to
give the vehicle the acceleration a
c
.
The output torque T is fed into another block, called F
2
in the ﬁgure, before
delivery to the actuators. F
2
coordinates the work of the engine, brake and gear
box. Depending on the calculated torque T, action is taken either by the brake or
the engine, whereas the engine also can be used to decelerate.
a
c
is, as explained above, the control value from the controller given as input
to the block F
1
. It consists of two parts: the output from the PIDcontroller, and
the output from the block “Observer”. The task of the observer is to estimate
5.2 Modeling the Acceleration 35
T
e

G
e

T
engine
T
b

G
b

T
brake
Longitudinal Dynamics

v
real
a
real
Vehicle Model
Figure 5.2. Modeling engine and brake. The blocks G
e
and G
b
model the dynamics
of the engine and brake respectively. T
e
and T
b
are the desired torques given as input.
The engine and brake models calculate the estimated output torques T
engine
and T
brake
.
The model of the longitudinal dynamics uses these values to calculate the speed and
acceleration of the vehicle.
the drive resistance parameters and other unknown parameters not taken into
consideration by F
1
. This is performed by looking at the torques T
e
and T
b
given
to the actuators, and calculate an expected acceleration. The diﬀerence between
the expected acceleration and the measured acceleration gives a hint about the
model error. This error, called a
z
, is subtracted from the output from the PID
controller to form a
c
.
The block called “Vehicle” is further described in Figure 5.2. The blocks “G
e
”
and “G
b
” model the dynamics of the engine and brake as transfer functions with
torques T
engine
and T
brake
as outputs. These transfer functions and the equations
describing the vehicle longitudinal dynamics will be presented in the next section.
5.2 Modeling the Acceleration
A model for the expected longitudinal acceleration of the vehicle will now be
presented. Assume just for this section that the speed of the vehicle is v and
the acceleration of the vehicle in its driving direction is a. These are the variable
names used in this section for deriving the model, in later sections the acceleration
calculated by the model will be called a
exp
, and for the vehicle speed the measured
value v
m
will be used.
Using the classical mechanical law from Newton,
F = ma, the forces acting
on the vehicle can be written as
ma = F
drive
−F
brake
−F
resistance
(5.3)
where F
drive
is the force acting on the vehicle through the transmission and engine,
and F
brake
is the force from the braking system. The drive resistance F
resistance
is modeled as
F
resistance
= F
air
+F
roll
(5.4)
36 Kalman Filter Implementation
When a wheel is rolling, energy losses occur due to deﬂection of the tire. This
is modeled as a force acting on the wheel in the opposite direction of rolling
F
r
= c
rr
N (5.5)
where N is the normal force acting on the wheel from the ground and c
rr
is the
rolling resistance coeﬃcient [20]. N is in this case deﬁned as
N =
mg
n
(5.6)
where m is the mass of the vehicle, g is the gravitational acceleration and n is the
number of wheels. Assuming that all wheels have the same c
rr
, the total rolling
resistance acting on the vehicle from all wheels can be calculated
F
roll
= F
r
n = c
rr
mg
n
n = c
rr
mg (5.7)
The air resistance F
air
is modeled as follows. When an object is moving through
air at relatively high speed, the object experiences a force acting on it against its
direction of travel. This force can according to [14] be written as
F
air
=
1
2
ρc
d
A
w
(v +v
wind
)
2
(5.8)
where ρ is the density of the air, c
d
is the drag coeﬃcient and A
w
is a reference
area related to the projected front area of the object. v
wind
is the unknown speed
of the wind and it will therefore be neglected in this model.
F
drive
and F
brake
depend on the torques acting on the wheel axis, T
drive
and
T
brake
, and the wheel radius r
w
as
F
drive
=
T
drive
r
w
(5.9)
F
brake
=
T
brake
r
w
(5.10)
The torque acting on the wheel axis T
drive
depends on the output torque from the
engine T
engine
, the gearbox and diﬀerential ratios i
g
and i
d
, the eﬃciency factor
for the drivetrain η, the moment of inertia for engine and gear, I
e
and I
g
, and the
moment of inertia for the front and rear wheel axis, I
f
and I
r
, as follows [20]
T
drive
= ηi
d
i
g
T
engine
−(i
2
d
i
2
g
I
e
+i
2
d
I
g
)
a
r
w
−(I
f
+I
r
)
a
r
w
(5.11)
Inserting (5.4), (5.7), (5.8), (5.9), (5.10) and (5.11) in (5.3) yields
ma =
1
r
w
ηi
d
i
g
T
engine
−(i
2
d
i
2
g
I
e
+i
2
d
I
g
)
a
r
2
w
−(I
f
+I
r
)
a
r
2
w
−
1
r
w
T
brake
−
1
2
ρc
d
A
w
v
2
−c
rr
mg (5.12)
5.2 Modeling the Acceleration 37
Now let
˜ m = m+
I
f
+I
r
r
2
w
+i
2
d
i
2
g
I
e
r
2
w
+i
2
d
I
g
r
2
w
(5.13)
Inserting (5.13) in (5.12) gives
˜ ma =
ηi
d
i
g
r
w
T
engine
−
1
r
w
T
brake
−
ρc
d
A
w
2
v
2
−c
rr
mg (5.14)
Dividing with ˜ m yields the equation for the vehicle acceleration as
a =
ηi
d
i
g
r
w
˜ m
T
engine
−
1
r
w
˜ m
T
brake
−
ρc
d
A
w
2 ˜ m
v
2
−
c
rr
mg
˜ m
(5.15)
In previous work at DaimlerChrysler [19], models for the engine and brake were
prepared. The results are averages of several tests with diﬀerent vehicles and will
be presented here and used in this Master’s thesis. See [19] for more details.
The engine is modeled as a transfer function G
e
(s) as
G
e
(s) = L{g
e
(t)} =
k
1
ω
2
0
s
2
+ 2Dω
0
s +ω
2
0
e
−sT
t1
(5.16)
which relates the input torque T
e
to the output torque from the engine, T
engine
,
as
T
engine
(t) = g
e
(t) ∗ T
e
(t) (5.17)
In the same way, the brake is modeled as a transfer function G
b
(s) as
G
b
(s) = L{g
b
(t)} =
k
2
T
t2
s + 1
e
−sT
t3
(5.18)
which relates the input torque T
b
to the output torque from the brake, T
brake
, as
T
brake
(t) = g
b
(t) ∗ T
b
(t) (5.19)
The parameters in the models were found in [19] using system identiﬁcation and
chosen to the mean values of diﬀerent test drives with diﬀerent vehicles as
k
1
= 1
ω
0
= 16.7 rad/s
D = 0.82
T
t1
= 90 ms
k
2
= 0.98
T
t2
= 80 ms
T
t3
= 140 ms
Adding this information to (5.15) gives the model for the longitudinal acceler
ation of the vehicle used by the Kalman ﬁlter
a(t) =
ηi
d
i
g
r
w
˜ m
(g
e
(t) ∗ T
e
(t)) −
1
r
w
˜ m
(g
b
(t) ∗ T
b
(t)) −
ρc
d
A
w
2 ˜ m
v(t)
2
−
c
rr
mg
˜ m
(5.20)
In Section 5.4 this calculated (expected) acceleration will be called a
exp
.
38 Kalman Filter Implementation
0 10 20 30 40 50 60
1.5
1
0.5
0
0.5
1
1.5
Speedtronic: step down and up again
Time [s]
A
c
c
e
l
e
r
a
t
i
o
n
[
m
/
s
2
]
a expected
a measured
Figure 5.3. Test drive using cruise control. The vehicle is traveling with a speed
of 60 km/h when the driver changes the set desired speed to 30 km/h, then after
nearly 30 seconds changes back to 60 km/h again. The ﬁgure shows the calculated ex
pected acceleration (solid line) and the measured acceleration (dashed line). The mea
surement has been recorded during a test with a relatively nervous controller, causing
the large oscillations between 10 and 20 seconds.
5.3 Errors in the Acceleration Model
A thorough validation of the acceleration model is not a subject of this Master’s
thesis. But to verify that the model seems reasonable, some tests will now be
presented. During test drives, the signal a
m
from the sensors is recorded. This
measurement of the actual acceleration is then compared with the expected accel
eration calculated by the model in (5.20). In this section ﬁve such recordings will
be presented.
Figure 5.3 shows a test drive using cruise control (explained in Section 2.5).
The vehicle is traveling with a speed of 60 km/h when the driver changes the set
desired speed to 30 km/h, then after nearly 30 seconds changes back to 60 km/h
again. The ﬁgure shows the calculated expected acceleration (solid line) and the
measured acceleration (dashed line).
Figure 5.4 shows a similar test drive using cruise control, this time with set
speeds 60 km/h, 30 km/h, 60 km/h and then 30 km/h again.
In both Figure 5.3 and Figure 5.4 it can be observed that the agreement be
tween the measured and calculated expected acceleration is relatively good. The
main characteristics of the acceleration has been captured by the model. Some dif
ferences between the calculated and the measured signal can be seen in the ﬁgures.
This is expected, as the model does not exactly describe the speciﬁed vehicle. The
model parameters have been chosen as the mean values from several test drives
5.3 Errors in the Acceleration Model 39
0 10 20 30 40 50 60
2
1.5
1
0.5
0
0.5
1
1.5
Speedtronic: step up
Time [s]
A
c
c
e
l
e
r
a
t
i
o
n
[
m
/
s
2
]
a expected
a measured
Figure 5.4. Test drive using cruise control. The vehicle is traveling with a speed
of 60 km/h when the driver changes the set desired speed ﬁrst to 30 km/h, then back
to 60 km/h, and at last to 30 km/h again. The solid line is the calculated expected
acceleration and the dashed line is the measured acceleration.
with diﬀerent vehicles [19]. Therefore the model does not exactly comply with the
vehicle being used here.
Figure 5.5 shows the vehicle traveling with a constant speed of 30 km/h on
a bumpy road. The vehicle looses speed and the controller tries to compensate,
resulting in an oscillatory behavior. As can be seen, also here the agreement
of the measured and calculated acceleration can be recognized. An outstanding
feature of the calculated value is that it is always a bit, and sometimes up to 0.5 s
“faster” than the measured value. The reason for this could be that the identiﬁed
timedelays in the models for the engine and brake are too small when applied
to the vehicle used in the tests. Another reason is that the measurement of the
acceleration in the vehicle contains a lowpass ﬁlter with some timedelay. In
Figure 5.5, the calculated value is always a bit higher than the measured value.
The reason for this might be that the rolling resistance on the bumpy road is
higher than expected, and that the mass of the vehicle is higher than set in the
model, due to one extra passenger.
As can be seen in Figure 5.6 and Figure 5.7, the model does not perform as well
when changing the working conditions. In Figure 5.6 a test has been made using
the same vehicle but with an attached trailer with a mass of 2000 kg. The vehicle
is traveling using cruise control, with a desired speed of 60 km/h. After 16 seconds
the desired speed is changed to 80 km/h. As can be seen, the calculated expected
acceleration does not comply with the the measured acceleration in this case. The
large errors in the calculations is because of a wrong value of the parameter m,
the mass of the vehicle. In the current model, the vehicle mass is a constant
40 Kalman Filter Implementation
20 25 30 35 40 45 50
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
Constant speed, bumpy road
Time [s]
A
c
c
e
l
e
r
a
t
i
o
n
[
m
/
s
2
]
a expected
a measured
Figure 5.5. Test drive using cruise control on a bumpy road. The vehicle is traveling
with a constant speed of 30 km/h. It looses speed and the controller tries to compensate,
in this test resulting in an oscillating behavior. The test has been done using a relatively
nervous controller.
0 5 10 15 20 25 30 35 40 45
0.5
0
0.5
1
1.5
2
2.5
Speedtronic: step up and down, trailer 2000 kg
Time [s]
A
c
c
e
l
e
r
a
t
i
o
n
[
m
/
s
2
]
a expected
a measured
Figure 5.6. Test drive with a heavy trailer (2000 kg). The vehicle and trailer are
traveling using cruise control, with a desired speed of 60 km/h. After 16 seconds the
desired speed is changed to 80 km/h. As can be seen the calculated expected acceleration
does not comply with the the measured acceleration. The large errors in the calculations
is because of a wrong value of the parameter m, the mass of the vehicle.
5.3 Errors in the Acceleration Model 41
0 5 10 15 20 25
6
5
4
3
2
1
0
1
2
3
Driving up and down a hill, incline: 20% up, 15% down
Time [s]
A
c
c
e
l
e
r
a
t
i
o
n
[
m
/
s
2
]
a expected
a measured
Figure 5.7. Test drive up and down a steep hill using cruise control. First the slope of
the road is 0 % (horizontal road), then changed to 20 % (uphill), then to −15 % (downhill).
The calculated acceleration does not comply with the measured acceleration. The reason
is that the model does not include the case of a changed road slope.
parameter. Figure 5.7 shows a test drive with the same vehicle, this time without
trailer but with a changing slope. The vehicle is driven up and down a steep
hill. First the slope of the road is 0 % (horizontal road), then changed to 20 %
(uphill), then to −15 % (downhill). As expected, the calculated acceleration does
not comply with the measured acceleration. The model does not include the case
of a changing slope.
It should be mentioned that all models have errors. It does not matter how
complex the model is, it will in practice never exactly describe the real physical
system. In many implementations there are good reasons to keep the model simple.
Especially for real time systems it is a good practice to keep models as simple as
possible to avoid time consuming computations and dubious parameters.
In this case the model for the vehicle acceleration in (5.20) does not comply
with the real system in all situations. The following are some examples of what
might happen. Two of the cases have already been mentioned before in this text.
• The total mass of the vehicle is not m as in the model, due to extra pas
sengers, baggage or a trailer. This aﬀects the calculation of ˜ m in (5.13) as
well as F
roll
in (5.7) and has a large eﬀect on the calculation of the expected
acceleration in (5.20). The value of the parameter m is set to the mass of
the vehicle including full tank, plus 80 kg for the weight of the driver. If the
attached trailer is equipped with brakes, the large change in the mass will
only be experienced when accelerating. When braking, the trailer brake will
help and compensate partially for the extra weight.
42 Kalman Filter Implementation
• The parameter c
rr
in (5.7) is in the model set to a constant value. In practice,
however, the rolling resistance changes depending on the driving conditions,
for example in case of tirepressure drop or when driving on sand. According
to [8] the real value of the parameter can vary up to 3.5 times the standard
value.
• In the calculation of the air resistance F
air
in (5.8), the speed of the wind
v
wind
cannot be taken into account. In real life the wind speed can have
a large impact on the actual resistance. The drag coeﬃcient c
d
might also
change, as well as the reference area A
w
(for example due to extra baggage).
According to [8] the real value of F
air
can be up to 9 times the calculated
value.
• All the parameters in (5.16) and (5.18) have been estimated with system
identiﬁcation. From several test drives the mean values have been selected.
These parameters diﬀer from those found in a real vehicle. As an example
the interval for the engine parameters in (5.16) were found to be [19]
15.1 < ω
0
< 19.2
0.54 < D < 1.05
0.07 < T
t1
< 0.12
• The slope has been totally neglected in the derived model. When driving the
vehicle in a slope, a force F
slope
arises having a direct eﬀect on the vehicle’s
acceleration. Assume that the slope of the road is α , the longitudinal force
acting on the vehicle is given by
F
slope
= mg sin α (5.21)
• Engine and brake might not behave as expected due to inaccuracy, errors or
change in the friction coeﬃcient of the brakes. This is observed to happen
relatively often. For example, the friction coeﬃcient of the brake may vary
between +10% and −15% during a normal vehicle stop maneuver.
Actually there is a longitudinal acceleration sensor mounted in the vehicles
that could be used to estimate the slope α. The sensor measures the sum of the
vehicle’s acceleration and the gravitational component parallel to the ground, as
a
sensor
= a +g sin α (5.22)
where a
sensor
is the sensor value and a is the longitudinal acceleration of the
vehicle. One problem with the sensor is that it might be diﬃcult making good
estimates of the road slope while cornering. In [16] it is proposed how to do road
slope and vehicle mass estimation using Kalman ﬁltering.
5.4 Kalman Filter Model 43
5.4 Kalman Filter Model
The model for the vehicle longitudinal acceleration a in (5.20) has to be changed
to comply with “the real world”. Therefore, let the calculated expected accelera
tion a
exp
be deﬁned as
a
exp
=
ηi
d
i
g
r
w
˜ m
T
engine
−
1
r
w
˜ m
T
brake
−
ρc
d
A
w
2 ˜ m
v
2
m
−
c
rr
mg
˜ m
(5.23)
This is the model that was derived in Section 5.2. Then the real vehicle accelera
tion a
real
is
a
real
= a
exp
+a
z
(5.24)
where a
z
is called “disturbance acceleration”. This state variable represents the
part of the vehicle’s acceleration caused by disturbances not described by the
model for the longitudinal dynamics. It should cover all the model errors found in
the previous section, and is connected parallel to the PIDcontroller as described
in Section 5.1 and shown in Figure 5.1. Given a good description on how the
state a
z
is changing, the Kalman ﬁlter can be used to estimate this state.
The process noise is modeled in continuous time under the assumption that
the state a
z
undergoes slight changes each sampling period. According to [3] such
changes can be modeled by a continuous time Gaussian noise w as
˙ a
z
(t) = w(t) (5.25)
where
E[w(t)] = 0 (5.26)
E[w(t)w(τ)] = qδ(t −τ) (5.27)
The scalar value q is here the process noise intensity (assumed to be timeinvariant)
and δ(·) is the Dirac (impulse) delta function [3].
Using the statespace model presented in (3.1) and (3.2), and choosing the
state vector x = a
z
, the continuous time statespace model for the Kalman ﬁlter
becomes
˙ x =
_
0
¸
. ¸¸ .
A
x +
_
1
¸
. ¸¸ .
G
w (5.28)
y =
_
1
¸
. ¸¸ .
C
x +e (5.29)
Here y = x+e = a
z
+e means that the Kalman ﬁlter needs a measurement of the
signal a
z
. This can be provided by feeding it with a new constructed signal a
∆
.
With the deﬁnition a
m
= a
real
+e together with (5.24), a
∆
can be deﬁned as
a
∆
= a
m
−a
exp
= a
z
+e (5.30)
44 Kalman Filter Implementation
In this way, the Kalman ﬁlter will estimate the state a
z
, given the information
that a
∆
is a noisy measurement of the true value. How noisy the measurement is
can be deﬁned by modeling e. Here e will be modeled as Gaussian noise in the
same way as w
E[e(t)] = 0 (5.31)
E[e(t)e(τ)] = rδ(t −τ) (5.32)
The scalar value r is here the measurement noise intensity. It is assumed to be
timeinvariant.
The system is observable, as can be veriﬁed using the rank test in Section 3.4.
This means that the state is uniquely determinable from the inputs and outputs
in the model.
The statespace model is discretized into a digital statespace model with sam
ple time T, using the theory in Section 3.2. In this case it is easy, resulting in
x
k+1
=
_
1
¸
. ¸¸ .
A
d
x
k
+
_
1
¸
. ¸¸ .
G
d
w
k
(5.33)
y
k
=
_
1
¸
. ¸¸ .
C
d
x
k
+e
k
(5.34)
5.5 Choosing the Filter Parameters
Diﬀerent values of the noise intensities q and r will now be chosen and the per
formance evaluated using openloop simulation described in Section 4.3.1. It is
possible to use other methods from Chapter 4, for example the script for autotun
ing developed in Section 4.4. However, since the estimated signal a
z
in this case
will be directly connected to the engine and brakes (see Figure 5.1), the signal
will direct aﬀect the comfort of the driver and passengers. Therefore this section
will show the function of the developed Kalman ﬁlter by choosing the parameters
manually.
As explained in Section 4.2 the quotient between q and r is the design param
eter, the absolute values do not matter. Therefore r is set to 1 and the Kalman
ﬁlter is simulated using diﬀerent values for q. The ﬁgures that follow have been
generated using measured data from test drives. The Kalman ﬁlter is fed with the
signal y = a
∆
= a
m
−a
exp
, and those values are also shown in the ﬁgures as dots.
Figure 5.8 shows two diﬀerent Kalman ﬁlters, one with q = 1 and the other
with q = 0.01. As can be seen, the one using q = 1 is faster and follows the
measured values more accurately. This was expected, as choosing a high q always
means a faster ﬁlter. The faster ﬁlter is more sensitive to measurement noise,
while the slower ﬁlter delivers a smoother estimate of a
z
. The measurement is
taken from a test drive on a bumpy road.
Figure 5.9 shows the same parameter choices, but this time with a measurement
of a vehicle driven up and down a steep hill. The output from the Kalman ﬁlter
with q = 1 follows the measurement almost exactly. It can be seen that, comparing
5.5 Choosing the Filter Parameters 45
2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7
1.2
1
0.8
0.6
0.4
0.2
0
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
= a
m
a
exp
Kalman filter (q=1)
Kalman filter (q=0.01)
Figure 5.8. Simulation of two fast ﬁlters with diﬀerent parameters (q = 1 and q = 0.01)
using a measurement of a test drive on a bumpy road. The ﬁlter with q = 1 is fastest
and follows the measured values most accurate. This was expected, as choosing q high
always means a faster ﬁlter. The faster ﬁlter is also more sensitive to measurement noise.
The slower ﬁlter delivers a smoother estimate of a
z
.
with the faster ﬁlter, a smaller q makes the time delay for large signal changes
unavoidable larger. The Kalman ﬁlter q = 0.01 still reacts relatively fast and
when only looking at these two ﬁgures (5.8 and 5.9) q = 0.01 seems a logical
choice.
However, every unnecessary oscillation or jerk in the estimate a
z
will have a
direct eﬀect of the control values for the engine and brakes. It has been observed
during test drives that the comfort is negatively aﬀected by having a too fast ﬁlter.
With this in mind, two slower ﬁlters are evaluated, shown in the next two ﬁgures.
This time q = 0.001 and q = 0.0003 are simulated. Figure 5.10 shows the drive
on the bumpy road. The Kalman ﬁlter now ignores the oscillations even more,
making it better for controlling purposes. The price one has to pay, as shown in
Figure 5.11, is an even slower ﬁlter.
The time delay for the ﬁlter with q = 0.0003 is so large that the driver will
probably feel it when driving up and down the hill shown in Figure 5.11. The
hill is rather steep, and the change from the horizontal road to a slope of 20%
comes very fast. The task of choosing the optimal parameters is in this case a
compromise between ignoring small changes in the signal, or react fast to large
changes. A linear ﬁlter of this type cannot do both.
Figure 5.12 shows the slowest ﬁlter (with q = 0.0003) during a drive on a very
bumpy road. The oscillations of the signal y = a
∆
= a
m
−a
exp
are even larger
than in the previous ﬁgures. Even the slowest of the tested Kalman ﬁlters is in
46 Kalman Filter Implementation
4 6 8 10 12 14 16 18
2
1.5
1
0.5
0
0.5
1
1.5
2
2.5
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
= a
m
a
exp
Kalman filter (q=1)
Kalman filter (q=0.01)
Figure 5.9. Simulation of the two fast ﬁlters using a measurement of a test drive of a
vehicle driving up and down a steep hill. The output from the Kalman ﬁlter with q = 1
follows the measurement almost exactly. It can be seen that, comparing with the faster
ﬁlter, a smaller q makes the time delay for large signal changes unavoidably larger. The
Kalman ﬁlter q = 0.01 still reacts relatively fast.
this case “not slow enough”. But choosing a slower ﬁlter will also make the time
delay for changes even larger. The ideal ﬁlter would ignore these oscillations, but
still react fast to large changes.
5.5 Choosing the Filter Parameters 47
2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7
1.2
1
0.8
0.6
0.4
0.2
0
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
= a
m
a
exp
Kalman filter (q=0.001)
Kalman filter (q=0.0003)
Figure 5.10. Simulation of two slow ﬁlters (q = 0.001 and q = 0.0003) using measure
ments from a test drive on a bumpy road. The slow Kalman ﬁlters ignore the oscillations
even more, making them better for controlling purposes.
4 6 8 10 12 14 16 18
2
1.5
1
0.5
0
0.5
1
1.5
2
2.5
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
= a
m
a
exp
Kalman filter (q=0.001)
Kalman filter (q=0.0003)
Figure 5.11. Simulation of the two slow ﬁlters (q = 0.001 and q = 0.0003) using
measurements from a test drive with a vehicle driving up and down a steep hill. When
trying to avoid small changes and oscillations, the price one has to pay is a slower ﬁlter.
48 Kalman Filter Implementation
14 16 18 20 22 24 26 28 30
0.8
0.6
0.4
0.2
0
0.2
0.4
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
= a
m
a
exp
Kalman filter (q=0.0003)
Figure 5.12. Simulation of the slowest Kalman ﬁlter using a measurement of a very
bumpy road. Even this ﬁlter is in this driving situation “not slow enough”. But choosing
such a slow ﬁlter will also make the time delay for changes even larger.
Chapter 6
Alternative Kalman Filter
Models
As shown in Chapter 5, the behavior of the Kalman ﬁlter is easy to understand
when using simple models. Another advantage of using simple models is low com
putational eﬀort. This chapter derives some more complex models, with the aim
of explaining how the Kalman ﬁlter implemented in the test vehicles is working.
First a model is presented which can be used when it is not possible to measure
the acceleration. Then other models of the parameter a
z
is derived. At the end of
this chapter it is shown that the implemented Kalman ﬁlter behaves like a lowpass
ﬁlter.
6.1 Vehicle Speed as Feedback
In some situations it is not practical to use the signal a
∆
= a
m
−a
exp
as feedback
to the ﬁlter, for example when the signal a
m
is not available. This is the case
at DaimlerChrysler when using hill descent control (explained in Section 2.6). In
this situation the measurement of the acceleration by conventional methods is not
considered good enough. In this case the measurements of the vehicle speed, v
m
,
can be used instead. The Kalman ﬁlter is then designed using the state vector
x =
_
x
1
x
2
_
=
_
v
real
a
z
_
(6.1)
so that
˙ v
real
= a
real
= a
z
+a
exp
(6.2)
˙ a
z
= w (6.3)
Input to the ﬁlter is the signal a
exp
, as deﬁned in (5.23), and the (assumed noisy)
measurement v
m
of the vehicle speed v
real
, with
v
m
= v
real
+e (6.4)
49
50 Alternative Kalman Filter Models
where e is the measurement noise and w is the process noise, modeled as described
in Section 5.4. Notice that e is the noise in the measurement of the speed, and
not the acceleration as in Section 5.4. The statespace model becomes
˙ x =
_
0 1
0 0
_
. ¸¸ .
A
x +
_
1
0
_
. ¸¸ .
B
a
exp
+
_
0
1
_
. ¸¸ .
G
w (6.5)
y =
_
1 0
¸
. ¸¸ .
C
x +e (6.6)
The noises w and e are modeled as Gaussian noises with intensities r and q.
Simulating the ﬁlter with the same measurements as in Chapter 5 shows that the
basic behavior remains the same. Figure 6.1 shows the output from the ﬁlter when
fed with the measurement from the test drive on the bumpy road. The process
noise intensity q has been chosen to 5 and measurement noise intensity r is 1.
Figure 6.2 shows the same ﬁlter simulated with the measurement from the drive
up and down the steep hill. The dotted line is a
∆
= a
m
−a
exp
as deﬁned in (5.30),
which still can be used as a reference. The dashed line in the ﬁgures is the output
from the ﬁlter in Section 5.5, which used a
∆
as feedback. As can be seen the
overall behavior is the same.
The Kalman ﬁlter now has to estimate both v
real
and a
z
, resulting in higher
computational costs. Choosing a smaller q makes the ﬁlter slower, and choosing a
larger q makes it faster, just as before. Of course the value of q is not the same as
in Section 5.5 because the measurements are no longer the same.
6.2 Modeling the Disturbance a
z
The model of a
z
so far says that its ﬁrst derivative is equal to Gaussian noise. This
means that a
z
undergoes slight changes each sampling period. These changes are
uncorrelated, which means that the derivative changes each period to a value
independent of the last value. This model allows the derivative of a
z
to jump
quickly from a positive value to a negative, which does not comply with the “real”
parameter the ﬁlter is trying to estimate. a
z
represents large changes in the
environment of the vehicle, such as changes in the mass of the vehicle or the slope
of the road. These parameters do not change so quickly, and therefore another
model will now be examined.
6.2.1 FirstOrder Lag Function
For a ﬁrstorder lag function with input signal u, the output signal y satisﬁes the
ordinary diﬀerential equation
τ ˙ y +y = u (6.7)
where τ is the time constant of the step response. The transfer function is
G(s) =
1
1 +τs
(6.8)
6.2 Modeling the Disturbance a
z
51
2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7
1.8
1.6
1.4
1.2
1
0.8
0.6
0.4
0.2
0
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
=a
m
a
exp
Kalman filter with v as feedback
Kalman filter from Chapter 5 (q=0.0003)
Figure 6.1. Simulation of the Kalman ﬁlter using the measurement from the drive on
a bumpy road. Input to the ﬁlter is the measurement of the vehicle speed. q has been
chosen to 5. The solid line is the Kalman ﬁlter with the measurement of v as feedback.
The dashed line is the ﬁlter developed in Section 5.5. As can be seen the overall behavior
of the ﬁlter remains the same.
To evaluate the frequency response for the function, set s = jω and plot the
magnitude of the function
G(jω) =
1
√
1 +ω
2
τ
2
(6.9)
ω is here the frequency of the input in radians per second. Figure 6.3 shows the
Bode plot of the transfer function with three diﬀerent values of τ. Deﬁne the break
frequency ω
0
as
ω
0
=
1
τ
(6.10)
Then the magnitude of the function is approximately
G(jω) ≈
_
1 when ω < ω
0
ω
0
jω
when ω > ω
0
(6.11)
The ﬁrstorder lag function dampens all signals with frequencies higher than the
break frequency ω
0
and can be used as a lowpass ﬁlter. As can be seen in the
plot, a larger τ means a lower break frequency, which complies with the deﬁnition
in (6.10). A larger τ also means a slower response. [9]
52 Alternative Kalman Filter Models
4 6 8 10 12 14 16 18
2
1.5
1
0.5
0
0.5
1
1.5
2
2.5
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
=a
m
a
exp
Kalman filter with v as feedback
Kalman filter from Chapter 5 (q=0.0003)
Figure 6.2. Simulation of the Kalman ﬁlter using the measurement from the vehicle
driving up and down a steep hill. q is set to 5. The solid line is the Kalman ﬁlter with
the measurement of v as feedback. The dashed line is the ﬁlter developed in Section 5.5.
As can be seen the overall behavior of the ﬁlter remains the same.
6.2.2 FirstOrder GaussMarkov Process
The ﬁrstorder lag function can be used to model physical systems. The input u
in (6.7) is then set to w, where w represents Gaussian noise. With this choice of u
the function is called a ﬁrstorder GaussMarkov process [22]. This function has
turned out to be important in applied work since it seems to ﬁt a large number of
physical systems with reasonable accuracy but still has a very simple mathematical
description [5].
The described function will now be used to model a
z
. Let
˙ a
z
+
1
τ
a
z
= w (6.12)
Now the problem is to choose a reasonable τ and the intensity of the noise w.
According to [3] the autocorrelation of the GaussMarkov process in (6.12) can be
written as
E[a
z
(t
1
)a
z
(t
2
)] = e
−
1
τ
t
1
−t
2

E[a
z
(t
1
)
2
] (6.13)
The autocorrelation is a measure of how well the signal matches a timeshifted
version of itself, where t
1
and t
2
deﬁnes the time shift. This means that the value
of a
z
at a sample time t
k
will depend on the value at the last sample time t
k−1
, as
a
z
(t
k
) = e
−
1
τ
T
a
z
(t
k−1
) +w(t
k−1
) (6.14)
6.2 Modeling the Disturbance a
z
53
Bode Diagram
Frequency (rad/sec)
P
h
a
s
e
(
d
e
g
)
M
a
g
n
i
t
u
d
e
(
d
B
)
50
40
30
20
10
0
τ=1
τ=0.5
τ=0.25
10
1
10
0
10
1
10
2
90
45
0
Figure 6.3. Bode plot of the ﬁrstorder lag function, with three diﬀerent values of τ.
Larger τ means a lower break frequency.
where T is the sampling interval [5]. If τ is chosen very large (τ approaches ∞),
a
z
will be integrated Gaussian noise just as before. If τ is small the correlation is
high.
6.2.3 Identifying the Time Constant
The technique of system identiﬁcation is used to build mathematical models of a
dynamic system based on measurement data. This is done by adjusting param
eters within a given model until its output coincides as well as possible with the
measured output [17]. Matlab contains a toolbox called “System Identiﬁcation
Toolbox” [18]. It contains all the common techniques to adjust parameters in all
kinds of linear models, including statespace models, as well as some nonlinear
models. In this section an introduction is given on how to use this toolbox to
identify the unknown parameters in a model.
A Matlab script is found in Appendix C, which creates a model of a
z
described
by (6.12) and deﬁnes τ and the intensity of w as parameters to be identiﬁed. As
identiﬁcation data measurements of the slope of the road during a test drive up and
down the steep hill is used. This data set will represent the “maximum dynamic”
of a
z
that the ﬁlter will have to estimate. When driving a vehicle at 30 km/h
over this steep hill, the highest demands on the ﬁlter is said to be reached. As
54 Alternative Kalman Filter Models
identiﬁcation data the part of a
z
caused by the slope of the road is chosen. This
is done by setting
a
real
z
≡ g sin(α) (6.15)
where g is the gravitational acceleration and α is the slope of the road.
When the noise intensity is set to a constant value, the script can be used to
choose the optimal value of τ. An intensity value of 1 results in the optimal choice
τ ≈ 7. In Figure 6.4 the output from the model is compared with the measurement.
As can be seen, the identiﬁed model does not ﬁt the identiﬁcation data exactly.
4 6 8 10 12 14 16 18
2.5
2
1.5
1
0.5
0
0.5
1
1.5
y
1
Measured Output and 1step Ahead Predicted Model Output
Measured Output
Model Fit: 83.67%
Figure 6.4. Identiﬁcation of time constant τ. Setting the noise intensity to a constant
value and identify the parameter gives τ = 7, results in a model ﬁt of 83.67%. Letting
the script identify the noise intensity with τ = 7 will give a model ﬁt of over 99%.
Setting the parameter τ to 7 and letting Matlab identify the noise intensity,
results in a model ﬁt of over 99%. The noise intensity is then identiﬁed to 70.
This means that by choosing τ = 7, it is possible to ﬁnd a perfect ﬁt by adjusting
the parameter for the noise intensity. In fact, by choosing any value of τ larger
than 0.1 and then letting Matlab ﬁnd the optimal noise intensity, results in a
model ﬁt of at least 90%, and τ > 0.3 gives a ﬁt of over 95%. For τ = 0.3 the
optimal noise intensity is identiﬁed to 91. A smaller choice of τ demands a larger
noise intensity to make a good model ﬁt.
Figure 6.5 shows the calculated signal a
real
z
and the predicted output from the
model with τ = 0.3 and noise intensity calculated by Matlab.
The quality of the model can be tested by looking at what the model could not
reproduce in the data, the “residuals”
(t) = y(t) − ˆ y(t) (6.16)
6.2 Modeling the Disturbance a
z
55
4 6 8 10 12 14 16 18
2.5
2
1.5
1
0.5
0
0.5
1
1.5
y
1
Measured Output and 1step Ahead Predicted Model Output
Measured Output
model Fit: 96.26%
Figure 6.5. Identiﬁcation of time constant τ. Here τ = 0.3 is chosen and the noise
intensity is identiﬁed to 91, giving a model ﬁt of 96.26%.
where y is the validation data and ˆ y is the output from the model. The residuals
should not be correlated with the past inputs u. If they are, then there is a part
of y that originates from the past input that has not been picked up properly by the
model. The command “resid” in Matlab computes the correlation function of
the residuals from the model, as well as 99% conﬁdence intervals assuming that the
residuals are Gaussian. The rule is that if the correlation function go signiﬁcantly
outside these conﬁdence intervals, do not accept the corresponding model as a good
description of the system. In that case the model can be improved, for example
by adjusting the number of parameters in the model [17].
6.2.4 Testing the Model of a
z
Modeling a
z
using the equation for the ﬁrstorder GaussMarkov process (6.12)
with state vector x = [x
1
, x
2
]
T
= [v, a
z
]
T
gives the statespace model
˙ x =
_
0 1
0 −
1
τ
_
. ¸¸ .
A
x +
_
1
0
_
. ¸¸ .
B
a
exp
+
_
0
1
_
. ¸¸ .
G
w (6.17)
y =
_
1 0
¸
. ¸¸ .
C
x +e (6.18)
The Kalman ﬁlter using this model is simulated in the same way as in Section 5.5.
Figure 6.6 shows the ﬁlter during the drive on the very bumpy road. Here τ is
set to 7, r is set to 1 and q is set to 70. Figure 6.7 shows the estimate of a
z
during simulating driving up and down the steep hill. As can be seen, there are no
56 Alternative Kalman Filter Models
relevant diﬀerences in comparison to the simple model used in Section 5.4. This
means that both models can be used to estimate a
z
in the simulated situations,
giving the same performance.
14 16 18 20 22 24 26 28 30
0.8
0.6
0.4
0.2
0
0.2
0.4
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
=a
m
a
exp
Kalman filter with a
z
modeled as GaussMarkov Process
Kalman filter from Chapter 5 (q=0.001)
Figure 6.6. Kalman ﬁlter with a
z
modeled as a GaussMarkov process. The ﬁgure
shows a simulation using recorded data from the vehicle driving on a very bumpy road.
τ is set to 7, r is set to 1 and q is set to 70. When comparing with the Kalman ﬁlter
developed in Section 5.4, no relevant changes can be found.
6.2.5 HigherOrder Derivative of a
z
In this section the model proposed by [19] will be examined. Recall Section 5.4
where it was stated that the changes in the parameter a
z
can be modeled by setting
the ﬁrst derivative of a
z
to Gaussian noise, according to
˙ a
z
(t) = w(t) (6.19)
where
E[w(t)] = 0 (6.20)
E[w(t)w(τ)] = qδ(t −τ) (6.21)
This was implemented and tested in Chapter 5, and it was shown that it is possible
to get an arbitrary fast (or slow) estimate by adjusting the noise parameter q.
Another way of modeling the changes is by setting a higher derivative of the
parameter equal to Gaussian noise, for example
¨ a
z
(t) = w(t) (6.22)
6.2 Modeling the Disturbance a
z
57
4 6 8 10 12 14 16 18
3
2
1
0
1
2
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
=a
m
a
exp
Kalman filter with a
z
modeled as GaussMarkov Process
Kalman filter from Chapter 5 (q=0.001)
Figure 6.7. Kalman ﬁlter with a
z
modeled as a GaussMarkov process. The ﬁgure is
generated using recorded data from the vehicle driving up and down a steep hill. τ is set
to 7, r is set to 1 and q is set to 70. When comparing with the Kalman ﬁlter developed
in Section 5.4, no relevant changes can be found.
This is used in [19] and also suggested as an alternative by [3] when making
estimates for kinematic models. For example when estimating position ξ and
speed
˙
ξ of an object, one might use the state vector x = [x
1
, x
2
]
T
= [ξ,
˙
ξ]
T
. The
speed of the object undergoes slight changes, which often are modeled as Gaussian
noise with
¨
ξ = w.
There is still the possibility to choose τ according to
¨ a
z
(t) +
1
τ
˙ a
z
(t) = w(t) (6.23)
For the problem at hand, there is no practical need to estimate the extra state ˙ a
z
,
but in order to take advantage of (6.22) or (6.23), the state vector is chosen as
x =
_
_
x
1
x
2
x
3
_
_
=
_
_
v
real
a
z
˙ a
z
_
_
(6.24)
The statespace model becomes
˙ x =
_
_
0 1 0
0 0 1
0 0 −
1
τ
_
_
. ¸¸ .
A
x +
_
_
1
0
0
_
_
. ¸¸ .
B
a
exp
+
_
_
1 0 0
0 1 0
0 0 1
_
_
. ¸¸ .
G
w (6.25)
y =
_
1 0 0
¸
. ¸¸ .
C
x +e (6.26)
58 Alternative Kalman Filter Models
e is Gaussian noise as before with intensity r. Here w consists of three components,
w = [w
1
, w
2
, w
3
]
T
, meaning that Gaussian noise is added to all three equations in
the statespace model. The covariance matrix for w is
Q =
_
_
q
1
0 0
0 q
2
0
0 0 q
3
_
_
(6.27)
meaning that the noise components of w are independent of each other, with noise
intensities q
1
, q
2
and q
3
. A possible approach when adding process noise to all
estimated parameters in the statespace model, is to set all intensities to the same
value, so that
Q = q
_
_
1 0 0
0 1 0
0 0 1
_
_
(6.28)
This method makes the choice of the parameters easier, but w
1
, w
2
and w
3
still
remain independent of each other. [13]
The design parameters are the noise intensities for each of the Gaussian noises
w
1
, w
2
, w
3
and e, and the value of τ. As has been explained in Section 3.5.6, the
noise intensities are dependent of each other. Letting the values of q
1
, q
2
and q
3
remain constant while changing the value of r, will aﬀect all three estimates in
the state vector. By letting r be constant, the three estimates can be adjusted
individually. Therefore, the parameters to choose are the intensities of w
1
, w
2
and w
3
, and the value of τ.
As can be seen in (6.24), (6.25) and (6.26), the equations in the model are
˙ v
real
= a
exp
+a
z
+w
1
(6.29)
˙ a
z
= ˙ a
z
+w
2
(6.30)
¨ a
z
= −
1
τ
˙ a
z
+w
3
(6.31)
y = v
m
= v
real
+e (6.32)
This might not seem logical, as (6.29) does not comply with the deﬁnition of a
z
given in (5.24). Also, the process noise w
2
could according to (6.30) be set to 0.
The statespace model is transformed into a discrete statespace model, using
the theory presented in Section 3.2. With the sample time T the result is
x
n+1
=
_
_
1 T
1
2
T
2
0 1 T
0 0 1
_
_
. ¸¸ .
A
d
x
n
+
_
_
T
0
0
_
_
. ¸¸ .
B
d
u
n
+
_
_
T
1
2
T
2 1
6
T
3
0 T
1
2
T
2
0 0 T
_
_
. ¸¸ .
G
d
w (6.33)
y =
_
1 0 0
¸
. ¸¸ .
C
d
x
n
+e
n
(6.34)
6.3 Implementation and Testing in Arjeplog 59
The observability matrix O has full rank, which according to the test in Section 3.4
means that the system is observable
O =
_
_
C
d
C
d
A
d
C
d
A
2
d
_
_
=
_
_
1 0 0
1 T
1
2
T
2
1 2T 2T
2
_
_
(6.35)
Running the ﬁlter oﬀline in Simulink with measurements from test drives, the
parameters are set using trialanderror, until the ﬁlter gets acceptable behavior.
The following parameter set is found to work properly
q
1
= 4.0 (6.36)
q
2
= 0.1 (6.37)
q
3
= 20.0 (6.38)
r = 0.2 (6.39)
τ = 0.500 (6.40)
With “properly” is meant that the ﬁlter with these parameters has the same behav
ior as the other ﬁlters evaluated in this thesis, compare to Section 5.5, Section 6.1
and Section 6.2.4. Plots of the Kalman ﬁlter implemented in this section is not
shown here, but it will be used in Section 6.4, where a comparison of all ﬁlter mod
els is made. Plots of this ﬁlter will also be shown in Section 6.5 in a comparison
with a lowpass ﬁlter.
6.3 Implementation and Testing in Arjeplog
The Kalman ﬁlter is implemented in the test vehicles at DaimlerChrysler. By the
implementation concern has to be taken to the diﬀerent driver assistance functions
in the outer control loop, as well as to certain driving situations, as described below.
• The Kalman ﬁlter can be halted, for example when the vehicle is stopped.
The estimate for a
z
in the state vector is then kept constant, while the
other estimates are set to initial values. This is done because there is no
information about the acceleration while the vehicle is standing still. This is
for example necessary when Distronic Plus is stopping the vehicle or when
Downhill Speed Regulation (DSR) is active and the tires are blocked. (Refer
to Section 2.8 and Section 2.6 for explanations of Distronic Plus and DSR.)
• The Kalman ﬁlter can be restarted, for example when the vehicle is started,
when Distronic Plus tells the vehicle to start moving or when the vehicle has
moved against the desired direction of travel.
• The output from the Kalman ﬁlter is limited to some maximum and min
imum values, due to safety reasons. These values are changed if DSR is
active.
The Kalman ﬁlter was also evaluated during a testing expedition to Arjeplog in
Sweden. Some of the plots in this thesis have been generated there. The Kalman
ﬁlter was then thoroughly tested in diﬃcult situations to detect adverse behavior.
60 Alternative Kalman Filter Models
6.4 Comparing the Kalman Filter Models
It is interesting to know if the models derived in this chapter can improve the
estimate in any way. Before continuing, a comparison between the diﬀerent models
will therefore be made. This is done by adjusting the parameters so that the ﬁlters
become the same behavior when simulating the vehicle driving up and down the
steep hill, and then by comparing their output when simulating other situations.
By doing this, all the diﬀerent models have almost the same performance with
respect to estimating large changes. The other driving situations (drive on bumpy
road for example) show if any of the models can ignore small changes better than
the other. Figure 6.8 shows the simulation of driving up and down the steep hill.
The parameters have been adjusted so that the diﬀerent ﬁlters almost have the
same behavior. Only the output from the Kalman ﬁlter using the model derived
in Section 6.1 is a bit diﬀerent than the others. Figure 6.9 and Figure 6.10 show
simulations of a test drive on two diﬀerent bumpy roads. By looking at these
ﬁgures, it becomes obvious that the behavior of the diﬀerent ﬁlters remain the
same.
4 6 8 10 12 14 16 18
3
2
1
0
1
2
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
=a
m
a
exp
a
z
Kalman filter from Chapter 5
a
z
Kalman filter with v as feedback
a
z
Kalman filter with a
z
as GaussMarkov process
a
z
Kalman filter implemented in test vehicles
Figure 6.8. This ﬁgure shows the simulation of driving up and down the steep hill. The
parameters have been adjusted so that the diﬀerent ﬁlters almost have the same behavior.
Only the output from the Kalman ﬁlter using the model derived in Section 6.1, plotted
with a dashed line, is a bit diﬀerent than the others.
In this chapter diﬀerent Kalman ﬁlter models have been tested and evaluated.
After some work with the models trying to tune the parameters, it turns out that
modeling a
z
in diﬀerent ways does not make the estimate much better. In fact,
during this Master’s project no simulated situation has been found where any of
the models examined in this chapter can make a better estimate than the simple
model used in Section 5.5.
6.5 Comparing the Kalman Filter with a FirstOrder Lag Function 61
2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7
1.8
1.6
1.4
1.2
1
0.8
0.6
0.4
0.2
0
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
=a
m
a
exp
a
z
Kalman filter from Chapter 5
a
z
Kalman filter with v as feedback
a
z
Kalman filter with a
z
as GaussMarkov process
a
z
Kalman filter implemented in test vehicles
Figure 6.9. This ﬁgure shows a simulation of a test drive on a bumpy road. By looking
at the output from the diﬀerent Kalman ﬁlters, it cannot be said that any of the ﬁlters
is better than the other.
The reason for this is that the Kalman ﬁlter remains a linear ﬁlter giving the
user to choose between a fast but jerky, or a slow but smooth estimate. With the
application at hand, it is important that the estimate is smooth, as the output
will be directly connected to the engine and brakes. Another conclusion is that
inserting more complexity and more parameters into the model makes the tuning
work more time consuming and harder to understand.
6.5 Comparing the Kalman Filter with a First
Order Lag Function
With the application at hand, the process noise w and measurement noise e cannot
be measured or estimated. Instead the ﬁlter is tuned using a subjective feeling
about what is a good compromise when sitting in the car. A fast ﬁlter makes a
faster controller, but it does not necessary mean that the controller works better.
It has been noticed that a faster controller makes the deviation from the desired
speed smaller, but at the same time the drive gets more uncomfortable. The
demands on the ﬁlter correspond to those of an ordinary lowpass ﬁlter. Therefore
this section will try to explain the similarities between these ﬁlters.
The ﬁgures that follow show the similarities between the Kalman ﬁlter from
Section 6.2.5 and a ﬁrstorder lag function as described in Section 6.2.1. The
ﬁgures are from simulations in Simulink, using measured data. The output from
the Kalman ﬁlter is represented with a solid line. As reference a
∆
= a
m
−a
exp
is
also plotted with a dotted line. The dashed line is the output from a ﬁrstorder
62 Alternative Kalman Filter Models
14 16 18 20 22 24 26 28 30
0.8
0.6
0.4
0.2
0
0.2
0.4
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
=a
m
a
exp
a
z
Kalman filter from Chapter 5
a
z
Kalman filter with v as feedback
a
z
Kalman filter with a
z
as GaussMarkov process
a
z
Kalman filter implemented in test vehicles
Figure 6.10. This ﬁgure shows a simulation of a test drive on a very bumpy road. By
looking at the output from the diﬀerent Kalman ﬁlters, it cannot be said that any of the
ﬁlters is better than the other.
lag function with time constant 1.1, when the signal a
∆
= a
m
− a
exp
is given as
input.
The measurement in Figure 6.11 comes from a test drive when the vehicle
drives up and down the steep hill, and Figure 6.12 comes from a drive on the
bumpy road. Figure 6.13 shows a test drive with an attached trailer of 2000 kg,
where the driver uses the cruise control lever to fast step the set speed up and
down several times, without giving the controller enough time to adjust the speed
completely.
The Kalman ﬁlter is very practical when the task is to extract information from
noisy measurements (also from many sensors in combination – so called sensor
fusion) or estimating more than one parameter in a complex statespace model.
When knowing the intensities of the process noise w and measurement noise e,
the Kalman ﬁlter equations are used, as explained in Section 3.5, to calculate the
optimal gain L for the observer. Looking at the ﬁgures, it is obvious that the
Kalman ﬁlter with these parameters behaves as a lowpass ﬁlter. The calculated
gain L is used to adjust the frequency properties of the Kalman ﬁlter so that the
gain is high when the signaltonoise ratio is high, but low when the ratio is low.
This behavior is also described in [12]. When knowing what type of behavior is
wanted from the ﬁlter, the same work can be done using traditional ﬁlter methods.
The Kalman ﬁlter used in the comparison does not have the signal a
∆
as in
put. Instead the measurement of the vehicle speed v
m
is used as described in
Section 6.2.5. Therefore it is not a regular lowpass ﬁlter. Instead, the Kalman
ﬁlter uses the measurement of the vehicle speed as input, and this is one example
of the advantage of developing ﬁlters using the Kalman model.
6.5 Comparing the Kalman Filter with a FirstOrder Lag Function 63
4 6 8 10 12 14 16 18
3
2
1
0
1
2
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
=a
m
a
exp
a
z
Kalman filter
a
∆
lowpass filtered
Figure 6.11. The measurement in this ﬁgure comes from a test drive when the vehicle
drives up and down the steep hill. The dashed line is the output from a ﬁrstorder lag
function with time constant τ = 1.1. As can be seen the behavior is similar to the output
from the Kalman ﬁlter (solid line).
According to [12], the transfer function for the stationary Kalman ﬁlter is
G
kf
(s) = (sI −A+LCA)
−1
Ls (6.41)
where L is the steadystate gain parameters calculated by (3.27). Calculating G
kf
with the model used for the Kalman ﬁlter gives a matrix containing three transfer
functions from the input v
m
to each of the ﬁlter outputs v, a
z
and ˙ a
z
. Taking the
transfer function from v
m
to a
z
, letting s = e
iω
and plotting its absolute value
gives the magnitude plot of the Bode diagram in Figure 6.14. The solid line is given
by the parameter set used in Section 6.2.5 and above in this section. The dashed
line shows a ﬁlter with smaller r and the dasheddotted line shows a ﬁlter with a
larger r. The ﬁlter has the function of a highpass ﬁlter. This is expected, as the
transfer function used in the plot estimates a
z
using measurements of the speed v.
Its characteristic is normal for all derivating ﬁlters. The ﬁlter with a smaller r has
a higher break frequency, and a larger r means lower break frequency. This was
also expected, because a smaller measurement noise means that the ﬁlter also can
diﬀerentiate higher frequencies. [12]
64 Alternative Kalman Filter Models
10 12 14 16 18 20 22 24 26 28 30
0.4
0.3
0.2
0.1
0
0.1
0.2
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
=a
m
a
exp
a
z
Kalman filter
a
∆
lowpass filtered
Figure 6.12. The ﬁgure is from a simulation using recorded data from a test drive on
a bumpy road. The dashed line is the output from a ﬁrstorder lag function with time
constant τ = 1.1. As can be seen the behavior is similar to the output from the Kalman
ﬁlter (solid line).
10 15 20 25 30 35 40 45
3
2.5
2
1.5
1
0.5
0
0.5
1
1.5
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
=a
m
a
exp
a
z
Kalman filter
a
∆
lowpass filtered
Figure 6.13. The ﬁgure is from a simulation using recorded data from a test drive
with a heavy loaded trailer. The driver uses the cruise control lever to step the set
speed up and down several times, without giving the controller enough time to adjust
the speed completely. The dashed line is the output from a ﬁrstorder lag function with
time constant τ = 1.1. As can be seen the behavior is similar to the output from the
Kalman ﬁlter (solid line).
6.5 Comparing the Kalman Filter with a FirstOrder Lag Function 65
Bode Diagram
Frequency (rad/sec)
P
h
a
s
e
(
d
e
g
)
M
a
g
n
i
t
u
d
e
(
d
B
)
70
60
50
40
30
20
10
r smaller (faster filter)
original Kalman filter
r larger (slower filter)
10
3
10
2
10
1
10
0
10
1
180
135
90
Figure 6.14. Bode Diagram of the transfer function from v
m
to a
z
, with the Kalman
ﬁlter presented in Section 6.2.5. The solid line is the parameters chosen in Section 6.2.5,
the dashed line is from a ﬁlter with smaller r and the dasheddotted line is from a ﬁlter
with a larger r. The ﬁlter has the function of a normal highpass ﬁlter. This is expected,
as the transfer function used in the plot estimates a
z
using measurements of the speed v.
The ﬁlter with a smaller r has a higher break frequency, and a larger r means lower break
frequency. A smaller measurement noise means that the ﬁlter also can diﬀerentiate higher
frequencies.
66 Alternative Kalman Filter Models
Chapter 7
Change Detection
In this chapter an overview of diﬀerent change detection algorithms is given, and
then one of them is chosen and implemented. An introduction on how to adjust
the parameters for this algorithm is given and simulations of diﬀerent driving
situations are made. It wil l be shown that it is possible to improve the estimate
of a
z
using this algorithm.
7.1 Idea of Change Detection
When constructing a ﬁlter, it is desirable that the output follows the desired target
signal, ignoring the noise. The gain in a linear ﬁlter is a compromise between noise
attenuation and tracking ability. Choosing a large gain makes it fast and sensitive
to measurement noise, and choosing a low gain makes it slow when large changes
in the signal occurs.
When driving the vehicle on a straight road, a slow ﬁlter could be used. The
function could be satisfying for some time, but then suddenly the slope changes
and the model used by the ﬁlter is no longer correct. It would be practical to
be able to detect such changes in the environment, and react by making the ﬁlter
faster. The presentation that follow is based on [13], where a thorough explanation
of the subject is given.
Consider a ﬁlter trying to estimate a signal x. The ﬁlter uses measurements x
m
to calculate an estimate ˆ x. The measurement is modeled as
x
m,k
= x
k
+e
k
(7.1)
where e is the measurement noise. The quality of the estimate ˆ x can be tested by
looking at the residuals
k
= x
m,k
− ˆ x
k
(7.2)
If there is no change in the system and the model is correct, then the residuals
are white noise, a sequence of independent stochastic variables with zero mean
and known variance. After a change either the mean or variance or both changes,
67
68 Change Detection

x
k

u
k
Kalman Filter
k

Distance

s
k
Stop rule
p 
Alarm

ˆ x
k
6
Change Detector
Figure 7.1. A change detector consists of distance measure and a stopping rule. The
distance measure transform the residuals from the Kalman ﬁlter to a signal s, repre
senting the change in the residuals. The stopping rule decides whether the change is
signiﬁcant or not. If the change in the residuals is signiﬁcant, the change detector gives
an alarm and the Kalman ﬁlter can take appropriate action (for example by making the
ﬁlter faster).
that is, the residuals become “large” in some sense. This can be used by a change
detection algorithm. The problem is to decide what “large” is. Change detection
is also referred to as “fault detection”. It is often used to detect faults in a system,
for example when a sensor is broken or temporarily unavailable.
There are three diﬀerent categories of change detection methods [13]
• Methods using one ﬁlter, where a whiteness test is applied to the residuals.
The ﬁlter is temporarily made faster when a change is detected.
• Methods using two ﬁlters, one slow and one fast, in parallel. Depending on
the residuals from the two ﬁlters, one of them is chosen as the currently “best
one”.
• Methods using multiple ﬁlters in parallel, each one matched to certain as
sumptions on the abrupt changes. For each ﬁlter the probability of that ﬁlter
being correct is calculated, and output is the weighted sum of the output
from all the individual ﬁlters, depending on their current probabilites.
In this chapter, a method using one ﬁlter will be implemented and tested.
7.2 One Kalman Filter with WhitenessTest
The task of the change detector is to decide which of the following hypotheses is
correct, concerning the residuals from the Kalman ﬁlter
H
0
: is white noise (7.3)
H
1
: is not white noise (7.4)
A change detector consists of a distance measure and a stopping rule, as in
Figure 7.1. The residuals are transformed to a distance measure s
k
, that mea
sures the deviation from the hypothesis H
0
. The stopping rule decides whether
the deviation is signiﬁcant or not. Diﬀerent implementations of the distance mea
sures s
k
are [13]
7.2 One Kalman Filter with WhitenessTest 69
• Change in mean. The residual itself is used, giving
s
k
=
k
(7.5)
• Change in variance. The squared residual subtracted by a known “normal”
residual variance λ is used, giving
s
k
=
2
k
−λ (7.6)
• Change in correlation. The correlation between the residual
t
at the current
time step k and past outputs y
k−l
or inputs u
k−l
at a time step k − l are
used as
s
k
=
k
y
k−l
(7.7)
or
s
k
=
k
u
k−l
(7.8)
for some value l.
• Change in sign correlation. For instance, one can use the fact that white
residuals should in average change sign every second sample and use
s
k
= sign(
k
k−1
) (7.9)
A stopping rule is created by lowpass ﬁltering s
k
and comparing this value to a
threshold h. Two common lowpass ﬁlters described in [13] are
• The CUmulative SUM (CUSUM) test
g
k
= max(g
k−1
+s
k
−ν, 0) (7.10)
The “drift parameter” ν inﬂuences the lowpass eﬀect.
• The Geometric Moving Average (GMA) test
g
k
= λg
k−1
+ (1 −λ)s
k
(7.11)
Here the forgetting factor λ is used to tune the lowpass eﬀect. λ can be
chosen as 0, which means no lowpass eﬀect and s
k
will in this case be
thresholded directly.
The stopping rule gives an alarm when g
k
> h. When an alarm is given, the
Kalman ﬁlter is temporarily made faster by adjusting the parameters, and g
k
is
reset to 0.
70 Change Detection
7.3 Implementation
In this section one change detection algorithm is implemented and tested. As
distance measure s
k
=
2
k
−λ is chosen, and as stopping rule the CUSUMtest
g
k
= max(g
k−1
+s
k
−ν, 0). Inserting (7.6) in (7.10) gives
g
k
= max(g
k−1
+
2
k
−λ −ν, 0)
= max(g
k−1
+
2
k
−β, 0) (7.12)
Here β has been deﬁned as β = λ +ν.
The Kalman ﬁlter from Chapter 5 with R = 1 and Q = 0.0003 is selected. This
gives L = L
slow
= 0.0172 and results in a slow ﬁlter. The change detector gives an
alarm when g
k
> h, and the Kalman ﬁlter is temporarily made faster by changing
the calculated value L to another value L
fast
. Choosing R = 1 and Q = 0.01 from
Chapter 5 gives L
fast
= 0.0951.
To choose the threshold h and the parameter β in (7.12) for the change detec
tion algorithm, the following steps are taken, inspired by the general advice given
in [13]
• Start with a very large threshold h and choose β to the size of the expected
change. Simulate the system with measurements from test drives on bumpy
roads. The Kalman ﬁlter should in these situations remain slow, ignoring
the noise. Adjust β such that g
k
= 0 more than 50% of the time.
• Then simulate the system with measurements where large changes occur, for
example driving up and down a steep hill, or stepping the cruise controller
set speed up and down with a heavy loaded vehicle. Set the threshold h so
the delay for detection of these large changes is reasonable.
• Then simulate all the driving situations again. If faster detection is sought,
try to decrease β. If fewer false alarms are wanted, try to increase β. If there
is a subset of the change times that does not make sense, try to increase β.
The parameters for the change detection found using this method are β = 0.005
and h = 0.2.
7.4 Results
The Kalman ﬁlter with the change detection algorithm chosen in Section 7.3 is
simulated using measurements from test drives representing diﬀerent driving sit
uations. The output from the simulated Kalman ﬁlter is plotted in a diagram
together with the measured signal a
m
−a
exp
. As a reference the output from the
“original” Kalman ﬁlter without change detection, presented in Section 6.2.5, is
also plotted. The discrete signal at the bottom of the diagrams is the output from
the change detection algorithm, called “Alarm” in Figure 7.1. When this signal is
high, the faster parameter of the Kalman ﬁlter is chosen.
Figure 7.2 is a simulation of a test drive up and down a steep hill, with a slope
of 20% up and 15% down. Figure 7.3 shows a vehicle with a trailer with a weight
7.4 Results 71
of 2000 kg driving up and down the same hill. Figure 7.4 shows the vehicle with
the trailer again, this time driving with cruise control. The driver is stepping the
set speed fast up and down without letting the vehicle reach the desired speed.
From the three ﬁgures it can be seen that the estimates from the Kalman ﬁlter
with change detection is faster than the original implementation. Faster estimates
are better in these driving situations because it would give the controller a better
chance to compensate for the large changes.
Figure 7.5 and Figure 7.6 each show a test drive on two diﬀerent bumpy roads.
As can be seen, not so many alarms are given, and the change detection algorithm
does not aﬀect the estimate. This shows that the change detection algorithm does
not aﬀect the estimate when it is not necessary.
0 5 10 15 20 25
3
2
1
0
1
2
3
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
= a
m
a
exp
a
z
Kalman filter
a
z
Change Detection
Alarm
Figure 7.2. Simulation of a Kalman ﬁlter with change detection algorithm when driving
up and down a steep hill. The change detection algorithm detects the large changes and
makes the Kalman ﬁlter faster.
72 Change Detection
0 5 10 15 20 25
6
5
4
3
2
1
0
1
2
3
4
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
= a
m
a
exp
a
z
Kalman filter
a
z
Change Detection
Alarm
Figure 7.3. Simulation of a Kalman ﬁlter with change detection algorithm when driving
up and down a steep hill with a 2000 kg trailer. The change detection algorithm detects
the large changes and makes the Kalman ﬁlter faster. (The original Kalman ﬁlter becomes
saturated at −3ms
−2
. This is not implemented in the simulation for the ﬁlter with change
detection.)
10 15 20 25 30 35 40 45
3
2
1
0
1
2
3
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
= a
m
a
exp
a
z
Kalman filter
a
z
Change Detection
Alarm
Figure 7.4. Simulation of a Kalman ﬁlter with change detection algorithm when driving
with an attached trailer. The driver uses the cruise control lever to fast step up and down
witout letting the vehicle reach the desired speed. The change detection algorithm detects
the large changes and makes the Kalman ﬁlter faster than the original implementation.
7.4 Results 73
0 1 2 3 4 5 6 7 8 9 10
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
= a
m
a
exp
a
z
Kalman filter
a
z
Change Detection
Alarm
Figure 7.5. Simulation of a Kalman ﬁlter with change detection algorithm when driving
on a bumpy road. The change detection algorithm does not give many alarms, and
therefore the estimate is not aﬀected, as desired.
0 10 20 30 40 50 60
0.6
0.5
0.4
0.3
0.2
0.1
0
0.1
0.2
Time [s]
D
i
s
t
u
r
b
a
n
c
e
[
m
/
s
2
]
a
∆
= a
m
a
exp
a
z
Kalman filter
a
z
Change Detection
Alarm
Figure 7.6. Simulation of a Kalman ﬁlter with change detection algorithm when driving
on a very bumpy road. The change detection algorithm does not give many alarms, and
therefore the estimate is not aﬀected, as desired.
74 Change Detection
Chapter 8
Conclusions and Future
Work
In this chapter the thesis is concluded with a short summary of the obtained results
and observations made. The chapter also includes a section in which interesting
future work is brieﬂy introduced.
8.1 Conclusions
In this Master’s thesis the theory for the Kalman ﬁlter and ﬁlter tuning have been
presented. It has been shown how to implement a Kalman ﬁlter estimating the
part called a
z
of the vehicle’s acceleration caused by disturbances not included
in the model of the vehicle. The easiest method is to use a constructed sig
nal a
∆
= a
exp
−a
m
as input to the ﬁlter, where a
exp
is the expected acceleration
calculated by the model and a
m
is the measured actual acceleration.
It has been shown that the ﬁlter parameters can be chosen either
• by knowledge about the noise intensities (when they are not known they can
be estimated),
• by running simulations in Simulink and optimizing the parameters using a
script in Matlab (for this purpose the algorithm simulated annealing has
been implemented),
• or by adjusting the parameters as a compromise between a slow ﬁlter, or a
fast but jerky ﬁlter (to do this a subjective choice has to be made).
Some more complex models for the Kalman ﬁlter have been implemented and
tested. First it was shown how to use the speed of the vehicle as input to the
ﬁlter, instead of the constructed signal a
∆
. Then two models of a
z
were derived
and tested, inspired by the ﬁrstorder lag function and the GaussMarkov process.
These models have a higher computational cost, but it could not be proven that
they improve the estimate in any way.
75
76 Conclusions and Future Work
It has been shown that the Kalman ﬁlter implemented in the vehicles today
can be replaced by a ﬁrstorder lag function, with no loss in performance.
A change detection algorithm has also been implemented in Simulink and
simulations show that it is possible to improve the estimate using this algorithm.
8.2 Future Work
There are several interesting aspects that deserve further investigation.
• The change detection algorithm implemented in Simulink should be tested
in a real vehicle. If this test shows a positive result, the parameters can then
be adjusted by practical methods to suit the actual application.
• It is suggested to implement, simulate and test the other methods for change
detection described in this Master’s thesis. For example the method of using
two ﬁlters in parallel, one slow and one fast, may be of interest.
• It should be practically tested if the Kalman ﬁlter can be exchanged with
another simpler type of lowpass ﬁlter, as the simulations in this thesis sug
gest.
• As the parameters m (the mass of the vehicle) and α (the slope of the
road) have a big impact on the calculation of the expected acceleration (see
Section 5.3) it would be interesting to see if the performance of the controller
could be improved by estimating these parameters, instead of estimating a
z
.
List of Notations
This table shows the symbols and abbreviations used in this thesis, together with
a reference to the page where they are deﬁned.
Symbol Description Page
α Slope of the road 42
a
c
Output from the controller 34
a
dev
Deviation from desired acceleration 33
a
des
Desired acceleration 33
a
exp
Calculated expected acceleration 43
a
m
Measured acceleration of the vehicle 33
a
real
Actual aceleration of the vehicle 33
a
z
Output from the observer 43
A
w
Air resistance reference area 36
c
d
Drag coeﬃcient 36
c
rr
Rolling resistance coeﬃcient 36
η Eﬃciency factor for the drivetrain 36
e Measurement noise 12
F
air
Air resistance 36
F
brake
Force from the brakes 35
F
drive
Force from transmission and engine 35
F
resistance
Drive resistance 35
F
roll
Rollin resistance 36
g Gravitational acceleration 36
i
d
Diﬀerential ratio 36
I
e
Moment of inertia for the engine 36
I
f
Moment of inertia for the front axes 36
i
g
Gearbox ratio 36
I
g
Moment of inertia for the gear 36
I
r
Moment of inertia for the rear axes 36
L Observer gain 14
m Mass of the vehicle 36
˜ m Mass and moments of inertia 37
P Covariance matrix 16
q Measurement noise intensity 43
77
78 List of Notations
Q Measurement noise covariance matrix 15
ρ Density of the air 36
r Process noise intensity 44
r
w
Wheel radius 34
R Process noise covariance matrix 15
T
b
Desired brake torque 33
T
brake
Expected output torque from the brakes 35
T
drive
Output torque from the transmission and engine 36
T
e
Desired engine torque 33
T
engine
Expected output torque from the engine 35
u Input signal 12
v
m
Measured speed of the vehicle 33
v
real
Actual speed of the vehicle 33
v
wind
Speed of the wind 36
w Process noise 12
x State 12
ˆ x Estimate of the state 14
Abbreviation Description Page
ABS Antilock Braking System 5
ACC Adaptive Cruise Control 7
BAS Brake Assist System 7
CMS Collision Mitigation System 6
DSR Downhill Speed Regulation 6
ESP Electronic Stability Program 5
RMSE Root Mean Square Error 25
SA Simulated Annealing 26
Bibliography
[1] B. Adiprasito, Fahrzeuglängsführung im Niedergeschwindigkeitsbereich,
PhD thesis, Shaker Verlag, Aachen, 2004.
[2] P. Andersson, Air Charge Estimation in Turbocharged Spark Ignition Engines,
PhD thesis No. 989, Linköpings universitet, Linköping, 2005.
[3] Y. BarShalom, X. Li and T. Kirubarajan, Estimation with Applications to
Tracking and Navigation, John Wiley & Sons, Inc., New York, 2001.
[4] G. Blom, Sannolikhetsteori och statistikteori med til lämpningar, Studentlit
teratur, Lund, fourth edition, 1989.
[5] R.G Brown and P.Y.C Hwang, Introduction to Random Signals and Applied
Kalman Filtering, John Wiley & Sons, Inc., New York, third edition, 1997.
[6] T. Coleman, M.A Branch and A. Grace, Optimization Toolbox User’s Guide,
The MathWorks, Inc., Natick, 1999.
[7] A. Eidehall, Tracking and threat assessment for automotive col lision avoid
ance, PhD thesis No. 1066, Linköpings universitet, Linköping, 2007.
[8] M. Fach, Robustheits und Stabilitätsbetrachtung des Fahrzeuglängsreglers im
Mercedes Benz Pkw, Master’s thesis, Universität Stuttgart, Stuttgart, 2003.
[9] T. Glad and L. Ljung, Reglerteknik  Grundläggande teori, Studentlitteratur,
Lund, fourth edition, 2006.
[10] T. Glad and L. Ljung, Reglerteori  Flervariabla och olinjära metoder, Stu
dentlitteratur, Lund, second edition, 2003.
[11] M. Grewal and A. Andrews, Kalman Filtering  Theory and Practice Using
Matlab, John Wiley & Sons, Inc., Ney York, second edition, 2001.
[12] F. Gustafsson, L. Ljung and M. Millnert, Signalbehandling, Studentlitteratur,
Lund, second edition, 2001.
[13] F. Gustafsson, Adaptive Filtering and Change Detection, John Wiley &
Sons, Inc. New York, 2001.
79
80 Bibliography
[14] U. Kienecke and L. Nielsen, Automotive Control Systems For Engine, Drive
line and Vehicle, SpringerVerlag, Berlin, second edition, 2005.
[15] S. Kirkpatrick, C.D. Gelatt and M.P. Vecchi, Optimization by Simulated An
nealing, Science(220) : 671680, 1983.
[16] P. Lingman and B. Schmidtbauer, Road Slope and Vehicle Mass Estimation
Using Kalman Filtering, Vehicle System Dynamics Supplement 37 page 1223,
2002.
[17] L. Ljung, System Identiﬁcation  Theory for the User, Prentice Hall, Upper
Saddle River, second edition, 1999.
[18] L. Ljung, System Identiﬁcation Toolbox User’s Guide, The Math Works, Inc.,
Natick, 1995.
[19] D. Pfrommer, Regelung der Fahrzeuglängsdynamik unter Berücksichtigung der
unterschiedlichen Dynamik von Motor und Bremse, Master’s thesis, Univer
sität Stuttgart, Stuttgart, 2005.
[20] K. Popp and W. Schiehlen, Fahrzeugdynamik, B.G. Teubner, Stuttgart, 1993.
[21] R. Regis and C. Shoemaker, A Stochastic Radial Basis Function Method
for the Global Optimization of Expensive Functions, Online Supplement, IN
FORMS Journal on Computing, Acc. 20070201
http://joc.pubs.informs.org/Supplements/Regis.pdf
[22] R. Rosander, Sensor Fusion between a Synthetic Attitude and Heading
Reference System and GPS, Master’s thesis No. LITHISYEX34082003,
Linköpings Universitet, Linköping, 2003.
[23] G. Welch and G. Bishop, An Introduction to the Kalman Filter, Technical
Report TR95041, University of North Carolina at Chapel Hill, Chapel Hill,
1995.
[24] Control System Toolbox User’s Guide, The MathWorks, Inc., Natick, 1998.
[25] Owner’s Manual SClass, DaimlerChrysler AG, Stuttgart, 2006.
[26] Owner’s Manual MClass, DaimlerChrysler AG, Stuttgart, 2006.
Appendix A
Matlab Implementation of
“lsqnonlin”
function [q11,q22,q33] = opt_param_lsq(tolx, tolfun)
% Optimize control parameters using LSQNONLIN and Simulink model
if (nargin < 2)
warning(’Using standard value for tolx and tolfun (0.001)’);
tolfun = 0.001;
tolx = 0.001;
end
load_system(’opt_param_model’) % Load the model
start_parameters = [0.1 1 10]; % Set initial values
% Set optimization options (for example termination options)
options =
optimset(’LargeScale’,’off’,’Display’,’iter’,
’TolX’,tolx,’TolFun’,tolfun);
% Run lsqnonlin to solve the optimization problem
best_parameters = lsqnonlin(@tracklsq, start_parameters,
[], [], options);
% Save the result
q11 = best_parameters(1);
q22 = best_parameters(2);
q33 = best_parameters(3);
% This is the callback function used by lsqnonlin
function F = tracklsq(current_parameters)
81
82 Matlab Implementation of “lsqnonlin”
% Current values are passed by lsqnonlin
q11 = current_parameters(1);
q22 = current_parameters(2);
q33 = current_parameters(3);
% Calculate the observer
Q_d = [q11 0 0 ; 0 q22 0 ; 0 0 q33];
\textsc{Simulink}_model_parameters
% Create simulation options and run simulation
[tout,xout,yout] = sim(’opt_param_model’);
% Calculate the cost function value
% (In the model used, error is the 2:nd output)
error = yout(:,2);
% (lsqnonlin uses sqrt(F) as cost function, therefore ^2
F = rmse(error)^2;
end
function rmse = RMSE(error)
% Calculate a cost function based on the insignal error
error = estimated_valuereal_value);
t = length(error);
rmse=sqrt(1/t*sum(error.^2));
Appendix B
Matlab Implementation of
Simulated Annealing
This is the developed optimization script implementing the simulated annealing
(SA) algorithm in Matlab.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% [param_best, cost_best] = sim_annealing(param_start,steps_max)
%
% This Matlab function recursively tries to find the optimal
% parameters, using Simulinksimulation and
% the algorithm "simulated annealing".
%
% Required parameters:
% param_start = [q11 q22 q33], initial state for the algorithm
% steps_max, the maximum number of evaluations allowed
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [param_best, cost_best] =
sim_annealing(param_start,steps_max)
if(nargin<2)
error(’Specifz initial values and max evaluations’);
end
param_current = param_start; % Initial state
cost_current = sim_cost(param_current); % Initial error
cost_stop = 0.1
P_start = 0.9;
P_stop = 0.000001;
83
84 Matlab Implementation of Simulated Annealing
[temp_start alpha]=
init(param_current,cost_current,steps_max,P_start,P_stop);
param_best = param_current; % Initial "best" solution
cost_best = cost_current;
temp_current = temp_start; % Initial temperature
rand(’state’,sum(100*clock)); % reset random generator
disp(sprintf(
’steps: \t [q11 \t q22 \t q33] = \t cost \t T=temp’));
steps = 0; % Evaluation count.
% While time remains & not good enough
while steps < steps_max & cost_current > cost_stop
% Pick some neighbour
param_neighbour = neighbour(param_current);
% Compute its energy
cost_neighbour = sim_cost(param_neighbour);
if cost_neighbour < cost_best % Is this a new best?
param_best = param_neighbour;
cost_best = cost_neighbour; % Yes, save it.
end
% Should we move to the new state?
if rand < trans_P(cost_current, cost_neighbour, temp_current)
param_current = param_neighbour; % Yes, change state
cost_current = cost_neighbour;
end
steps = steps + 1; % One more evaluation
cost_history(steps) = cost_current; % Log the cost (path)
temp_history(steps) = temp_current;
temp_current = alpha*temp_current; % Cool down
disp(sprintf(’%d: \t [%0.5g \t %0.5g \t %0.5g]
= \t %0.5g \t T=%0.5g’, steps,
param_current(1), param_current(2), param_current(3),
cost_current,temp_current));
end
figure(1);
subplot(2,1,1), plot(cost_history), xlabel(’costfunction’);
subplot(2,1,2), plot(temp_history), xlabel(’temperature’);
85
% Print the best parameters and their evaluated cost value
param_best
cost_best
% Pick some neighbour to the current parameters
% Should try to get nearby values!
function n = neighbour(param)
n = [1 1 1];
% Can not allow negative values
while n(1) < 0  n(2) < 0  n(3) < 0
% Randomize between 0.5 and +0.5
change = (rand(1,3)0.5).*param;
% Calculate new parameters
n = param + change;
end
end
% Calculate the transition probability function P
% The probability that we move to new parameters
function P = trans_P(cost_current, cost_neighbour, temp)
if cost_current < cost_neighbour
P = 1; % Always go down the hill
else
% Go up the hill if the temperature is high,
% but stay if the temperature is low
P = exp((cost_currentcost_neighbour)/temp);
end
end
% sim_cost executes the simulation and returns the RMSEerror
function cost = sim_cost(param)
global simin_Ld1 simin_Ld2 simin_Ld3
q11 = param(1);
q22 = param(2);
q33 = param(3);
r_d = 0.2;
lrg_para_lrg;
% These parameters have to be defined as global
simin_Ld1 = L_d(1);
simin_Ld2 = L_d(2);
simin_Ld3 = L_d(3);
disp([’Simulating...’]);
86 Matlab Implementation of Simulated Annealing
sim(’rdu_simmod_tl_fumo’);
% Check global parameters
if(simin_Ld1 == max(simout_Ld1))
disp([’OK’]);
else
error(’Parameters are not received by Simulink’);
end
% Calculate the cost function value
error = simout_car_pos_gsimout_LRG_az_SGB;
% Pick out the interesting part (skip beginning!)
parterror = error(400:2600);
% Calculate cost (Root mean square error)
cost = rmse(parterror);
end
% Calculate a reasonable initial temperature and alpha
function [temp_start, alpha] =
init(param_start,cost_start,steps_max,P_start,P_stop)
cost_best=cost_start; % best of all the neighbours
cost_worst=cost_start; % worst of all the neighbours
for i=1:5
% Generate some random neighbours, evaluate costs
param_neighbour = neighbour(param_start);
cost_neighbour = sim_cost(param_neighbour);
% Save the worst and best neighbour costs
if( cost_neighbour < cost_best )
cost_best = cost_neighbour;
end
if( cost_neighbour > cost_worst )
cost_worst = cost_neighbour;
end
end
% Calculate the maximum uphill move needed
if( cost_worst > cost_start )
max_change = cost_worst  cost_start
else
max_change = cost_start  cost_best
end
87
% Set initial temperature so that this maximum move
% is accepted with a high probability P_start.
% P_start = exp(max_change/temp_start) gives
temp_start = max_change / log(P_start);
% Now calculate the cooling factor alpha
% P_stop = exp(max_change/(temp_start*alpha^steps_max))
alpha = (max_change / (temp_start*log(P_stop)))^(1/steps_max);
end
Appendix C
Time Constant Identiﬁcation
Here is the Matlab identiﬁcation script that was used to identify the unknown
parameter τ and the intesitiy of w in the ﬁrstorder lag function τ ˙ a
z
+a
z
= w.
% Identifies the parameter "tau" and "K" in the matrix A
% dot{x} = Ax + Bu + Ke
% y = Cx + Du + e
% The noise intensities of e is 1
load ’C:\Messungen\221_836_RS141p_pr21.mat’
% Calculate the disturbance a_z due to the slope alpha
alpha = atan((B_LRdeSteigSe)/100);
real_az_Slope = 9.81*sin(alpha);
az = real_az_Slope’;
T = 0.02; % Sampling time
tau_start = 0.5; % Start values
K_start = 1;
A = [1/tau_start];
B = [0];
C = [1];
D = [0];
K = [K_start];
x0 = [0];
% Create statespace identification model
m = idss(A,B,C,D,K,x0,’Ts’,0);
m.as = [NaN]; % NaN means "please identify"
m.ks = m.k;
m.bs = m.b;
m.cs = m.c;
88
89
m.ds = m.d;
% Automatically adjust initial values to suit model
m_init = init(m);
% Load identification data, az output, no input
identificationData = iddata(az, zeros(length(az),1), T);
% Identify unknown parameters
model = pem(identificationData,m_init);
% Save the identified parameters
tau_save = inv(model.A)
K_save = model.K
lambda = model.NoiseVariance
% Check the model’s ability to predict one step ahead
figure(15);
compare (identificationData,model,1);
Observer for a vehicle longitudinal controller
Examensarbete utfört i Reglerteknik vid Tekniska högskolan i Linköping av
Peter Rytterstedt LiTHISYEX2007/3950SE
Handledare:
Johanna Wallén
isy, Linköpings universitet
Volker Maaß
Mercedes Benz Technology Center, DaimlerChrysler AG
Examinator:
Thomas Schön
isy, Linköpings universitet
Linköping, 1 April, 2007
.
numbering — URL för elektronisk version http://www. ﬁlter tuning.e. In this Master’s thesis it is veriﬁed that the parameter choice is a compromise between a fast but jerky. longitudinal controller. etc. for example by a changed vehicle mass or the slope of the road. A ﬁlter using change detection is implemented and simulations show that it is possible to improve the estimate using this method. and react accordingly – for example by making the ﬁlter faster.ep. It is suggested to implement the change detection algorithm in a test vehicle and evaluate it further. cruise control.isy. The outer control loop contains the driver assistance functions such as speed limiter.. Change detection is a method that can be used to detect large changes in the signal. Department Division of Automatic Control Department of Electrical Engineering Linköpings universitet SE581 83 Linköping. Simulated annealing is a global optimization technique which can be used when autotuning. Sweden Språk Language Svenska/Swedish Engelska/English Rapporttyp Report category Licentiatavhandling Examensarbete Cuppsats Duppsats Övrig rapport ISBN — ISRN Datum Date 20070401 LiTHISYEX2007/3950SE Serietitel och serienummer ISSN Title of series. simulated annealing.control. Nyckelord Keywords Kalman ﬁlter.Avdelning. It is shown that the Kalman ﬁlter implemented in the test vehicles today can be exchanged with a ﬁrstorder lag function.liu.liu. or a slow but smooth estimate. i. As the output from the Kalman ﬁlter is directly added to the control value for the engine and brakes. Institution Division. It is the optimal ﬁlter when the process model is linear and the process noise and measurement noise can be modeled as Gaussian noise. To be able to perform autotuning for the longitudinal controller one has to model the environment and driving situations. The inner control loop consists of a PIDcontroller and an observer. as there is only one parameter to choose. The task of the observer is to estimate the part of the vehicle’s acceleration caused by large disturbances.se http://www. without loss in performance. automatically ﬁnd the optimal parameter settings. As observer the Kalman ﬁlter is selected. In this Master’s thesis the theory for the Kalman ﬁlter is presented and it is shown how to choose the ﬁlter parameters. it is important that the output is smooth.se/2007/3950 Titel Title Observatör för en längsregulator i fordon Observer for a vehicle longitudinal controller Författare Peter Rytterstedt Author Sammanfattning Abstract The longitudinal controller at DaimlerChrysler AG consists of two cascade controllers. change detection . This makes the ﬁlter tuning easier.
.
The outer control loop contains the driver assistance functions such as speed limiter. As observer the Kalman ﬁlter is selected. and react accordingly – for example by making the ﬁlter faster. for example by a changed vehicle mass or the slope of the road. as there is only one parameter to choose. This makes the ﬁlter tuning easier. A ﬁlter using change detection is implemented and simulations show that it is possible to improve the estimate using this method. It is shown that the Kalman ﬁlter implemented in the test vehicles today can be exchanged with a ﬁrstorder lag function. cruise control. automatically ﬁnd the optimal parameter settings.. without loss in performance. it is important that the output is smooth. or a slow but smooth estimate. v . It is the optimal ﬁlter when the process model is linear and the process noise and measurement noise can be modeled as Gaussian noise. Change detection is a method that can be used to detect large changes in the signal. In this Master’s thesis it is veriﬁed that the parameter choice is a compromise between a fast but jerky. i. As the output from the Kalman ﬁlter is directly added to the control value for the engine and brakes.Abstract The longitudinal controller at DaimlerChrysler AG consists of two cascade controllers. The task of the observer is to estimate the part of the vehicle’s acceleration caused by large disturbances. The inner control loop consists of a PIDcontroller and an observer. It is suggested to implement the change detection algorithm in a test vehicle and evaluate it further.e. Simulated annealing is a global optimization technique which can be used when autotuning. In this Master’s thesis the theory for the Kalman ﬁlter is presented and it is shown how to choose the ﬁlter parameters. To be able to perform autotuning for the longitudinal controller one has to model the environment and driving situations. etc.
.
It completes my international studies for a Master of Science degree in Applied Physics and Electrical Engineering at Linköpings Universitet. who has always had time for my questions and helped me in any way possible. The teams EP/ERW and GR/EAT deserve many thanks for welcoming me at the department. and my girlfriend for her support and encouragement. DaimlerChrysler AG in Sindelﬁngen. I would like to express my greatest gratitude to my supervisor at DaimlerChrysler. Sindelﬁngen. My supervisor Johanna Wallén and examiner Thomas Schön at Linköpings Universitet. Germany. Peter JuhlinDannfelt and Erik Almgren for proofreading. Sweden. Volker Maaß. Finally I would like to thank Marie Rytterstedt.Acknowledgments This Master’s thesis has been performed between October 2006 and March 2007 at the Mercedes Technology Center. who have given insightful comments and tips. also have a part in this thesis. and for answering questions about the cars and development tools that have come up during this thesis. March 2007 Peter Rytterstedt vii .
.
Contents
1 Introduction 1.1 Background . . . . . 1.2 Problem Formulation 1.3 Objective . . . . . . 1.4 DaimlerChrysler AG 1.5 Method . . . . . . . 1.6 Outline . . . . . . . 1.7 Limitations . . . . . 1 1 2 2 3 3 3 4 5 5 5 5 6 6 6 6 7 7 7 8 8 8 11 11 12 13 14 15 15 15 16 17
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
2 Driver Assistance Systems 2.1 Antilock Braking System . . . . . . 2.2 Traction Control . . . . . . . . . . . 2.3 Stability Control . . . . . . . . . . . 2.4 Speed Limiter . . . . . . . . . . . . . 2.5 Cruise Control . . . . . . . . . . . . 2.6 Hill Descent Control . . . . . . . . . 2.7 Forward Collision Mitigation System 2.7.1 Distance Warning . . . . . . 2.7.2 Brake Assist System . . . . . 2.8 Adaptive Cruise Control . . . . . . . 2.9 Lane Guidance System . . . . . . . . 2.10 Blindspot Warning . . . . . . . . . . 2.11 Systems Supported by the Controller
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
3 Basic Filter Theory 3.1 StateSpace Models . . . . . . . . . . . . . . . . 3.2 Discretization . . . . . . . . . . . . . . . . . . . 3.3 Observer . . . . . . . . . . . . . . . . . . . . . . 3.4 Observability . . . . . . . . . . . . . . . . . . . 3.5 Kalman Filter . . . . . . . . . . . . . . . . . . . 3.5.1 Process and Measurement Model . . . . 3.5.2 Discrete Time Kalman Filter Equations 3.5.3 Initialization . . . . . . . . . . . . . . . 3.5.4 Steady State . . . . . . . . . . . . . . . ix
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
x
Contents 3.5.5 Block Diagram of the Stationary Kalman Filter . . . . 3.5.6 Design Parameters . . . . . . . . . . . . . . . . . . . . Shaping Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.6.1 Shaping Filters for NonGaussian Process Noise . . . . 3.6.2 Shaping Filters for NonGaussian Measurement Noise . . . . . . . . . . . . . . . 17 17 17 19 19 21 21 22 23 23 24 25 25 25 26 33 33 35 38 43 44 49 49 50 50 52 53 55 56 59 60 61 67 67 68 70 70 75 75 76 77
3.6
4 Choosing the Kalman Filter Parameters 4.1 Estimating the Covariances . . . . . . . . 4.2 Choosing Q and R Manually . . . . . . . 4.3 Simulation . . . . . . . . . . . . . . . . . . 4.3.1 OpenLoop Simulation . . . . . . . 4.3.2 ClosedLoop Simulation . . . . . . 4.4 Autotuning . . . . . . . . . . . . . . . . . 4.4.1 Evaluation Using RMSE . . . . . . 4.4.2 Autotuning Using Matlab . . . . . 4.4.3 Simulated Annealing . . . . . . . . 5 Kalman Filter Implementation 5.1 Overview of the Inner Control Loop 5.2 Modeling the Acceleration . . . . . . 5.3 Errors in the Acceleration Model . . 5.4 Kalman Filter Model . . . . . . . . . 5.5 Choosing the Filter Parameters . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
6 Alternative Kalman Filter Models 6.1 Vehicle Speed as Feedback . . . . . . . . . . . . . . . . . . . . . 6.2 Modeling the Disturbance az . . . . . . . . . . . . . . . . . . . 6.2.1 FirstOrder Lag Function . . . . . . . . . . . . . . . . . 6.2.2 FirstOrder GaussMarkov Process . . . . . . . . . . . . 6.2.3 Identifying the Time Constant . . . . . . . . . . . . . . 6.2.4 Testing the Model of az . . . . . . . . . . . . . . . . . . 6.2.5 HigherOrder Derivative of az . . . . . . . . . . . . . . . 6.3 Implementation and Testing in Arjeplog . . . . . . . . . . . . . 6.4 Comparing the Kalman Filter Models . . . . . . . . . . . . . . 6.5 Comparing the Kalman Filter with a FirstOrder Lag Function 7 Change Detection 7.1 Idea of Change Detection . . . . . . . . 7.2 One Kalman Filter with WhitenessTest 7.3 Implementation . . . . . . . . . . . . . . 7.4 Results . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
8 Conclusions and Future Work 8.1 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . List of Notations
Bibliography A Matlab Implementation of “lsqnonlin” B Matlab Implementation of Simulated Annealing C Time Constant Identiﬁcation
79 81 83 88
xii Contents .
By vehicle longitudinal regulation.. so that the vehicle is traveling smoothly. In this Master’s thesis the focus will be on the driver assistance systems supported by the longitudinal controller at DaimlerChrysler AG. The tasks for these systems are to support and relieve the driver. ad1 .” (coordinator) in the ﬁgure chooses which of the functions that should have aﬀect. The task of the observer is to estimate the part of the vehicle’s acceleration caused by disturbances not included in the vehicle model. The outer controller contains the driver assistance functions (such as Speedtronic. The block called “Coord. ad2 . even when switching between the diﬀerent assistance functions. The longitudinal controller can be thought of as two cascade controllers. . A Kalman ﬁlter is chosen as observer. The current speed v and acceleration a are measured and used as feedback signals by the controllers.for further information see Chapter 2). The resulting calculated acceleration ad is delivered to the inner control loop.1 Background Driver assistance systems are more and more becoming standard in the new vehicles built today.1. adn are the desired accelerations calculated by the assistance functions. as well as an outline for the thesis. 1. . and this Master’s thesis will explain the function and implementation of the Kalman ﬁlter in more detail. It also contains a jerk damper. but not to take the driving task from him or her. DSR. v is here the actual vehicle speed. brake and gearbox. etc . whose task is to make the vehicle have the same acceleration as the desired value. 1 . where the thesis project has been performed.Chapter 1 Introduction This chapter will give an introduction to the problem investigated in this Master’s thesis. depending on the driver’s choice. . DaimlerChrysler AG. which are aﬀecting the vehicle. Distronic. The inner controller delivers a desired torque T to the actuators engine. The inner controller contains a PIDcontroller and an observer. see Figure 1. will be presented. one understands the inﬂuence of the vehicle in its driving direction by means of a controller.
It should also be examined if the structure of the ﬁlter can be improved. The ﬁlter is directly attached to the engine and brakes. describe methods for choosing the parameters. The coordinator (“Coord”) chooses which of the functions that should have aﬀect and delivers a desired acceleration ad to the inner control loop.. The inner control loop consists of a PIDcontroller and an observer. 1. For this purpose the theory behind the ﬁlter and the methods for ﬁlter tuning had to be better investigated. brake and gearbox which are aﬀecting the vehicle. The Kalman ﬁlter has to be tuned to work optimally.1. and to ﬁnd good parameter settings justiﬁed by theoretical and practical methods. a Outer controller Inner controller Figure 1.2 Introduction v v v  Speedtronic ad1 ad2 Coord. . adn  6 v. They deliver a desired torque T to the engine.. Overview of the longitudinal controller in the vehicle.3 Objective The goal of this thesis is to explain the function of the Kalman ﬁlter.2 Problem Formulation The Kalman ﬁlter attached parallel to the PIDcontroller should estimate the part of the vehicle’s acceleration caused by large disturbances (for example a changed mass or slope of the road). Distronic ad PID T  Vehicle DSR ad3 Observer . and it is therefore important that the output from the ﬁlter is smooth. Otherwise the comfort is negatively aﬀected. The speed v and acceleration a are used as feedback signals. 1. The driver assistance functions in the outer control loop calculates accelerations adi .
Finally. Chapter three discusses some basic estimation ﬁlter theory needed to implement an observer in the controller. Smart and Maybach. conclusions are drawn and some extensions for the thesis are presented. . Germany. CLSClass. At the end of chapter six a comparison between the developed Kalman ﬁlter and a standard lowpass ﬁlter is made. The model of the disturbance used in the existing Kalman ﬁlter will be examined. 9500 persons are working with development. At Mercedes Technology Center in Sindelﬁngen. Jeep.1. among others.6 Outline In the introductory chapter the purpose and method of the thesis is presented. Chapter six starts with a presentation of some more complex models used to model the estimated parameter.4 DaimlerChrysler AG DaimlerChrysler AG is a major automobile and truck manufacturer formed in 1998 by the merge of DaimlerBenz in Germany (the manufacturer of MercedesBenz) and the Chrysler Corporation in USA. It will be examined if this makes the ﬁlter both work properly in case of small noise as well as respond quickly in case of sudden larger changes (as is two competitive goals with the Kalman ﬁlter). CLClass and Maybach cars. and continues with a discussion of the advantages and disadvantages of using these models. and simulations are made oﬀline. In chapter ﬁve the model for the longitudinal dynamics of the vehicle is derived. Dodge. vans and busses under the brands Chrysler. The ﬁlter will then be extended with an algorithm for change detection. and an algorithm that uses this theory is simulated and evaluated. In January 2007 the company was the second largest auto manufacturer. The company produces cars. in the last chapter. over 35000 employees are producing the CClass. Then a stationary Kalman ﬁlter is designed for the model and good working parameters will be found using simulation. Chapter seven discusses the possibilities given by some ideas picked up from the area of “Change Detection”. The development of the observer is performed in Matlab and Simulink. 1. MercedesBenz.4 DaimlerChrysler AG 3 1.5 Method The necessary theory describing the Kalman ﬁlter will be presented using literature studies. 1. Diﬀerent methods for choosing the ﬁlter parameters will be explained and implemented. trucks. and an initial version of the Kalman ﬁlter is implemented and tested. SClass. An overview of the diﬀerent driver assistance systems supported by the longitudinal controller is given in the second chapter. The team working with driving assistance systems is developing control systems such as adaptive cruise control and hill descent control. Using previous Master’s theses at DaimlerChrysler the process model for the vehicle’s longitudinal dynamics will be developed. Diﬀerent possibilities to choose and tune the ﬁlter parameters are presented in chapter four. EClass.
It has not been examined if the ﬁlter described in this thesis would make better estimates by using unﬁltered data.7 Limitations The use of an observer in an inner controlloop to estimate the model errors was suggested in [1].4 Introduction 1. The sensors used in this Master’s thesis to measure the speed and acceleration of the vehicle use Kalman ﬁlters and sensor fusion techniques to obtain stable measurements. the advantages and disadvantages of attaching an observer in parallel to a PIDcontroller (as described in this Master’s thesis) have not been examined. A comparison between this method and the use of a PIDcontroller was made in [19]. However. . It is a method used for about a year in test vehicles at DaimlerChrysler and accepted as a basis for this thesis.
. i. [7] 5 . Among the driver assistance systems there are comfort functions. an introduction to driver assistance systems is given in this chapter.2 Traction Control The functioning of the traction control system is very similar to that of the ABS. When the German automotive supplier Bosch launched their stability control system they called it “electronic stability program” (ESP). If the deviation is greater than a certain threshold. The system measures the velocity of all four wheels. which relieve the driver in his/her tasks. and compares it with the desired trajectory. The system prevents the wheels from slipping during acceleration by using the same velocity sensors as the ABS. During bad road conditions.Chapter 2 Driver Assistance Systems To better understand the task of the controller discussed in this thesis. passive safety functions. the rotation in the ground plane.1 Antilock Braking System Antilock braking system (ABS) prevents the wheels from locking and maintains the steering ability of the vehicle during hard braking. and if one of the sensors reports an abnormal deceleration it concludes that the wheel is about to lock and the pressure in the braking system is reduced. If the vehicle starts to slip. the system will activate the brakes on one side of the vehicle to correct this. 2. [7] 2. [7] 2. and active safety functions which help the driver to avoid accidents. ABS will also reduce the stopping distance. which reduce the consequence of an accident.3 Stability Control A stability control system basically measures the yaw rate of the vehicle.e. the engine power is reduced in order to maintain control of the vehicle.
The driver can easily set and change the desired speed during driving. The variable limit can easily be set and changed during driving. [25] 2. [7] . It uses the ABS brake system to control each wheel’s speed and keeps the speed of travel to the speed set in the operating system. The permanent limit is used for permanent longterm speed restrictions. often referred to as “kickdown”. automatically controls the speed of the vehicle. It is automatically deactivated if the driver pushes down the accelerator pedal beyond the pressure point. The driver will be able to maintain control of the vehicle when driving down hills with slippery or rough terrain and the system is therefore especially helpful in oﬀroad conditions. [26] 2. Most manufacturers have a similar functionality when it comes to the intervention strategy. This is useful when overtaking. This function is called “Speedtronic” by DaimlerChrysler. the CMS will reduce the impact speed by applying the brakes when a collision with the leading vehicle appears to be unavoidable. If the driver does not brake himself.4 Speed Limiter The speed limitation function is used to make sure that the driver does not exceed a set speed. If the driver pushes down the accelerator pedal to temporarily drive faster. The driver can set a variable or permanent limit speed.6 Driver Assistance Systems 2. the cruise control adjusts the vehicle’s speed to the last stored speed when he/she again releases the accelerator pedal. [25] 2. sometimes called “speed control” or “autocruise”. and it cannot be exceeded by kickdown. It is possible to drive at a higher or a lower speed than that set in the operating system at any time by manually braking or accelerating. This is useful when overtaking. such as driving on winter tires. The hill descent control system used in DaimlerChrysler vehicles is called “Downhill Speed Regulation” (DSR). and cruise control maintains the set speed and accelerates and brakes the vehicle automatically if necessary. The permanent limit speed is set using the onboard computer.5 Cruise Control The cruise control.7 Forward Collision Mitigation System Collision mitigation system (CMS) uses radar sensors to detect obstacles which are in the path of the vehicle.6 Hill Descent Control The hill descent control system is essentially a lowspeed cruise control system for steep descents. They use increasing warning levels as the threat approaches.
If the vehicle detects that a higher deceleration is required to avoid colliding with the leading vehicle. and activates the brake assist system to reduce impact speed.8 Adaptive Cruise Control 7 2. [25] 2. The driver has to apply the brakes in order to maintain the correct distance and avoid a collision. If Distronic Plus detects .2. an audible warning is given to the driver. [7] DaimlerChrysler oﬀers adaptive cruise control under the name “Distronic”. This helps to reduce the consequence of an accident.7.1 Distance Warning This function warns the driver when the distance to the vehicle in front is too small. the system interprets this action as emergency braking. ACC operates in the same way as cruise control. ACC uses a forward looking sensor. but the driver has to apply the brakes himself/herself in order to avoid a collision. With the Distronic system. which functions at speeds between 0 and 200 km/h. A message or a warning lamp in the instrument cluster then lights up. if the driver applies the brakes.7. usually radar or laser. there are no obstacles detected in the path of the vehicle and there is no longer a risk of collision. [25]. If the driver pushes down the brake pedal quickly.8 Adaptive Cruise Control Adaptive cruise control (ACC) is also known as “active cruise control” or “intelligent cruise control”. If the vehicle is equipped with radar sensors. [25] If the system has detected a risk of collision and the driver does not brake or steer himself/herself. In DaimlerChrysler vehicles this function is called “BAS Plus”. the vehicle will automatically brake in order to maintain distance. the system calculates the brake pressure necessary to avoid a collision. In Europe there are government restrictions which limit the permitted braking rate. If the system is active and the time gap to the leading vehicle falls below a certain threshold. This system is called “presafe brake” in DaimlerChrysler vehicles. If there is no vehicle in front. It functions at speeds between 30 and 200 km/h. If the driver is approaching the vehicle in front at high speed. the system automatically boosts the braking force to a level appropriate to the traﬃc situation.2 Brake Assist System Brake assist system (BAS) operates in emergency braking situations. the vehicle is automatically braked gently and the seat belts are retracted gently two or three times to warn the driver. The brake assist system is deactivated and the brakes will function as normal when the driver releases the brake pedal. At this point. BAS automatically boosts the braking force and thus shortens the stopping distance. [7] 2. to monitor the distance to leading vehicles. The system uses radar sensors to measure the distance to the vehicle in front. the distance to the leading vehicle is set as a time between one and two seconds. he/she will also hear a signal. When the driver pushes down the brake pedal forcefully. [25] Some DaimlerChrysler vehicles are equipped with a system called Distronic Plus.
the grooved lane markings that are sometimes used on motorways to indicate lane departure. it will cause the vehicle to brake and come to a halt. it will remain so without the driver having to push down the brake pedal. the focus will be on those driver assistance systems that are supported by the longitudinal controller at DaimlerChrysler AG. and the driver pulls the cruise control lever or brieﬂy pushes down the accelerator pedal. Systems typically use an audible warning or a steering wheel torque to alert the driver if the vehicle is approaching the lane markings. If the vehicle in front pulls away. These are • Speed limiter • Cruise control • Adaptive cruise control • Collision mitigation system • Brake assist system • Hill descent control Figure 2.10 Blindspot Warning The general idea behind a blindspot warning system is to lower the risk of lane change accidents by warning the driver about vehicles in the blind spot. Another idea is to try to mimic the sounds and vibrations that are generated by rumble strips. thus working almost like an autopilot. [25] 2.8 Driver Assistance Systems that the vehicle in front has stopped. The steering wheel torque used by some of the systems will automatically steer the vehicle back into the center of the lane. i. ..9 Lane Guidance System Lane guidance system refers to systems that try to help the driver stay in the lane. Once the vehicle is stationary.11 Systems Supported by the Controller In this Master’s thesis. The vehicles are listed together with the driver assistance systems that are used in the vehicles. There are diﬀerent techniques for achieving this but usually ocular vision or radar is used. the vehicle automatically pulls away and adapts its speed to the vehicle in front.1 gives an overview of the vehicles sold by DaimlerChrysler. [7] 2. [7] 2.e.
Class 209 CLS .Class 230 SLK .Class 211 R .11 Systems Supported by the Controller 9 Speedtronic C .Class 164 G .Class 463 GL . The names that are used in the ﬁgure are the names used by DaimlerChrysler.Class 171 M .2.1.Class CL203 CL .Class X164 Sprinter Viano 639 Vito 639 Crafter (VW) Cruise Control Distance Warning Distronic Distronic Plus DSR PreSafe Brake BASPlus x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Figure 2.Class 221 SL .Class 216 CLK . Driver assistance systems supported by the vehicle longitudinal controller at DaimlerChrysler. .Class 219 E .Class WS203 C .Class 215 CL .Class 251 S . The ﬁgure shows which DaimlerChrysler vehicles are using the systems.
10 Driver Assistance Systems .
3. [11] The order of a diﬀerential equation is equal to the order of the highest derivative.Chapter 3 Basic Filter Theory This chapter starts with an introduction to statespace models often used when working with control systems.1 StateSpace Models To design an estimation ﬁlter one ﬁrst needs a mathematical model of the controlled process. Almost every physical system can in the same way be described using diﬀerential equations. When doing control design it is preferable to have all equations of ﬁrst order. When the equations describing a system are 11 . The Kalman ﬁlter is “certainly one of the greater discoveries in the history of statistical estimation theory and possibly the greatest discovery in the twentieth century” [11]. [9] In this Master’s thesis a special type of diﬀerential equations will be used. Sir Isaac Newton (16421727) discovered that the sun and its planets are governed by laws of motion that depend only upon their current relative positions and current velocities. Then some basic theory for observers is presented. By expressing these laws as a system of diﬀerential equations and feed them with the current positions and velocities he could uniquely determine the positions and velocities of the planets for all times. The equations for this ﬁlter are presented and the function of the stationary Kalman ﬁlter is explained. It is shown how to transform a continuous time model into a time discrete model. In the end of this chapter it is described how to construct shaping ﬁlters for nonGaussian process noise and nonGaussian measurement noise. called ordinary diﬀerential equations (ODE). This model is also referred to as the continuoustime statespace model. One can reduce the form of any system of higher order diﬀerential equations to an equivalent system of ﬁrstorder diﬀerential equations by introducing new variables. One popular observer is the Kalman ﬁlter.
5) The index d is referring to the discrete form of the matrices.2 Discretization Almost every physical system is best described using a continuoustime model.4) and (3. which cannot be directly measured. The “measurement model” (3.5) is being used xk+1 yk = Ad xk + Bd uk + Gd wk = Cd xk + ek (3. They can only be observed through their inﬂuence on the output.1) and (3.6) (3..1) and (3. based on [10] and [13]. This means that it satisﬁes the Markov Property [3] p[x(t)x(τ ). This gives the linear discrete timeinvariant statespace model x(kT + T ) = Ad x(kT ) + Bd u(kT ) + Gd w(kT ) y(kT ) = Cd x(kT ) + e(kT ) (3. How this is done is explained in this section. or “The future is independent of the past if the present is known”. but the controller is often implemented in a computer using discrete methods.2) The variables x = [x1 .2) are commonly called “state variables” (or “states”) and they represent all important characteristics of the system at the current time. The continuous dynamic system described by (3. xn ]T in (3. In words this means that the past up to any time t1 is fully characterized by the value of the process at t1 . τ < t1 ] = p[x(t)x(t1 )].4) (3. one only needs to know the current state. .3) The construction p[AB] in this statement should be read “the probability of A given B”.1) and (3. e is here some noise added to the measurement.2) describes how the noisy measurements y are related to the internal variables. typically available to or controlled by the system. x2 ..12 Basic Filter Theory linear. ∀t > t1 (3. It can be shown that a system described by (3.7) . The variable u represents a known external signal. [3] 3. the model can be written as the linear statespace model [3] x(t) = Ax(t) + Bu(t) + Gw(t) ˙ y(t) = Cx(t) + e(t) (3. assuming that the input signal u is piecewise constant during the sampling interval T . [3] Usually e and w are modeled as unpredictable random processes with null as mean value and a known variance. because when trying to predict future states of the system with a good model. Often an easier and more compact form of (3. The “process model” (3..2) can be transformed into a discrete statespace system.2) with e and w modeled as Gaussian noise is a Markov Process.1) (3. This is an important property. The variable w is used to model unknown disturbances or model uncertainties. The model therefore has to be sampled and changed into a discrete time statespace model. This is usually the case when the input u is generated by a computer.1) describes the dynamics of the system. often referred to as Gaussian noise.
Another alternative is “triangle approximation”.9) (3.3. Assuming that the stochastic input e also is constant during the sampling intervals. where the input e is assumed piecewise linear over the sampling period. There are several possibilities to calculate the matrix Gd . called “zeroorder hold”.7). Consider the discrete time system described by (3. is used by the command “c2d” (=continuous to discrete) in Matlab when nothing else is speciﬁed [24]. An . 3. The matrices A.6) and (3.3 Observer 13 In this Master’s thesis the indices d will be left out. An observer may be used to estimate the unknown states with help from the available measured states and the measured signals y and u. the same method can be used as for the matrix Bd . The discrete form of the matrices are calculated using the matrices in (3. One of them is eAT = L−1 (sI − A)−1 (3.11) where L−1 is the inverse Laplace transform.10) = 0 eAT Bdt = C There are several ways to calculate eAT .1) giving [13] T Gd = 0 eAT Gdt (3.8) (3. Other methods are using Taylor series approximation or the Padé approximation. In this section some basic theory about the observer is discussed. see [11] for a more detailed description. B and C are time invariant and known.3 Observer When designing a controller it is important to have information about the states of the system. The states x cannot be measured but are needed for controlling purposes. This method is generally more accurate than zeroorder hold when the input e is assumed to be smooth [24]. It is seldom the case that e is constant during the sampling intervals [13]. when there is no risk of confusion.1) and (3. based on parts from [9] and [3]. and the signals u and y can be measured. Normally all states cannot be measured. Gd is then calculated using A and G from (3.2) as Ad Bd Cd = eAT T (3. Other methods include “impulseinvariant discretization” (where the impulse response of the discretized system is matched with that of the continuous system) and “Tustin approximation” (which instead matches the frequency response of the systems).12) This method.
14) 3. In the context of ﬁlters this term is often called the measurement “innovation” or the “residual”. however.14 Basic Filter Theory initial approach to estimate the states would be to simulate the system using only the known input values u xk+1 = Aˆk + Buk ˆ x (3. The matrix L is here a design parameter and it adjusts how much the residuals should aﬀect the estimated states. Therefore. the diﬀerence yk − C xk can be used. described in detail in Section 3. This criteria does however not give any information about how good the estimate will be. To measure the quality of the ˆ estimation. CAn−1 (3. (3. . and will also be so in absence of ˆ errors.15) All states are observable if and only if O has full rank. The optimal value of L can be calculated in diﬀerent ways. This diﬀerence should be null ˆ if the estimate xk is equal to the real state xk . none of the rows can be written as a linear combination of . This will in practice. such that ˆ xk+1 = Aˆk + Buk + L(yk − C xk ) ˆ x ˆ In words this can be written as “Estimated state” = “Predicted state” + L · “Correction term” The correction term reﬂects the diﬀerence between the predicted measurement and the actual measurement as explained above. It is a trade oﬀ between how fast the estimations converge toward the measurement (high L gives a fast convergence) and how sensitive the estimate is to measurement noise (high L gives a more noise sensitive estimate). resulting in diﬀerent types of observers. the states x has to be “seen” in the output y. described in [9] as O= C CA CA2 . .4 Observability The observer estimates the states x with the help of measurements y. never be the case. When a matrix has full rank.13) where xk is the estimated value of x at time step k. A good way to improve the estimates is to use yk − C xk as a feedback. since there are always model errors and disturbances w as well as measurement noise e. there has to be a connection between the states and the measurement. One type of observer is the Kalman ﬁlter. This limitation is formulated with the help of the observability matrix O.5.
3.16) (3. Q) p(e) ∼ N (0.6) and (3. The easiest way to compute the rank of a matrix is given by the Gauss elimination algorithm.5 Kalman Filter 15 the other rows. for example on how to derive the equations.17) T The covariance matrices are thus deﬁned R = E{ek eT } and Q = E{wk wk } k with E{ek } = E{wk } = 0. In Matlab this is calculated with the command “rank”. C and G might change with each time step or measurement. then there is one or more rows that are “unnecessary”. and with normal probability distributions according to p(w) ∼ N (0. Therefore the equations presented here might diﬀer from those found in other literature. Gaussian. but in this Master’s thesis they will be assumed stationary and known. 3. [23] ˆ The Kalman ﬁlter estimates the states of a discrete time controlled process described in the form of (3. Note that the equations can be algebraically manipulated into several forms. given a linear model of the system and statistical information about the process noise w and measurement noise e. and it can do so even when the precise nature of the modeled system is unknown [11]. When the system and noise are modeled in the way described in this section.2 Discrete Time Kalman Filter Equations In this section the Kalman ﬁlter equations will be presented to give an overview of how the ﬁlter works. measurement noise covariance matrix R and the matrices A..3.1 Process and Measurement Model The Kalman ﬁlter is a set of equations that calculates the optimal L. based on parts from [23]. see [3]. 3. If the matrix does not have full rank.5.5 Kalman Filter The Kalman ﬁlter is very powerful in several aspects. and future states. R) (3. The process noise covariance matrix Q. It supports estimates of past. present. In the following sections the basic theory of the Kalman ﬁlter is presented. following the presentation in [23] and [12]. For more information. B. the Kalman ﬁlter will compute the value of L that minimizes the variance of the state estimation error. [12] and [13].7). xk − xk . repeated below xk+1 yk = Axk + Buk + Gwk = Cxk + ek The random variables w and e are assumed to be independent of each other. The Kalman ﬁlter estimates a process by using a feedback control.e. [11] or [12]. The ﬁlter estimates the process state at some time and then obtains feedback in the form .5. i.
if x is a random constant . predictor equations and measurement update equations.16 Basic Filter Theory of (noisy) measurements. As such.23) is to obtain the estimate error covariance Ptt . For example. After each predictor and measurement update pair. which is needed in the next time step. the calculated values xtt and Ptt are saved so they can be used in the next time step. The correction (3. This update is performed with the time update equations xt−1t−1 ˆ Pt−1t−1 = xtt ˆ = Ptt (3. Ptt−1 can be thought of as the uncertainties of how the states x are evolving.22) (3. The discrete Kalman ﬁlter measurement update equations are [13] Lt xtt ˆ Ptt = Ptt−1 C T (CPtt−1 C T + R)−1 = xtt−1 + Lt (yt − C xtt−1 ) ˆ ˆ = (I − Lt C)−1 Ptt−1 (3. the equations for the Kalman ﬁlter are divided into two groups.19) which translates the estimate from the last time step xt−1t−1 to obtain the estiˆ mate for the current time step.14) in Section 3. x−1 is ˆ ˆ chosen with knowledge about the state x.24) (3.21) computes the Kalman gain Lt that minimizes the estimation error covariance Ptt = E[(xt − xtt )(xt − xtt )T ]. i.22) ˆ ˆ generates the state estimate by incorporating the new measurement yt . Q. also referred to as the “a priori” estimate error.. xtt−1 refers to the estimate of x at the current ˆ time step t given all the measurements prior to this time step. The discrete Kalman ﬁlter predictor equations are [13] xtt−1 ˆ Ptt−1 = Aˆt−1t−1 + But x = APt−1t−1 AT + GQGT (3.20) and is the estimation error covariance given measurements prior to this time step.18) (3.3 Initialization The initial values x−1 and P−1 have to be chosen before starting the ﬁlter. Together are (3. This recursive nature of the Kalman ﬁlter is practical when doing the implementation. for improving the estimate incorporating a new measurement.18) and (3.23) The measurement update equations are responsible for the feedback. They can also be thought of as corrector equations.25) The process is then repeated using these values in the algorithms for the next time step. Note that Ptt−1 is calculated using the estimate error from the last time step.5.21) (3.19) is deﬁned Ptt−1 = E[(xt − xtt−1 )(xt − xtt−1 )T ] ˆ ˆ (3.e.22) forming (3. [23] 3. also referred to as the “a priori” state estimate. Ptt−1 in (3. (3. The ﬁnal step (3. Pt−1t−1 .3. and the process noise covariance (or “model uncertainties”).
giving a new linear statespace model driven by Gaussian noise.3. In Chapter 4 it will be discussed how to choose the parameters Q and R. the design parameters are Q. [23] ˆ 3. These ﬁlters are called shaping ﬁlters.6 Shaping Filter 17 with normal probability distribution. The stationary value of L can then be calculated as L = AP C T (CP C T + R)−1 (3. . P−1 is the ˆ uncertainty in the initial estimate x−1 . Q and R are timeinvariant. these parameters can be precomputed by either running the ﬁlter oﬀline. For many physical systems encountered in practice.6 Shaping Filter When implementing a Kalman ﬁlter.e. C.26) and (3..26) This equation is referred to as the algebraic Riccati equation. it may not be justiﬁed to assume that all noises are Gaussian. a model with nonGaussian noise can be extended to a ﬁlter driven by Gaussian noise. B.5 Block Diagram of the Stationary Kalman Filter The computational procedure and the relation of the ﬁlter to the system is illustrated as a block diagram in Figure 3. When one is absolutely certain that the ˆ initial state estimate is correct. The ﬁlter can be included in the original statespace system.4 Steady State If the matrices A. then P−1 should be set to 0. both the estimation error covariance Pk and the Kalman gain Lk will converge to a stationary value. the signal can be described as the output of a ﬁlter driven by Gaussian noise. If this is the case. i.5.5.5. it is necessary to have all disturbances acting as Gaussian noise.[23] 3. the best choice is x−1 = 0. Using this. The model used in this Master’s thesis is developed in Chapter 5.6 Design Parameters Design parameters for an observer are the matrices A.27) are used to calculate L. but in this Master’s thesis they will be assumed stationary. Otherwise the best choice is the variance of x. If the spectrum of a signal is known. or by calculating the stationary value P as described in [12] and [19] P = AP AT + GQGT − AP C T (CP C T + R)−1 CP AT (3. a random signal with null as mean value. the initial estiˆ mate xt−1t−1 and the input data yt . The Kalman ﬁlter recursively computes values of x using the precalculated stationary values of P and L.1. [12]. and they shape the Gaussian noise to represent the spectrum of the actual system. the choice is not critical. the functionality to calculate new values for L also has to be implemented. C and L. 3. If the Kalman ﬁlter equations (3. R and G instead of L.27) 3. However. If the matrices are time dependent.
so that it can be ˆ used in the next time step. [11] .18 Basic Filter Theory Discrete System Measurement ut .B wt + + ? f + 6 xt A delay xt−1 . The variable xtt−1 is calculated Aˆt−1t−1 + But as in (3.C et + + f ? yt Discrete Kalman Filter xtt ˆ ? delay xt−1t−1 ˆ . Kalman ﬁlter block diagram.7). and its relation to the system.C B 6 ut Figure 3. ˆ x The estimate for the current time step xtt is calculated xtt−1 + L(yt − C xtt − 1) as ˆ ˆ ˆ in (3. It can here be seen how the estimate xtt delivered from the Kalman ﬁlter is saved in the delay block.22). The Kalman ﬁlter recursively computes values of x using the precalculated ˆ stationary values of P and L.6) and (3. and the input signals y and u.18).A + f + 6 xtt ˆ + + f 6 L − + f 6 xtt−1 ˆ .1. This ﬁgure shows the computational procedure of the Kalman ﬁlter. The blocks “Discrete System” and “Measurement” are a graphically representation of the statespace model (3.
28) (3. e1 is nonGaussian noise and w is Gaussian noise.43) .29) Consider a system given on the form where w1 is nongaussian noise and e is zeromean Gaussian noise.40) (3.36) (3.34) (3. giving the new statespace system x = Ax + Gw ˙ y = Cx + e where x = A = G C = = x1 xSF A1 0 0 GSF C1 0 G1 CSF ASF (3.30) (3.1 Shaping Filters for NonGaussian Process Noise x1 ˙ y = A1 x1 + G1 w1 = C1 x1 + e (3.31) where w is Gaussian noise.2 Shaping Filters for NonGaussian Measurement Noise x1 ˙ y = A1 x1 + G1 w = C1 x1 + e1 (3. following the theory in [11].41) where e is Gaussian noise. 3. In this case the new statespace system becomes x = Ax + GW ˙ y = Cx (3.39) Consider a system given on the form In this case.33) 3.38) (3.6.6.35) (3.37) (3.32) (3. Suppose w1 can be modeled by a linear shaping ﬁlter according to xSF ˙ w1 = ASF xSF + GSF w = CSF xSF (3.42) (3. Suppose e1 can be modeled by a linear shaping ﬁlter according to xSF ˙ e1 = ASF xSF + GSF e = CSF xSF (3. Then the ﬁlter can be included in the original statespace system.6 Shaping Filter 19 This is done for systems with nonGaussian process noise and nonGaussian measurement noise in the next two sections.3.
44) (3.47) (3.48) .20 where x = A = G C W = = = x1 xSF A1 0 G1 0 C1 w v 0 ASF 0 GSF CSF Basic Filter Theory (3.46) (3.45) (3.
1) where ei is the mean value of ei . [12] Each element of R is deﬁned as [3] Rij = E[(ei − ei )(ej − ej )T ] ¯ ¯ (4. using openloop or closedloop simulation. it is possible to obtain an estimation of the covariance matrix R. and the formulation E[ζ] means the statistical ¯ expected value of ζ.1 Estimating the Covariances The Kalman ﬁlter assumes that all disturbances are stochastic variables known in advance. A global optimization technique called simulated annealing is implemented for autotuning in Matlab and Simulink. First it will be shown how to estimate the parameters using information about the process and measurement noise. In this case the covariance matrices Q and R should be estimated using measures of the noises e and w. If the system is linear and both the process noise w and measurement noise e have a normal distribution. while the oﬀdiagonal elements are the scalar covariances between its components. By investigating the measured signals. and ﬁnally using autotuning. If the components of e is independent of each other. the oﬀdiagonal elements of R should be set to 0. 4. The diagonal elements of the covariance matrix are the variances of the components of e. where n is the number of elements in e. it can be shown that the Kalman ﬁlter is the optimal ﬁlter (in the sense of minimizing the variance of the estimate error). Then it will be described how to tune the parameters using knowledge about the parameters’ inﬂuence on the behavior of the ﬁlter. The matrix R is a symmetric n × n matrix.Chapter 4 Choosing the Kalman Filter Parameters In this chapter diﬀerent possibilities on how to choose and tune the Kalman ﬁlter parameters are presented. Assume that the information in the measured signal y 21 .
22). To understand how the parameter choice aﬀects the ﬁlter.5) . The deﬁnition of the covariance matrix for the process noise Q is similar as for R and it can also be estimated using a similar method. The inﬂuence on L from diﬀerent choices of R and Q can be understood by inserting (3. C. L is calculated using A.3) where y is the lowpass ﬁltered signal. The elements of R can then be calculated as 1 ˆ Rij = N N ei (t)ej (t) t=1 (4.4) where i and j are the index of the measured signals and N is the number of samples used for the estimation. It may be possible to determine the measurement noise covariance from measurements. but determining the process noise covariance is more diﬃcult. The problem that might arise is the fact that not all states in the state vector are measurable. and N is the number ¯ of samples used for the estimation. The uncertainties of the measured signals are here assumed to be independent. for example when not all the states are measurable. a discussion of the function of the parameter will now be held based on parts from [12] and [11]. The measurement noise e can then be estimated by lowpass ﬁltering the signal y as [2] e = y(t) − y (4. Q and R. The estimation of the covariance matrix can be performed in Matlab using the command “covf” [18]. 4. Instead. which gives xk ˆ = x− + Lk (yk − C x− ) ˆk ˆk − = xk + Lk Cxk + Lk ek − Lk C x− ˆ ˆk − − = xk + Lk C(xk − xk ) + Lk ek ˆ ˆ (4.22 Choosing the Kalman Filter Parameters is constant. and will therefore depend on which characteristics the process noise and the measurement noise are given in the model. yi is the mean value of yi . Now assume that the necessary information in the measured signal is of low frequency. for example the speed of the vehicle. a common approach is to test diﬀerent choices of Q and R until the Kalman ﬁlter shows acceptable behavior.2) where i is the i:th measured signal. The elements of R can then be estimated as in [4] and [2] using Ri = 1 N −1 N (yi (t) − yi )2 ¯ t=1 (4.7) in (3. which results in a diagonal R matrix.2 Choosing Q and R Manually A drawback of the Kalman ﬁlter is that knowledge about process and measurement noise statistics is required.
Assume that the parameters are chosen as Q = Q1 and R = R1 . With this method. This type of simulation is used to produce all the diagrams presented in the next chapters. the resulting P in (3. If Q and R is both multiplied with the same value λ. the absolute values do not matter. The reason why this simulation method is called openloop is that the diﬀerent parameter choices does not aﬀect the behavior of the vehicle.27). The calculation of L in (3. as well as the measurement noise e.3. A large R results in a small L. 4. The ﬁlter is fed with the recorded measurements.26) and (3.6) In other words. L remains the same when Q and R is multiplied with the same value. which means that the measurements are not reliable. It is now possible to simulate the Kalman ﬁlter with diﬀerent parameters and compare the outputs. This demands good thrust in the model. measurements done in a test car can be recorded and given as input back to the model in Simulink.1 OpenLoop Simulation One method is openloop simulation. Then the stationary values of P and L can be calculated using (3.3 Simulation Using simulation in Simulink diﬀerent parameter choices can be evaluated without having to make a test drive in a real vehicle.3 Simulation 23 This shows that the state estimate xk is adjusted using the diﬀerence between the ˆ estimate x and the real state x. 4. openloop and closedloop. but it also makes the observer more sensitive to the measurement noise e. R can be set to a constant value and Q adjusted until the ﬁlter gets acceptable behavior. A large Q results in a large L. which means a fast ﬁlter with good trust in the measurements. This gives P = λP1 . When choosing the parameters. Assume that the calculated values are P1 and L1 . .4. Both terms ˆ are multiplied with the gain L. which makes the observer sensitive to errors in the model. but the output from the ﬁlter is not connected to the controller run in the simulation.26) is according to [12] also multiplied with λ.27) then becomes L = = = = = AP C T (CP C T + R)−1 A(λP1 )C T (C(λP1 )C T + (λR1 ))−1 λAP1 C T λ−1 (CP1 C T + R1 )−1 AP1 C T (CP1 C T + R1 )−1 L1 (4. The quotient between Q and R is therefore the design parameter. Here two diﬀerent simulation methods will be explained.
The ﬁrst part of the hill has a slope of 10% (meaning “uphill”). Simulation Scenarios For the closedloop simulation two diﬀerent scenarios are prepared. The driver adjusts the speed by using the cruise control lever. ﬁrst by increasing the set speed to 120 km/h and then by decreasing it again to 80 km/h. and the second part has a slope of −15% (meaning “downhill”). Total mass of the vehicle is 1. The vehicle. Figure 4. The second scenario represents the vehicle driven on a straight road. it’s controller and the environment are simulated together. The vehicle is driven at 80 km/h and the driver has activated the cruise control.8 times the normal mass. The vehicle is unloaded and the driver has activated the cruise control with a set speed of 120 km/h. With this method a scenario including the vehicle and the road is simulated. It is also possible to specify another vehicle which is traveling in front. and one of them is the controller containing the Kalman ﬁlter.3. Figure 4. a socalled “rabbit”.24 Choosing the Kalman Filter Parameters 4.1. The output of the ﬁlter will here aﬀect the behavior of the vehicle. all developed by DaimlerChrysler. The ﬁrst scenario represents the vehicle driven up and down a hill. The vehicle is heavy loaded. . The environment and the actions of the driver are speciﬁed using simulation scenarios.2 ClosedLoop Simulation The other type of simulation used is closedloop simulation.1 shows the Simulink model used by the closedloop simulation. The model consists of several subsystems. The output from the ﬁlter is attached to the controller and the behavior of the vehicle is aﬀected by how well the ﬁlter is performing. Closedloop simulation.
4. for instance when it is too expensive to repeat the same experiment many times. [12] 4.e. A systematic method of choosing Q and R is to perform many simulations using diﬀerent parameters and evaluate the performance. Poor tuning may result in unsatisfactory performance of an otherwise powerful algorithm. i.1 Evaluation Using RMSE The observer gives a so called point estimate x of the state vector x using the ˆ inputs u and measurements of the output y. A performance evaluation variable may be the variance of the state estimation error.4. Optimally this should be done using reallife testing (instead of simulation). The algorithm starts with some parameter values.4 Autotuning 25 4.4 Autotuning Tuning the ﬁlter. Performing it manually is timeconsuming with no guarantee for optimality.) This is an estimate of the n 1 standard deviation of the estimation error norm at each time instant. (The euclidean norm is deﬁned x2 = x2 + · · · + x2 . The cost function measures how good the actual . then simulates the system using these values for the Kalman ﬁlter and calculates a cost function based on RMSE explained in the previous section. but this might not be possible. choosing the values of the process noise covariance Q and measurement noise covariance R so that the ﬁlter performance is optimized with respect to some performance measure.4. [12] 4. is a challenging task. also called the euclidean norm.. One such performance measure is the root mean square error (RMSE) described in [13] RM SE(k) = 1 M M xk − xk 2 ˆ 2 j=1 (j) (4. A scalar measure for the whole data sequence is RM SE = 1 k k i=1 1 M M xk − xk 2 ˆ 2 j=1 (j) (4. For evaluation it is necessary to measure the performance of this estimation. as long as it is possible to generate several data sets under the same premises. an optimization algorithm is developed in Matlab.8) The scalar performance measure can be used for autotuning. It is therefore often desirable to develop automated systematic procedures for Kalman ﬁlter tuning.2 Autotuning Using Matlab To automatically ﬁnd the optimal parameters for the Kalman ﬁlter implemented at DaimlerChrysler. Suppose that it is possible to generate M realizations of the data u and y and apply the same estimator to all of them.7) where the subindex 2 stands for the 2norm. xk − xk (which is also ˆ minimized with the Kalman ﬁlter).
This probability is a ˜ function P (E(s). The optimization algorithm then changes the values.26 Choosing the Kalman Filter Parameters parameters are working. .3 Simulated Annealing The rest of this chapter will be used to present an algorithm implementing the theory of simulated annealing. More theory of the algorithm can be found in [15]. The heat causes the atoms to become unstuck from their initial positions (a local minimum of the internal energy) and the slow cooling gives them more chances of ﬁnding conﬁgurations with lower internal energy than the initial one.sn ]. “Simulated annealing” is a popular approach for the global optimization of continuous functions when derivatives of the objective functions are not available. The optimization function does not vary the parameters enough to see if there are any better solutions. Given a function E(s) depending on some parameter vector s = [s1 . This will be explained later. especially by oscillatory functions. Methods for global optimization problems can be categorized based on the properties of the problem that are used and the types of guarantees that the methods provide for the ﬁnal solution. each step of the SA algorithm considers some random neighbor s of the current parameter state s. Global optimization problems are typically quite diﬃcult to solve. Con . Using this optimization technique does not give a satisfactory result. They will only ﬁnd a global minimum if it is the only minimum and the function is continuous. T ) depending on the corresponding values of the function s for the states s and s. as long as some constraints are fulﬁlled. By analogy with this physical process. There are diﬀerent possibilities to choose the function P . The algorithm continues until optimal values for the parameters are found. and probabilistically ˜ decides between moving the system to state s or staying in s. The code is a modiﬁed example from the Optimization Toolbox [6]. the SA algorithm attempts to locate a good approximation to the global minimum of the function. Another explanation of the simulated annealing algorithm goes as follows. Simulated annealing (SA) is a stochastic global minimization technique. and on a parameter T (called the temperature). The source code for the script implementing this optimization technique is found in Appendix A. One reason is that Matlab’s optimization functions are designed to ﬁnd local minima and they can be fooled. [21] 4.4.. and the implementation in Matlab developed to do optimization with Simulink is found in Appendix B. a technique involving heating and controlled cooling of a material to increase the size of its crystals and reduce their defects. simulates again and calculates a new value for the cost function. that is ˜ gradually decreased during the process. E(˜). and it uses a function called “lsqnonlin”. The name and inspiration come from annealing in metallurgy.. After several (about 100) restarts with diﬀerent starting parameters the script each time ends up giving almost the same parameters back to the user.
save it e_best = e_neighbor. otherwise he may be stuck in a valley (local minimum) not knowing that a better solution is hiding in another valley behind the next hill. // Initial function minimum T = initialtemperature(k_max). // Return best solution found Implementation of the SAAlgorithm In order to apply the SA method to a speciﬁc problem. end if if random() < P(e.4.4 Autotuning 27 sider a man running in the mountains. // Count evaluations end while return s_best. // Yes. or until a state with the target function value etarget or less is found. T) // Move to the neighbor state? s = s_neighbor. The man’s will to go “uphill” is larger at the beginning. The function call “random()” should return a random value in the range [0. the neighbor selection method. When T tends to zero the man will only has the strength to run “downhill”. His task is to ﬁnd the place with the lowest altitude.k/k_max). when his strength T is large. end if T = tempfunction(T. To ﬁnd the place with the lowest altitude (the global minimum) he sometimes has to try running up the hills. change state e = e_neighbor. PseudoCode The following pseudocode describes the simulated annealing algorithm. // Evaluation count while k < k_max and e > e_target // While not good enough s_neighbor = neighbor(s). // Initial state e = E(s). the probability transition . The cost function that should be minimized is in this case the man’s altitude. The algorithm continues until a maximum number of evaluations kmax has been reached. The annealing schedule is deﬁned by “tempfunction()”. s = s0. // Yes. given the fraction r of the time that has passed so far. 1]. // Pick some neighbor e_neighbor = E(s_neighbor) // Compute its function value if e_neighbor < e_{best} then // Is this a new best? s_best = s_neighbor. // Calculate new temperature k = k + 1. // Initial function value s_best = s. which should yield the temperature to use. // Initial best parameters e_best = e. The function call “neighbor(s)” should generate a randomly chosen neighbor of a given state s. one must specify the parameter search space. and the variable T is his current strength. // Initial temperature k = 0. It starts at a state s0 and recursively explores the search space using the method described above. e_neighbor.
The Matlabcode is as follows move = (rand(1.28 Choosing the Kalman Filter Parameters function. This makes the system favor moves that go “downhill” s and avoid those that go “uphill”. and the complete implementation of the algorithm in Matlab can be found in Appendix B. This is an essential s requirement meaning that the system may move to the new state even when its solution is worse than the current one. The general demands and calculations are described here.5). there are no choices that will be good for all problems. It has therefore been observed that applying the SA method is more an art than a science. However.9) This is the method used in [21] and [15]. s_neigbour = s + move. In the following subsections it is explained how the algorithm is implemented. The function depends on the corresponding ˜ function values E(s) and E(˜). This makes the probability of moving to the new state higher. In the Matlab implementation found in Appendix B. The probability (a number s between 0 and 1) should be greater than 0 when E(˜) > E(s). The Matlabcode is as follows . Choosing the Neighbors The neighbors of the current state have to be chosen so that the function values of the neighboring states are not too far away from the function value of the current state. other than the fact that it corresponds to the requirements explained above. there is no mathematical justiﬁcation for using this particular formula in SA. and the annealing schedule (temperature function).5 and +0. It is this feature that prevents the method from becoming stuck in a local minimum. the probability P must tend to zero if E(˜) > E(s) and to a value greater s than zero if E(˜) < E(s).*s. It is true that choosing a neighbor far away from the current state could lead to ﬁnding the best solution faster. Unfortunately.5 times the current parameter vector s. These choices can have a signiﬁcant impact on the eﬀectiveness of the method.3)0.5 and +0. % Randomize between 0. In the implementation found in Appendix B the probability is calculated as P = 1 E(s)−E(˜) s T e if E(˜) < E(s) s otherwise (4. The script can be used to perform autotuning on the ﬁlter. As the algorithm evolves and T goes to zero. and the temperature T . and there is no general way to ﬁnd the best choices for a given problem. the neighbors s to the ˜ current state s are found by moving a random distance from s in a random direction. The distance has been chosen as a value between −0. When T is zero the algorithm will fall down to the nearest local minimum. but this also leads to a low probability of moving to the new solution and the risk of getting stuck in a nonoptimal solution is higher.5 % Calculate new parameters Transition Probability Function P The function P calculates the probability of making the transition from the current state s to a candidate new state s. and in this way the algorithm can move on ﬁnding a good solution.
9) gives 0. Tk−1 .4 Autotuning 29 function P = transition_P(E. which should be minimized. Let sbestn and sworstn be the best and worst among the neighbor solutions. assume that the ﬁnal acceptance probability for an “uphill” maxmove should be very low.9) now gives 10−6 = e −maxmove T0 αkmax (4. say 10−6 . To do that. If the ﬁnal probability is too high. Let s0 be the initial state of the system. Such a method is presented in [21] and used in this Master’s thesis. generate a set of solutions that lies in the neighborhood of s0 . % Move if temperature is high end end Annealing Schedule The annealing schedule must be chosen with care. Setting P = 0. one must have an estimate of the diﬀerence E(˜) − E(s) for s a random state and its neighbors. this function depends on the simulated model. deﬁne maxmove = E(s0 ) − E(sbestn ). or nearly zero. and as the evaluation of this function involves running a simulation in Simulink. It is now reasonable to assume that the initial temperature T0 is high enough if an “uphill” move maxmove will be accepted with a relatively high probability. T) if E_neighbor < E P = 1. say 0.12) . What is needed is an automatic and reasonable way of setting these parameters based on some initial information obtained by the algorithm. Next. As kmax is the maximum number of function evaluations allowed. Typically they are obtained by trial and error and tuned to the function E. the algorithm still behaves like a random search. The initial temperature must be large enough to make the “uphill” and “downhill” transition probabilities nearly the same. such tuning procedures are impractical. this is also the number of times the temperature is reduced. For this thesis an exponential schedule has been chosen. when the algorithm is supposed to ﬁnish.11) and T = T0 can be calculated. To pick the initial temperature T0 . (4.4. (4. where the temperature decreases by a ﬁxed cooling factor 0 < α < 1 at each step. In the problem at hand. as Tk = αTk−1 (4. If E(sworstn ) > E(s0 ). the cooling parameter α is calculated. % Always go down the hill else P = exp((EE_neighbor)/T). The temperature Tk for the current time step k is calculated using the cooling factor α and the temperature from the previous time step. E_neighbor. The temperature must then decrease so that it is zero. To do this. deﬁne the maximum uphill move as maxmove = E(sworstn ) − E(s0 ).9. Otherwise.9 = e− maxmove T (4.10) The initial temperature T0 and the cooling factor α now have to be chosen.9 for an “uphill” move of maxmove.
calculated by using the diﬀerence between the ﬁlter estimate and the “real” value. which means that several executions may give diﬀerent outputs. Restarting Choosing the Kalman Filter Parameters The SAalgorithm uses a random method to ﬁnd the solution.2 shows one execution of the SA script with 200 closedloop simulations in the ﬁrst scenario (the hill) described in Section 4. Results Figure 4. and more computer time is available.2. . The diagram shows that the SAalgorithm is trying to ﬁnd the global minimum of the cost function. it is sometimes better to start the algorithm over with a new initial state s0 . but decreases together with the temperature shown in the lower diagram. In this way the algorithm can be left running for a long time. The Matlab implementation found in Appendix B can be executed recursively and the starting parameter state s0 for the next iteration is set to the best solution found in the previous iteration. The allowance for parameter changes causing a higher value of the cost function is high in the beginning. instead of justifying the maximum number of iterations allowed (kmax ).3.30 and α can be obtained. The upper diagram is the cost function described in Section 4.4. Moving back to a solution that was signiﬁcantly better rather than always moving from the current state is called restarting. or based on the current function value being too high from the best value so far. When a better solution is needed. but does not get stuck in local minima. The decision to restart could be based on a ﬁxed number of evaluation steps.1. restarting over and over again using the previous best solution found as the new initial solution.
As can be seen. The bottom diagram shows the temperature that is gradually decreasing during the process.2.4. One execution of the simulated annealing (SA) algorithm using 200 evaluations. . the current solution changes almost randomly when T is large.4 Autotuning 31 Figure 4. This allowance for “uphill” moves saves the method from becoming stuck at local minima. each step of the SA algorithm probabilistically decides between moving the system to the new state or staying in the old state. The probability depends on the parameter T (called the temperature). The top diagram shows the RMSE costfunction for all the states evaluated. By analogy with the physical process.
32 Choosing the Kalman Filter Parameters .
The desired engine torque Te and the desired brake torque Tb are calculated and given as input to the actuators. 5.) The controlled system is the vehicle with its actuators engine. refer to Figure 1. Input to the controller is the desired acceleration ades . The measured speed vm and acceleration am are derived from wheel speed sensors. brake and gearbox. resulting in a large error in the calculated acceleration. The block “Sensors” in the ﬁgure contains signal processing software which analyzes the motion of the vehicle and gives information back to the controller.1 Overview of the Inner Control Loop Before implementing the Kalman ﬁlter. and an initial version of the Kalman ﬁlter is implemented and tested. the inner control loop of the vehicle longitudinal controller. An overview of the inner control loop is given in Figure 5. The momentary deviation adev from the desired value is calculated as adev = ades − am (5.Chapter 5 Kalman Filter Implementation In this chapter the model for the longitudinal dynamics of the vehicle is derived.1) This deviation is fed into a PIDcontroller which calculates a control value to the 33 . The output from the controlled system is the actual motion of the vehicle and can be thought of as the actual speed vreal and the actual acceleration areal .1. a short explanation of its surroundings. a Kalman ﬁlter is implemented. To deal with this error. It will be shown that this model cannot take all driving situations into consideration. (For a complete diagram of the outer and inner control loop.1. First the function of the observer in the context of the inner control loop will be explained and then a model for the expected acceleration of the vehicle will be derived. In the end of this chapter a discussion will be held on how to best choose the ﬁlter parameters. is needed.
is acting on the vehicle in its opposite direction of travel and is called “drive resistance”. T is the torque needed on the wheel axis to give the vehicle the acceleration ac . T b q. ac is. brake and gearbox.2. forming ac . before delivery to the actuators. as explained above.Vehicle F1 F2 am az Observer vm vreal . Input to the controller is the desired acceleration ades . action is taken either by the brake or the engine. whereas the engine also can be used to decelerate. respectively. Inner control loop of the longitudinal controller. called F2 in the ﬁgure. losses due to tire deﬂection. and the task is to get areal = ades . The deviation adev is given as input to a PIDcontroller. which are given as input to the vehicle’s actuators engine and brake. The observer looks at the torques Te and Tb and calculates the expected acceleration of the vehicle. By adding Fresistance to ac m and then ˜ multiplying with the wheel radius rw . The block F1 calculates the needed torque T on the wheel axis from the corresponding acceleration ac . The other force taken into consideration here. The control value ac is converted by two conversion functions F1 and F2 into the torques Te and Tb . and will be described in detail in Section 5. This is summarized with the output from the PIDcontroller. It consists of the force due to air resistance. Sensors are measuring the real speed vreal and acceleration areal of the vehicle. etc.2) Since m is the standard mass of the vehicle plus the moments of inertia of the ˜ wheel axis and other rotating parts. using the equation T = rw (ac m + Fresistance ) ˜ (5. The output from the PIDcontroller will form the variables Te and Tb described above. and the output from the block “Observer”. then ac m is the force needed to get the desired ˜ acceleration ac . areal Sensors Figure 5. after passing through two conversion steps F1 and F2 . actuators which minimizes the deviation. Depending on the calculated torque T .1. The output az from the observer is the estimated diﬀerence between the expected acceleration and the measured acceleration.PID − 6 ac + f − 6 Kalman Filter Implementation TTe .34 ades + adev f . The task of the observer is to estimate . The output torque T is fed into another block. Fresistance . the control value from the controller given as input to the block F1 . It consists of two parts: the output from the PIDcontroller. F2 coordinates the work of the engine.
Te and Tb are the desired torques given as input. Modeling engine and brake. This error.5. F = ma. The engine and brake models calculate the estimated output torques Tengine and Tbrake . 5.2. The model of the longitudinal dynamics uses these values to calculate the speed and acceleration of the vehicle. is subtracted from the output from the PIDcontroller to form ac . the drive resistance parameters and other unknown parameters not taken into consideration by F1 . The blocks Ge and Gb model the dynamics of the engine and brake respectively. Using the classical mechanical law from Newton. The blocks “Ge ” and “Gb ” model the dynamics of the engine and brake as transfer functions with torques Tengine and Tbrake as outputs. This is performed by looking at the torques Te and Tb given to the actuators. These transfer functions and the equations describing the vehicle longitudinal dynamics will be presented in the next section.2.2 Modeling the Acceleration 35 Tb Te  Gb Ge Tbrake Tengine Longitudinal Dynamics vreal areal Vehicle Model Figure 5.4) . and calculate an expected acceleration. The diﬀerence between the expected acceleration and the measured acceleration gives a hint about the model error.2 Modeling the Acceleration A model for the expected longitudinal acceleration of the vehicle will now be presented. The drive resistance Fresistance is modeled as Fresistance = Fair + Froll (5. The block called “Vehicle” is further described in Figure 5. Assume just for this section that the speed of the vehicle is v and the acceleration of the vehicle in its driving direction is a. and Fbrake is the force from the braking system. and for the vehicle speed the measured value vm will be used. the forces acting on the vehicle can be written as ma = Fdrive − Fbrake − Fresistance (5. called az . These are the variable names used in this section for deriving the model.3) where Fdrive is the force acting on the vehicle through the transmission and engine. in later sections the acceleration calculated by the model will be called aexp .
and the moment of inertia for the front and rear wheel axis. as follows [20] Tdrive = ηid ig Tengine − (i2 i2 Ie + i2 Ig ) d g d a a − (If + Ir ) rw rw (5. the object experiences a force acting on it against its direction of travel.10) The torque acting on the wheel axis Tdrive depends on the output torque from the engine Tengine .8).9) (5.12) . energy losses occur due to deﬂection of the tire. the moment of inertia for engine and gear. This force can according to [14] be written as Fair = 1 ρcd Aw (v + vwind )2 2 (5. Assuming that all wheels have the same crr .5) where N is the normal force acting on the wheel from the ground and crr is the rolling resistance coeﬃcient [20]. (5. cd is the drag coeﬃcient and Aw is a reference area related to the projected front area of the object. When an object is moving through air at relatively high speed. Fdrive and Fbrake depend on the torques acting on the wheel axis.4). the gearbox and diﬀerential ratios ig and id .11) Inserting (5. If and Ir . (5. Ie and Ig .7). and the wheel radius rw as Fdrive Fbrake = = Tdrive rw Tbrake rw (5. Tdrive and Tbrake . N is in this case deﬁned as N= mg n (5. the total rolling resistance acting on the vehicle from all wheels can be calculated Froll = Fr n = crr mg n = crr mg n (5. (5.11) in (5. g is the gravitational acceleration and n is the number of wheels. (5.36 Kalman Filter Implementation When a wheel is rolling.9). the eﬃciency factor for the drivetrain η.7) The air resistance Fair is modeled as follows.8) where ρ is the density of the air. This is modeled as a force acting on the wheel in the opposite direction of rolling Fr = crr N (5.3) yields ma = a 1 ηid ig Tengine − (i2 i2 Ie + i2 Ig ) 2 d g d rw rw a 1 1 −(If + Ir ) 2 − Tbrake − ρcd Aw v 2 − crr mg rw rw 2 (5.6) where m is the mass of the vehicle.10) and (5. vwind is the unknown speed of the wind and it will therefore be neglected in this model.
2 Modeling the Acceleration Now let m=m+ ˜ Inserting (5.20) rw m ˜ rw m ˜ 2m ˜ m ˜ In Section 5. the brake is modeled as a transfer function Gb (s) as Gb (s) = L {gb (t)} = k2 e−sTt3 Tt2 s + 1 (5.18) (5.15) In previous work at DaimlerChrysler [19]. as Tbrake (t) = gb (t) ∗ Tb (t) (5. Tbrake .13) (5. as Tengine (t) = ge (t) ∗ Te (t) In the same way.16) which relates the input torque Te to the output torque from the engine. The engine is modeled as a transfer function Ge (s) as Ge (s) = L {ge (t)} = 2 k1 ω0 −sTt1 2e s2 + 2Dω0 s + ω0 (5. The results are averages of several tests with diﬀerent vehicles and will be presented here and used in this Master’s thesis.7 rad/s 0.5.13) in (5.4 this calculated (expected) acceleration will be called aexp .15) gives the model for the longitudinal acceleration of the vehicle used by the Kalman ﬁlter a(t) = ηid ig 1 ρcd Aw crr mg (ge (t) ∗ Te (t)) − (gb (t) ∗ Tb (t)) − v(t)2 − (5. See [19] for more details.82 90 ms 0.14) Dividing with m yields the equation for the vehicle acceleration as ˜ a= ηid ig 1 ρcd Aw 2 crr mg Tengine − Tbrake − v − rw m ˜ rw m ˜ 2m ˜ m ˜ (5.19) The parameters in the models were found in [19] using system identiﬁcation and chosen to the mean values of diﬀerent test drives with diﬀerent vehicles as k1 ω0 D Tt1 k2 Tt2 Tt3 = = = = = = = 1 16. Tengine .12) gives ma = ˜ ηid ig 1 ρcd Aw 2 Tengine − Tbrake − v − crr mg rw rw 2 Ie Ig If + Ir + i2 i2 2 + i2 2 d g d 2 rw rw rw 37 (5. models for the engine and brake were prepared. .98 80 ms 140 ms Adding this information to (5.17) which relates the input torque Tb to the output torque from the brake.
The main characteristics of the acceleration has been captured by the model. as the model does not exactly describe the speciﬁed vehicle. then after nearly 30 seconds changes back to 60 km/h again.20).3.5 1 1. The ﬁgure shows the calculated expected acceleration (solid line) and the measured acceleration (dashed line). Figure 5. During test drives. Figure 5.38 1.5 0 10 20 30 Time [s] 40 50 60 Figure 5.5).4 it can be observed that the agreement between the measured and calculated expected acceleration is relatively good.5 Acceleration [m/s 2] 0 0. 60 km/h and then 30 km/h again. In this section ﬁve such recordings will be presented. The measurement has been recorded during a test with a relatively nervous controller.3 and Figure 5.5 Kalman Filter Implementation Speedtronic: step down and up again a expected a measured 1 0. But to verify that the model seems reasonable.4 shows a similar test drive using cruise control. The ﬁgure shows the calculated expected acceleration (solid line) and the measured acceleration (dashed line). The vehicle is traveling with a speed of 60 km/h when the driver changes the set desired speed to 30 km/h. then after nearly 30 seconds changes back to 60 km/h again. The vehicle is traveling with a speed of 60 km/h when the driver changes the set desired speed to 30 km/h. In both Figure 5.3 Errors in the Acceleration Model A thorough validation of the acceleration model is not a subject of this Master’s thesis. 30 km/h. causing the large oscillations between 10 and 20 seconds. The model parameters have been chosen as the mean values from several test drives . Test drive using cruise control. This measurement of the actual acceleration is then compared with the expected acceleration calculated by the model in (5.3 shows a test drive using cruise control (explained in Section 2. 5. this time with set speeds 60 km/h. Some differences between the calculated and the measured signal can be seen in the ﬁgures. This is expected. some tests will now be presented. the signal am from the sensors is recorded.
due to one extra passenger.5 1 1. As can be seen in Figure 5. Another reason is that the measurement of the acceleration in the vehicle contains a lowpass ﬁlter with some timedelay. then back to 60 km/h. The vehicle is traveling using cruise control. As can be seen.7. In Figure 5. After 16 seconds the desired speed is changed to 80 km/h. with a desired speed of 60 km/h. resulting in an oscillatory behavior. the calculated expected acceleration does not comply with the the measured acceleration in this case.5 Acceleration [m/s 2] 0 0. and at last to 30 km/h again. As can be seen. the vehicle mass is a constant .5 shows the vehicle traveling with a constant speed of 30 km/h on a bumpy road.5 s “faster” than the measured value.6 a test has been made using the same vehicle but with an attached trailer with a mass of 2000 kg. In the current model. with diﬀerent vehicles [19]. The reason for this could be that the identiﬁed timedelays in the models for the engine and brake are too small when applied to the vehicle used in the tests. The solid line is the calculated expected acceleration and the dashed line is the measured acceleration. the calculated value is always a bit higher than the measured value. Test drive using cruise control. The reason for this might be that the rolling resistance on the bumpy road is higher than expected. Figure 5. and sometimes up to 0. and that the mass of the vehicle is higher than set in the model.5. the model does not perform as well when changing the working conditions.4.5.5 a expected a measured 1 39 0. In Figure 5. The large errors in the calculations is because of a wrong value of the parameter m.6 and Figure 5. the mass of the vehicle.5 2 0 10 20 30 Time [s] 40 50 60 Figure 5.3 Errors in the Acceleration Model Speedtronic: step up 1. Therefore the model does not exactly comply with the vehicle being used here. An outstanding feature of the calculated value is that it is always a bit. also here the agreement of the measured and calculated acceleration can be recognized. The vehicle looses speed and the controller tries to compensate. The vehicle is traveling with a speed of 60 km/h when the driver changes the set desired speed ﬁrst to 30 km/h.
8 Kalman Filter Implementation Constant speed. Test drive using cruise control on a bumpy road.6 0. The test has been done using a relatively nervous controller.6.4 Acceleration [m/s 2] 0. bumpy road a expected a measured 0. trailer 2000 kg 2.40 0.6 20 25 30 35 Time [s] 40 45 50 Figure 5. As can be seen the calculated expected acceleration does not comply with the the measured acceleration.5 a expected a measured 2 1.5 0 5 10 15 20 Time [s] 25 30 35 40 45 Figure 5. in this test resulting in an oscillating behavior. It looses speed and the controller tries to compensate. The vehicle is traveling with a constant speed of 30 km/h. The vehicle and trailer are traveling using cruise control. the mass of the vehicle. Test drive with a heavy trailer (2000 kg).4 0. Speedtronic: step up and down.5 0 0.2 0. The large errors in the calculations is because of a wrong value of the parameter m.5 Acceleration [m/s 2] 1 0. with a desired speed of 60 km/h.2 0 0. .5. After 16 seconds the desired speed is changed to 80 km/h.
13) as ˜ well as Froll in (5.7) and has a large eﬀect on the calculation of the expected acceleration in (5. The following are some examples of what might happen. First the slope of the road is 0 % (horizontal road).5. In many implementations there are good reasons to keep the model simple. baggage or a trailer. Especially for real time systems it is a good practice to keep models as simple as possible to avoid time consuming computations and dubious parameters. 15% down 3 a expected a measured 2 41 1 0 Acceleration [m/s 2] 1 2 3 4 5 6 0 5 10 Time [s] 15 20 25 Figure 5. Two of the cases have already been mentioned before in this text.7. this time without trailer but with a changing slope. The reason is that the model does not include the case of a changed road slope. It does not matter how complex the model is. The vehicle is driven up and down a steep hill. then to −15 % (downhill).20) does not comply with the real system in all situations. If the attached trailer is equipped with brakes. plus 80 kg for the weight of the driver. In this case the model for the vehicle acceleration in (5. the large change in the mass will only be experienced when accelerating.7 shows a test drive with the same vehicle. First the slope of the road is 0 % (horizontal road).20). then changed to 20 % (uphill). due to extra passengers. Test drive up and down a steep hill using cruise control. then changed to 20 % (uphill). incline: 20% up. . This aﬀects the calculation of m in (5. The model does not include the case of a changing slope. Figure 5. it will in practice never exactly describe the real physical system.3 Errors in the Acceleration Model Driving up and down a hill. When braking. parameter. the trailer brake will help and compensate partially for the extra weight. The value of the parameter m is set to the mass of the vehicle including full tank. As expected. then to −15 % (downhill). The calculated acceleration does not comply with the measured acceleration. • The total mass of the vehicle is not m as in the model. It should be mentioned that all models have errors. the calculated acceleration does not comply with the measured acceleration.
According to [8] the real value of the parameter can vary up to 3.54 < D 0. the speed of the wind vwind cannot be taken into account.18) have been estimated with system identiﬁcation. In real life the wind speed can have a large impact on the actual resistance. • All the parameters in (5. the longitudinal force acting on the vehicle is given by Fslope = mg sin α (5. For example. as well as the reference area Aw (for example due to extra baggage). as asensor = a + g sin α (5. Actually there is a longitudinal acceleration sensor mounted in the vehicles that could be used to estimate the slope α.42 Kalman Filter Implementation • The parameter crr in (5.05 < 0.07 < Tt1 < 19. This is observed to happen relatively often.8). however.21) • Engine and brake might not behave as expected due to inaccuracy. • In the calculation of the air resistance Fair in (5. These parameters diﬀer from those found in a real vehicle. In practice.16) and (5. a force Fslope arises having a direct eﬀect on the vehicle’s acceleration. for example in case of tirepressure drop or when driving on sand.1 < ω0 0.5 times the standard value.2 < 1. According to [8] the real value of Fair can be up to 9 times the calculated value.16) were found to be [19] 15. In [16] it is proposed how to do road slope and vehicle mass estimation using Kalman ﬁltering.22) where asensor is the sensor value and a is the longitudinal acceleration of the vehicle. The drag coeﬃcient cd might also change. .12 • The slope has been totally neglected in the derived model. The sensor measures the sum of the vehicle’s acceleration and the gravitational component parallel to the ground. One problem with the sensor is that it might be diﬃcult making good estimates of the road slope while cornering.7) is in the model set to a constant value. the friction coeﬃcient of the brake may vary between +10% and −15% during a normal vehicle stop maneuver. From several test drives the mean values have been selected. Assume that the slope of the road is α . As an example the interval for the engine parameters in (5. When driving the vehicle in a slope. the rolling resistance changes depending on the driving conditions. errors or change in the friction coeﬃcient of the brakes.
24). Therefore.1) and (3.5. Given a good description on how the state az is changing. and is connected parallel to the PIDcontroller as described in Section 5. It should cover all the model errors found in the previous section.1 and shown in Figure 5. This state variable represents the part of the vehicle’s acceleration caused by disturbances not described by the model for the longitudinal dynamics. Then the real vehicle acceleration areal is areal = aexp + az (5. This can be provided by feeding it with a new constructed signal a∆ .26) (5. According to [3] such changes can be modeled by a continuous time Gaussian noise w as az (t) = w(t) ˙ where E[w(t)] = 0 E[w(t)w(τ )] = qδ(t − τ ) (5.4 Kalman Filter Model 43 5.20) has to be changed to comply with “the real world”.23) This is the model that was derived in Section 5.28) (5.27) (5. the Kalman ﬁlter can be used to estimate this state.1. the continuous time statespace model for the Kalman ﬁlter becomes x = ˙ y = 0 A x+ x+e 1 G w (5. and choosing the state vector x = az . a∆ can be deﬁned as a∆ = am − aexp = az + e (5. With the deﬁnition am = areal + e together with (5. The process noise is modeled in continuous time under the assumption that the state az undergoes slight changes each sampling period.2). Using the statespace model presented in (3.24) where az is called “disturbance acceleration”.2.4 Kalman Filter Model The model for the vehicle longitudinal acceleration a in (5. let the calculated expected acceleration aexp be deﬁned as aexp = ηid ig 1 ρcd Aw 2 crr mg Tengine − Tbrake − v − rw m ˜ rw m ˜ 2m m ˜ m ˜ (5.29) 1 C Here y = x + e = az + e means that the Kalman ﬁlter needs a measurement of the signal az .25) The scalar value q is here the process noise intensity (assumed to be timeinvariant) and δ(·) is the Dirac (impulse) delta function [3].30) .
31) (5.1. Here e will be modeled as Gaussian noise in the same way as w E[e(t)] = 0 E[e(t)e(τ )] = rδ(t − τ ) (5. the Kalman ﬁlter will estimate the state az . As explained in Section 4.5 Choosing the Filter Parameters Diﬀerent values of the noise intensities q and r will now be chosen and the performance evaluated using openloop simulation described in Section 4. Figure 5. It can be seen that.33) (5. the signal will direct aﬀect the comfort of the driver and passengers. However. The ﬁgures that follow have been generated using measured data from test drives. This means that the state is uniquely determinable from the inputs and outputs in the model. The Kalman ﬁlter is fed with the signal y = a∆ = am − aexp . As can be seen. for example the script for autotuning developed in Section 4.9 shows the same parameter choices. It is assumed to be timeinvariant.1). The measurement is taken from a test drive on a bumpy road.44 Kalman Filter Implementation In this way. The system is observable. In this case it is easy. resulting in xk+1 yk = = 1 Ad xk + xk + ek 1 Gd wk (5. since the estimated signal az in this case will be directly connected to the engine and brakes (see Figure 5.8 shows two diﬀerent Kalman ﬁlters. the one using q = 1 is faster and follows the measured values more accurately. How noisy the measurement is can be deﬁned by modeling e.4. the absolute values do not matter. Figure 5. Therefore this section will show the function of the developed Kalman ﬁlter by choosing the parameters manually. comparing . as can be veriﬁed using the rank test in Section 3.4. one with q = 1 and the other with q = 0.34) 1 Cd 5. Therefore r is set to 1 and the Kalman ﬁlter is simulated using diﬀerent values for q. It is possible to use other methods from Chapter 4. This was expected. given the information that a∆ is a noisy measurement of the true value.2 the quotient between q and r is the design parameter. The statespace model is discretized into a digital statespace model with sample time T . while the slower ﬁlter delivers a smoother estimate of az . and those values are also shown in the ﬁgures as dots. The faster ﬁlter is more sensitive to measurement noise.32) The scalar value r is here the measurement noise intensity.3. as choosing a high q always means a faster ﬁlter. using the theory in Section 3. but this time with a measurement of a vehicle driven up and down a steep hill.01.2. The output from the Kalman ﬁlter with q = 1 follows the measurement almost exactly.
This was expected.12 shows the slowest ﬁlter (with q = 0. The hill is rather steep. The ﬁlter with q = 1 is fastest and follows the measured values most accurate. Even the slowest of the tested Kalman ﬁlters is in .01) using a measurement of a test drive on a bumpy road.01 still reacts relatively fast and when only looking at these two ﬁgures (5.8 and 5. or react fast to large changes. every unnecessary oscillation or jerk in the estimate az will have a direct eﬀect of the control values for the engine and brakes.9) q = 0.01) 2 2. The task of choosing the optimal parameters is in this case a compromise between ignoring small changes in the signal.5 3 3. making it better for controlling purposes. and the change from the horizontal road to a slope of 20% comes very fast. as shown in Figure 5. Figure 5. The slower ﬁlter delivers a smoother estimate of az . two slower ﬁlters are evaluated. a smaller q makes the time delay for large signal changes unavoidable larger. shown in the next two ﬁgures.5 Time [s] 5 5.6 0. The faster ﬁlter is also more sensitive to measurement noise.8.2 0. With this in mind. A linear ﬁlter of this type cannot do both. The oscillations of the signal y = a∆ = am − aexp are even larger than in the previous ﬁgures.5 4 4.001 and q = 0.4 Disturbance [m/s 2] 0. The price one has to pay.0003) during a drive on a very bumpy road.5 Choosing the Filter Parameters 0 45 0. is an even slower ﬁlter. The time delay for the ﬁlter with q = 0.8 1 1. This time q = 0. The Kalman ﬁlter now ignores the oscillations even more.10 shows the drive on the bumpy road.5 6 6.11.5. as choosing q high always means a faster ﬁlter. Simulation of two fast ﬁlters with diﬀerent parameters (q = 1 and q = 0. The Kalman ﬁlter q = 0.0003 is so large that the driver will probably feel it when driving up and down the hill shown in Figure 5.2 a∆ = amaexp Kalman filter (q=1) Kalman filter (q=0. It has been observed during test drives that the comfort is negatively aﬀected by having a too fast ﬁlter. However.11.5 7 Figure 5. with the faster ﬁlter.0003 are simulated.01 seems a logical choice. Figure 5.
Simulation of the two fast ﬁlters using a measurement of a test drive of a vehicle driving up and down a steep hill.9.01 still reacts relatively fast.5 1 1. The ideal ﬁlter would ignore these oscillations. But choosing a slower ﬁlter will also make the time delay for changes even larger.01) 2 4 6 8 10 Time [s] 12 14 16 18 Figure 5.5 Kalman Filter Implementation 2 1. It can be seen that.5 1 Disturbance [m/s 2] 0.46 2. a smaller q makes the time delay for large signal changes unavoidably larger. comparing with the faster ﬁlter. this case “not slow enough”. The output from the Kalman ﬁlter with q = 1 follows the measurement almost exactly.5 0 0. but still react fast to large changes. The Kalman ﬁlter q = 0. .5 a∆ = amaexp Kalman filter (q=1) Kalman filter (q=0.
When trying to avoid small changes and oscillations. 2.0003) using measurements from a test drive with a vehicle driving up and down a steep hill.0003) 2 2. the price one has to pay is a slower ﬁlter. making them better for controlling purposes.2 0.5 6 6. The slow Kalman ﬁlters ignore the oscillations even more.001) Kalman filter (q=0.8 1 1. Simulation of two slow ﬁlters (q = 0.6 0.5 Choosing the Filter Parameters 47 0 0.5.10.5 2 1.2 a∆ = amaexp Kalman filter (q=0.0003) 2 4 6 8 10 Time [s] 12 14 16 18 Figure 5.5 a∆ = amaexp Kalman filter (q=0.0003) using measurements from a test drive on a bumpy road.001 and q = 0.11.001) Kalman filter (q=0.5 7 Figure 5. Simulation of the two slow ﬁlters (q = 0.5 3 3. .5 0 0.5 1 Disturbance [m/s 2] 0.4 Disturbance [m/s 2] 0.5 4 4.001 and q = 0.5 Time [s] 5 5.5 1 1.
6 a∆ = amaexp Kalman filter (q=0.12. But choosing such a slow ﬁlter will also make the time delay for changes even larger.8 14 16 18 20 22 Time [s] 24 26 28 30 Figure 5.4 0.2 Disturbance [m/s 2] 0 0.0003) 0.2 0. Simulation of the slowest Kalman ﬁlter using a measurement of a very bumpy road. . Even this ﬁlter is in this driving situation “not slow enough”.4 0.48 Kalman Filter Implementation 0.
23). with vm = vreal + e 49 (6. In this situation the measurement of the acceleration by conventional methods is not considered good enough. Another advantage of using simple models is low computational eﬀort. with the aim of explaining how the Kalman ﬁlter implemented in the test vehicles is working. First a model is presented which can be used when it is not possible to measure the acceleration. At the end of this chapter it is shown that the implemented Kalman ﬁlter behaves like a lowpass ﬁlter.4) . can be used instead.1 Vehicle Speed as Feedback In some situations it is not practical to use the signal a∆ = am − aexp as feedback to the ﬁlter. the behavior of the Kalman ﬁlter is easy to understand when using simple models. vm . 6.6). Then other models of the parameter az is derived. for example when the signal am is not available. This chapter derives some more complex models. and the (assumed noisy) measurement vm of the vehicle speed vreal .1) Input to the ﬁlter is the signal aexp . In this case the measurements of the vehicle speed.3) x1 x2 = vreal az (6.Chapter 6 Alternative Kalman Filter Models As shown in Chapter 5. as deﬁned in (5. This is the case at DaimlerChrysler when using hill descent control (explained in Section 2. The Kalman ﬁlter is then designed using the state vector x = so that vreal ˙ az ˙ = areal = az + aexp = w (6.2) (6.
Choosing a smaller q makes the ﬁlter slower. Notice that e is the noise in the measurement of the speed. which means that the derivative changes each period to a value independent of the last value.1 shows the output from the ﬁlter when fed with the measurement from the test drive on the bumpy road. These changes are uncorrelated. which still can be used as a reference. The dashed line in the ﬁgures is the output from the ﬁlter in Section 5. which used a∆ as feedback. az represents large changes in the environment of the vehicle. Of course the value of q is not the same as in Section 5.2 shows the same ﬁlter simulated with the measurement from the drive up and down the steep hill.7) . Simulating the ﬁlter with the same measurements as in Chapter 5 shows that the basic behavior remains the same.30).8) (6. The dotted line is a∆ = am − aexp as deﬁned in (5.4.2 Modeling the Disturbance az The model of az so far says that its ﬁrst derivative is equal to Gaussian noise. and not the acceleration as in Section 5. resulting in higher computational costs. such as changes in the mass of the vehicle or the slope of the road. which does not comply with the “real” parameter the ﬁlter is trying to estimate. This model allows the derivative of az to jump quickly from a positive value to a negative.50 Alternative Kalman Filter Models where e is the measurement noise and w is the process noise. and choosing a larger q makes it faster. The statespace model becomes x = ˙ 0 1 0 0 A x+ 1 0 B aexp + 0 1 G w (6.2. As can be seen the overall behavior is the same. just as before. The Kalman ﬁlter now has to estimate both vreal and az . and therefore another model will now be examined.5) y = 1 0 C x+e (6. Figure 6.5.6) The noises w and e are modeled as Gaussian noises with intensities r and q. 6. 6. the output signal y satisﬁes the ordinary diﬀerential equation τy + y = u ˙ where τ is the time constant of the step response. modeled as described in Section 5. Figure 6.5 because the measurements are no longer the same.4. The process noise intensity q has been chosen to 5 and measurement noise intensity r is 1. These parameters do not change so quickly.1 FirstOrder Lag Function For a ﬁrstorder lag function with input signal u. The transfer function is G(s) = 1 1 + τs (6. This means that az undergoes slight changes each sampling period.
A larger τ also means a slower response.6.6 Disturbance [m/s 2] 0. The dashed line is the ﬁlter developed in Section 5.5 6 6.5.5 7 Figure 6.9) ω is here the frequency of the input in radians per second. Input to the ﬁlter is the measurement of the vehicle speed. Figure 6.2 Modeling the Disturbance az 0 51 0.0003) 1.2 1.8 1 1.10). which complies with the deﬁnition in (6.6 a∆=amaexp Kalman filter with v as feedback Kalman filter from Chapter 5 (q=0.11) The ﬁrstorder lag function dampens all signals with frequencies higher than the break frequency ω0 and can be used as a lowpass ﬁlter. a larger τ means a lower break frequency. Simulation of the Kalman ﬁlter using the measurement from the drive on a bumpy road. As can be seen in the plot. As can be seen the overall behavior of the ﬁlter remains the same. [9] .3 shows the Bode plot of the transfer function with three diﬀerent values of τ . The solid line is the Kalman ﬁlter with the measurement of v as feedback.8 2 2.4 1. To evaluate the frequency response for the function.5 3 3. q has been chosen to 5.10) Then the magnitude of the function is approximately G(jω) ≈ 1 ω0 jω when ω < ω0 when ω > ω0 (6.1.5 Time [s] 5 5. set s = jω and plot the magnitude of the function G(jω) = √ 1 1 + ω2 τ 2 (6.4 0.5 4 4. Deﬁne the break frequency ω0 as ω0 = 1 τ (6.2 0.
With this choice of u the function is called a ﬁrstorder GaussMarkov process [22].2. where w represents Gaussian noise.5 0 0.5 a∆=amaexp Kalman filter with v as feedback Kalman filter from Chapter 5 (q=0.2 FirstOrder GaussMarkov Process The ﬁrstorder lag function can be used to model physical systems. According to [3] the autocorrelation of the GaussMarkov process in (6. where t1 and t2 deﬁnes the time shift. 6. The described function will now be used to model az . The solid line is the Kalman ﬁlter with the measurement of v as feedback.13) The autocorrelation is a measure of how well the signal matches a timeshifted version of itself.2.52 2.5 Alternative Kalman Filter Models 2 1. Let az + ˙ 1 az = w τ (6. This function has turned out to be important in applied work since it seems to ﬁt a large number of physical systems with reasonable accuracy but still has a very simple mathematical description [5].12) can be written as E[az (t1 )az (t2 )] = e− τ t1 −t2  E[az (t1 )2 ] 1 (6.5.12) Now the problem is to choose a reasonable τ and the intensity of the noise w. As can be seen the overall behavior of the ﬁlter remains the same. This means that the value of az at a sample time tk will depend on the value at the last sample time tk−1 . as az (tk ) = e− τ T az (tk−1 ) + w(tk−1 ) 1 (6. The input u in (6. q is set to 5.14) .7) is then set to w.5 1 Disturbance [m/s 2] 0. The dashed line is the ﬁlter developed in Section 5.5 1 1.0003) 2 4 6 8 10 Time [s] 12 14 16 18 Figure 6. Simulation of the Kalman ﬁlter using the measurement from the vehicle driving up and down a steep hill.
As .2. az will be integrated Gaussian noise just as before. including statespace models. If τ is chosen very large (τ approaches ∞). A Matlab script is found in Appendix C. 6.6.2 Modeling the Disturbance az Bode Diagram 0 53 10 Magnitude (dB) 20 30 τ=1 τ=0. This data set will represent the “maximum dynamic” of az that the ﬁlter will have to estimate.3. as well as some nonlinear models. with three diﬀerent values of τ . If τ is small the correlation is high. which creates a model of az described by (6. It contains all the common techniques to adjust parameters in all kinds of linear models. In this section an introduction is given on how to use this toolbox to identify the unknown parameters in a model. When driving a vehicle at 30 km/h over this steep hill.12) and deﬁnes τ and the intensity of w as parameters to be identiﬁed.25 40 50 0 Phase (deg) 45 90 10 1 10 0 10 Frequency (rad/sec) 1 10 2 Figure 6. the highest demands on the ﬁlter is said to be reached. Matlab contains a toolbox called “System Identiﬁcation Toolbox” [18].3 Identifying the Time Constant The technique of system identiﬁcation is used to build mathematical models of a dynamic system based on measurement data. where T is the sampling interval [5]. Larger τ means a lower break frequency. As identiﬁcation data measurements of the slope of the road during a test drive up and down the steep hill is used. This is done by adjusting parameters within a given model until its output coincides as well as possible with the measured output [17].5 τ=0. Bode plot of the ﬁrstorder lag function.
A smaller choice of τ demands a larger noise intensity to make a good model ﬁt. the script can be used to choose the optimal value of τ .54 Alternative Kalman Filter Models identiﬁcation data the part of az caused by the slope of the road is chosen. In fact. This means that by choosing τ = 7.67%.5 2 2. results in a model ﬁt of over 99%. This is done by setting areal ≡ g sin(α) z (6. Figure 6. For τ = 0.15) where g is the gravitational acceleration and α is the slope of the road. results in a model ﬁt of at least 90%.5 4 6 8 10 12 14 16 18 Figure 6. and τ > 0.3 and noise intensity calculated by Matlab. by choosing any value of τ larger than 0. When the noise intensity is set to a constant value.4 the output from the model is compared with the measurement.67% 1 0. As can be seen. results in a model ﬁt of 83. Letting the script identify the noise intensity with τ = 7 will give a model ﬁt of over 99%. Identiﬁcation of time constant τ .4.3 gives a ﬁt of over 95%.5 shows the calculated signal areal and the predicted output from the z model with τ = 0. the “residuals” (t) = y(t) − y (t) ˆ (6.3 the optimal noise intensity is identiﬁed to 91. In Figure 6.5 1 1. An intensity value of 1 results in the optimal choice τ ≈ 7. The noise intensity is then identiﬁed to 70. the identiﬁed model does not ﬁt the identiﬁcation data exactly. Setting the parameter τ to 7 and letting Matlab identify the noise intensity.1 and then letting Matlab ﬁnd the optimal noise intensity.5 Measured Output Model Fit: 83. Measured Output and 1step Ahead Predicted Model Output 1.16) . The quality of the model can be tested by looking at what the model could not reproduce in the data. it is possible to ﬁnd a perfect ﬁt by adjusting the parameter for the noise intensity.5 0 y1 0. Setting the noise intensity to a constant value and identify the parameter gives τ = 7.
x2 ]T = [v.2. Here τ is set to 7. 6. Figure 6. The rule is that if the correlation function go signiﬁcantly outside these conﬁdence intervals. r is set to 1 and q is set to 70.17) y = 1 0 C x+e (6. In that case the model can be improved.5.5 0 y1 0.5 4 6 8 10 12 14 16 18 Figure 6. there are no .2 Modeling the Disturbance az Measured Output and 1step Ahead Predicted Model Output 1.5 1 1.12) with state vector x = [x1 .7 shows the estimate of az during simulating driving up and down the steep hill.26% 55 1 0. Figure 6. The residuals ˆ should not be correlated with the past inputs u.18) The Kalman ﬁlter using this model is simulated in the same way as in Section 5. then there is a part of y that originates from the past input that has not been picked up properly by the model. Identiﬁcation of time constant τ .26%.3 is chosen and the noise intensity is identiﬁed to 91. giving a model ﬁt of 96. for example by adjusting the number of parameters in the model [17].6 shows the ﬁlter during the drive on the very bumpy road.5 Measured Output model Fit: 96. where y is the validation data and y is the output from the model. Here τ = 0.4 Testing the Model of az Modeling az using the equation for the ﬁrstorder GaussMarkov process (6. The command “resid” in Matlab computes the correlation function of the residuals from the model.5 2 2. If they are. As can be seen. az ]T gives the statespace model x = ˙ 0 1 1 0 −τ A x+ 1 0 B aexp + 0 1 G w (6.5.6. as well as 99% conﬁdence intervals assuming that the residuals are Gaussian. do not accept the corresponding model as a good description of the system.
4 0.20) (6. according to az (t) = w(t) ˙ where E[w(t)] = 0 E[w(t)w(τ )] = qδ(t − τ ) (6. The ﬁgure shows a simulation using recorded data from the vehicle driving on a very bumpy road.22) .4 0.6.21) (6.2 Disturbance [m/s 2] 0 0. no relevant changes can be found.4 where it was stated that the changes in the parameter az can be modeled by setting the ﬁrst derivative of az to Gaussian noise. This means that both models can be used to estimate az in the simulated situations. Another way of modeling the changes is by setting a higher derivative of the parameter equal to Gaussian noise.8 Figure 6. for example az (t) = w(t) ¨ (6. r is set to 1 and q is set to 70. When comparing with the Kalman ﬁlter developed in Section 5.4.2 0. 0. Recall Section 5.6 a∆=amaexp Kalman filter with az modeled as GaussMarkov Process Kalman filter from Chapter 5 (q=0.2.5 HigherOrder Derivative of az In this section the model proposed by [19] will be examined. τ is set to 7.4. giving the same performance.001) 14 16 18 20 22 Time [s] 24 26 28 30 0.56 Alternative Kalman Filter Models relevant diﬀerences in comparison to the simple model used in Section 5. Kalman ﬁlter with az modeled as a GaussMarkov process. and it was shown that it is possible to get an arbitrary fast (or slow) estimate by adjusting the noise parameter q.19) This was implemented and tested in Chapter 5. 6.
there is no practical need to estimate the extra state az . ˙ but in order to take advantage of (6. no relevant changes can be found.23) For the problem at hand.2 Modeling the Disturbance az 57 2 1 Disturbance [m/s 2] 0 1 2 3 a∆=amaexp Kalman filter with az modeled as GaussMarkov Process Kalman filter from Chapter 5 (q=0. The ﬁgure is generated using recorded data from the vehicle driving up and down a steep hill. For example when estimating position ξ and ˙ ˙ speed ξ of an object. When comparing with the Kalman ﬁlter developed in Section 5. Kalman ﬁlter with az modeled as a GaussMarkov process.26) .001) 4 6 8 10 Time [s] 12 14 16 18 Figure 6. ξ]T . the state vector is chosen as x1 vreal x = x2 = az (6. This is used in [19] and also suggested as an alternative by [3] when making estimates for kinematic models. one might use the state vector x = [x1 . There is still the possibility to choose τ according to az (t) + ¨ 1 az (t) = w(t) ˙ τ (6.24) x3 az ˙ The statespace model becomes 0 1 0 1 1 x = 0 0 1 x + 0 aexp + 0 ˙ 1 0 0 0 0 −τ A B 0 1 0 G 0 0 w 1 (6. τ is set to 7.25) y = 1 0 0 C x+e (6. The speed of the object undergoes slight changes.22) or (6.4. r is set to 1 and q is set to 70.23). x2 ]T = [ξ.7. which often are modeled as Gaussian ¨ noise with ξ = w.6.
6.31) (6. w2 and w3 . q2 and q3 remain constant while changing the value of r. w2 . the three estimates can be adjusted individually. A possible approach when adding process noise to all estimated parameters in the statespace model. As has been explained in Section 3. and the value of τ . With the sample time T the result is 1 T = 0 1 0 0 Ad 1 2 2T xn+1 T 1 T T xn + 0 un + 0 0 0 Bd 1 2 2T T 0 Gd 1 3 6T 1 2 2T w (6. Also.58 Alternative Kalman Filter Models e is Gaussian noise as before with intensity r. meaning that Gaussian noise is added to all three equations in the statespace model. (6.24). with noise intensities q1 .29) (6. [13] The design parameters are the noise intensities for each of the Gaussian noises w1 . Therefore.29) does not comply with the deﬁnition of az given in (5. w2 and w3 still remain independent of each other. but w1 . as (6.2.25) and (6. the equations in the model are vreal ˙ az ˙ az ¨ y = aexp + az + w1 = az + w2 ˙ 1 = − az + w3 ˙ τ = vm = vreal + e (6. w2 . will aﬀect all three estimates in the state vector. As can be seen in (6. w3 and e. is to set all intensities to the same value.33) T (6. and the value of τ .32) This might not seem logical. q2 and q3 .30) be set to 0.27) meaning that the noise components of w are independent of each other. w = [w1 . the process noise w2 could according to (6. By letting r be constant. Here w consists of three components. The covariance matrix for w is q1 Q = 0 0 0 q2 0 0 0 q3 (6.5.24). Letting the values of q1 . The statespace model is transformed into a discrete statespace model. the parameters to choose are the intensities of w1 .26).28) This method makes the choice of the parameters easier. using the theory presented in Section 3.34) y = 1 0 0 Cd xn + en . so that 1 0 Q = q 0 1 0 0 0 0 1 (6. the noise intensities are dependent of each other.30) (6. w3 ]T .
for example when the vehicle is started. Some of the plots in this thesis have been generated there.3 Implementation and Testing in Arjeplog 59 The observability matrix O has full rank. This is done because there is no information about the acceleration while the vehicle is standing still.38) (6. but it will be used in Section 6.1 and Section 6.) • The Kalman ﬁlter can be restarted.36) (6.40) With “properly” is meant that the ﬁlter with these parameters has the same behavior as the other ﬁlters evaluated in this thesis. 6. Plots of this ﬁlter will also be shown in Section 6.4. (Refer to Section 2.2 0. which according to the test in Section 3. where a comparison of all ﬁlter models is made. The Kalman ﬁlter was then thoroughly tested in diﬃcult situations to detect adverse behavior. as well as to certain driving situations. as described below. when Distronic Plus tells the vehicle to start moving or when the vehicle has moved against the desired direction of travel.6. • The Kalman ﬁlter can be halted. By the implementation concern has to be taken to the diﬀerent driver assistance functions in the outer control loop.5.5 in a comparison with a lowpass ﬁlter. the parameters are set using trialanderror. for example when the vehicle is stopped. compare to Section 5. These values are changed if DSR is active. until the ﬁlter gets acceptable behavior.37) (6. • The output from the Kalman ﬁlter is limited to some maximum and minimum values. Section 6. while the other estimates are set to initial values.1 20. The Kalman ﬁlter was also evaluated during a testing expedition to Arjeplog in Sweden.500 (6.39) (6.4 means that the system is observable 1 0 0 Cd 1 2 O = Cd Ad = 1 T (6.4.2. The following parameter set is found to work properly q1 q2 q3 r τ = = = = = 4. The estimate for az in the state vector is then kept constant.35) 2T 2 Cd Ad 1 2T 2T 2 Running the ﬁlter oﬀline in Simulink with measurements from test drives.0 0. This is for example necessary when Distronic Plus is stopping the vehicle or when Downhill Speed Regulation (DSR) is active and the tires are blocked.0 0.3 Implementation and Testing in Arjeplog The Kalman ﬁlter is implemented in the test vehicles at DaimlerChrysler. . due to safety reasons. Plots of the Kalman ﬁlter implemented in this section is not shown here.6 for explanations of Distronic Plus and DSR.8 and Section 2.
all the diﬀerent models have almost the same performance with respect to estimating large changes. 2 1 Disturbance [m/s 2] 0 1 2 a∆=amaexp az Kalman filter from Chapter 5 az Kalman filter with v as feedback az Kalman filter with az as GaussMarkov process az Kalman filter implemented in test vehicles 4 6 8 10 Time [s] 12 14 16 18 3 Figure 6. plotted with a dashed line.60 Alternative Kalman Filter Models 6. In this chapter diﬀerent Kalman ﬁlter models have been tested and evaluated. This ﬁgure shows the simulation of driving up and down the steep hill. This is done by adjusting the parameters so that the ﬁlters become the same behavior when simulating the vehicle driving up and down the steep hill. Only the output from the Kalman ﬁlter using the model derived in Section 6. is a bit diﬀerent than the others. it turns out that modeling az in diﬀerent ways does not make the estimate much better. and then by comparing their output when simulating other situations. The parameters have been adjusted so that the diﬀerent ﬁlters almost have the same behavior. Figure 6.1. during this Master’s project no simulated situation has been found where any of the models examined in this chapter can make a better estimate than the simple model used in Section 5.8.1 is a bit diﬀerent than the others. . it becomes obvious that the behavior of the diﬀerent ﬁlters remain the same. The other driving situations (drive on bumpy road for example) show if any of the models can ignore small changes better than the other.5. In fact.4 Comparing the Kalman Filter Models It is interesting to know if the models derived in this chapter can improve the estimate in any way. Only the output from the Kalman ﬁlter using the model derived in Section 6.9 and Figure 6. Figure 6. After some work with the models trying to tune the parameters. By looking at these ﬁgures. a comparison between the diﬀerent models will therefore be made. The parameters have been adjusted so that the diﬀerent ﬁlters almost have the same behavior. By doing this.10 show simulations of a test drive on two diﬀerent bumpy roads.8 shows the simulation of driving up and down the steep hill. Before continuing.
2 0. or a slow but smooth estimate. as the output will be directly connected to the engine and brakes.6. The reason for this is that the Kalman ﬁlter remains a linear ﬁlter giving the user to choose between a fast but jerky. The demands on the ﬁlter correspond to those of an ordinary lowpass ﬁlter. By looking at the output from the diﬀerent Kalman ﬁlters.5 7 1. 6.2.2.6 a∆=amaexp az Kalman filter from Chapter 5 az Kalman filter with v as feedback az Kalman filter with az as GaussMarkov process az Kalman filter implemented in test vehicles 2 2.5 Comparing the Kalman Filter with a FirstOrder Lag Function With the application at hand. The output from the Kalman ﬁlter is represented with a solid line. It has been noticed that a faster controller makes the deviation from the desired speed smaller.5 Comparing the Kalman Filter with a FirstOrder Lag Function 61 0 0. but at the same time the drive gets more uncomfortable.5 and a ﬁrstorder lag function as described in Section 6. This ﬁgure shows a simulation of a test drive on a bumpy road. Instead the ﬁlter is tuned using a subjective feeling about what is a good compromise when sitting in the car.5 6 6. The dashed line is the output from a ﬁrstorder .4 1. The ﬁgures are from simulations in Simulink.8 Figure 6.5 Time [s] 5 5. A fast ﬁlter makes a faster controller.9. but it does not necessary mean that the controller works better.1. the process noise w and measurement noise e cannot be measured or estimated. Therefore this section will try to explain the similarities between these ﬁlters.2 1.4 0. The ﬁgures that follow show the similarities between the Kalman ﬁlter from Section 6.5 4 4.6 Disturbance [m/s 2] 0. using measured data. With the application at hand. As reference a∆ = am − aexp is also plotted with a dotted line. it is important that the estimate is smooth.8 1 1. Another conclusion is that inserting more complexity and more parameters into the model makes the tuning work more time consuming and harder to understand.5 3 3. it cannot be said that any of the ﬁlters is better than the other.
11 comes from a test drive when the vehicle drives up and down the steep hill. By looking at the output from the diﬀerent Kalman ﬁlters. and this is one example of the advantage of developing ﬁlters using the Kalman model.1. When knowing what type of behavior is wanted from the ﬁlter.5. Instead the measurement of the vehicle speed vm is used as described in Section 6. when the signal a∆ = am − aexp is given as input.10.6 0. lag function with time constant 1. Instead. Figure 6. This behavior is also described in [12]. the same work can be done using traditional ﬁlter methods. The Kalman ﬁlter is very practical when the task is to extract information from noisy measurements (also from many sensors in combination – so called sensor fusion) or estimating more than one parameter in a complex statespace model. where the driver uses the cruise control lever to fast step the set speed up and down several times. the Kalman ﬁlter equations are used.8 Figure 6. the Kalman ﬁlter uses the measurement of the vehicle speed as input.2 Disturbance [m/s 2] 0 0. Therefore it is not a regular lowpass ﬁlter. The Kalman ﬁlter used in the comparison does not have the signal a∆ as input.5. but low when the ratio is low. without giving the controller enough time to adjust the speed completely. and Figure 6. it is obvious that the Kalman ﬁlter with these parameters behaves as a lowpass ﬁlter. to calculate the optimal gain L for the observer. as explained in Section 3.4 0.62 Alternative Kalman Filter Models 0. This ﬁgure shows a simulation of a test drive on a very bumpy road.2 0. The calculated gain L is used to adjust the frequency properties of the Kalman ﬁlter so that the gain is high when the signaltonoise ratio is high. When knowing the intensities of the process noise w and measurement noise e. Looking at the ﬁgures.12 comes from a drive on the bumpy road.4 a∆=amaexp az Kalman filter from Chapter 5 az Kalman filter with v as feedback az Kalman filter with az as GaussMarkov process az Kalman filter implemented in test vehicles 14 16 18 20 22 Time [s] 24 26 28 30 0. The measurement in Figure 6. . it cannot be said that any of the ﬁlters is better than the other.2.13 shows a test drive with an attached trailer of 2000 kg.
6.5 Comparing the Kalman Filter with a FirstOrder Lag Function 63
2
1
Disturbance [m/s 2]
0
1
2
3
a∆=amaexp az Kalman filter a∆ lowpass filtered 4 6 8 10 Time [s] 12 14 16 18
Figure 6.11. The measurement in this ﬁgure comes from a test drive when the vehicle drives up and down the steep hill. The dashed line is the output from a ﬁrstorder lag function with time constant τ = 1.1. As can be seen the behavior is similar to the output from the Kalman ﬁlter (solid line).
According to [12], the transfer function for the stationary Kalman ﬁlter is Gkf (s) = (sI − A + LCA)−1 Ls (6.41)
where L is the steadystate gain parameters calculated by (3.27). Calculating Gkf with the model used for the Kalman ﬁlter gives a matrix containing three transfer functions from the input vm to each of the ﬁlter outputs v, az and az . Taking the ˙ transfer function from vm to az , letting s = eiω and plotting its absolute value gives the magnitude plot of the Bode diagram in Figure 6.14. The solid line is given by the parameter set used in Section 6.2.5 and above in this section. The dashed line shows a ﬁlter with smaller r and the dasheddotted line shows a ﬁlter with a larger r. The ﬁlter has the function of a highpass ﬁlter. This is expected, as the transfer function used in the plot estimates az using measurements of the speed v. Its characteristic is normal for all derivating ﬁlters. The ﬁlter with a smaller r has a higher break frequency, and a larger r means lower break frequency. This was also expected, because a smaller measurement noise means that the ﬁlter also can diﬀerentiate higher frequencies. [12]
64
Alternative Kalman Filter Models
a∆=amaexp az Kalman filter a∆ lowpass filtered
0.2
0.1
Disturbance [m/s 2]
0
0.1
0.2
0.3
0.4 10
12
14
16
18
20 Time [s]
22
24
26
28
30
Figure 6.12. The ﬁgure is from a simulation using recorded data from a test drive on a bumpy road. The dashed line is the output from a ﬁrstorder lag function with time constant τ = 1.1. As can be seen the behavior is similar to the output from the Kalman ﬁlter (solid line).
1.5
1
0.5
0 Disturbance [m/s 2]
0.5
1
1.5
2 a∆=amaexp az Kalman filter a∆ lowpass filtered 15 20 25 Time [s] 30 35 40 45
2.5
3 10
Figure 6.13. The ﬁgure is from a simulation using recorded data from a test drive with a heavy loaded trailer. The driver uses the cruise control lever to step the set speed up and down several times, without giving the controller enough time to adjust the speed completely. The dashed line is the output from a ﬁrstorder lag function with time constant τ = 1.1. As can be seen the behavior is similar to the output from the Kalman ﬁlter (solid line).
6.5 Comparing the Kalman Filter with a FirstOrder Lag Function 65
Bode Diagram 10 20 30 40 50 60 70 90 r smaller (faster filter) original Kalman filter r larger (slower filter)
Phase (deg)
Magnitude (dB)
135
180 10
3
10
2
10
1
10
0
10
1
Frequency (rad/sec)
Figure 6.14. Bode Diagram of the transfer function from vm to az , with the Kalman ﬁlter presented in Section 6.2.5. The solid line is the parameters chosen in Section 6.2.5, the dashed line is from a ﬁlter with smaller r and the dasheddotted line is from a ﬁlter with a larger r. The ﬁlter has the function of a normal highpass ﬁlter. This is expected, as the transfer function used in the plot estimates az using measurements of the speed v. The ﬁlter with a smaller r has a higher break frequency, and a larger r means lower break frequency. A smaller measurement noise means that the ﬁlter also can diﬀerentiate higher frequencies.
66 Alternative Kalman Filter Models .
It would be practical to be able to detect such changes in the environment.1 Idea of Change Detection When constructing a ﬁlter. where a thorough explanation of the subject is given. a sequence of independent stochastic variables with zero mean and known variance. The gain in a linear ﬁlter is a compromise between noise attenuation and tracking ability. The ﬁlter uses measurements xm to calculate an estimate x.k − xk ˆ (7. and then one of them is chosen and implemented. The function could be satisfying for some time.1) where e is the measurement noise. After a change either the mean or variance or both changes. and react by making the ﬁlter faster. 67 . it is desirable that the output follows the desired target signal. 7.2) If there is no change in the system and the model is correct. then the residuals are white noise.k = xk + ek (7. Consider a ﬁlter trying to estimate a signal x. It will be shown that it is possible to improve the estimate of az using this algorithm. ignoring the noise. An introduction on how to adjust the parameters for this algorithm is given and simulations of diﬀerent driving situations are made. The quality of the estimate x can be tested by ˆ looking at the residuals k = xm. a slow ﬁlter could be used. and choosing a low gain makes it slow when large changes in the signal occurs.Chapter 7 Change Detection In this chapter an overview of diﬀerent change detection algorithms is given. When driving the vehicle on a straight road. Choosing a large gain makes it fast and sensitive to measurement noise. but then suddenly the slope changes and the model used by the ﬁlter is no longer correct. The presentation that follow is based on [13]. The measurement is modeled as ˆ xm.
for example when a sensor is broken or temporarily unavailable. If the change in the residuals is signiﬁcant. This can be used by a change detection algorithm. The residuals are transformed to a distance measure sk . the change detector gives an alarm and the Kalman ﬁlter can take appropriate action (for example by making the ﬁlter faster). one slow and one fast. It is often used to detect faults in a system. Diﬀerent implementations of the distance measures sk are [13] . in parallel. each one matched to certain assumptions on the abrupt changes. The distance measure transform the residuals from the Kalman ﬁlter to a signal s. In this chapter. representing the change in the residuals. that is. Change detection is also referred to as “fault detection”. A change detector consists of distance measure and a stopping rule.1.3) (7.1. The problem is to decide what “large” is. depending on their current probabilites. and output is the weighted sum of the output from all the individual ﬁlters. • Methods using two ﬁlters. The ﬁlter is temporarily made faster when a change is detected. The stopping rule decides whether the change is signiﬁcant or not.2 One Kalman Filter with WhitenessTest The task of the change detector is to decide which of the following hypotheses is correct. • Methods using multiple ﬁlters in parallel. that measures the deviation from the hypothesis H0 . concerning the residuals from the Kalman ﬁlter H0 H1 : : is white noise is not white noise (7.Kalman Filter 6 xˆk k Distance  sk Stop rule Alarm p Change Detector Figure 7. where a whiteness test is applied to the residuals.4) A change detector consists of a distance measure and a stopping rule. Depending on the residuals from the two ﬁlters. as in Figure 7. For each ﬁlter the probability of that ﬁlter being correct is calculated.68 Change Detection ukxk. a method using one ﬁlter will be implemented and tested. the residuals become “large” in some sense. one of them is chosen as the currently “best one”. The stopping rule decides whether the deviation is signiﬁcant or not. 7. There are three diﬀerent categories of change detection methods [13] • Methods using one ﬁlter.
When an alarm is given. The stopping rule gives an alarm when gk > h.10) Here the forgetting factor λ is used to tune the lowpass eﬀect.2 One Kalman Filter with WhitenessTest • Change in mean. • Change in sign correlation. . giving sk = k 69 (7.7) (7.9) A stopping rule is created by lowpass ﬁltering sk and comparing this value to a threshold h. which means no lowpass eﬀect and sk will in this case be thresholded directly.8) (7. • The Geometric Moving Average (GMA) test gk = λgk−1 + (1 − λ)sk (7. The correlation between the residual t at the current time step k and past outputs yk−l or inputs uk−l at a time step k − l are used as sk = or sk = for some value l. Two common lowpass ﬁlters described in [13] are • The CUmulative SUM (CUSUM) test gk = max(gk−1 + sk − ν. the Kalman ﬁlter is temporarily made faster by adjusting the parameters. and gk is reset to 0.11) (7.6) • Change in correlation. 0) The “drift parameter” ν inﬂuences the lowpass eﬀect. The residual itself is used. λ can be chosen as 0.5) • Change in variance. one can use the fact that white residuals should in average change sign every second sample and use sk = sign( k k−1 ) k uk−l k yk−l (7. giving sk = 2 k −λ (7. For instance. The squared residual subtracted by a known “normal” residual variance λ is used.7.
try to increase β. inspired by the general advice given in [13] • Start with a very large threshold h and choose β to the size of the expected change. The discrete signal at the bottom of the diagrams is the output from the change detection algorithm.2.12) for the change detection algorithm. called “Alarm” in Figure 7. Inserting (7. 0) (7.12) Here β has been deﬁned as β = λ + ν. and as stopping rule the CUSUMtest k gk = max(gk−1 + sk − ν. If fewer false alarms are wanted. As distance measure sk = 2 − λ is chosen. The Kalman ﬁlter should in these situations remain slow. The output from the simulated Kalman ﬁlter is plotted in a diagram together with the measured signal am − aexp .2. This gives L = Lslow = 0.3 is simulated using measurements from test drives representing diﬀerent driving situations.3 shows a vehicle with a trailer with a weight .3 Implementation In this section one change detection algorithm is implemented and tested. with a slope of 20% up and 15% down. • Then simulate all the driving situations again. the faster parameter of the Kalman ﬁlter is chosen.0951. 0). 0) − β. Figure 7. To choose the threshold h and the parameter β in (7.5. try to increase β.2 is a simulation of a test drive up and down a steep hill. The Kalman ﬁlter from Chapter 5 with R = 1 and Q = 0. Choosing R = 1 and Q = 0. or stepping the cruise controller set speed up and down with a heavy loaded vehicle. 7.6) in (7. is also plotted. The parameters for the change detection found using this method are β = 0. Simulate the system with measurements from test drives on bumpy roads.70 Change Detection 7. ignoring the noise. Adjust β such that gk = 0 more than 50% of the time. the following steps are taken. for example driving up and down a steep hill.0172 and results in a slow ﬁlter. When this signal is high. and the Kalman ﬁlter is temporarily made faster by changing the calculated value L to another value Lf ast . Figure 7. The change detector gives an alarm when gk > h. presented in Section 6. try to decrease β.005 and h = 0.4 Results The Kalman ﬁlter with the change detection algorithm chosen in Section 7. As a reference the output from the “original” Kalman ﬁlter without change detection. If faster detection is sought. If there is a subset of the change times that does not make sense.10) gives gk = max(gk−1 + = max(gk−1 + 2 k 2 k − λ − ν. Set the threshold h so the delay for detection of these large changes is reasonable.0003 is selected.01 from Chapter 5 gives Lf ast = 0.1. • Then simulate the system with measurements where large changes occur.
Faster estimates are better in these driving situations because it would give the controller a better chance to compensate for the large changes. The change detection algorithm detects the large changes and makes the Kalman ﬁlter faster.7.4 shows the vehicle with the trailer again. not so many alarms are given.5 and Figure 7. . This shows that the change detection algorithm does not aﬀect the estimate when it is not necessary. The driver is stepping the set speed fast up and down without letting the vehicle reach the desired speed. 3 a∆ = amaexp az Kalman filter az Change Detection 2 Alarm 1 Disturbance [m/s 2] 0 1 2 3 0 5 10 Time [s] 15 20 25 Figure 7. Simulation of a Kalman ﬁlter with change detection algorithm when driving up and down a steep hill. Figure 7.6 each show a test drive on two diﬀerent bumpy roads. and the change detection algorithm does not aﬀect the estimate.4 Results 71 of 2000 kg driving up and down the same hill. As can be seen. Figure 7. this time driving with cruise control. From the three ﬁgures it can be seen that the estimates from the Kalman ﬁlter with change detection is faster than the original implementation.2.
The change detection algorithm detects the large changes and makes the Kalman ﬁlter faster.) 3 a∆ = amaexp az Kalman filter az Change Detection 2 Alarm 1 Disturbance [m/s 2] 0 1 2 3 10 15 20 25 Time [s] 30 35 40 45 Figure 7. The change detection algorithm detects the large changes and makes the Kalman ﬁlter faster than the original implementation. . (The original Kalman ﬁlter becomes saturated at −3ms−2 .4. Simulation of a Kalman ﬁlter with change detection algorithm when driving up and down a steep hill with a 2000 kg trailer. Simulation of a Kalman ﬁlter with change detection algorithm when driving with an attached trailer. The driver uses the cruise control lever to fast step up and down witout letting the vehicle reach the desired speed.3.72 4 a∆ = amaexp az Kalman filter az Change Detection Alarm 2 Change Detection 3 1 Disturbance [m/s 2] 0 1 2 3 4 5 6 0 5 10 Time [s] 15 20 25 Figure 7. This is not implemented in the simulation for the ﬁlter with change detection.
3 0.7. The change detection algorithm does not give many alarms.2 a∆ = amaexp az Kalman filter az Change Detection Alarm 0 0.4 Results 73 0.4 0. The change detection algorithm does not give many alarms. Simulation of a Kalman ﬁlter with change detection algorithm when driving on a bumpy road.5 0. as desired.2 0.5.4 0.8 0 1 2 3 4 5 Time [s] 6 7 8 9 10 Figure 7.2 Disturbance [m/s 2] 0 0.6 a∆ = amaexp az Kalman filter az Change Detection Alarm 0.6.6 0. .2 0. and therefore the estimate is not aﬀected. and therefore the estimate is not aﬀected. as desired. Simulation of a Kalman ﬁlter with change detection algorithm when driving on a very bumpy road.4 0.1 0.6 0 10 20 30 Time [s] 40 50 60 Figure 7. 0.1 Disturbance [m/s 2] 0.
74 Change Detection .
These models have a higher computational cost. Some more complex models for the Kalman ﬁlter have been implemented and tested. • or by adjusting the parameters as a compromise between a slow ﬁlter. inspired by the ﬁrstorder lag function and the GaussMarkov process. • by running simulations in Simulink and optimizing the parameters using a script in Matlab (for this purpose the algorithm simulated annealing has been implemented).Chapter 8 Conclusions and Future Work In this chapter the thesis is concluded with a short summary of the obtained results and observations made. or a fast but jerky ﬁlter (to do this a subjective choice has to be made). 8. It has been shown that the ﬁlter parameters can be chosen either • by knowledge about the noise intensities (when they are not known they can be estimated). 75 . It has been shown how to implement a Kalman ﬁlter estimating the part called az of the vehicle’s acceleration caused by disturbances not included in the model of the vehicle. First it was shown how to use the speed of the vehicle as input to the ﬁlter. where aexp is the expected acceleration calculated by the model and am is the measured actual acceleration. The chapter also includes a section in which interesting future work is brieﬂy introduced. instead of the constructed signal a∆ .1 Conclusions In this Master’s thesis the theory for the Kalman ﬁlter and ﬁlter tuning have been presented. but it could not be proven that they improve the estimate in any way. The easiest method is to use a constructed signal a∆ = aexp − am as input to the ﬁlter. Then two models of az were derived and tested.
3) it would be interesting to see if the performance of the controller could be improved by estimating these parameters. the parameters can then be adjusted by practical methods to suit the actual application. with no loss in performance. instead of estimating az .2 Future Work There are several interesting aspects that deserve further investigation. as the simulations in this thesis suggest. • It is suggested to implement. • As the parameters m (the mass of the vehicle) and α (the slope of the road) have a big impact on the calculation of the expected acceleration (see Section 5. . A change detection algorithm has also been implemented in Simulink and simulations show that it is possible to improve the estimate using this algorithm. simulate and test the other methods for change detection described in this Master’s thesis. For example the method of using two ﬁlters in parallel. • The change detection algorithm implemented in Simulink should be tested in a real vehicle. If this test shows a positive result. 8. may be of interest.76 Conclusions and Future Work It has been shown that the Kalman ﬁlter implemented in the vehicles today can be replaced by a ﬁrstorder lag function. • It should be practically tested if the Kalman ﬁlter can be exchanged with another simpler type of lowpass ﬁlter. one slow and one fast.
List of Notations This table shows the symbols and abbreviations used in this thesis. Symbol α ac adev ades aexp am areal az Aw cd crr η e Fair Fbrake Fdrive Fresistance Froll g id Ie If ig Ig Ir L m m ˜ P q Description Slope of the road Output from the controller Deviation from desired acceleration Desired acceleration Calculated expected acceleration Measured acceleration of the vehicle Actual aceleration of the vehicle Output from the observer Air resistance reference area Drag coeﬃcient Rolling resistance coeﬃcient Eﬃciency factor for the drivetrain Measurement noise Air resistance Force from the brakes Force from transmission and engine Drive resistance Rollin resistance Gravitational acceleration Diﬀerential ratio Moment of inertia for the engine Moment of inertia for the front axes Gearbox ratio Moment of inertia for the gear Moment of inertia for the rear axes Observer gain Mass of the vehicle Mass and moments of inertia Covariance matrix Measurement noise intensity 77 Page 42 34 33 33 43 33 33 43 36 36 36 36 12 36 35 35 35 36 36 36 36 36 36 36 36 14 36 37 16 43 . together with a reference to the page where they are deﬁned.
78 Q ρ r rw R Tb Tbrake Tdrive Te Tengine u vm vreal vwind w x x ˆ Abbreviation ABS ACC BAS CMS DSR ESP RMSE SA List of Notations Measurement noise covariance matrix Density of the air Process noise intensity Wheel radius Process noise covariance matrix Desired brake torque Expected output torque from the brakes Output torque from the transmission and engine Desired engine torque Expected output torque from the engine Input signal Measured speed of the vehicle Actual speed of the vehicle Speed of the wind Process noise State Estimate of the state Description Antilock Braking System Adaptive Cruise Control Brake Assist System Collision Mitigation System Downhill Speed Regulation Electronic Stability Program Root Mean Square Error Simulated Annealing 15 36 44 34 15 33 35 36 33 35 12 33 33 36 12 12 14 Page 5 7 7 6 6 5 25 26 .
Reglerteknik . Aachen. 2001. Master’s thesis. Inc. [5] R. Fach. [2] P. Linköpings universitet. second edition. 2001.G Brown and P. Kirubarajan. fourth edition. [7] A. 79 . Coleman. Kalman Filtering . Li and T. Andrews. third edition. Reglerteori .. Inc. [12] F. Grewal and A. Inc. BarShalom. M. Estimation with Applications to Tracking and Navigation. 1066. PhD thesis No. Robustheits. Linköping. Adiprasito. Inc. Adaptive Filtering and Change Detection.Flervariabla och olinjära metoder. [13] F. 1997. Lund. Studentlitteratur. John Wiley & Sons. Glad and L. Ljung. Blom. Introduction to Random Signals and Applied Kalman Filtering. [6] T. John Wiley & Sons. Eidehall. Optimization Toolbox User’s Guide. L. [3] Y. New York.Bibliography [1] B.Grundläggande teori. Linköping.A Branch and A. fourth edition. Fahrzeuglängsführung im Niedergeschwindigkeitsbereich. Gustafsson.. PhD thesis. Stuttgart. John Wiley & Sons. Glad and L. John Wiley & Sons.. Ljung and M.. [9] T. New York. Ljung. Natick. [11] M. Lund. PhD thesis No. 2003. Andersson. X. Studentlitteratur. Sannolikhetsteori och statistikteori med tillämpningar. Studentlitteratur. 2003. New York. [4] G. [10] T. second edition. 1989. Lund. The MathWorks. Ney York.Theory and Practice Using Matlab.und Stabilitätsbetrachtung des Fahrzeuglängsreglers im Mercedes Benz Pkw.Y. Inc.C Hwang. 2005. Gustafsson. Linköpings universitet. Lund. 989. 2001. 1999. Signalbehandling. second edition. 2006. Shaker Verlag. 2004. Universität Stuttgart. Studentlitteratur. Air Charge Estimation in Turbocharged Spark Ignition Engines. 2007. Grace. Tracking and threat assessment for automotive collision avoidance. [8] M. 2001. Millnert.
Regelung der Fahrzeuglängsdynamik unter Berücksichtigung der unterschiedlichen Dynamik von Motor und Bremse. A Stochastic Radial Basis Function Method for the Global Optimization of Expensive Functions. 1995.pubs. Optimization by Simulated Annealing.. [23] G. DaimlerChrysler AG. Automotive Control Systems For Engine. 2006. Kirkpatrick. [24] Control System Toolbox User’s Guide. [20] K. 2006. Pfrommer. 1993. 20070201 http://joc. 1995.pdf [22] R. second edition. Sensor Fusion between a Synthetic Attitude and Heading Reference System and GPS. Upper Saddle River. Stuttgart.P. Master’s thesis.G. [21] R. Natick. Shoemaker. C. Science(220) : 671680. . Kienecke and L. 2005. Bishop. An Introduction to the Kalman Filter. Online Supplement. System Identiﬁcation . Master’s thesis No. Nielsen. Technical Report TR95041. [17] L. INFORMS Journal on Computing. Linköping. Stuttgart. 2005. System Identiﬁcation Toolbox User’s Guide. Vecchi. Vehicle System Dynamics Supplement 37 page 1223. The MathWorks.. Inc. Berlin. [15] S. DaimlerChrysler AG. 1999. Natick. Prentice Hall. Rosander. SpringerVerlag. Acc. Inc. [16] P. [18] L. Chapel Hill. Ljung.org/Supplements/Regis. Lingman and B. University of North Carolina at Chapel Hill. Welch and G. Linköpings Universitet.Theory for the User. Ljung. Popp and W. Gelatt and M. Schmidtbauer. [19] D. 1983. Road Slope and Vehicle Mass Estimation Using Kalman Filtering. Teubner. [25] Owner’s Manual SClass. The Math Works. [26] Owner’s Manual MClass.80 Bibliography [14] U. 2002. Fahrzeugdynamik. Schiehlen. B. Stuttgart.informs. LITHISYEX34082003. Stuttgart. 2003.D. second edition. Driveline and Vehicle. Universität Stuttgart. Regis and C. 1998.
tolfun = 0. tolx = 0. start_parameters. [].001. q33 = best_parameters(3). % Save the result q11 = best_parameters(1).tolfun).001)’). [].001. options).q22.1 1 10].’TolFun’.tolx.’Display’. end load_system(’opt_param_model’) start_parameters = [0. % Load the model % Set initial values % Set optimization options (for example termination options) options = optimset(’LargeScale’. tolfun) % Optimize control parameters using LSQNONLIN and Simulink model if (nargin < 2) warning(’Using standard value for tolx and tolfun (0.Appendix A Matlab Implementation of “lsqnonlin” function [q11. q22 = best_parameters(2).’iter’.q33] = opt_param_lsq(tolx. % Run lsqnonlin to solve the optimization problem best_parameters = lsqnonlin(@tracklsq.’off’. ’TolX’. % This is the callback function used by lsqnonlin function F = tracklsq(current_parameters) 81 .
xout. therefore ^2 F = rmse(error)^2.yout] = sim(’opt_param_model’). 0 0 q33].82 Matlab Implementation of “lsqnonlin” % Current values are passed by lsqnonlin q11 = current_parameters(1). q33 = current_parameters(3).^2)). rmse=sqrt(1/t*sum(error. error is the 2:nd output) error = yout(:. t = length(error). % Calculate the observer Q_d = [q11 0 0 . \textsc{Simulink}_model_parameters % Create simulation options and run simulation [tout. % (lsqnonlin uses sqrt(F) as cost function. . % Calculate the cost function value % (In the model used. q22 = current_parameters(2).2). 0 q22 0 . end function rmse = RMSE(error) % Calculate a cost function based on the insignal error error = estimated_valuereal_value).
83 % Initial state % Initial error . cost_best] = sim_annealing(param_start. initial state for the algorithm % steps_max.000001. % % Required parameters: % param_start = [q11 q22 q33].steps_max) if(nargin<2) error(’Specifz initial values and max evaluations’). cost_best] = sim_annealing(param_start.steps_max) % % This Matlab function recursively tries to find the optimal % parameters. the maximum number of evaluations allowed %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [param_best. using Simulinksimulation and % the algorithm "simulated annealing".1 P_start = 0. cost_current = sim_cost(param_current). cost_stop = 0.9. P_stop = 0.Appendix B Matlab Implementation of Simulated Annealing This is the developed optimization script implementing the simulated annealing (SA) algorithm in Matlab. end param_current = param_start. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [param_best.
subplot(2. change state cost_current = cost_neighbour.P_start. % Initial "best" solution cost_best = cost_current. cost_best = cost_neighbour. % Yes. . % While time remains & not good enough while steps < steps_max & cost_current > cost_stop % Pick some neighbour param_neighbour = neighbour(param_current). cost_neighbour.5g] = \t %0. xlabel(’temperature’).5g \t T=%0. plot(temp_history).5g \t %0. steps = 0.cost_current. cost_history(steps) = cost_current. subplot(2.1. % Cool down disp(sprintf(’%d: \t [%0.1).steps_max. steps. % Evaluation count. end steps = steps + 1. % Compute its energy cost_neighbour = sim_cost(param_neighbour).5g \t %0. temp_current) param_current = param_neighbour. cost_current. % One more evaluation % Log the cost (path) temp_current = alpha*temp_current. % Initial temperature rand(’state’. param_current(1). end % Is this a new best? % Yes. temp_current = temp_start. param_best = param_current.temp_current)).5g’.sum(100*clock)). temp_history(steps) = temp_current.P_stop). xlabel(’costfunction’). param_current(2). param_current(3). end figure(1). % Should we move to the new state? if rand < trans_P(cost_current.84 Matlab Implementation of Simulated Annealing [temp_start alpha]= init(param_current.2). plot(cost_history). save it. if cost_neighbour < cost_best param_best = param_neighbour. % reset random generator disp(sprintf( ’steps: \t [q11 \t q22 \t q33] = \t cost \t T=temp’)).1.
temp) if cost_current < cost_neighbour P = 1. end end % Calculate the transition probability function P % The probability that we move to new parameters function P = trans_P(cost_current. % Can not allow negative values while n(1) < 0  n(2) < 0  n(3) < 0 % Randomize between 0.2.*param. cost_neighbour. simin_Ld2 = L_d(2)..5 change = (rand(1. simin_Ld3 = L_d(3).3)0. r_d = 0. lrg_para_lrg. q33 = param(3). % Always go down the hill else % Go up the hill if the temperature is high.5 and +0. . % but stay if the temperature is low P = exp((cost_currentcost_neighbour)/temp). disp([’Simulating.85 % Print the best parameters and their evaluated cost value param_best cost_best % Pick some neighbour to the current parameters % Should try to get nearby values! function n = neighbour(param) n = [1 1 1]. % Calculate new parameters n = param + change.’]).5). % These parameters have to be defined as global simin_Ld1 = L_d(1). end end % sim_cost executes the simulation and returns the RMSEerror function cost = sim_cost(param) global simin_Ld1 simin_Ld2 simin_Ld3 q11 = param(1). q22 = param(2)..
else error(’Parameters are not received by Simulink’). cost_worst=cost_start.cost_best end . % best of all the neighbours % worst of all the neighbours for i=1:5 % Generate some random neighbours.P_start.cost_start else max_change = cost_start .86 Matlab Implementation of Simulated Annealing sim(’rdu_simmod_tl_fumo’). end if( cost_neighbour > cost_worst ) cost_worst = cost_neighbour. % Pick out the interesting part (skip beginning!) parterror = error(400:2600). % Save the worst and best neighbour costs if( cost_neighbour < cost_best ) cost_best = cost_neighbour.cost_start.P_stop) cost_best=cost_start. end end % Calculate the maximum uphill move needed if( cost_worst > cost_start ) max_change = cost_worst . % Check global parameters if(simin_Ld1 == max(simout_Ld1)) disp([’OK’]). % Calculate cost (Root mean square error) cost = rmse(parterror). cost_neighbour = sim_cost(param_neighbour).steps_max. evaluate costs param_neighbour = neighbour(param_start). end % Calculate a reasonable initial temperature and alpha function [temp_start. alpha] = init(param_start. end % Calculate the cost function value error = simout_car_pos_gsimout_LRG_az_SGB.
% Now calculate the cooling factor alpha % P_stop = exp(max_change/(temp_start*alpha^steps_max)) alpha = (max_change / (temp_start*log(P_stop)))^(1/steps_max).87 % Set initial temperature so that this maximum move % is accepted with a high probability P_start. % P_start = exp(max_change/temp_start) gives temp_start = max_change / log(P_start). end .
0).cs = m. % Create statespace identification model m = idss(A.5.x0. B = [0].02.D. K = [K_start].b. A = [1/tau_start].Appendix C Time Constant Identiﬁcation Here is the Matlab identiﬁcation script that was used to identify the unknown parameter τ and the intesitiy of w in the ﬁrstorder lag function τ az + az = w. m. az = real_az_Slope’. T = 0.k. D = [0]. ˙ % % % % Identifies the parameter "tau" and "K" in the matrix A dot{x} = Ax + Bu + Ke y = Cx + Du + e The noise intensities of e is 1 load ’C:\Messungen\221_836_RS141p_pr21.’Ts’. tau_start = 0.B.as = [NaN]. x0 = [0].C.81*sin(alpha). % NaN means "please identify" m.c.K.bs = m. C = [1]. 88 % Sampling time % Start values . real_az_Slope = 9. m. K_start = 1.ks = m. m.mat’ % Calculate the disturbance a_z due to the slope alpha alpha = atan((B_LRdeSteigSe)/100).
T). % Identify unknown parameters model = pem(identificationData. az output. compare (identificationData. % Save the identified parameters tau_save = inv(model. zeros(length(az).1). % Load identification data.A) K_save = model.NoiseVariance % Check the model’s ability to predict one step ahead figure(15). % Automatically adjust initial values to suit model m_init = init(m).m_init).1).model.ds = m.d.89 m.K lambda = model. . no input identificationData = iddata(az.
This action might not be possible to undo. Are you sure you want to continue?