Institutionen för systemteknik

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
LiTH-ISY-EX--2007/3950--SE
Linköping 2007
Department of Electrical Engineering Linköpings tekniska högskola
Linköpings universitet Linköpings universitet
SE-581 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
LiTH-ISY-EX--2007/3950--SE
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
SE-581 83 Linköping, Sweden
Datum
Date
2007-04-01
Språk
Language
Svenska/Swedish
Engelska/English

Rapporttyp
Report category
Licentiatavhandling
Examensarbete
C-uppsats
D-uppsats
Övrig rapport

URL för elektronisk version
http://www.control.isy.liu.se
http://www.ep.liu.se/2007/3950
ISBN

ISRN
LiTH-ISY-EX--2007/3950--SE
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 filter is selected. It is the optimal filter 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 filter
is presented and it is shown how to choose the filter parameters. Simulated an-
nealing is a global optimization technique which can be used when autotuning,
i.e., automatically find 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 verified that the parameter choice is a compromise
between a fast but jerky, or a slow but smooth estimate. As the output from
the Kalman filter 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 filter
implemented in the test vehicles today can be exchanged with a first-order lag
function, without loss in performance. This makes the filter 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 filter faster. A filter
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 filter, longitudinal controller, filter 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 filter is selected. It is the optimal filter 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 filter
is presented and it is shown how to choose the filter parameters. Simulated an-
nealing is a global optimization technique which can be used when autotuning,
i.e., automatically find 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 verified that the parameter choice is a compromise
between a fast but jerky, or a slow but smooth estimate. As the output from
the Kalman filter 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 filter
implemented in the test vehicles today can be exchanged with a first-order lag
function, without loss in performance. This makes the filter 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 filter faster. A filter
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 Sindelfingen, 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 Juhlin-Dannfelt and Erik
Almgren for proof-reading, and my girlfriend for her support and encouragement.
Sindelfingen, 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 Anti-lock 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 Blind-spot Warning . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.11 Systems Supported by the Controller . . . . . . . . . . . . . . . . . 8
3 Basic Filter Theory 11
3.1 State-Space 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 Non-Gaussian Process Noise . . . . . . . 19
3.6.2 Shaping Filters for Non-Gaussian 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 Open-Loop Simulation . . . . . . . . . . . . . . . . . . . . . 23
4.3.2 Closed-Loop 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 First-Order Lag Function . . . . . . . . . . . . . . . . . . . 50
6.2.2 First-Order Gauss-Markov Process . . . . . . . . . . . . . . 52
6.2.3 Identifying the Time Constant . . . . . . . . . . . . . . . . 53
6.2.4 Testing the Model of a
z
. . . . . . . . . . . . . . . . . . . . 55
6.2.5 Higher-Order 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 First-Order Lag Function . . 61
7 Change Detection 67
7.1 Idea of Change Detection . . . . . . . . . . . . . . . . . . . . . . . 67
7.2 One Kalman Filter with Whiteness-Test . . . . . . . . . . . . . . . 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 Identification 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 influence 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 figure
chooses which of the functions that should have affect, depending on the driver’s
choice. It also contains a jerk damper, so that the vehicle is traveling smoothly,
even when switching between the different 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 affecting the vehicle. The current speed v and acceleration a
are measured and used as feedback signals by the controllers.
The inner controller contains a PID-controller 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 filter is chosen as observer, and this
Master’s thesis will explain the function and implementation of the Kalman filter
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 affect and delivers a desired ac-
celeration a
d
to the inner control loop. The inner control loop consists of a PID-controller
and an observer. They deliver a desired torque T to the engine, brake and gearbox which
are affecting the vehicle. The speed v and acceleration a are used as feedback signals.
1.2 Problem Formulation
The Kalman filter attached parallel to the PID-controller should estimate the part
of the vehicle’s acceleration caused by large disturbances (for example a changed
mass or slope of the road). The filter is directly attached to the engine and brakes,
and it is therefore important that the output from the filter is smooth. Otherwise
the comfort is negatively affected.
The Kalman filter has to be tuned to work optimally. For this purpose the
theory behind the filter and the methods for filter tuning had to be better inves-
tigated.
1.3 Objective
The goal of this thesis is to explain the function of the Kalman filter, describe
methods for choosing the parameters, and to find good parameter settings justified
by theoretical and practical methods. It should also be examined if the structure
of the filter 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 Daimler-Benz in Germany (the manufacturer of Mercedes-Benz)
and the Chrysler Corporation in USA. The company produces cars, trucks, vans
and busses under the brands Chrysler, Dodge, Jeep, Mercedes-Benz, Smart and
Maybach, among others. In January 2007 the company was the second largest
auto manufacturer.
At Mercedes Technology Center in Sindelfingen, Germany, over 35000 employ-
ees are producing the C-Class, E-Class, S-Class, CLS-Class, CL-Class 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 filter will be presented using literature
studies. Different methods for choosing the filter 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 filter will be examined. Then a stationary
Kalman filter 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 off-line. The filter will then be extended with
an algorithm for change detection. It will be examined if this makes the filter 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 filter).
1.6 Outline
In the introductory chapter the purpose and method of the thesis is presented. An
overview of the different driver assistance systems supported by the longitudinal
controller is given in the second chapter. Chapter three discusses some basic esti-
mation filter theory needed to implement an observer in the controller. Different
possibilities to choose and tune the filter parameters are presented in chapter four.
In chapter five the model for the longitudinal dynamics of the vehicle is derived,
and an initial version of the Kalman filter 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 filter and a standard low-pass filter 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 control-loop to estimate the model errors was
suggested in [1]. A comparison between this method and the use of a PID-controller
was made in [19]. However, the advantages and disadvantages of attaching an
observer in parallel to a PID-controller (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 filters and sensor fusion techniques to obtain stable
measurements. It has not been examined if the filter described in this thesis
would make better estimates by using unfiltered 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 Anti-lock Braking System
Anti-lock 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 long-term speed restrictions, such as driving
on winter tires. The permanent limit speed is set using the on-board 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 low-speed 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 off-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 “pre-safe 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 traffic 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 offers 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 briefly 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 Blind-spot Warning
The general idea behind a blind-spot warning system is to lower the risk of lane
change accidents by warning the driver about vehicles in the blind spot. There are
different 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 figure shows which DaimlerChrysler vehicles are using the
systems. The names that are used in the figure are the names used by DaimlerChrysler.
10 Driver Assistance Systems
Chapter 3
Basic Filter Theory
This chapter starts with an introduction to state-space 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 filter. The Kalman filter 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 filter are presented and the function of the stationary Kalman filter is ex-
plained. In the end of this chapter it is described how to construct shaping filters
for non-Gaussian process noise and non-Gaussian measurement noise.
3.1 State-Space Models
To design an estimation filter one first needs a mathematical model of the con-
trolled process. Sir Isaac Newton (1642-1727) 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
differential 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 differential
equations. [11]
The order of a differential equation is equal to the order of the highest deriva-
tive. When doing control design it is preferable to have all equations of first order.
One can reduce the form of any system of higher order differential equations to
an equivalent system of first-order differential equations by introducing new vari-
ables. [9]
In this Master’s thesis a special type of differential equations will be used,
called ordinary differential equations (ODE). This model is also referred to as the
continuous-time state-space model. When the equations describing a system are
11
12 Basic Filter Theory
linear, the model can be written as the linear state-space 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 influence 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 satisfies the Markov
Property [3]
p[x(t)|x(τ), τ < t
1
] = p[x(t)|x(t
1
)], ∀t > t
1
(3.3)
The construction p[A|B] 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 continuous-time 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 state-space
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 state-space 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 state-space 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 “zero-order hold”, is used by the command “c2d” (=con-
tinuous to discrete) in Matlab when nothing else is specified [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 zero-order hold when the input e is assumed to be smooth [24]. Other meth-
ods include “impulse-invariant 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 difference y
k
− Cˆ x
k
can be used. This difference 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 reflects the difference between the predicted measurement
and the actual measurement as explained above. In the context of filters 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 affect the estimated states. It is a trade off 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 different ways, resulting in different
types of observers. One type of observer is the Kalman filter, 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 filter 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 filter is presented, based on parts from [23], [12] and [13].
3.5.1 Process and Measurement Model
The Kalman filter 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 filter will compute the value of L that minimizes the
variance of the state estimation error, i.e., x
k
− ˆ x
k
. [23]
The Kalman filter 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 defined 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 filter equations will be presented to give an overview
of how the filter 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 differ from those found in other literature. For
more information, for example on how to derive the equations, see [3], [11] or [12].
The Kalman filter estimates a process by using a feedback control. The filter
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 filter are divided
into two groups; predictor equations and measurement update equations.
The discrete Kalman filter predictor equations are [13]
ˆ x
t|t−1
= Aˆ x
t−1|t−1
+Bu
t
(3.18)
P
t|t−1
= AP
t−1|t−1
A
T
+GQG
T
(3.19)
which translates the estimate from the last time step ˆ x
t−1|t−1
to obtain the esti-
mate for the current time step. ˆ x
t|t−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
t|t−1
in (3.19) is defined
P
t|t−1
= E[(x
t
− ˆ x
t|t−1
)(x
t
− ˆ x
t|t−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
t|t−1
is calculated using
the estimate error from the last time step, P
t−1|t−1
, and the process noise covari-
ance (or “model uncertainties”), Q. P
t|t−1
can be thought of as the uncertainties
of how the states x are evolving.
The discrete Kalman filter measurement update equations are [13]
L
t
= P
t|t−1
C
T
(CP
t|t−1
C
T
+R)
−1
(3.21)
ˆ x
t|t
= ˆ x
t|t−1
+L
t
(y
t
−Cˆ x
t|t−1
) (3.22)
P
t|t
= (I −L
t
C)
−1
P
t|t−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
t|t
= E[(x
t
− ˆ x
t|t
)(x
t
− ˆ x
t|t
)
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 final step (3.23) is to
obtain the estimate error covariance P
t|t
, which is needed in the next time step.
After each predictor and measurement update pair, the calculated values x
t|t
and P
t|t
are saved so they can be used in the next time step. This update is
performed with the time update equations
ˆ x
t−1|t−1
= ˆ x
t|t
(3.24)
P
t−1|t−1
= P
t|t
(3.25)
The process is then repeated using these values in the algorithms for the next
time step. This recursive nature of the Kalman filter 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 filter. ˆ 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 time-invariant, 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 pre-computed by either running the filter off-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 filter to the system is illus-
trated as a block diagram in Figure 3.1. The Kalman filter recursively computes
values of ˆ x using the pre-calculated stationary values of P and L, the initial esti-
mate ˆ x
t−1|t−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
filter 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 filter, 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 justified 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 filter driven by Gaussian noise. Using this, a model with
non-Gaussian noise can be extended to a filter driven by Gaussian noise. These
filters are called shaping filters, and they shape the Gaussian noise to represent
the spectrum of the actual system. The filter can be included in the original state-
space system, giving a new linear state-space 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
t|t

ˆ x
t|t
?
delay
-
ˆ x
t−1|t−1
A
-
+
f
u
t
6
B
6
+
ˆ x
t|t−1
6
+
-
C
6

Discrete System
Measurement
Discrete Kalman Filter
Figure 3.1. Kalman filter block diagram. This figure shows the computational pro-
cedure of the Kalman filter, and its relation to the system. The blocks “Discrete Sys-
tem” and “Measurement” are a graphically representation of the state-space model (3.6)
and (3.7). The Kalman filter recursively computes values of ˆ x using the pre-calculated
stationary values of P and L, and the input signals y and u. It can here be seen how the
estimate ˆ x
t|t
delivered from the Kalman filter is saved in the delay block, so that it can be
used in the next time step. The variable ˆ x
t|t−1
is calculated Aˆ x
t−1|t−1
+Bu
t
as in (3.18).
The estimate for the current time step ˆ x
t|t
is calculated ˆ x
t|t−1
+ L(y
t
− Cˆ xt|t − 1) as
in (3.22). [11]
3.6 Shaping Filter 19
This is done for systems with non-Gaussian process noise and non-Gaussian
measurement noise in the next two sections, following the theory in [11].
3.6.1 Shaping Filters for Non-Gaussian 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 non-gaussian noise and e is zero-mean Gaussian noise. Suppose w
1
can be modeled by a linear shaping filter 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 filter can be included in the original state-
space system, giving the new state-space 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 Non-Gaussian 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 non-Gaussian noise and w is Gaussian noise. Suppose e
1
can be
modeled by a linear shaping filter 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 state-space 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 different possibilities on how to choose and tune the Kalman filter
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’ influence
on the behavior of the filter, using open-loop or closed-loop simulation, and final 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 filter 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 filter is the
optimal filter (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 defined 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 off-diagonal elements are the scalar
covariances between its components. If the components of e is independent of each
other, the off-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 low-pass filtering the signal y as [2]
e = y(t) −y (4.3)
where y is the low-pass filtered 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 definition 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 filter 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 difficult, for example when not all the states are measurable. Instead, a
common approach is to test different choices of Q and R until the Kalman filter
shows acceptable behavior. To understand how the parameter choice affects the
filter, 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 influence on L from different 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 difference 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
filter 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 filter gets acceptable behavior.
4.3 Simulation
Using simulation in Simulink different parameter choices can be evaluated without
having to make a test drive in a real vehicle. Here two different simulation methods
will be explained, open-loop and closed-loop.
4.3.1 Open-Loop Simulation
One method is open-loop 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 filter with different parameters and compare
the outputs. The reason why this simulation method is called open-loop is that
the different parameter choices does not affect the behavior of the vehicle. The
filter is fed with the recorded measurements, but the output from the filter 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 Closed-Loop Simulation
The other type of simulation used is closed-loop simulation. With this method
a scenario including the vehicle and the road is simulated. The output from the
filter is attached to the controller and the behavior of the vehicle is affected by how
well the filter is performing. Figure 4.1 shows the Simulink model used by the
closed-loop simulation. The model consists of several subsystems, all developed by
DaimlerChrysler, and one of them is the controller containing the Kalman filter.
Figure 4.1. Closed-loop simulation. The vehicle, it’s controller and the environment are
simulated together. The output of the filter will here affect the behavior of the vehicle.
The environment and the actions of the driver are specified using simulation scenarios. It
is also possible to specify another vehicle which is traveling in front, a so-called “rabbit”.
Simulation Scenarios
For the closed-loop simulation two different scenarios are prepared. The first
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
first 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, first 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 filter, i.e., choosing the values of the process noise covariance Q and
measurement noise covariance R so that the filter performance is optimized with
respect to some performance measure, is a challenging task. Performing it manu-
ally is time-consuming 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 filter
tuning.
A systematic method of choosing Q and R is to perform many simulations using
different 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 filter). [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 2-norm, also called the euclidean norm. (The
euclidean norm is defined ||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 auto-tuning, as long as it is
possible to generate several data sets under the same premises. Optimally this
should be done using real-life 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 find the optimal parameters for the Kalman filter 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 filter 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 modified 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 different 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 find local
minima and they can be fooled, especially by oscillatory functions. They will only
find a global minimum if it is the only minimum and the function is continuous.
Global optimization problems are typically quite difficult 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 final 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 finding configurations 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 different possibilities to choose
the function P, as long as some constraints are fulfilled. 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 find 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 find 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”.
Pseudo-Code
The following pseudo-code 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 defined 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 SA-Algorithm
In order to apply the SA method to a specific 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 significant impact on the effectiveness of the method. Unfortunately, there
are no choices that will be good for all problems, and there is no general way to
find 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 auto-tuning on the filter.
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 finding a good solution. It is true that choosing
a neighbor far away from the current state could lead to finding 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 non-optimal 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 Matlab-code 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
justification for using this particular formula in SA, other than the fact that it
corresponds to the requirements explained above. The Matlab-code 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((E-E_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 difference 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 finish. For this thesis
an exponential schedule has been chosen, where the temperature decreases by a
fixed 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
), define
the maximum uphill move as maxmove = E(s
worstn
) −E(s
0
). Otherwise, define
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 final
acceptance probability for an “uphill” maxmove should be very low, say 10
−6
. If
the final 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 SA-algorithm uses a random method to find the solution, which means that
several executions may give different 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 significantly better
rather than always moving from the current state is called restarting. The decision
to restart could be based on a fixed 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 closed-loop simulations
in the first 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 difference between
the filter estimate and the “real” value. The diagram shows that the SA-algorithm
is trying to find 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 filter 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 filter is implemented. In the end of this chapter a discussion wil l be held
on how to best choose the filter parameters.
5.1 Overview of the Inner Control Loop
Before implementing the Kalman filter, 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 figure 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 PID-controller 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 PID-controller. 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 difference between the expected acceleration and the measured
acceleration. This is summarized with the output from the PID-controller, forming a
c
.
actuators which minimizes the deviation. The output from the PID-controller 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 deflection, 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 figure, 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 PID-controller, 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 difference 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 deflection 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 coefficient [20]. N is in this case defined 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 coefficient 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 differential ratios i
g
and i
d
, the efficiency 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 different 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 identification and
chosen to the mean values of different test drives with different 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 filter
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 figure 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 five 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 figure 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 figures.
This is expected, as the model does not exactly describe the specified 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 first 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 different 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 identified
time-delays 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 low-pass filter with some time-delay. 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 affects the calculation of ˜ m in (5.13) as
well as F
roll
in (5.7) and has a large effect 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 tire-pressure 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 coefficient 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
identification. From several test drives the mean values have been selected.
These parameters differ 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 effect 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 coefficient of the brakes. This is observed to happen
relatively often. For example, the friction coefficient 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 difficult 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 filtering.
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 defined 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 PID-controller 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 filter 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 time-invariant)
and δ(·) is the Dirac (impulse) delta function [3].
Using the state-space model presented in (3.1) and (3.2), and choosing the
state vector x = a
z
, the continuous time state-space model for the Kalman filter
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 filter needs a measurement of the
signal a
z
. This can be provided by feeding it with a new constructed signal a

.
With the definition a
m
= a
real
+e together with (5.24), a

can be defined as
a

= a
m
−a
exp
= a
z
+e (5.30)
44 Kalman Filter Implementation
In this way, the Kalman filter 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 defined 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
time-invariant.
The system is observable, as can be verified 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 state-space model is discretized into a digital state-space 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
Different values of the noise intensities q and r will now be chosen and the per-
formance evaluated using open-loop 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 affect the comfort of the driver and passengers. Therefore this section
will show the function of the developed Kalman filter 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
filter is simulated using different values for q. The figures that follow have been
generated using measured data from test drives. The Kalman filter is fed with the
signal y = a

= a
m
−a
exp
, and those values are also shown in the figures as dots.
Figure 5.8 shows two different Kalman filters, 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 filter. The faster filter is more sensitive to measurement noise,
while the slower filter 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 filter
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 filters with different parameters (q = 1 and q = 0.01)
using a measurement of a test drive on a bumpy road. The filter with q = 1 is fastest
and follows the measured values most accurate. This was expected, as choosing q high
always means a faster filter. The faster filter is also more sensitive to measurement noise.
The slower filter delivers a smoother estimate of a
z
.
with the faster filter, a smaller q makes the time delay for large signal changes
unavoidable larger. The Kalman filter q = 0.01 still reacts relatively fast and
when only looking at these two figures (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 effect of the control values for the engine and brakes. It has been observed
during test drives that the comfort is negatively affected by having a too fast filter.
With this in mind, two slower filters are evaluated, shown in the next two figures.
This time q = 0.001 and q = 0.0003 are simulated. Figure 5.10 shows the drive
on the bumpy road. The Kalman filter 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 filter.
The time delay for the filter 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 filter of this type cannot do both.
Figure 5.12 shows the slowest filter (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 figures. Even the slowest of the tested Kalman filters 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 filters using a measurement of a test drive of a
vehicle driving up and down a steep hill. The output from the Kalman filter with q = 1
follows the measurement almost exactly. It can be seen that, comparing with the faster
filter, a smaller q makes the time delay for large signal changes unavoidably larger. The
Kalman filter q = 0.01 still reacts relatively fast.
this case “not slow enough”. But choosing a slower filter will also make the time
delay for changes even larger. The ideal filter 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 filters (q = 0.001 and q = 0.0003) using measure-
ments from a test drive on a bumpy road. The slow Kalman filters 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 filters (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 filter.
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 filter using a measurement of a very
bumpy road. Even this filter is in this driving situation “not slow enough”. But choosing
such a slow filter 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 filter is easy to understand
when using simple models. Another advantage of using simple models is low com-
putational effort. This chapter derives some more complex models, with the aim
of explaining how the Kalman filter 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 filter behaves like a low-pass
filter.
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 filter, 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 filter 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 filter is the signal a
exp
, as defined 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 state-space 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 filter with the same measurements as in Chapter 5 shows that the
basic behavior remains the same. Figure 6.1 shows the output from the filter 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 filter simulated with the measurement from the drive
up and down the steep hill. The dotted line is a

= a
m
−a
exp
as defined in (5.30),
which still can be used as a reference. The dashed line in the figures is the output
from the filter in Section 5.5, which used a

as feedback. As can be seen the
overall behavior is the same.
The Kalman filter now has to estimate both v
real
and a
z
, resulting in higher
computational costs. Choosing a smaller q makes the filter 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 first 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 filter 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 First-Order Lag Function
For a first-order lag function with input signal u, the output signal y satisfies the
ordinary differential 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 filter using the measurement from the drive on
a bumpy road. Input to the filter is the measurement of the vehicle speed. q has been
chosen to 5. The solid line is the Kalman filter with the measurement of v as feedback.
The dashed line is the filter developed in Section 5.5. As can be seen the overall behavior
of the filter 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 different values of τ. Define the break
frequency ω
0
as
ω
0
=
1
τ
(6.10)
Then the magnitude of the function is approximately
|G(jω)| ≈
_
1 when ω < ω
0
ω
0

when ω > ω
0
(6.11)
The first-order lag function dampens all signals with frequencies higher than the
break frequency ω
0
and can be used as a low-pass filter. As can be seen in the
plot, a larger τ means a lower break frequency, which complies with the definition
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 filter using the measurement from the vehicle
driving up and down a steep hill. q is set to 5. The solid line is the Kalman filter with
the measurement of v as feedback. The dashed line is the filter developed in Section 5.5.
As can be seen the overall behavior of the filter remains the same.
6.2.2 First-Order Gauss-Markov Process
The first-order 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 first-order Gauss-Markov process [22]. This function has
turned out to be important in applied work since it seems to fit 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 Gauss-Markov 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 time-shifted
version of itself, where t
1
and t
2
defines 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 first-order lag function, with three different 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 identification 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 Identification
Toolbox” [18]. It contains all the common techniques to adjust parameters in all
kinds of linear models, including state-space 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 defines τ and the intensity of w as parameters to be identified. As
identification 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 filter will have to estimate. When driving a vehicle at 30 km/h
over this steep hill, the highest demands on the filter is said to be reached. As
54 Alternative Kalman Filter Models
identification 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 identified model does not fit the identification 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 1-step Ahead Predicted Model Output
Measured Output
Model Fit: 83.67%
Figure 6.4. Identification of time constant τ. Setting the noise intensity to a constant
value and identify the parameter gives τ = 7, results in a model fit of 83.67%. Letting
the script identify the noise intensity with τ = 7 will give a model fit of over 99%.
Setting the parameter τ to 7 and letting Matlab identify the noise intensity,
results in a model fit of over 99%. The noise intensity is then identified to 70.
This means that by choosing τ = 7, it is possible to find a perfect fit by adjusting
the parameter for the noise intensity. In fact, by choosing any value of τ larger
than 0.1 and then letting Matlab find the optimal noise intensity, results in a
model fit of at least 90%, and τ > 0.3 gives a fit of over 95%. For τ = 0.3 the
optimal noise intensity is identified to 91. A smaller choice of τ demands a larger
noise intensity to make a good model fit.
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 1-step Ahead Predicted Model Output
Measured Output
model Fit: 96.26%
Figure 6.5. Identification of time constant τ. Here τ = 0.3 is chosen and the noise
intensity is identified to 91, giving a model fit 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% confidence intervals assuming that the
residuals are Gaussian. The rule is that if the correlation function go significantly
outside these confidence 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 first-order Gauss-Markov process (6.12)
with state vector x = [x
1
, x
2
]
T
= [v, a
z
]
T
gives the state-space 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 filter using this model is simulated in the same way as in Section 5.5.
Figure 6.6 shows the filter 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 differences 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 Gauss-Markov Process
Kalman filter from Chapter 5 (q=0.001)
Figure 6.6. Kalman filter with a
z
modeled as a Gauss-Markov process. The figure
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 filter
developed in Section 5.4, no relevant changes can be found.
6.2.5 Higher-Order 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 first 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 Gauss-Markov Process
Kalman filter from Chapter 5 (q=0.001)
Figure 6.7. Kalman filter with a
z
modeled as a Gauss-Markov process. The figure 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 filter 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 state-space 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 state-space 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 state-space 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 affect 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 definition of a
z
given in (5.24). Also, the process noise w
2
could according to (6.30) be set to 0.
The state-space model is transformed into a discrete state-space 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 filter off-line in Simulink with measurements from test drives, the
parameters are set using trial-and-error, until the filter 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 filter with these parameters has the same behav-
ior as the other filters evaluated in this thesis, compare to Section 5.5, Section 6.1
and Section 6.2.4. Plots of the Kalman filter implemented in this section is not
shown here, but it will be used in Section 6.4, where a comparison of all filter mod-
els is made. Plots of this filter will also be shown in Section 6.5 in a comparison
with a low-pass filter.
6.3 Implementation and Testing in Arjeplog
The Kalman filter is implemented in the test vehicles at DaimlerChrysler. By the
implementation concern has to be taken to the different driver assistance functions
in the outer control loop, as well as to certain driving situations, as described below.
• The Kalman filter 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 filter 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 filter is limited to some maximum and min-
imum values, due to safety reasons. These values are changed if DSR is
active.
The Kalman filter was also evaluated during a testing expedition to Arjeplog in
Sweden. Some of the plots in this thesis have been generated there. The Kalman
filter was then thoroughly tested in difficult 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 different models
will therefore be made. This is done by adjusting the parameters so that the filters
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 different 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 different filters almost have the
same behavior. Only the output from the Kalman filter using the model derived
in Section 6.1 is a bit different than the others. Figure 6.9 and Figure 6.10 show
simulations of a test drive on two different bumpy roads. By looking at these
figures, it becomes obvious that the behavior of the different filters 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 Gauss-Markov process
a
z
Kalman filter implemented in test vehicles
Figure 6.8. This figure shows the simulation of driving up and down the steep hill. The
parameters have been adjusted so that the different filters almost have the same behavior.
Only the output from the Kalman filter using the model derived in Section 6.1, plotted
with a dashed line, is a bit different than the others.
In this chapter different Kalman filter 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 different 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 First-Order 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 Gauss-Markov process
a
z
Kalman filter implemented in test vehicles
Figure 6.9. This figure shows a simulation of a test drive on a bumpy road. By looking
at the output from the different Kalman filters, it cannot be said that any of the filters
is better than the other.
The reason for this is that the Kalman filter remains a linear filter 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 filter is tuned using a subjective feeling
about what is a good compromise when sitting in the car. A fast filter 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 filter correspond to those of an ordinary low-pass filter. Therefore
this section will try to explain the similarities between these filters.
The figures that follow show the similarities between the Kalman filter from
Section 6.2.5 and a first-order lag function as described in Section 6.2.1. The
figures are from simulations in Simulink, using measured data. The output from
the Kalman filter 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 first-order
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 Gauss-Markov process
a
z
Kalman filter implemented in test vehicles
Figure 6.10. This figure shows a simulation of a test drive on a very bumpy road. By
looking at the output from the different Kalman filters, it cannot be said that any of the
filters 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 filter 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 state-space model.
When knowing the intensities of the process noise w and measurement noise e,
the Kalman filter equations are used, as explained in Section 3.5, to calculate the
optimal gain L for the observer. Looking at the figures, it is obvious that the
Kalman filter with these parameters behaves as a low-pass filter. The calculated
gain L is used to adjust the frequency properties of the Kalman filter so that the
gain is high when the signal-to-noise 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 filter, the same work can be done using traditional filter methods.
The Kalman filter 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 low-pass filter. Instead, the Kalman
filter uses the measurement of the vehicle speed as input, and this is one example
of the advantage of developing filters using the Kalman model.
6.5 Comparing the Kalman Filter with a First-Order 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

low-pass filtered
Figure 6.11. The measurement in this figure comes from a test drive when the vehicle
drives up and down the steep hill. The dashed line is the output from a first-order lag
function with time constant τ = 1.1. As can be seen the behavior is similar to the output
from the Kalman filter (solid line).
According to [12], the transfer function for the stationary Kalman filter is
G
kf
(s) = (sI −A+LCA)
−1
Ls (6.41)
where L is the steady-state gain parameters calculated by (3.27). Calculating G
kf
with the model used for the Kalman filter gives a matrix containing three transfer
functions from the input v
m
to each of the filter outputs v, a
z
and ˙ a
z
. Taking the
transfer function from v
m
to a
z
, letting s = e

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 filter with smaller r and the dashed-dotted line shows a filter with a
larger r. The filter has the function of a high-pass filter. 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 filters. The filter 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 filter also can
differentiate 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

low-pass filtered
Figure 6.12. The figure is from a simulation using recorded data from a test drive on
a bumpy road. The dashed line is the output from a first-order lag function with time
constant τ = 1.1. As can be seen the behavior is similar to the output from the Kalman
filter (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

low-pass filtered
Figure 6.13. The figure 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 first-order lag function with
time constant τ = 1.1. As can be seen the behavior is similar to the output from the
Kalman filter (solid line).
6.5 Comparing the Kalman Filter with a First-Order 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
filter presented in Section 6.2.5. The solid line is the parameters chosen in Section 6.2.5,
the dashed line is from a filter with smaller r and the dashed-dotted line is from a filter
with a larger r. The filter has the function of a normal high-pass filter. This is expected,
as the transfer function used in the plot estimates a
z
using measurements of the speed v.
The filter with a smaller r has a higher break frequency, and a larger r means lower break
frequency. A smaller measurement noise means that the filter also can differentiate higher
frequencies.
66 Alternative Kalman Filter Models
Chapter 7
Change Detection
In this chapter an overview of different 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 different 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 filter, it is desirable that the output follows the desired target
signal, ignoring the noise. The gain in a linear filter 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 filter could be used. The
function could be satisfying for some time, but then suddenly the slope changes
and the model used by the filter is no longer correct. It would be practical to
be able to detect such changes in the environment, and react by making the filter
faster. The presentation that follow is based on [13], where a thorough explanation
of the subject is given.
Consider a filter trying to estimate a signal x. The filter 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 filter to a signal s, repre-
senting the change in the residuals. The stopping rule decides whether the change is
significant or not. If the change in the residuals is significant, the change detector gives
an alarm and the Kalman filter can take appropriate action (for example by making the
filter 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 different categories of change detection methods [13]
• Methods using one filter, where a whiteness test is applied to the residuals.
The filter is temporarily made faster when a change is detected.
• Methods using two filters, one slow and one fast, in parallel. Depending on
the residuals from the two filters, one of them is chosen as the currently “best
one”.
• Methods using multiple filters in parallel, each one matched to certain as-
sumptions on the abrupt changes. For each filter the probability of that filter
being correct is calculated, and output is the weighted sum of the output
from all the individual filters, depending on their current probabilites.
In this chapter, a method using one filter will be implemented and tested.
7.2 One Kalman Filter with Whiteness-Test
The task of the change detector is to decide which of the following hypotheses is
correct, concerning the residuals from the Kalman filter
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 significant or not. Different implementations of the distance mea-
sures s
k
are [13]
7.2 One Kalman Filter with Whiteness-Test 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 low-pass filtering s
k
and comparing this value to a
threshold h. Two common low-pass filters described in [13] are
• The CUmulative SUM (CUSUM) test
g
k
= max(g
k−1
+s
k
−ν, 0) (7.10)
The “drift parameter” ν influences the low-pass effect.
• 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 low-pass effect. λ can be
chosen as 0, which means no low-pass effect 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 filter 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 CUSUM-test
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 defined as β = λ +ν.
The Kalman filter from Chapter 5 with R = 1 and Q = 0.0003 is selected. This
gives L = L
slow
= 0.0172 and results in a slow filter. The change detector gives an
alarm when g
k
> h, and the Kalman filter 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 filter 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 filter with the change detection algorithm chosen in Section 7.3 is
simulated using measurements from test drives representing different driving sit-
uations. The output from the simulated Kalman filter is plotted in a diagram
together with the measured signal a
m
−a
exp
. As a reference the output from the
“original” Kalman filter 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 filter 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 figures it can be seen that the estimates from the Kalman filter
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 different bumpy roads.
As can be seen, not so many alarms are given, and the change detection algorithm
does not affect the estimate. This shows that the change detection algorithm does
not affect 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 filter with change detection algorithm when driving
up and down a steep hill. The change detection algorithm detects the large changes and
makes the Kalman filter 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 filter 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 filter faster. (The original Kalman filter becomes
saturated at −3ms
−2
. This is not implemented in the simulation for the filter 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 filter 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 filter 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 filter 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 affected, 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 filter 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 affected, 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 briefly introduced.
8.1 Conclusions
In this Master’s thesis the theory for the Kalman filter and filter tuning have been
presented. It has been shown how to implement a Kalman filter 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 filter, 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 filter 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 filter, or a
fast but jerky filter (to do this a subjective choice has to be made).
Some more complex models for the Kalman filter have been implemented and
tested. First it was shown how to use the speed of the vehicle as input to the
filter, instead of the constructed signal a

. Then two models of a
z
were derived
and tested, inspired by the first-order lag function and the Gauss-Markov 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 filter implemented in the vehicles today
can be replaced by a first-order 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 filters in parallel, one slow and one fast, may be of interest.
• It should be practically tested if the Kalman filter can be exchanged with
another simpler type of low-pass filter, 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 defined.
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 coefficient 36
c
rr
Rolling resistance coefficient 36
η Efficiency 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
Differential 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 Anti-lock 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. Bar-Shalom, 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, Springer-Verlag, Berlin, second edition, 2005.
[15] S. Kirkpatrick, C.D. Gelatt and M.P. Vecchi, Optimization by Simulated An-
nealing, Science(220) : 671-680, 1983.
[16] P. Lingman and B. Schmidtbauer, Road Slope and Vehicle Mass Estimation
Using Kalman Filtering, Vehicle System Dynamics Supplement 37 page 12-23,
2002.
[17] L. Ljung, System Identification - Theory for the User, Prentice Hall, Upper
Saddle River, second edition, 1999.
[18] L. Ljung, System Identification 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. 2007-02-01
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. LITH-ISY-EX-3408-2003,
Linköpings Universitet, Linköping, 2003.
[23] G. Welch and G. Bishop, An Introduction to the Kalman Filter, Technical
Report TR95-041, 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 S-Class, DaimlerChrysler AG, Stuttgart, 2006.
[26] Owner’s Manual M-Class, 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 call-back 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_value-real_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 Simulink-simulation 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_current-cost_neighbour)/temp);
end
end
% sim_cost executes the simulation and returns the RMSE-error
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_g-simout_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 Identification
Here is the Matlab identification script that was used to identify the unknown
parameter τ and the intesitiy of w in the first-order 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 state-space 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 LiTH-ISY-EX--2007/3950--SE

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. filter tuning.e. In this Master’s thesis it is verified 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 filter 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 filter 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 SE-581 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 C-uppsats D-uppsats Övrig rapport ISBN — ISRN Datum Date 2007-04-01 LiTH-ISY-EX--2007/3950--SE Serietitel och serienummer ISSN Title of series. simulated annealing.control. Nyckelord Keywords Kalman filter.Avdelning. It is shown that the Kalman filter implemented in the test vehicles today can be exchanged with a first-order lag function.liu.liu. or a slow but smooth estimate. i. As the output from the Kalman filter is directly added to the control value for the engine and brakes. Institution Division. It is the optimal filter 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 find the optimal parameter settings. As observer the Kalman filter is selected. In this Master’s thesis the theory for the Kalman filter is presented and it is shown how to choose the filter 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 filter tuning easier.

.

The outer control loop contains the driver assistance functions such as speed limiter. As observer the Kalman filter is selected. and react accordingly – for example by making the filter 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 filter tuning easier. A filter 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 filter implemented in the test vehicles today can be exchanged with a first-order lag function. cruise control. automatically find 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 filter 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 verified that the parameter choice is a compromise between a fast but jerky. i. As the output from the Kalman filter 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 filter is presented and it is shown how to choose the filter 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 Sindelfingen. I would like to express my greatest gratitude to my supervisor at DaimlerChrysler. Sindelfingen. My supervisor Johanna Wallén and examiner Thomas Schön at Linköpings Universitet. Germany. Peter Juhlin-Dannfelt and Erik Almgren for proof-reading. 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 Anti-lock 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 Blind-spot Warning . . . . . . . . . . 2.11 Systems Supported by the Controller

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

3 Basic Filter Theory 3.1 State-Space 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 Non-Gaussian Process Noise . . . . 3.6.2 Shaping Filters for Non-Gaussian 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 Open-Loop Simulation . . . . . . . 4.3.2 Closed-Loop 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 First-Order Lag Function . . . . . . . . . . . . . . . . . 6.2.2 First-Order Gauss-Markov Process . . . . . . . . . . . . 6.2.3 Identifying the Time Constant . . . . . . . . . . . . . . 6.2.4 Testing the Model of az . . . . . . . . . . . . . . . . . . 6.2.5 Higher-Order 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 First-Order Lag Function 7 Change Detection 7.1 Idea of Change Detection . . . . . . . . 7.2 One Kalman Filter with Whiteness-Test 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 Identification

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 figure chooses which of the functions that should have affect. 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 different assistance functions. The longitudinal controller can be thought of as two cascade controllers. . A Kalman filter 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 filter 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 affecting the vehicle. Distronic. The inner controller delivers a desired torque T to the actuators engine. The inner controller contains a PID-controller and an observer. see Figure 1. will be presented. one understands the influence of the vehicle in its driving direction by means of a controller.

It should also be examined if the structure of the filter can be improved. The filter 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 affect and delivers a desired acceleration ad to the inner control loop.. The inner control loop consists of a PID-controller and an observer. 1. For this purpose the theory behind the filter and the methods for filter tuning had to be better investigated. brake and gearbox which are affecting the vehicle. The Kalman filter has to be tuned to work optimally.1. and to find good parameter settings justified 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 filter.2 Problem Formulation The Kalman filter attached parallel to the PID-controller 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 filter is smooth. Otherwise the comfort is negatively affected. 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 filter theory needed to implement an observer in the controller. Smart and Maybach. conclusions are drawn and some extensions for the thesis are presented. . Germany. CLS-Class. At the end of chapter six a comparison between the developed Kalman filter and a standard low-pass filter is made. The model of the disturbance used in the existing Kalman filter will be examined. 9500 persons are working with development. At Mercedes Technology Center in Sindelfingen. 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 Daimler-Benz in Germany (the manufacturer of Mercedes-Benz) and the Chrysler Corporation in USA. It will be examined if this makes the filter 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 filter). CL-Class and Maybach cars. and continues with a discussion of the advantages and disadvantages of using these models. and simulations are made off-line. In chapter five the model for the longitudinal dynamics of the vehicle is derived. Dodge. vans and busses under the brands Chrysler. The filter 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 C-Class. Then a stationary Kalman filter 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. Mercedes-Benz.4 DaimlerChrysler AG 3 1.5 Method The necessary theory describing the Kalman filter will be presented using literature studies. 1. Different methods for choosing the filter parameters will be explained and implemented. trucks. and an initial version of the Kalman filter is implemented and tested. S-Class. An overview of the different 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. Different possibilities to choose and tune the filter parameters are presented in chapter four. E-Class.

It has not been examined if the filter described in this thesis would make better estimates by using unfiltered data.7 Limitations The use of an observer in an inner control-loop 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 filters and sensor fusion techniques to obtain stable measurements. the advantages and disadvantages of attaching an observer in parallel to a PID-controller (as described in this Master’s thesis) have not been examined. A comparison between this method and the use of a PID-controller 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 Anti-lock Braking System Anti-lock 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 long-term 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 off-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 on-board 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 low-speed 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 offers 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 “pre-safe 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 traffic 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 briefly 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 Blind-spot Warning The general idea behind a blind-spot 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 different 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 figure 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 figure shows which DaimlerChrysler vehicles are using the systems.

10 Driver Assistance Systems .

3. [11] The order of a differential equation is equal to the order of the highest derivative.Chapter 3 Basic Filter Theory This chapter starts with an introduction to state-space models often used when working with control systems.1 State-Space Models To design an estimation filter one first needs a mathematical model of the controlled process. Almost every physical system can in the same way be described using differential equations. When doing control design it is preferable to have all equations of first order. When the equations describing a system are 11 . The Kalman filter 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 differential equations will be used. Sir Isaac Newton (1642-1727) 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 differential 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 filter are presented and the function of the stationary Kalman filter 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 filters for non-Gaussian process noise and non-Gaussian measurement noise. called ordinary differential equations (ODE). This model is also referred to as the continuous-time state-space model. One can reduce the form of any system of higher order differential equations to an equivalent system of first-order differential equations by introducing new variables. One popular observer is the Kalman filter.

5) The index d is referring to the discrete form of the matrices.2 Discretization Almost every physical system is best described using a continuous-time 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 influence on the output.1) and (3.6) (3..1) and (3. based on [10] and [13]. This means that it satisfies the Markov Property [3] p[x(t)|x(τ ). This gives the linear discrete timeinvariant state-space 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[A|B] 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 state-space 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 state-space 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 state-space 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 “zero-order 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 specified [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 zero-order 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 “impulse-invariant 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 filters 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 affect the estimated states. Therefore. the difference 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 different ways. This difference 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 reflects the difference between the predicted measurement and the actual measurement as explained above. It is a trade off 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 different 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 filter. 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 defined 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 differ from those found in other literature. Gaussian. but in this Master’s thesis they will be assumed stationary and known. 3. [23] ˆ The Kalman filter 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 filter equations will be presented to give an overview of how the filter works. measurement noise covariance matrix R and the matrices A..3.1 Process and Measurement Model The Kalman filter 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 filter 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 filter is presented. following the presentation in [23] and [12]. For more information. B. the Kalman filter 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 filter estimates a process by using a feedback control.e. [11] or [12]. The filter 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 Pt|t . For example. After each predictor and measurement update pair. which is needed in the next time step. the calculated values xt|t and Pt|t 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−1|t−1 ˆ Pt−1|t−1 = xt|t ˆ = Pt|t (3. Pt|t−1 can be thought of as the uncertainties of how the states x are evolving.22) (3. The discrete Kalman filter measurement update equations are [13] Lt xt|t ˆ Pt|t = Pt|t−1 C T (CPt|t−1 C T + R)−1 = xt|t−1 + Lt (yt − C xt|t−1 ) ˆ ˆ = (I − Lt C)−1 Pt|t−1 (3. the equations for the Kalman filter are divided into two groups.19) which translates the estimate from the last time step xt−1|t−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 Pt|t = E[(xt − xt|t )(xt − xt|t )T ]. i.22) ˆ ˆ generates the state estimate by incorporating the new measurement yt . Q. also referred to as the “a priori” estimate error.. xt|t−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 filter predictor equations are [13] xt|t−1 ˆ Pt|t−1 = Aˆt−1|t−1 + But x = APt−1|t−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 filter. Together are (3. This recursive nature of the Kalman filter 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 Pt|t−1 is calculated using the estimate error from the last time step.5.21) (3.19) is defined Pt|t−1 = E[(xt − xt|t−1 )(xt − xt|t−1 )T ] ˆ ˆ (3.e.22) forming (3. [23] 3. also referred to as the “a priori” state estimate. Pt|t−1 in (3. (3. The final step (3. Pt−1|t−1 .3. and the process noise covariance (or “model uncertainties”).

giving a new linear state-space 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 filters are called shaping filters.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 time-invariant. these parameters can be pre-computed by either running the filter off-line. For many physical systems encountered in practice.6 Shaping Filter When implementing a Kalman filter.e. C.26) and (3..26) This equation is referred to as the algebraic Riccati equation. it may not be justified to assume that all noises are Gaussian. a model with non-Gaussian noise can be extended to a filter driven by Gaussian noise. B.5 Block Diagram of the Stationary Kalman Filter The computational procedure and the relation of the filter 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 filter 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 filter 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−1|t−1 and the input data yt . The Kalman filter recursively computes values of x using the pre-calculated 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 filter 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 xt|t−1 is calculated Aˆt−1|t−1 + But as in (3.C et + + f -? yt Discrete Kalman Filter  xt|t ˆ ? delay xt−1|t−1 ˆ . Kalman filter block diagram.7). and its relation to the system.C B 6 ut Figure 3. ˆ x The estimate for the current time step xt|t is calculated xt|t−1 + L(yt − C xt|t − 1) as ˆ ˆ ˆ in (3. It can here be seen how the estimate xt|t delivered from the Kalman filter is saved in the delay block.22). The Kalman filter recursively computes values of x using the pre-calculated ˆ stationary values of P and L.6) and (3. and the input signals y and u.18).A + -f + 6 xt|t ˆ + + f  6 L  − + f  6 xt|t−1 ˆ .1. This figure shows the computational procedure of the Kalman filter. The blocks “Discrete System” and “Measurement” are a graphically representation of the state-space model (3.

28) (3. e1 is non-Gaussian noise and w is Gaussian noise.43) .29) Consider a system given on the form where w1 is non-gaussian noise and e is zero-mean Gaussian noise.40) (3.36) (3.34) (3. giving the new state-space 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 Non-Gaussian Process Noise x1 ˙ y = A1 x1 + G1 w1 = C1 x1 + e (3.31) where w is Gaussian noise.2 Shaping Filters for Non-Gaussian 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 state-space 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 filter according to xSF ˙ w1 = ASF xSF + GSF w = CSF xSF (3.42) (3. Suppose e1 can be modeled by a linear shaping filter according to xSF ˙ e1 = ASF xSF + GSF e = CSF xSF (3. Then the filter can be included in the original statespace system.6 Shaping Filter 19 This is done for systems with non-Gaussian process noise and non-Gaussian 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 defined as [3] Rij = E[(ei − ei )(ej − ej )T ] ¯ ¯ (4. using open-loop or closed-loop 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 filter 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 off-diagonal elements are the scalar covariances between its components. By investigating the measured signals. and finally using autotuning. If the components of e is independent of each other. the off-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 filter is the optimal filter (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’ influence on the behavior of the filter. The matrix R is a symmetric n × n matrix.Chapter 4 Choosing the Kalman Filter Parameters In this chapter different possibilities on how to choose and tune the Kalman filter parameters are presented. Assume that the information in the measured signal y 21 .

22). To understand how the parameter choice affects the filter.5) . The definition 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 influence on L from different choices of R and Q can be understood by inserting (3. C. L is calculated using A.3) where y is the low-pass filtered 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 difficult. 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 low-pass filtering 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 different choices of Q and R until the Kalman filter 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 filter 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 open-loop is that the different parameter choices does not affect 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 filter 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 filter with different 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 Open-Loop Simulation One method is open-loop simulation. Then the stationary values of P and L can be calculated using (3.3 Simulation Using simulation in Simulink different 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 difference between the ˆ estimate x and the real state x. 4. open-loop and closed-loop. 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 filter gets acceptable behavior. A large Q results in a large L. which means a fast filter 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 filter 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 different simulation methods will be explained.

The first part of the hill has a slope of 10% (meaning “uphill”). Simulation Scenarios For the closed-loop simulation two different scenarios are prepared. The driver adjusts the speed by using the cruise control lever. first 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 filter.3. Figure 4. a so-called “rabbit”.24 Choosing the Kalman Filter Parameters 4.1. The output of the filter will here affect the behavior of the vehicle. all developed by DaimlerChrysler. The first scenario represents the vehicle driven up and down a hill. The vehicle is heavy loaded. . The environment and the actions of the driver are specified using simulation scenarios.2 Closed-Loop Simulation The other type of simulation used is closed-loop simulation.1 shows the Simulink model used by the closed-loop simulation. The model consists of several subsystems. The output from the filter is attached to the controller and the behavior of the vehicle is affected by how well the filter is performing. Closed-loop 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 different 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 real-life testing (instead of simulation). The algorithm starts with some parameter values.4 Autotuning 25 4.4 Autotuning Tuning the filter. Performing it manually is time-consuming 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 defined ||x||2 = x2 + · · · + x2 . The cost function measures how good the actual . then simulates the system using these values for the Kalman filter 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 filter 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 auto-tuning. It is therefore often desirable to develop automated systematic procedures for Kalman filter tuning.2 Autotuning Using Matlab To automatically find the optimal parameters for the Kalman filter 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 2-norm. xk − xk (which is also ˆ minimized with the Kalman filter).

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 finding configurations 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 final solution. each step of the SA algorithm considers some random neighbor s of the current parameter state s. Global optimization problems are typically quite difficult to solve. Con- . Using this optimization technique does not give a satisfactory result. They will only find 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 fulfilled. By analogy with this physical process. There are different 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 modified 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 find 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 different 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 SA-Algorithm In order to apply the SA method to a specific 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 find the place with the lowest altitude.k/k_max). when his strength T is large. end if T = tempfunction(T. To find the place with the lowest altitude (the global minimum) he sometimes has to try running up the hills. change state e = e_neighbor. Pseudo-Code The following pseudo-code 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 defined 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 Matlab-code 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 Matlab-code 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 justification 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 finding the best solution faster. Unfortunately.5 times the current parameter vector s. These choices can have a significant impact on the effectiveness 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 auto-tuning on the filter. As the algorithm evolves and T goes to zero. and the temperature T . and there is no general way to find 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 non-optimal 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 finding 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 final 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 final 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 difference E(˜) − E(s) for s a random state and its neighbors. this function depends on the simulated model. define 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 finish.11) and T = T0 can be calculated. To pick the initial temperature T0 . (4.4. (4. where the temperature decreases by a fixed 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((E-E_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. define 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 difference between the filter estimate and the “real” value. which means that several executions may give different outputs. Restarting Choosing the Kalman Filter Parameters The SA-algorithm uses a random method to find the solution.2 shows one execution of the SA script with 200 closed-loop simulations in the first scenario (the hill) described in Section 4. Results Figure 4. and more computer time is available.2. . The diagram shows that the SA-algorithm is trying to find 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 significantly 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 fixed 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 figure 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 filter. and an initial version of the Kalman filter 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 PID-controller 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 filter 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 filter 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 figure. losses due to tire deflection. and the task is to get areal = ades . The deviation adev is given as input to a PID-controller. 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 PID-controller. 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 PID-controller 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 difference 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 PID-controller. 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 difference 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 deflection 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 coefficient [20]. (5. cd is the drag coefficient 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 differential 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 defined 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 efficiency 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 different 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 filter 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 identification and chosen to the mean values of different test drives with different 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 specified vehicle. then after nearly 30 seconds changes back to 60 km/h again.20).3.5 -1 -1. The figure 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 five 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 figure 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 figures. 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 low-pass filter with some time-delay. 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 different vehicles [19]. The reason for this could be that the identified time-delays 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 first 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 effect 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 affects 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 identification. 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 differ from those found in a real vehicle. In practice.16) and (5. a force Fslope arises having a direct effect on the vehicle’s acceleration. for example in case of tire-pressure 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 filtering.22) where asensor is the sensor value and a is the longitudinal acceleration of the vehicle. The drag coefficient 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 difficult making good estimates of the road slope while cornering.7) is in the model set to a constant value. the friction coefficient 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 coefficient 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 PID-controller 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 filter can be used to estimate this state.1. the continuous time state-space model for the Kalman filter becomes x = ˙ y = 0 A x+ x+e 1 G w (5. and choosing the state vector x = az . a∆ can be defined as a∆ = am − aexp = az + e (5. With the definition 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 state-space 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 defined 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 filter needs a measurement of the signal az .25) The scalar value q is here the process noise intensity (assumed to be time-invariant) 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 filter will estimate the state az . As explained in Section 4.5 Choosing the Filter Parameters Different values of the noise intensities q and r will now be chosen and the performance evaluated using open-loop simulation described in Section 4. Figure 5. It can be seen that.33) (5. the signal will direct affect the comfort of the driver and passengers. However. The figures 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 filter 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 time-invariant.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 different Kalman filters. the one using q = 1 is faster and follows the measured values more accurately. How noisy the measurement is can be defined by modeling e.4. the absolute values do not matter. Figure 5. Therefore this section will show the function of the developed Kalman filter by choosing the parameters manually. comparing . as can be verified 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 filter is simulated using different 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 state-space model is discretized into a digital state-space model with sample time T . while the slower filter delivers a smoother estimate of az . and those values are also shown in the figures as dots. The faster filter 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 filter. 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 filter with q = 1 follows the measurement almost exactly.

This was expected.12 shows the slowest filter (with q = 0. The hill is rather steep. The filter with q = 1 is fastest and follows the measured values most accurate. Even the slowest of the tested Kalman filters 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 figures (5.8 and 5. or react fast to large changes. every unnecessary oscillation or jerk in the estimate az will have a direct effect 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 filter delivers a smoother estimate of az . two slower filters are evaluated. a smaller q makes the time delay for large signal changes unavoidable larger. shown in the next two figures.5 Time [s] 5 5.6 -0. The faster filter is also more sensitive to measurement noise.8.2 -0. With this in mind. A linear filter of this type cannot do both. The oscillations of the signal y = a∆ = am − aexp are even larger than in the previous figures.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 filter. The time delay for the filter with q = 0.8 -1 -1. This time q = 0. The Kalman filter 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 filter. Simulation of two fast filters with different parameters (q = 1 and q = 0. The Kalman filter 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∆ = am-aexp Kalman filter (q=1) Kalman filter (q=0. It has been observed during test drives that the comfort is negatively affected by having a too fast filter. However.11.5 7 Figure 5. with the faster filter.0003 are simulated.01 seems a logical choice. Figure 5.

Simulation of the two fast filters 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 filter would ignore these oscillations. But choosing a slower filter 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 filter. this case “not slow enough”. The output from the Kalman filter with q = 1 follows the measurement almost exactly.5 0 -0. but still react fast to large changes. The Kalman filter q = 0. .5 a∆ = am-aexp 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 filter. making them better for controlling purposes.2 -0.5 6 6. The slow Kalman filters ignore the oscillations even more.001) Kalman filter (q=0.8 -1 -1. Simulation of two slow filters (q = 0.6 -0.5 Choosing the Filter Parameters 47 0 -0.5.10.5 2 1.2 a∆ = am-aexp Kalman filter (q=0.0003) -2 4 6 8 10 Time [s] 12 14 16 18 Figure 5.5 a∆ = am-aexp 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 filters (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∆ = am-aexp Kalman filter (q=0.12. But choosing such a slow filter 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 filter using a measurement of a very bumpy road. . Even this filter 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 effort. with the aim of explaining how the Kalman filter 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 filter behaves like a low-pass filter.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 filter. the behavior of the Kalman filter 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 filter 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 defined in (5. This is the case at DaimlerChrysler when using hill descent control (explained in Section 2. The Kalman filter 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 filter 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 filter 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 figures is the output from the filter 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 filter simulated with the measurement from the drive up and down the steep hill.7) . Simulating the filter 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 defined in (5.4.2 Modeling the Disturbance az The model of az so far says that its first 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 filter 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 state-space 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 filter 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 satisfies the ordinary differential 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 First-Order Lag Function For a first-order 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 filter 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 filter 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 definition in (6.6 a∆=am-aexp Kalman filter with v as feedback Kalman filter from Chapter 5 (q=0.11) The first-order lag function dampens all signals with frequencies higher than the break frequency ω0 and can be used as a low-pass filter. a larger τ means a lower break frequency. Simulation of the Kalman filter 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 filter remains the same. [9] .3 shows the Bode plot of the transfer function with three different values of τ . The solid line is the Kalman filter 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. Define the break frequency ω0 as ω0 = 1 τ (6.2 -0.

With this choice of u the function is called a first-order Gauss-Markov process [22].2. where w represents Gaussian noise.5 0 -0.5 a∆=am-aexp Kalman filter with v as feedback Kalman filter from Chapter 5 (q=0.2 First-Order Gauss-Markov Process The first-order lag function can be used to model physical systems. According to [3] the autocorrelation of the Gauss-Markov process in (6. where t1 and t2 defines the time shift. 6. The described function will now be used to model az . The solid line is the Kalman filter with the measurement of v as feedback.13) The autocorrelation is a measure of how well the signal matches a time-shifted 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 fit 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 filter 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 filter 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 filter 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 state-space 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 filter will have to estimate.3. as well as some nonlinear models. with three different 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 defines τ and the intensity of w as parameters to be identified.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 filter is said to be reached. Matlab contains a toolbox called “System Identification Toolbox” [18].3 Identifying the Time Constant The technique of system identification 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 identification 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 first-order lag function.

A smaller choice of τ demands a larger noise intensity to make a good model fit. the script can be used to choose the optimal value of τ .54 Alternative Kalman Filter Models identification 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 fit 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 fit 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 fit of 83. Letting the script identify the noise intensity with τ = 7 will give a model fit of over 99%. Identification of time constant τ .4.3 gives a fit 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 identified to 91. In Figure 6.5 -1 -1. An intensity value of 1 results in the optimal choice τ ≈ 7. The noise intensity is then identified to 70. the identified model does not fit the identification data exactly. Setting the parameter τ to 7 and letting Matlab identify the noise intensity.1 and then letting Matlab find the optimal noise intensity.5 Measured Output Model Fit: 83. Measured Output and 1-step 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 find a perfect fit 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 significantly outside these confidence 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 1-step 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 filter 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. Identification of time constant τ .26%.3 is chosen and the noise intensity is identified to 91. giving a model fit of 96. for example by adjusting the number of parameters in the model [17].6 shows the filter 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 first-order Gauss-Markov 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 state-space model x = ˙ 0 1 1 0 −τ A x+ 1 0 B aexp + 0 1 G w (6.5.6. as well as 99% confidence 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 figure 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 first 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 filter developed in Section 5.4.2 -0. 0. Recall Section 5.6 a∆=am-aexp Kalman filter with az modeled as Gauss-Markov Process Kalman filter from Chapter 5 (q=0.2.5 Higher-Order 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 differences in comparison to the simple model used in Section 5. Kalman filter with az modeled as a Gauss-Markov 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∆=am-aexp Kalman filter with az modeled as Gauss-Markov Process Kalman filter from Chapter 5 (q=0. The figure 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 filter developed in Section 5. Kalman filter with az modeled as a Gauss-Markov 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 state-space 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 state-space 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 state-space 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 definition 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 affect 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 state-space model is transformed into a discrete state-space 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 filter can be restarted.36) (6.40) With “properly” is meant that the filter with these parameters has the same behavior as the other filters evaluated in this thesis. 6. Plots of this filter 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 filter models is made. The Kalman filter was then thoroughly tested in difficult 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 filter can be halted. By the implementation concern has to be taken to the different driver assistance functions in the outer control loop.5.5 in a comparison with a low-pass filter. the parameters are set using trial-and-error. for example when the vehicle is stopped. compare to Section 5. These values are changed if DSR is active. until the filter gets acceptable behavior.37) (6. • The output from the Kalman filter is limited to some maximum and minimum values. Section 6. while the other estimates are set to initial values.1 20. The Kalman filter 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 filter off-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 filter is implemented in the test vehicles at DaimlerChrysler. . due to safety reasons. Plots of the Kalman filter implemented in this section is not shown here.6 for explanations of Distronic Plus and DSR.8 and Section 2.

all the different models have almost the same performance with respect to estimating large changes. 2 1 Disturbance [m/s 2] 0 -1 -2 a∆=am-aexp az Kalman filter from Chapter 5 az Kalman filter with v as feedback az Kalman filter with az as Gauss-Markov 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 different Kalman filter models have been tested and evaluated. This figure shows the simulation of driving up and down the steep hill. This is done by adjusting the parameters so that the filters become the same behavior when simulating the vehicle driving up and down the steep hill. Only the output from the Kalman filter using the model derived in Section 6. is a bit different than the others. it turns out that modeling az in different 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 different filters 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 different than the others. . it becomes obvious that the behavior of the different filters 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 filter 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 figures. a comparison between the different models will therefore be made. The parameters have been adjusted so that the different filters almost have the same behavior. By doing this.10 show simulations of a test drive on two different 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 filter remains a linear filter giving the user to choose between a fast but jerky. The demands on the filter correspond to those of an ordinary low-pass filter. By looking at the output from the different Kalman filters.5 7 -1. 6.2.2.6 a∆=am-aexp az Kalman filter from Chapter 5 az Kalman filter with v as feedback az Kalman filter with az as Gauss-Markov 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 filter 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 First-Order Lag Function 61 0 -0. but at the same time the drive gets more uncomfortable.5 and a first-order lag function as described in Section 6. This figure shows a simulation of a test drive on a bumpy road. Instead the filter 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 first-order .4 -1. The figures are from simulations in Simulink.8 Figure 6.5 Time [s] 5 5. A fast filter 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 filters.2 -1.4 -0. The figures that follow show the similarities between the Kalman filter 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 filters 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 different Kalman filters. and this is one example of the advantage of developing filters using the Kalman model.1. When knowing what type of behavior is wanted from the filter.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 filter methods. The Kalman filter 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 state-space model. where the driver uses the cruise control lever to fast step the set speed up and down several times. the Kalman filter equations are used.8 Figure 6. the Kalman filter uses the measurement of the vehicle speed as input.2 Disturbance [m/s 2] 0 -0. Therefore it is not a regular low-pass filter. The Kalman filter 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 filter with these parameters behaves as a low-pass filter. to calculate the optimal gain L for the observer. as explained in Section 3.4 0.62 Alternative Kalman Filter Models 0. This figure 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 filter so that the gain is high when the signal-to-noise ratio is high. When knowing the intensities of the process noise w and measurement noise e. Looking at the figures.12 comes from a drive on the bumpy road.4 a∆=am-aexp az Kalman filter from Chapter 5 az Kalman filter with v as feedback az Kalman filter with az as Gauss-Markov 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 filters 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 First-Order Lag Function 63

2

1

Disturbance [m/s 2]

0

-1

-2

-3

a∆=am-aexp az Kalman filter a∆ low-pass filtered 4 6 8 10 Time [s] 12 14 16 18

Figure 6.11. The measurement in this figure comes from a test drive when the vehicle drives up and down the steep hill. The dashed line is the output from a first-order lag function with time constant τ = 1.1. As can be seen the behavior is similar to the output from the Kalman filter (solid line).

According to [12], the transfer function for the stationary Kalman filter is Gkf (s) = (sI − A + LCA)−1 Ls (6.41)

where L is the steady-state gain parameters calculated by (3.27). Calculating Gkf with the model used for the Kalman filter gives a matrix containing three transfer functions from the input vm to each of the filter 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 filter with smaller r and the dashed-dotted line shows a filter with a larger r. The filter has the function of a high-pass filter. 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 filters. The filter 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 filter also can differentiate higher frequencies. [12]

64

Alternative Kalman Filter Models
a∆=am-aexp az Kalman filter a∆ low-pass 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 figure is from a simulation using recorded data from a test drive on a bumpy road. The dashed line is the output from a first-order lag function with time constant τ = 1.1. As can be seen the behavior is similar to the output from the Kalman filter (solid line).
1.5

1

0.5

0 Disturbance [m/s 2]

-0.5

-1

-1.5

-2 a∆=am-aexp az Kalman filter a∆ low-pass filtered 15 20 25 Time [s] 30 35 40 45

-2.5

-3 10

Figure 6.13. The figure 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 first-order lag function with time constant τ = 1.1. As can be seen the behavior is similar to the output from the Kalman filter (solid line).

6.5 Comparing the Kalman Filter with a First-Order 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 filter presented in Section 6.2.5. The solid line is the parameters chosen in Section 6.2.5, the dashed line is from a filter with smaller r and the dashed-dotted line is from a filter with a larger r. The filter has the function of a normal high-pass filter. This is expected, as the transfer function used in the plot estimates az using measurements of the speed v. The filter with a smaller r has a higher break frequency, and a larger r means lower break frequency. A smaller measurement noise means that the filter also can differentiate 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 filter. 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 filter is a compromise between noise attenuation and tracking ability. The filter 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 filter 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 filter 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 different driving situations are made. The quality of the estimate x can be tested by ˆ looking at the residuals k = xm. a slow filter 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 different 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 filter 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 significant. 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 filter can take appropriate action (for example by making the filter faster). one slow and one fast. It is often used to detect faults in a system. Different 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 filter 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 filters. • Methods using two filters. The filter is temporarily made faster when a change is detected. The stopping rule decides whether the change is significant or not.2 One Kalman Filter with Whiteness-Test The task of the change detector is to decide which of the following hypotheses is correct. • Methods using multiple filters in parallel. that measures the deviation from the hypothesis H0 . concerning the residuals from the Kalman filter 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 filters. as in Figure 7. For each filter the probability of that filter being correct is calculated.68 Change Detection ukxk. a method using one filter 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 significant or not. 7. There are three different categories of change detection methods [13] • Methods using one filter.

When an alarm is given. The stopping rule gives an alarm when gk > h.10) Here the forgetting factor λ is used to tune the low-pass effect.2 One Kalman Filter with Whiteness-Test • Change in mean. • Change in sign correlation. . giving sk = k 69 (7.7) (7.9) A stopping rule is created by low-pass filtering sk and comparing this value to a threshold h. which means no low-pass effect 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 low-pass filters described in [13] are • The CUmulative SUM (CUSUM) test gk = max(gk−1 + sk − ν. the Kalman filter is temporarily made faster by adjusting the parameters. and gk is reset to 0.11) (7.6) • Change in correlation. 0) The “drift parameter” ν influences the low-pass effect. 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 defined as β = λ + ν. and as stopping rule the CUSUM-test k gk = max(gk−1 + sk − ν. If fewer false alarms are wanted. As distance measure sk = 2 − λ is chosen. The Kalman filter should in these situations remain slow. The output from the simulated Kalman filter 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 different 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 filter 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 filter 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 filter. When this signal is high. and the Kalman filter 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 filter with the change detection algorithm chosen in Section 7. As a reference the output from the “original” Kalman filter 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 filter 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 affect 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∆ = am-aexp 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 filter with change detection algorithm when driving up and down a steep hill. Figure 7.6 each show a test drive on two different bumpy roads. and the change detection algorithm does not affect 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 figures it can be seen that the estimates from the Kalman filter with change detection is faster than the original implementation.2.

The change detection algorithm detects the large changes and makes the Kalman filter faster.) 3 a∆ = am-aexp 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 filter faster than the original implementation. . (The original Kalman filter becomes saturated at −3ms−2 .4. Simulation of a Kalman filter with change detection algorithm when driving up and down a steep hill with a 2000 kg trailer. Simulation of a Kalman filter 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∆ = am-aexp 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 filter with change detection.

3 -0.7. The change detection algorithm does not give many alarms.2 a∆ = am-aexp 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 filter 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∆ = am-aexp az Kalman filter az Change Detection Alarm 0.6.6 -0. .2 -0. and therefore the estimate is not affected. and therefore the estimate is not affected. as desired. Simulation of a Kalman filter 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 filter have been implemented and tested. • or by adjusting the parameters as a compromise between a slow filter. inspired by the first-order lag function and the Gauss-Markov 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 filter (to do this a subjective choice has to be made). 8. It has been shown that the filter 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 filter 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 filter. 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 briefly introduced. instead of the constructed signal a∆ .1 Conclusions In this Master’s thesis the theory for the Kalman filter and filter 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 filter. 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 filters 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 filter implemented in the vehicles today can be replaced by a first-order lag function. • It should be practically tested if the Kalman filter can be exchanged with another simpler type of low-pass filter. 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 coefficient Rolling resistance coefficient Efficiency factor for the drivetrain Measurement noise Air resistance Force from the brakes Force from transmission and engine Drive resistance Rollin resistance Gravitational acceleration Differential 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 defined.

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 Anti-lock 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. Bar-Shalom. 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. 2007-02-01 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) : 671-680. . Kienecke and L. 2005. Bishop. An Introduction to the Kalman Filter. Online Supplement. System Identification . Master’s thesis No. Nielsen. Technical Report TR95-041. [17] L. INFORMS Journal on Computing. Linköping. Stuttgart. 2005. System Identification Toolbox User’s Guide. Vecchi. Vehicle System Dynamics Supplement 37 page 12-23. The MathWorks.. Inc. Berlin. [15] S. DaimlerChrysler AG. 1999. Natick. Prentice Hall. Rosander. Springer-Verlag. 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 S-Class. The Math Works. [26] Owner’s Manual M-Class.80 Bibliography [14] U. 2002. Fahrzeugdynamik. Schiehlen. B. Stuttgart.informs. LITH-ISY-EX-3408-2003. 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 call-back 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_value-real_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 Simulink-simulation 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_current-cost_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 RMSE-error 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_g-simout_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 state-space identification model m = idss(A.5.x0. B = [0].02.D. K = [K_start].b. A = [-1/tau_start].Appendix C Time Constant Identification Here is the Matlab identification script that was used to identify the unknown parameter τ and the intesitiy of w in the first-order 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.