\appendix
\chapter{Models}
\section{Ground Vehicle Model}
\label{subs:vehmod}
In this appendix, we present a model of ground vehicle in a turning maneuver, for example, a step lane change. During such a maneuver, the vehicle undergoes translational as well as rotational motion. When modeling a moving vehicle it is convenient to use reference coordinate frame attached to and moving with the vehicle. This is because with respect to the vehicle coordinate frame moments of inertias of the vehicle are constant. We use the Society of Automotive Engineers~(SAE) standard coordinate system as shown in Figure~\ref{fig:one}. Our modeling follows that of Wong~\cite{wong93} and Will and \.{Z}ak~\cite{will97}.
\begin{figure}
\vspace{4in}
\hskip.2in\special{bmp:c:/sliding/sae2.bmp x=5.33in y=4in}
\caption{The Society of Automotive Engineers (SAE) coordinate system attached to the vehicle.}
\label{fig:one}
\end{figure}
We use lower case letters to label axes of the vehicle coordinate system. Following the SAE convention, we define the coordinates as follows:
\begin{itemize}
\item the $x$-coordinate is directed forward and on the longitudinal plane of symmetry of the vehicle,
\item the $y$-coordinate has a lateral direction out the right side of the vehicle,
\item the $z$-coordinate is directed downward with respect to the vehicle,
\item the yaw velocity about the $z$-axis is denoted $\dot{\theta}$.
\end{itemize}
In developing our simple model, we neglect the effects of roll and pitch. The origin of the vehicle coordinate system is located at the vehicle center of gravity (CG). We also use a global, or fixed coordinate system. Its axes are labeled using upper case letters as shown in Figure~\ref{fig:veh_pth}.
\begin{figure}
\vspace{3in}
\hskip1in\special{bmp:c:/sliding/veh_pth.bmp x=4in y=3in}
\caption{Analyzing vehicle motion using coordinate frame attached to the vehicle; snapshots of the vehicle velocity at times $t$ and $t+\Delta t$.}
\label{fig:veh_pth}
\end{figure}
To form the equations of motion of the vehicle, we need an expression for the vehicle CG acceleration. We first compute the change in the longitudinal component of the velocity. Using Figure~\ref{fig:veh_pth} and Figure~\ref{fig:veh_acc}, and assuming small angles, we obtain
\begin{eqnarray*}
\left( v_x+\Delta v_x\right)\cos \Delta \theta -\left( v_y+\Delta v_y\right)\sin \Delta \theta - v_x &\approx& \Delta v_x-v_y \Delta \theta\\
&=& \Delta \dot{x}-\dot{y}\Delta \theta. 
\end{eqnarray*}
\begin{figure}
\vspace{3in}
\hskip1in\special{bmp:c:/sliding/veh_acc.bmp x=4in y=3in}
\caption{Computing the change in the longitudinal and lateral components of the vehicle velocity.}
\label{fig:veh_acc}
\end{figure}
We form the Newton quotient using the above. Then, taking the limit, we obtain the total longitudinal acceleration component $a_x$,
\begin{eqnarray}
a_x &=&  \lim_{\Delta t \to 0}\frac{\Delta v_x - v_y \Delta \theta}{\Delta t}\nonumber\\
&=& \dot{v}_x-v_y\dot{\theta}\nonumber\\
&=& \ddot{x}-\dot{y}\omega_z,
\label{eq:axinloncoov}
\end{eqnarray}
where $\omega_z=\dot{\theta}$. Using similar argument to the one above, we obtain the lateral acceleration component $a_y$ to be
\begin{eqnarray}
a_y &=& \dot{v}_y+v_x\dot{\theta}\nonumber\\
&=& \ddot{y}+\dot{x}\omega_z.
\label{eq:axinlaterdir}
\end{eqnarray}
We assume that the vehicle is symmetric with respect to the $x$-$z$ plane. We use the so called bicycle model that is shown in Figure~\ref{fig:veh_for}, where $\delta_f$ denotes the front wheels' steering angle and $\delta_r$ is the rear wheels' steering angle. We denote by $2F_{xf}$ lumped longitudinal force at the front axle and by $2F_{xr}$ lumped longitudinal force at the rear axle. The lumped lateral force at the front axle is denoted $2F_{yf}$, while lumped lateral force at the rear axle is denoted $2F_{yr}$.
\begin{figure}
\vspace{3in}
\hskip1.2in\special{bmp:c:/sliding/veh_for2.bmp x=4in y=3in}
\caption{A simplified, bicycle model of a vehicle.}
\label{fig:veh_for}
\end{figure}
Summing the forces along the $x$ axis and assuming small angles, we obtain
\begin{eqnarray}
m\left(\ddot{x}-\dot{y}\omega_z \right)&=&2F_{xf}\cos \delta_f-2F_{yf}\sin\delta_f +2F_{xr}\cos \delta_r + 2F_{yr}\sin \delta_r\nonumber\\
&\approx& 2F_{xf}+2F_{xr}.
\label{eq:suoffoinlongd}
\end{eqnarray}
Next, summing the forces along the $y$ axis and assuming small angles yields
\begin{eqnarray}
m\left(\ddot{y}+\dot{x}\omega_z \right)&=&2F_{xf}\sin \delta_f+2F_{yf}\cos\delta_f +2F_{yr}\cos\delta_r-2F_{xr}\sin\delta_r\nonumber\\
&\approx& 2F_{yf}+2F_{yr}.
\label{eq:suoflongdi}
\end{eqnarray}
The third equation of motion is obtained by summing the torques with respect to the $z$-axis. Let $I_z$ denote the moment of inertia of the vehicle about the $z$ axis. Then, referring again to Figure~\ref{fig:veh_for} and assuming small angles, we obtain:
\begin{eqnarray}
I_z\dot{\omega}_z&=&2l_1F_{yf}\cos\delta_f + 2l_1F_{xf}\sin\delta_f-2l_2F_{yr}\cos\delta_r + 2l_2F_{xr}\sin\delta_r\nonumber\\
&\approx& 2l_1F_{yf}-2l_2F_{yr}.
\label{eq:rotnelabom}
\end{eqnarray}
In our further analysis, we assume $v_x=\dot{x}=\mb{constant}$, that is, the driver neither is accelerating nor braking the vehicle. This means that we need to use only the last two equations of motion in our model. To proceed, we need to define tire slip angles and cornering stiffness coefficients. The tire slip angle is the difference between the tire's actual travel direction and the tire's heading direction, which is the steer angle. In other words, the the tire slip angle is the angle between the desired direction of motion of the tire specified by the steer angle and the actual direction of travel of the center of the tire contact. We dnote by $C_{\alpha f}$ the cornering stiffness coefficient of the front tires and by $C_{\alpha r}$ the cornering stiffness coefficient of the rear tires. The coefficients $C_{\alpha f}$ and $C_{\alpha r}$ are measured experimentally. A typical relation between a tire slip angle and a cornering force is shown in Figure~\ref{fig:dugoffb}. It is a nonlinear relation, where the cornering coefficient is
\[
C_{\alpha w}=\frac{d F_{yw}}{d \alpha_w},
\]
where $w=f$ or $w=r$.
\begin{figure}
\vspace{3.5in}
\hskip.9in\special{bmp:c:/mybook/dugoffb.bmp x=4.67in y=3.5in}
\caption{A typical cornering characteristic.}
\label{fig:dugoffb}
\end{figure}
The lateral forces $F_{yf}$ and $F_{yr}$ that appear in~(\ref{eq:suoffoinlongd})--(\ref{eq:rotnelabom}) are functions of the corresponding tire slip angles $\alpha_f$ and $\alpha_r$ and cornering stiffness coefficients $C_{\alpha f}$ and $C_{\alpha r}$,In our simple linearized model, we assume that $C_{\alpha f}=C_{\alpha r} =$~constant, and model dependencies between the lateral fopces and tire slip angles as
\begin{equation}
F_{yf}=C_{\alpha f}\alpha_f,
\label{eq:laforacof}
\end{equation}
and
\begin{equation}
F_{yr}=C_{\alpha r}\alpha_r.
\label{eq:relafocor}
\end{equation}
We formulate expressions for the tire slip angles using Figure~\ref{fig:veh_vel}.
\begin{figure}
\vspace{3in}
\hskip1in\special{bmp:c:/sliding/veh_vel2.bmp x=4in y=3in}
\caption{A diagram of a simplified vehicle model for computing tire slip angles.}
\label{fig:veh_vel}
\end{figure}
Assuming small angles, we form an expression for the front tire slip angle
\begin{eqnarray}
\alpha_f &=& \delta_f-\tan^{-1}\left( \frac{l_1\omega_z+v_y}{v_x}\right)\nonumber\\
&\approx& \delta_f-\frac{l_1\omega_z+v_y}{v_x}\nonumber\\
&=& \delta_f-\frac{l_1\omega_z+\dot{y}}{\dot{x}}.
\label{eq:alphafexpr}
\end{eqnarray}
The rear tire slip angle is
\begin{eqnarray}
\alpha_r &=& \delta_r-\tan^{-1}\left(-\frac{l_2\omega_z-v_y}{v_x}\right)\nonumber\\
 &=& \delta_r+\tan^{-1}\left(\frac{l_2\omega_z-v_y}{v_x}\right)\nonumber\\
