# A VR Truck Docking Simulator Platform for Developing Personalized Driver Assistance
## 2 VISTA VR-Simulator Platform (VISTA-Sim)
### Path Planner and Path Tracking Controller
#### 2.2.2 Path Tracking Controller  
The main role of the path following controller is to navigate the central turn point \(U\) of the last vehicle unit (described by \(x_{2}\) and \(y_{2}\) in Figure 4) along the reference path, whilst actuating the steering angle of the hauling unit \(\delta\). It is required that the controller is bi-directional, thus working for both the forward and reverse motion in the docking manoeuvre, and needs to be modular to be applicable to multiple vehicle combination layouts. The control problem is formulated as a path following problem and uses a technique of virtual tractor, fully described in [28]. Herewith, the vehicle combination is considered with respect to a set of known reference nodes \(R_{i}\), which constitute the reference path generated by the path planner as shown in Figure 4. Each node \(R_{i}\) is defined by the position represented by \((X_{\text{ref(i)}},Y_{\text{ref(i)}})\) and orientation represented by \(\theta_{\text{ref(i)}}\), all measured in the coordinate system \(e^{\to 0}\). Although the reference path is characterized by discrete nodes, thanks to their high density, no interpolation is required. Subsequently, the lateral error \(e_{\text{yU}}\) can be obtained in the local coordinate system \(e^{\to 3}\) fixed to the controlled turn-point \(U\) of the rear-most vehicle unit.  
The lateral error reads:  
\[e_{y_{U}}=\Delta ycos\theta_{2}-\Delta xsin\theta_{2}\]  
Figure 4: Determination of relevant reference point which is used to determine the tracking errors.  
Figure 3: (a) Path planning environment with polygons; and (b) motion primitives of a truck semitrailer.  
Besides the lateral error, the controller also employs an angular error \(e_{0U}\) in order to ensure the rearmost vehicle has the same orientation as the relevant reference point \(R_{REL}\).  
The angular error is defined by:  
\[e_{\theta_{U}}=f(x)=\left\{\begin{array}{c}\theta_{ref}-\theta_{2},\wedge \left|\theta_{ref}-\theta_{2}\right|\leq\pi\\ \theta_{ref}-\theta_{2}-2\pi sign\left(\theta_{ref}-\theta_{2}\right),\wedge \text{otherwise}\end{array}\right.\]  
To formalize the control problem, the classical model of nonlinear kinematic articulated vehicle can be rewritten as follows:  
\[\dot{x}(t)=f(x(t))+g(x(t),u(t))\] \[y(t)=\left[\begin{array}{c}x_{2}(t)\\ y_{2}(t)\\ \theta_{2}(t)\end{array}\right]\]  
In the model above, \(x=[\theta_{0};\,x_{0};\,y_{0};\,\theta_{2}]^{\text{T}}\) are system states representing the pose of the hauling unit and yaw angle of the semitrailer, \(u=[\delta]\) is the control input representing the steering angle of the hauling unit, the velocity of the hauling unit \(v_{0}\) is known to be constant, which can be either positive or negative, and \(y\) is the output which gives the pose of the point \(U\) given by \(x_{2},\,y_{2},\) and \(\theta_{2}.\) To solve the control problem, the goal is to design the control input \(u\) such that closed-loop stability is guaranteed and the controlled output \(y\) follows the reference path, such that:  
\[e(t)\left[\begin{array}{c}e_{y_{U}}(t)\\ e_{\theta_{U}}(t)\end{array}\right]=h(y(t),R_{i})\to 0,\text{ for }t\rightarrow\infty\]  
In Figure 5, the control loop structure is depicted. As can be seen, it includes a known set of reference path nodes from which the relevant nodes are selected based on the current pose of point \(U,\) a controller, and a kinematic model of the articulated vehicle. The controller consists of three blocks, these being an error definition, a driver model and the inverse kinematic model, respectively. Further details are provided in [29], where the controller is also subjected to the stability analysis and the robustness is tested by deployment on the scaled vehicle lab-platform. Achieved results provided solid evidence that the controller framework may be employed also for \"driver in the loop\" applications, which is further exploited in the VISTA project and the VR simulator.