## 3 Proposed Approach
### Tracking the Mobile Platform
#### 3.3.2 Height-Adaptive, Predictive PID Controller  
In this section, we describe how we integrated the pedestrian trajectory prediction algorithm developed in a previous work by the authors [22] into the height-adaptive PID controller described in the previous section. The resulting pipeline looks as follows:  
1. The detection-localization algorithm (Section 3.2) outputs the centroid of the landing platform in the UAV's camera frame. The prediction algorithm requires as input a 3D point relative to an _inertial_ reference system. Therefore, we must transform the centroid of the landing platform from the drone's camera frame into the the world's frame: \[P_{world}=T_{world\_cam}\ P_{cam}.\] (8)
2. The new position is then sent to the prediction algorithm (Kalman filter), which returns a vector of future positions of the centroid of the landing platform relative to the world frame \(\hat{P}_{world}\). The first element in this vector (with index zero) corresponds to the current position of the landing platform. The next element (index one) corresponds to the next predicted position after a user-defined time step. Correspondingly, the element with index two corresponds to a prediction carried out with twice the defined time step. In general, the number of steps in this path of predicted positions is computed as the ratio between a user-provided _path time_ and the _time step_. 3. Subsequently, the predicted future position of the landing platform is transformed from the world's frame into the UAV's body frame: \[\hat{P}_{body}=T_{body\_world}\ \hat{P}_{world}.\] (9)
4. Finally, the x and y coordinates of \(\hat{P}_{body}\) are used to calculate the controller's error, i.e., the distance in the xy-plane between the UAV and the predicted position of the landing platform. Using this error we can now calculate the speed commands in x and y, i.e., \(u(t)\) in (4), that make this error converge to zero. **Configuration of the Kalman filter. ** We use a value of 0.1 s as the time step for our predictions and a path time of 0.1 s, thus obtaining a vector of future predictions of size two, where the element with index one corresponds to the predicted position of the landing platform. (Recall that the element with index zero corresponds to the _current_ position of the landing platform's centroid.) We studied the effect of using different path times and then accessing different future positions within this vector of predictions depending on the altitude, but in a set of preliminary experiments, we found that the performance improvement of this design choice was minor or even negative. By using the time step and path time defined above, if the landing platform were to move, for instance, linearly at a speed of 0.5 m s\({}^{-1}\), the prediction algorithm would estimate an increment of 0.05 m along the current trajectory of the moving target. We found that such a minor prediction (in this example, the predicted position differs only in 5 cm from the current position) benefits the landing accuracy notably, as presented in Section 4, when compared to the non-predictive system. For completeness, we detail the co-variance matrices of the process noise, \(Q\), and the observation noise, \(R\), both diagonal matrices of the form:  
\[Q= \begin{pmatrix}2&0&0&0\\ 0&2&0&0\\ 0&0&2&0\\ 0&0&0&2\end{pmatrix} ,\qquad R= \begin{pmatrix}2&0\\ 0&2\end{pmatrix} , \tag{10}\]  
which were obtained empirically. As will become apparent in Section 4, employing a Kalman filter to predict the future positions of the landing platform not only provided the system with knowledge about the trajectory described by the UGV, but also helped further stabilize the measurements from the detection-localization algorithm (Section 3.2). In this section, we described a system for the autonomous takeoff, tracking, and landing of a small UAV on a moving landing platform.