&\approx& \delta_r+\frac{l_2\omega_z-v_y}{v_x}\nonumber\\
&=& \delta_r+\frac{l_2\omega_z-\dot{y}}{\dot{x}}.
\label{eq:reatialphr}
\end{eqnarray}
Hence
\begin{equation}
F_{yf} = C_{\alpha f}\left( \delta_f-\frac{l_1\omega_z+\dot{y}}{\dot{x}}\right),
\label{eq:fyfwafacaf}
\end{equation}
and
\begin{equation}
F_{yr} = C_{\alpha r}\left( \delta_r+\frac{l_2\omega_z-\dot{y}}{\dot{x}}\right).
\label{eq:fyrcar}
\end{equation}
Substituting the above two equations into~(\ref{eq:suoflongdi}), and assuming small angles yields
\[
m\ddot{y}+m\dot{x}\omega_z=2C_{\alpha f}\delta_f-2C_{\alpha f}\frac{l_1\omega_z+\dot{y}}{v_x}+2C_{\alpha r}\delta_r+2C_{\alpha r}\frac{l_2\omega_z-\dot{y}}{v_x}.
\]
Rearranging terms and performing some manipulations, we get
\begin{equation}
\ddot{y}=-\left( \frac{2C_{\alpha f}+2C_{\alpha r}}{mv_x}\right)\dot{y}+\left( -v_x-\frac{2C_{\alpha f}l_1-2C_{\alpha r}l_2}{mv_x}\right)\omega_z +\frac{2 C_{\alpha f}}{m}\delta_f+\frac{2 C_{\alpha r}}{m}\delta_r.
\label{eq:lataxcafr}
\end{equation}
Substituting the expressions for $F_{yf}$ and $F_{yr}$ into~(\ref{eq:rotnelabom}) and assuming small angles, we obtain
\[
I_z\dot{\omega}_z=2l_1C_{\alpha f}\left( \delta_f -\frac{l_1\omega_z + \dot{y}}{v_x}\right)\delta_f-2l_2C_{\alpha r}\left(\delta_r+\frac{l_2\omega_z-\dot{y}}{v_x}\right).
\]
Rearranging and performing manipulations yields
\begin{equation}
\dot{\omega}_z=-\left(\frac{2l_1C_{\alpha f} - 2l_2C_{\alpha r}}{I_zv_x} \right)\dot{y}-\left( \frac{2l_1^2C_{\alpha f}+2l_2^2C_{\alpha r}}{I_zv_x}\right)\omega_z+\frac{2l_1C_{\alpha f}}{I_z}\delta_f-\frac{2l_2C_{\alpha r}}{I_z}\delta_r.
\label{eq:rotnewaftman}
\end{equation}
Later, we will analyze a vehicle performance in the fixed coordinates. In particular, we will be interested in an emergency lane change maneuver. This requires that we transform the vehicle lateral variable into the fixed coordinates. Assuming small angles and referring to Figure~\ref{fig:veh_lat}, we obtain
\begin{eqnarray}
\dot{Y} &=& -\dot{x}\sin \psi -\dot{y}\cos \psi\nonumber\\
&\approx& -v_x\psi - \dot{y}.
\label{eq:lineexfobiy}
\end{eqnarray}
\begin{figure}
\vspace{3.5in}
\hskip.7in\special{bmp:c:/sliding/veh_lat.bmp x=4.67in y=3.5in}
\caption{Computing the velocity of a vehicle with respect to the fixed coordinates.}
\label{fig:veh_lat}
\end{figure}
Note that
\[
\dot{X} = \dot{x}\cos \psi - \dot{y}\sin \psi.
\]
For the step lane change, the yaw rate of the vehicle is equal to the yaw rate error, that is,
\[
\omega_z=\dot{\psi}.
\]
We further assume that
\begin{equation}
\theta=\psi.
\label{eq:theaeqpsi}
\end{equation}
We can now represent the vehicle modeling equations in a state space format. Let
\[
x_1 =\dot{y},\quad x_2=\theta,\quad x_3=\omega_z,\quad x_4=Y.
\]
Then, using~(\ref{eq:lataxcafr}), (\ref{eq:rotnewaftman}), (\ref{eq:theaeqpsi}) and~(\ref{eq:lineexfobiy}), we obtain
\begin{eqnarray}
\left[\begin{array}{c}
\dot{x}_1\\
\dot{x}_2\\
\dot{x}_3\\
\dot{x}_4
\end{array}\right]&=&\left[\begin{array}{cccc}
-\frac{2C_{\alpha f}+2C_{\alpha r}}{mv_x}& 0 & -v_x-\frac{2C_{\alpha f}l_1-2C_{\alpha r}l_2}{mv_x}& 0\\
0 & 0 & 1 & 0\\
-\frac{2l_1C_{\alpha f} - 2l_2C_{\alpha r}}{I_zv_x}& 0 & -\frac{2l_1^2C_{\alpha f}+2l_2^2C_{\alpha r}}{I_zv_x}& 0\\
-1 & -v_x & 0 & 0
\end{array}\right]\left[\begin{array}{c}
{x_1}\\
{x_2}\\
{x_3}\\
{x_4}
\end{array}\right]\nonumber\\
&{}&\quad+\left[\begin{array}{cc}
\frac{2C_{\alpha f}}{m}&\frac{2C_{\alpha r}}{m} \\
0 & 0\\
\frac{2l_1C_{\alpha f}}{I_z}&-\frac{2l_2C_{\alpha r}}{I_z} \\
0 & 0
\end{array}\right]\left[\begin{array}{c}
\delta_f\\
\delta_r
\end{array}\right]\nonumber\\
&=&\b A\b x+\b B\b u.
\label{veh_model}
\end{eqnarray}
A possible vehicle parameters are given in Table~\ref{tab:par}.
\begin{table}
\caption{Typical vehicle data.}
\label{tab:par}
\begin{center}
\begin{tabular}{cc}\hline
$C_{\alpha f}=C_{\alpha r}$ & $30,000.00\,\mb{N/rad}$\\
$l_1$ & $1.20\,\mb{m}$\\
$l_2$ & $1.22\,\mb{m}$\\
$m$ & $1280\,\mb{kg}$\\
$I_z$ & 2500\,kg$\cdot$m$^2$\\
$v_x$ & $18.3\,\mb{m/sec}$\\ \hline
\end{tabular}
\end{center}
\end{table}



