# Vehicle-in-the-Loop in Global Coordinates for Advanced Driver Assistance System
## 2 Vehicle in the Loop
### Sensor Emulation  
ADAS controllers receive information on objects that have been recognized and judged from the radar or vision sensors via Control Area Network (CAN). However, in the VIL environment, there are no real objects that real sensors can recognize. Thus, the sensor emulation module uses the information of the virtual object and the location of the actual synchronized test vehicle to process it. For example, radar sensor emulators are used to calculate relative distance, speed, and azimuth values for synchronized test vehicles and vehicles or pedestrians. The vision sensor emulator processes left and right road lines, and these values are sent to the real controller. The radar sensor emulator generates the signal processed through the shape points \(\left\{x_{k}^{V},y_{k}^{V}\right\}\) of the virtual object and the sensor pose \(\left\{x_{S}^{EGO},y_{S}^{EGO},y_{S}^{EGO}\right\}\) on the real test vehicle. These points and this pose can be obtained by using (1). The relative distances and azimuth angles of the objects are determined by Euclidean geometry using the \(x_{k}^{V},y_{k}^{V},x_{S}^{EGO},y_{S}^{EGO}\), and \(y_{S}^{EGO}\). We can define nodes positions \(N_{1}\) and \(N_{2}\) on the object, sensor position \(S\), and the position \(H\) on the object located at the shortest distance between the sensor and the object. Additionally, \(T\) is a temporary point to obtain \(H\). These are shown in Figure 4a. \[N_{1}=\left[ \begin{array}{c}x_{1}^{V}\\ y_{1}^{V}\end{array} \right]\text{, }N_{2}=\left[ \begin{array}{c}x_{2}^{V}\\ y_{2}^{V}\end{array} \right]\text{, }S=\left[ \begin{array}{c}x_{s}^{EGO}\\ y_{s}^{EGO}\end{array} \right]\text{, }H=\left[ \begin{array}{c}x_{h}^{V}\\ x_{h}^{V}\end{array} \right]\text{, }T=\left[ \begin{array}{c}x_{h}^{N}\\ y_{t}^{N}\end{array} \right] \tag{9}\]  
The shortest distance between the sensor position and a line that includes two nodes can be obtained through the norm as shown in (10), and the position is calculated by (11). \[\parallel\overrightarrow{SH}\parallel=\frac{\overrightarrow{N_{1}N_{2}}}{ \parallel\overrightarrow{N_{1}N_{2}}\parallel}.\overrightarrow{N_{1}S} \tag{10}\]  
\[T=N_{1}+\parallel\overrightarrow{ST}\parallel\times\frac{\overrightarrow{N_{ 1}N_{2}}}{\parallel\overrightarrow{N_{1}N_{2}}\parallel} \tag{11}\]  
The position \(H\) must exist between the two nodes \(N_{1}\) and \(N_{2}\). Therefore, it can be selected as follows. \[N_{k}=\left\{ \begin{array}{ll}N_{1},&\parallel\overrightarrow{N_{1}S} \parallel<\parallel\overrightarrow{N_{2}S}\parallel\\ N_{2},&\text{else}\end{array} \right. \tag{12}\]  
\[H= \begin{cases}T,&x_{t}^{N}\in\left[x_{1}^{V},x_{2}^{V}\right]\wedge y_{t}^{N} \in\left[y_{1}^{V},y_{2}^{V}\right]\\ N_{k},&\text{else}\end{cases}  \tag{13}\]  
Finally, the shortest distance and the recognized azimuth angle of the object is:  
\[d_{SH}=\parallel\overrightarrow{SH}\parallel \tag{14}\]  
\[\theta_{SH}=tan^{-1}\left(\frac{x_{h}^{V}-x_{s}^{EGO}}{y_{h}^{V}-y_{s}^{EGO}} \right)-\theta_{s}^{EGO} \tag{15}\]  
The \(d_{SH}\) and \(\theta_{SH}\) are idle results from the geometric model and cannot represent perception in real environment. For the more realistic, it can be added that some noise caused by component tolerances, temperature drifts and quantization, as shown in (16):  
\[\left[ \begin{array}{c}d_{noisy}\\ \theta_{noisy}\end{array} \right]=\left[ \begin{array}{c}d_{SH}\\ \theta_{SH}\end{array} \right]+\left[ \begin{array}{cc}N\left(0,\sigma_{d}^{2} \right)&N\left(0,\sigma_{\theta}^{2}\right)\end{array} \right]^{\text{T}} \tag{16}\]\(N\big{(}0,\sigma_{d}^{2}\big{)}\) and \(N\big{(}0,\sigma_{\theta}^{2}\big{)}\) represent random numbers with a mean of 0 and standard deviations of \(\sigma_{d}\) and \(\sigma_{\theta}\). The standard deviations are linearly dependent on the distance and angle from the sensor, and more detail is given in [34]. The vision sensor emulator transmits information from the virtual environment as images. In this paper, however, only line recognition is considered for a lateral control system.