# A Low Cost Vision-Based Road-Following System for Mobile Robots
## 4 Road Detection System
### Fusion Module with UKF
The UKF uses an unscented transformation to model non-linear dynamics, while the EKF will linearize the nonlinear system with the use of the Jacobian of the model; this linearization could cause divergence problems. In the presented approach, the borders of the road are represented by lines in a 2D Cartesian space. A line has two parameters, which are \(l\) and \(\psi\). \(l\) represents the intersection point with the \"x-axis\" of the reference frame, and \(\psi\) represents the angle between the line and the \"y-axis\" of the reference frame; see \[T_{color}=\frac{\text{Number of circles}\times 100}{2\times\text{Number of rows}} \tag{5}\]0  
(1) The state  
In the proposed approach, the left and the right borders will have an independent state, both of them have their own filter and will be computed separately. A state is represented as \(x=[l,\psi]\). The state of the estimated line is represented as \(\hat{x}=[l^{-},\psi^{-}]\), and \(\hat{x}^{-}\) is the last state of \(\hat{x}\). (2) Measurement update  
The state is updated based on the measurements by using (8). \[ \begin{array}{l}K_{k}=\frac{P_{k}^{-}}{(P_{k}^{-}+R_{k})}\\ \hat{x}_{k}=\hat{x}_{k}^{-}+K_{k}(z_{k}-\hat{x}_{k}^{-})\\ P_{k}=(I-K_{k})P_{k}^{-}\end{array}  \tag{8}\]  
in which the matrix \(R\) represents the covariance of the measurements. \(K\) is the Kalman gain that updates the ratio gain between the estimates and the measurements. The matrix \(P\) is the covariance error, and \(P^{-}\) is the covariance error of last period. The matrix \(R\) is updated in every step because the error variance of the measurements varies over time. The function \(z\) represents the process of detecting the road borders in the images. (3) Time update  
The function that models the movement of the lines will be represented by the function \(f\) (\(x_{k-1}\), \(u_{k-1}\), \(w_{k-1}\)). The function \(f\) relates the state \(x_{k}\) based on the previous state \(x_{k-1}\), and the control input \(u_{k-1}\) and \(w_{k-1}\), which is the function that models the noise of the motion model. The motion model is a non-linear function that includes the homogeneous transformation which rotates and translates the lines based on the motion of the mobile robot \(m(\varphi,\Delta x,\Delta y)\), where \(\varphi\) is the angle of difference of the robot between time steps, and \(\Delta x\), \(\Delta y\) are the displacements in the \"\(x\)-axis\" and \"\(y\)-axis\"  
Figure 12: Line parametrization. respectively. The model also includes the transformation of lines from the polar to the corresponding Cartesian representation. \[A=\left| \begin{array}{ccc}\cos\varphi&-\sin\varphi&\Delta x\\ \sin\varphi&\cos\varphi&\Delta y\\ 0&0&1\end{array} \right| \tag{9}\]  
The Polar and Cartesian coordinates are related as:  
\[ \begin{array}{l}P(x,y)=(r\times\cos\varphi,r\times\sin\varphi)\\ P(r,\varphi)=(\sqrt{x^{2}+y^{2}},\arctan(y/x))\end{array}  \tag{10}\]  
Therefore, the time update is governed by:  
\[ \begin{array}{l}\hat{x}_{k}^{-}=f(\hat{x}_{k-1},u_{k-1},w_{k-1})\\ P_{k}^{-}=P_{k-1}+Q_{k-1}\end{array}  \tag{11}\]  
in which the matrix \(Q\) represents the covariance of the motion model. It is updated in every step. It is updated based on the influence of the robot's movement on the estimated line.