\section{Stick Balancer Model}
\label{subsection:truth}
In this appendix, we present a model of the stick balancer, also known as the cart with an inverted pendulum. In our derivation of the model, we use Newton's laws, in a similar fashion as in Kwakernaak and Sivan~\cite{kwakernaak72}, and Ogata~\cite{ogata97}, where linearized models of the stick balancer were developed. An alternative derivation, using the method of D'Alembert, can be found in Cannon~\cite[Section 22.4]{cannon67}.

A free body diagram of a cart on which a stick, an inverted pendulum, is mounted is shown in Figure~\ref{fig:inp_free}.
\begin{figure}
\vspace{4in}
\hskip.75in\special{bmp:c:/papers/inp_free.bmp x=5.33in y=4in}
%\centerbmp{4.67in}{3.5in}{c:/papers/inp_free.bmp x=4.67in y=3.5in}
\caption{Free body diagram of a cart with an inverted pendulum.}
\label{fig:inp_free}
\end{figure}
We denote by $H=H(t)$ and $V=V(t)$ horizontal and vertical reaction forces, respectively. The $x$ and $y$ are the coordinates of the fixed, nonrotating coordinate frame $xy$. The angular displacement of the stick from the vertical position is denoted by $\theta=\theta(t)$. The mass of the cart is denoted by $M$, while the mass of the stick by $m$. The length of the stick is $2l$, and its center of gravity is at its geometric center. The control force applied to the cart is labeled by $u$. We assume that the wheels of the cart do not slip. We model the frictional force of the cart wheels on the track by
\begin{equation}
f_c=\mu_c\mb{sign}(\dot{x}),
\label{eq:kinetic_fr}
\end{equation}
where $\mu_c$ is the cart friction coefficient. Friedland~\cite[page 201]{friedland96} refers to this model of friction as the classical Coulomb friction model. Let $(x_G,y_G)$ be the coordinates of the center of gravity of the stick. Then,
\begin{equation}
\left\{\begin{array}{lcl}
x_G & = & x+l\sin(\theta)\\
y_G &=& l\cos(\theta).
\end{array}\right.
\label{eq:cog_stick}
\end{equation}
We are now ready to write down equations modeling the system. The equation that describes the rotational motion of the stick about its center of gravity is obtained by applying the rotational version of Newton's second law. Summing the moments about the center of gravity of the stick, we obtain
\begin{equation}
I\frac{d^2\theta}{dt^2}=Vl\sin(\theta)-Hl\cos(\theta),
\label{eq:newton_rot}
\end{equation}
where
\begin{equation}
I=\int_{-l}^lr^2dm=ml^2/3,
\label{eq:mom_inertia}
\end{equation}
is the moment of inertia of the stick with respect to its center of gravity.

We next write the equation that describes the horizontal motion of the center of gravity of the stick. Applying Newton's second along the $x$ axis yields
\begin{equation}
m\frac{d^2}{dt^2}\left( x+l\sin(\theta)\right)=H.
\label{eq:newt_hor}
\end{equation}
Performing the required differentiation, we get
\begin{equation}
m\left(\ddot{x}+l\left(-\dot{\theta}^2\sin(\theta)+\ddot{\theta}\cos(\theta)\right)\right)=H.
\label{eq:newt_hort}
\end{equation}
The equation that describes the vertical motion of the center of gravity of the stick is obtained by applying Newton's second law along the $y$ axis. We have
\begin{equation}
m\frac{d^2}{dt^2}\left( l\cos(\theta)\right)=V-mg.
\label{eq:newt_vert}
\end{equation}
Performing the needed differentiation yields
\begin{equation}
ml\left(-\dot{\theta}^2\cos(\theta)-\ddot{\theta}\sin(\theta)\right)=V-mg.
\label{eq:newt_vertt}
\end{equation}
Finally, we apply Newton's second law to the cart to get
\begin{equation}
M\frac{d^2x}{dt^2}=u-H-f_c.
\label{eq:newt_cart}
\end{equation}
Substituting~(\ref{eq:newt_cart}) into~(\ref{eq:newt_hort}) gives
\begin{equation}
m\ddot{x}+ml\ddot{\theta}\cos(\theta)-ml\dot{\theta}^2\sin(\theta)+f_c=u-M\ddot{x}.
\label{eq:four_two}
\end{equation}
Substituting now equations~(\ref{eq:newt_vertt}) and~(\ref{eq:newt_cart}) into~(\ref{eq:newton_rot}) yields
\begin{equation}
I\ddot{\theta}=\left( mg-ml\dot{\theta}^2\cos(\theta)-ml\ddot{\theta}\sin(\theta)\right)l\sin(\theta)+f_cl\cos(\theta)-\left(u-M\ddot{x}\right)l\cos(\theta).
\label{eq:three_four}
\end{equation}
We next substitute $u-M\ddot{x}$ from~(\ref{eq:four_two}) into~(\ref{eq:three_four}) and perform manipulations to get
\begin{equation}
I\ddot{\theta}=mgl\sin(\theta)-ml^2\ddot{\theta}-m\ddot{x}l\cos(\theta).
\label{eq:almost}
\end{equation}
Let
\[
a=\frac{1}{m+M}.
\]
Then, we can represent~(\ref{eq:four_two}) as
\begin{equation}
\ddot{x}=-mal\ddot{\theta}\cos(\theta)+mal\dot{\theta}^2\sin(\theta)-af_c+au.
\label{eq:xtwodot}
\end{equation}
We substitute~(\ref{eq:xtwodot}) into~(\ref{eq:almost}) to obtain
\begin{equation}
\ddot{\theta}=\frac{mgl\sin(\theta)-m^2l^2a\dot{\theta}^2\sin(2\theta)/2+ mal\cos(\theta)f_c - mal\cos(\theta)u}{I-m^2l^2a\cos^2(\theta)+ml^2}.
\label{eq:theta_fin}
\end{equation}
Let $x_1=\theta$ and $x_2=\dot{\theta}$. Using the expression for $I$, given by~(\ref{eq:mom_inertia}), we represent~(\ref{eq:theta_fin}) in state space format as follows
\begin{equation}
\left.\begin{array}{ccl}
\dot{x}_1 &=& x_2\\
\dot{x}_2 &=& \frac{g\sin(x_1)-mlax_2^2\sin(2x_1)/2+ a\cos(x_1)f_c}{4l/3-mla\cos^2(x_1)}-\frac{mal\cos(x_1)u}{4ml^2/3-m^2l^2a\cos^2(x_1)}.
\end{array}\right\}
\label{eq:mod_space}
\end{equation}
We next substitute $\ddot{\theta}$, obtained from~(\ref{eq:almost}), into~(\ref{eq:xtwodot}) to get
\begin{equation}
\ddot{x}=\frac{-mag\sin(2x_1)/2+ax_2^2\sin(x_1)4ml/3+(u-f_c)4a/3}{4/3-ma\cos^2(x_1)}.
\label{eq:xddot}
\end{equation}
Let $x_3=x$ and $x_4=\dot{x}$. Then, combining~(\ref{eq:mod_space}) and~(\ref{eq:xddot}) we obtain a state space model of the inverted pendulum on a cart of the form,
\begin{equation}
\left[\begin{array}{c}
\dot{x}_1\\
\dot{x}_2\\
\dot{x}_3\\
\dot{x}_4
\end{array}\right]=\left[\begin{array}{c}
x_2\\
\frac{g\sin(x_1)-mlax_2^2\sin(2x_1)/2}{4l/3-mla\cos^2(x_1)}\\
{x}_4\\
\frac{-mag\sin(2x_1)/2+alx_2^2\sin(x_1)4m/3}{4/3-ma\cos^2(x_1)}\end{array}\right]+\left[\begin{array}{c}
0\\
\frac{-a\cos(x_1)}{4l/3-mla\cos^2(x_1)}\\
0\\
\frac{4a/3}{4/3-ma\cos^2(x_1)}\end{array}\right](u-f_c).
\label{eq:state_stick}
\end{equation}
While designing a controller for the stick balancer system, we will use an equivalent representation of~(\ref{eq:state_stick}),
\begin{equation}
\left[\begin{array}{c}
\dot{x}_1\\
\dot{x}_2\\
\dot{x}_3\\
\dot{x}_4
\end{array}\right]=\left[\begin{array}{c}
x_2\\
\frac{g\sin(x_1)}{4l/3-mla\cos^2(x_1)}\\
{x}_4\\
\frac{-mag\sin(2x_1)/2}{4/3-ma\cos^2(x_1)}\end{array}\right]+\left[\begin{array}{c}
0\\
\frac{-a\cos(x_1)}{4l/3-mla\cos^2(x_1)}\\
0\\
\frac{4a/3}{4/3-ma\cos^2(x_1)}\end{array}\right](u-f_c+mlx_2^2\sin(x_1)).
\label{eq:stick_eqiv}
\end{equation}
\label{ex:fullmo}
