{'fraction_non_alphanumeric': 0.022970328345227036, 'fraction_numerical': 0.010338624547808725, 'mean_word_length': 4.729105322763307, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Brain over Brawn -- Using a Stereo Camera to Detect, Track and Intercept a Faster UAV by Reconstructing Its Trajectory

The work presented in this paper demonstrates our approach to intercepting a faster intruder UAV, inspired by the MBZIRC2020 Challenge 1. By leveraging the knowledge of the shape of the intruder's trajectory we are able to calculate the interception point. Target tracking is based on image processing by a YOLOv3 Tiny convolutional neural network, combined with depth calculation using a gimbal-mounted ZED Mini stereo camera. We use RGB and depth data from ZED Mini to extract the 3D position of the target, for which we devise a histogram-of-depth based processing to reduce noise. Obtained 3D measurements of target's position are used to calculate the position, the orientation and the size of a figure-eight shaped trajectory, which we approximate using lemniscate of Bernoulli. Once the approximation is deemed sufficiently precise, measured by Hausdorff distance between measurements and the approximation, an interception point is calculated to position the intercepting UAV right on the path of the target. The proposed method, which has been significantly improved based on the experience gathered during the MBZIRC competition, has been validated in simulation and through field experiments. The results confirmed that an efficient visual perception module which extracts information related to the motion of the target UAV as a basis for the interception, has been developed. The system is able to track and intercept the target which is 30% faster than the interceptor in majority of simulation experiments. Tests in the unstructured environment yielded 9 out of 12 successful results.


Introduction
Along with unmanned aerial vehicles becoming more capable and available, there has been a rise in discussion concerning the policies surrounding those systems (Fox, 2019) and the overall safety and security of UAVs (Yaacoub et al., 2020), (Best et al., 2020). The most common approach to counter the intruder UAVs is jamming the radio signal (Abughalwa et al., 2020), but with the rapid development of autonomous UAV solutions that do not require operator input, those techniques are becoming more and more obsolete with the alternative being the interception by tracking UAVs. Such a scenario is considered in the Mohamed Bin Zayed International Robotics Challenge 1 (MBZIRC, 2020), where the solution to countering an intruder UAV is to intercept it with another UAV. The Challenge 1 consists of two tasks: intercepting an unfriendly UAV and removing balloons from the tether. In this paper, we focus on the first task, shown in Figure 1, since it is closer to real-world applications.
Intercepting a runaway UAV is a well-researched topic in the aerial robotics community (Beard et al., 2002), (Moreira et al., 2019), (Hehn and D'Andrea, 2012), but the Challenge 1 of the MBZIRC2020 competition is more structured than a "runaway UAV" scenario. The structure in the challenge arises from the fact that the shape of the target trajectory is known in advance, while other parameters such as size, location and more importantly orientation of the trajectory are not known in advance. In the previous iteration of the competition (MBZIRC2017), the target moved on the ground and in a predefined path, which classifies it as a fully cooperative target. In the 2020 edition of MBZIRC, the target is flying in 3D space, which makes the challenge more difficult by itself, but the target is also not fully cooperative since all the parameters of its motion are not known in advance. Even though the MBZIRC2020 Challenge 1 is not tackling a general case of the intruder UAV, one can envision a scenario in which the intruder UAV is performing its nefarious actions by flying in a predefined pattern over an area. In real-world scenarios, this can be applied to the security of airports, nuclear power plants, military buildings, prisons, and other high-security areas. Figure 1: The scenario of an intruder UAV subtask of the MBZIRC2020 Challenge 1. The target UAV is following a 3D trajectory in the shape of a figure-eight with variable location and orientation inside the arena of size 100 m × 60 m. The follower UAV must autonomously track and detach a soft target from the target UAV, effectively mimicking the interception of the intruder UAV.
In this paper, we propose a vision-based system designed for the interception of unfriendly UAV in an unconstrained environment. Since the appearance of the unfriendly UAV is not known in advance, a deep learning based object detector is used to overcome this problem and provide valuable information about the target. The depth data acquired by the stereo camera is processed using a histogram of depth and in combination with the detection results, the information about the 3D position of the target is obtained. Continuous and robust information over time is provided by a tracking-by-detection algorithm based on the Kalman filter. Based on the observations of the target position, the trajectory is estimated using the Bernoulli's lemniscate and the interception point is selected on the straightest part of the lemniscate. Our approach to the problem of unfriendly UAV is fully autonomous and requires no input from the operator.
In the next section, we present the contributions of this work and position our research with respect to the state of the art in the field. The system architecture is described in Section 3, while in Section 4 we give a detailed description of the method used to determine the 3D position of the target object. Section 5 is dedicated to the presentation of an estimator of figure-eight shaped trajectory. Visual servoing and the target interception procedure are described in Section 6. Finally, experimental results are presented and commented in Section 7, and concluding remarks are given in the last section of the paper. signals from remote controllers (Ezuma et al., 2019), ii) acoustic footprint of propellers (Dumitrescu et al., 2020), iii) reflections obtained from a low-cost radar, or iv) images obtained by optical sensors (cameras). In some applications, a combination of those techniques is used to improve the probability of UAV detection. In most of the methods that employ RF and acoustic signals, as well as low-cost radars, the sensors are spatially distributed over an area of interest (e.g., an airport) so that some algorithm, based on signal time-of-arrival differences, can be applied. On the other hand, optical sensors are typically movable, mounted on a UAV that patrols over an area that should be protected. Recent detection methods (video stream processing) for such scenarios are predominantly based on the artificial intelligence paradigm -in most cases, deep neural networks are at the core of the method (Ç etin et al., 2020). In general, deep learning based object detection methods are categorized into two-stage and one-stage detectors. Due to the strong emphasis on detector efficiency in UAV applications, one-stage detectors, such as YOLO (Redmon and Farhadi, 2018) and SSD (Liu et al., 2016), and lightweight networks, whether new architectures or modifications of milestone detectors (e.g., YOLOv3 Tiny), are better choices. A promising trade-off between accuracy and efficiency is also offered by recent work on anchor-free one-stage detectors, like CenterNet (Duan et al., 2019) and FSAF (Zhu et al., 2019).
Once detected, a target UAV is usually tracked by the same technique used for detection, or alternatively, combination of sensors fixed on the ground and sensors mounted on the tracking UAV(s) can be implemented. Deploying tracking UAV(s) requires estimation of the trajectory of the target UAV and calculation of the tracking path. Such scenario, if successfully applied, finally ends in interdiction of the target by a single tracking UAV (for example by an on-board tethered net system (AeroGuard, 2020)) or by a group of UAVs (Brust et al., 2021).
The goal of the MBZIRC2020 Challenge 1 was to detach a ball suspended from the target UAV, prompting many teams to opt for detecting the ball rather than the UAV. In this paper we aim for a more general use-case and focus on the UAV, more specifically on the first part of the challenge: detecting and intercepting an UAV, by building upon our previous work (Barisic et al., 2019). To detect and track the target UAV, we use the stereo camera ZED Mini and the deep neural network YOLOv3 Tiny (Redmon and Farhadi, 2018) trained on our own dataset of 13 000 images. This differs from most of the published approaches from the MBZIRC2017 and the large body of research where the detection of the target is based on markers (Tzoumanikas et al., 2018), (Beul et al., 2019), . To contribute to the research community, we publicly release our validation dataset named UAV-Eagle. The UAV-Eagle dataset provides a benchmark in object detection of UAVs in an unconstrained environment characterised by illumination changes, motion effects, viewpoint changes, and a high-density environment.
Combining UAV detections with depth estimation from ZED, we reconstruct 3D position of the target and feed it to a Kalman filter to achieve robust target tracking. A similar approach using an Intel RealSense D435 was reported in (Vrba et al., 2019), where the authors use a custom depth image processing based on classical computer vision methods to detect intruder UAVs with the assumption that there are no other flying objects in the field of view. A deep neural network approach to a similar task was published in (Vrba and Saska, 2020) in which the authors assume a known size of the target to reconstruct its position. Alongside being more general compared to the most recent research, this work is backed by a more powerful graphics processor and a stereo camera with a larger baseline, providing improved performance. On top of the CNN-based UAV detection, we develop a depth processing algorithm that takes into account that the UAV is an object with known structure to generate more consistent and robust depth estimation in outdoor conditions.
To the best of our knowledge, all of the interception approaches require the interceptor to be faster than the intruder (Moreira et al., 2019), some even up to two times faster than the target (Yang and Quan, 2020), which will be increasingly difficult to achieve, especially since some researchers in the field estimate that within 5 years there could be UAVs with a top speed of 100 m/s (Bond et al., 2019). In this work, inspired by the challenging target speeds of MBZIRC2020 and constrained by limitations of our hardware, we explore the possibility of intercepting a faster and more agile target with a slower UAV. To that end, as a main contribution of this paper, we leverage the knowledge of the shape of the target trajectory to reconstruct the target trajectory in the global coordinate frame from sparse observations of the target in the image. Following a successful reconstruction of the target trajectory, measured by the distance between sets of observed positions of the target and the idealistic approximation of the trajectory, we select the interception point which will allow us to intercept the target with significantly reduced effort in control inputs.

Kopterworx Eagle UAV
The frame of the UAV (Fig. 2) consists of four arms, body and two legs with skis, all built from carbon. The vehicle is equipped with Flame 60A 12S ESCs, which are driving T-motor U8 Lite Kv150 12S motors with 22 inch carbon propellers. The vehicle's autopilot is a Pixhawk 2.0 running ArduPilot software. The maximum take-off weight of the vehicle is 12 kg with 2 kg of payload. The vehicle is equipped with an Intel NUC i7/16GB computer running Ubuntu 18.04 LTS and ROS Melodic. The modular design of the Eagle frame allows for various computational and sensory configurations, including multiple cameras and even 3D lidar sensors. In the configuration used for the first challenge of MBZIRC 2020, image processing and stereo reconstruction is performed using Nvidia Jetson TX2, with images being captured by a ZED Mini stereo camera mounted on a Gremsy Pixy F 3-axis gimbal. All components of the aerial vehicle are powered by two LiPo 12S 14000 mAh batteries, giving the vehicle up to 30 minutes of flight time.

Software architecture
The software components can be divided into four main modules: visual perception, estimation of figure-eight shaped trajectory, global state machine and control algorithms. An overview of the software architecture is shown in Figure 3 where the main modules are highlighted with blue, red, green and orange color, respectively. All algorithms communicate using Robot Operating system (ROS). Besides object detection and depth estimation, which are performed on the Jetson TX2, all other software components are running on the on-board Intel NUC computer.
The inputs of visual perception are color and depth images acquired from ZED Mini stereo camera. A convolutional neural network inference is performed on a given color image, while depth is estimated by analysing the histogram of depth. The pixel coordinates of the centre of detected target and the depth estimation are forwarded to the position reconstruction module in order to obtain (x, y, z) coordinates in the global coordinate system of the follower. The information about the target's position is further enhanced by a Kalman filter estimation.
The goal of moving object tracking is to keep the target in the field of view, which is achieved by a positionbased visual servoing (PBVS), which is a well-researched topic in the field of robotics (Sinopoli et al., 2001), (Chaumette and Hutchinson, 2006). The visual servoing module transforms errors in relative position with respect to the target into references for the on-board UAV controller. In order to continuously follow and promptly respond to target's movement, PBVS relies on the aforementioned Kalman filter estimation. The information for estimation of the figure-eight shaped trajectory and interception point is collected during the stint in which we are able to follow the target. Once the target is lost, the follower switches to local search mode trying to find the target again. Local search trajectories are generated using Time-Optimal Path Parameterization (TOPP-RA) library (Pham and Pham, 2018) and follow a Levy flight paradigm (Puljiz et al., 2012). The behavior switching is managed by a state machine which implements the proposed Search-Follow-Intercept strategy, with the emphasis of this work being on the Follow and Intercept parts of the strategy, as described in the remainder of the paper.

3D position of the target
The starting point of the proposed system is an object detection module. More precisely, a module that runs software for the detection of multicopters of any kind. Due to its complex structure and to achieve generalisation among different appearances of various multicopters, we apply a convolutional neural network (CNN) to solve this problem. Among the advanced object detectors, YOLOv3 was selected as the best solution due to its high efficiency and good accuracy, which was confirmed by many researchers. Specifically, we used a lightweight version of the network, YOLOv3 Tiny, which we modified by adding another YOLO layer to perform detection across three scales to improve the detection of objects that occupy only a small portion of the image. The network architecture consists of 30 layers of which 16 are convolutional layers. In the absence of a publicly available dataset of multicopters, we collected numerous images from the internet and filtered out duplicates and outliers using an open-source clustering method based on image fingerprints generated by a pre-trained deep convolutional network. After manual and pseudo-labeling, the final result is an annotated dataset of 13 000 images of various multicopters in different environments. In comparison to our previous work (Barisic et al., 2019), we extend our dataset with unlabeled images of objects that have a similar appearance to UAVs to achieve more robust detection.
Before training, anchor boxes used as priors for the prediction of bounding boxes are calculated by the Kmeans clustering algorithm on our dataset. The training started from the pre-trained weights from the COCO dataset and the following training parameters were used: batch size = 64, momentum = 0.9, decay = 0.0005 and learning rate = 0.001. The network was trained until the classification accuracy stopped improving, and the weights at 650 000 iteration were selected as the best based on the mean average precision (mAP) on the training and validation dataset to avoid overfitting. As presented in Figure 4, the trained network is able to detect different types of multicopters such as DJI Phantom 4, our custom aerial platform Eagle and Gazebo models of ArduCopter 3DR and Eagle. The presented results show the robustness of the trained YOLOv3 network for different weather conditions (foggy and sunny), different backgrounds and for both small and large objects. Figure 4: Object detection of multicopters used as targets for experiments. The target on the left image acquired from on-board ZED Mini stereo camera is a DJI Phantom 4. Even though barely seen by the human eye, the trained CNN successfully detects distant objects in difficult weather conditions. The center image shows the detection at the test site of our custom aerial platform Kopterworx Eagle. Despite the fact that the network has never seen the image of this multicopter during training, it is able to detect this target with high accuracy. The detection results of ArduCopter 3DR and aerial platform Eagle models in Gazebo simulator are shown on the right image.
An output of CNN inference is a list of detected objects defined by their position coordinates and dimension in the image plane. As we expect only one target object, the data association is performed based on the Kalman filter with the constant velocity model for a single instance. In the case of multiple detections, the measurement with the highest value of Intersection over Union (IoU), compared to the current estimate of the filter, is considered the most appropriate. Even though it is unlikely that multiple detections will occur in a single frame, the resilience to false positives is improved by enforcing the data association.
Following several consecutive detections of the target, we apply the Region of Interest (RoI) concept. The RoI is defined as the bounding box of the previous detection expanded equally in all directions by a certain factor. If there is no detection in the current frame, an estimation of the bounding box from the Kalman filter is used to define RoI. The minimum size of RoI is specified as the input size of the CNN, which is 608 × 608 pixels. The objective of the RoI is to keep only the part of the image where the target is expected to be found. In such manner, information from previous frames is exploited and detection of small objects is improved. If there are no new detections in the previous frames, the RoI is deactivated and another set of consecutive measurements is required to activate it again.

Depth of a well structured object
Calculating the depth of a well structured object based on the detection in the image, i.e., the bounding box, is not trivial because there is no prior knowledge on which pixels in the bounding box area are occupied by the real object. Under perfect conditions, such as a simulation setup, the depth could be obtained by averaging the depth values of all the pixels in the bounding box. However, field experiments with a real sensor have shown that in the case of multicopters, depth measurements are noisy, which can be partially eliminated using camera mounted on the gimbal due to reduced camera movement. The most challenging situation is the one with a multicopter without an outer shell, such as Eagle, because measurement values can vary due to the 'gaps' in the UAV body. Additionally, a large distance from the target, as well as simultaneous motion of the sensor and the target, aggravate the measurement errors.
Given all the above, taking into account all measurements enclosed by the bounding box results in noisy and unreliable depth data. As a solution, we propose to spread the depth data from the bounding box across bins of histogram in order to separate the true data from noise and inaccurate measurements. The peaks in histogram, i.e., the bins with the number of measurements higher than its two neighbouring bins, are selected as candidates. Two presumptions are made for selecting a final value: i) there are no other objects between the sensor and the target, and ii) the measurements contain more true depth values than noise. According to the second presumption, candidates are narrowed down to peaks which have a higher or equal number of measurements than the average number of measurements of all peaks. Since no other objects are expected to be between the sensor and the target, the final depth is the average value of the measurements in the first candidate peak. A good example of advantages of the proposed approach is shown in the right image in Figure 5. Obtained measurements extend in the range of 6 m to 15m, which can by no means be accurate because diagonal from motor to motor of the target is 113 cm. The corresponding histogram of depth contains eight peaks, which are reduced to only one after applying threshold. The selected value corresponds to the average value of the true depth. Figure 5: An example of depth estimation of a highly structured object based on object detection (left image) and histogram of depth (right image). Black pixels in the depth image (middle image) represent pixels where the depth could not be determined (such as occlusions) or objects are out of measurable range. The enlarged area shows the depth of pixels enclosed by the bounding box, and the blue pixels are the ones from the selected bin (marked with green color). Demonstrated example shows ability to extract relevant depth information from noisy and inaccurate measurements by analysing histogram of depth.
The maximum measurable range of depth for ZED Mini camera is from 0.1 m to 20 m. However, since the value of the measurable range affects demand for computational power and GPU memory, and also since the measurements significantly deteriorate for large distances from the target, a range from 2 m to 15 m is chosen as adequate for our application. For this range, the number of bins was experimentally determined to be 40. When the estimated depth exceeds the measurable range, the value of normalised bounding box size compared to the image size is used to declare the maximum or minimum depth value, which is used as the output of the proposed algorithm.

Calculating and tracking 3D position of the target
The final step of the visual perception module is transformation of visual information into position information in the coordinate frame of the follower. Coordinate frames of the scenario are shown in Figure 6. By knowing the depth d and target's coordinates u and v in the image plane, the 3D position p C m = (x c , y c , z c ) in camera coordinate frame C can be calculated as where f x and f y are the focal length in pixels, c x and c y are the principal point. As the camera is fixed to a gimbal, a known transformation T C F from camera frame C to the local follower frame F is applied to get a relative target position p F m = (x f , y f , z f ) = T C F p C m with respect to the follower. On-board localisation sensors compute pose of the follower in global frame G, which can be written in a from of transformation matrix T F G . Knowing the position and orientation of the follower in G, the target position p G m in global coordinate system G is calculated by: As position controller operates at a frequency of 50 Hz, the discrete Kalman filter with a constant velocity motion model is applied to meet the rate of the controller. The target is tracked in coordinate frame G, with

Estimator of figure-eight shaped trajectory
As stated in the description of the MBZIRC 2020 Challenge 1, the target is following a 3D trajectory in a shape of a figure-eight with a variable orientation in space. In mathematical terms, a figure-eight shaped curve is called a lemniscate. Among different representations of the lemniscate, the Bernoulli's lemniscate was selected as the most suitable because of its smoothness in curvature, but also because it is characterized by a single parameter and has simple parametric equations.

Estimation of the Bernoulli's lemniscate
The Bernoulli's lemniscate is a plane curve defined by two focal points whose distance is parameter a, which is called the focal distance. Points on the lemniscate, in the Cartesian coordinate system, can be calculated by parametric equations: Given an array of target observations [p m ] G that are assumed to be lying on a lemniscate, our goal is to find the parameter a L and a homogeneous transformation T L G that, when applied to all of the collected points, results in the best overlap of the transformed points with a lemniscate with focal distance of a L . Note that G denotes the global coordinate system in which the observations are made, while L denotes the local coordinate system attached to the lemniscate (see Figure 6). The translational part of T L G is calculated as a centroid of all target observations [p m ] G . The orientation of the lemniscate is calculated by performing Principal Component Analysis (PCA, (Pearson, 1901)) on [p m ] G , resulting in three principal axes. Taking into account that in the local coordinate frame of the lemniscate L, x is the longest axis of the lemniscate, the unit vector of the first principal component is set as the x-axis of L. Given the fact that the lemniscate is a plane curve, the smallest principal component is set as the z-axis of L, choosing the orientation that points upwards. Finally, the y-axis of L is set to form a right-handed coordinate frame. This procedure is detailed in Algorithm 1.
Knowing the rotation matrix and the translation vector of the lemniscate T L G , the vector of position measurements is transformed into the lemniscate coordinate system. The focal distance is determined by finding two opposite endpoints on the lemniscate arcs in what is now 2D space. Using the distance between these two endpoints, the parameter a L can be determined, as shown in step 10 of Algorithm 1. The set of k points, that defines the Bernoulli's lemniscate, is calculated by parametric equations with the estimated value of the focal distance.
Although the algorithm is simple and very precise for a large number of points, when detections of the target are sparse, the accumulation of points on one side tends to introduce errors in the estimation of the lemniscate center. To address these errors, we exploit the symmetry of the lemniscate with respect to the origin and axes of the coordinate frame, and shift the center until said symmetry is achieved. Since this effect is more pronounced for the x-axis of the lemniscate (caused by the sign of the y coordinate of a point on the lemniscate alternating with period of π/2 compared to period π for the sign of the x coordinate) we focus on the x-axis only and reuse the result [r] L (step 8 in Algorithm 1) from the calculation of parameter a. In determining the endpoints of the lemniscate, the resistance to possible outliers in the measurements is achieved by calculating max([r] L ) and min([r] L ) by taking the median of the several highest and lowest values of r in array [r] L .

Calculation of the interception point
For each new measurement of the target position, Algorithm 1 estimates the Bernoulli's lemniscate that best describes the motion of the target using all collected points. To validate the estimation and consequently conclude the estimation procedure, the bidirectional Hausdorff distance (Császár, 1978) is introduced as an evaluation metric. The Hausdorff distance between two discrete sets of points is the greatest of all distances from a set to the closest point in the other set. In the case of estimating a 3D trajectory, the first set are the 3D positions reconstructed from measurements of the target [p m ] G while the second set are sampled points of the estimated lemniscate [p e ] G , generated by Algorithm 1 using parametric equations (3) with the current estimation of a L and k = 100 values of t ∈ [0, 2π]. When those two sets are compared, the Hausdorff distance represents the most mismatched point of the lemniscate. As the Hausdorff distance is not always symmetrical, the bidirectional form is used. The equations of the one-sided and bidirectional Hausdorff distance are given in steps 2 and 4 of Algorithm 2.

// Position and orientation of the interception point
When the ratio of the bidirectional Hausdorff distance and the focal distance of the estimated lemniscate falls bellow a certain threshold 1 , we conclude that new measurements will not significantly improve the estimation and proceed with identification of interception point. First, we identify the direction of the target in the lemniscate by using the timestamps of target detections. The position of the interception point is selected on the end of the near-straight part of the lemniscate in the direction of the targets movement (see Figure 11) as this near-straight part allows the longest time interval for possible corrections in the interception point. For each direction of the target trajectory, there are two such points which can be calculated by plugging values of t ∈ {π/4, 3π/4} in lemniscate parametric equations (3). The orientation of the intercepting UAV is chosen to ensure that the target approaches straight towards the interceptor.

Control of the UAV in Follow mode and switching its behaviors
The general aim of visual servoing is to keep the target within the field of view and at a desired offsets relative to the follower. The two main approaches to the visual servoing are image-based and position-based.
In preparation for the competition image-based visual servoing was employed, but after the competition we decided to continue with the position-based approach because the more stable behaviour of the follower was achieved: Based upon the relative target position, a follower position reference, which is forwarded to the position controller, is generated by Equation 4 where k denotes the time step of the visual servoing module, ψ is a yaw angle, (x F t , y F t , z F t ) is the target position in local frame F and (x f , y f , z f ) is the follower position in the global frame. In the case of using visual servoing to follow the target, y F t in Equation 4 is set to zero because it is incorporated in the calculation of the desired yaw angle: The follower can be operated with these four references, and which one will be set as active depends on the application and the camera pose. For example, in case of visual servoing in the interception point, x F t would be set to zero while the y component would be active. The position offsets are also adaptable to the application and for the target following only x of f set is set to the desired value (in our case 7 m).

State Machine
Figure 7: Flowchart of Follow-and-Intercept state machine.
The top-level state machine converts data, which are received from all modules in the system, into decisions regarding which task must be done next in order to achieve the end goal. The tasks defined in the Followand-Intercept state machine connect the operation of the different modules, while independent decisions are made in individual modules. A flowchart of the state machine is presented in Figure 7, where the diamond shape indicates a decision and the rectangles represent the operating modes. Each transition is conditioned by signals from the visual perception module. The operating modes are stated and briefly described below.
i IDLE -Initial mode. The follower is on the ground and motors are disarmed.
ii TAKEOFF -Mission starts with a request for an autonomous takeoff. Ardupilot mode is set to GUIDED NOGPS, motors are armed and a takeoff trajectory reference is sent to the on-board controller.
iii SEARCH -After a successful takeoff, waypoints for search across the arena are generated. Search trajectory execution is immediately terminated if target detection occurs.
iv FOLLOW -In this state, visual servoing aims to eliminate position errors and to maintain the target at a relative distance of 7 m. The target's trajectory estimation is activated. If the target goes out of the field of view, the interceptor UAV returns to the 'SEARCH' state.
v INTERCEPT -When the quality threshold of the lemniscate estimation is reached, this state is activated, and therefore the estimated point of interception is sent to the follower as a waypoint to intercept the target.

Detection evaluation
Since the whole proposed system is based on the detection results, a detailed analysis of the accuracy of the trained YOLOv3 Tiny network and a qualitative evaluation of the detection on the data obtained during the MBZIRC2020 competition are presented below. The custom dataset of 13 000 images was divided into 90% of images for training and 10% of images for validation. As shown in Table 1, the trained network achieved mAP@0.5 value of 94.5% during training and mAP@0.5 value of 89.5% on the validation dataset. In addition to the standard validation on the training data sample, the accuracy of the trained network was also tested on the UAV-Eagle dataset. The UAV-Eagle dataset contains 510 annotated images of the Eagle quadcopter in a challenging environment. The result of an unstructured environment in which the dataset was recorded are illumination changes, motion effects, changes in viewpoint, and the presence of various objects in the background such as trees, building roofs, clouds, cars, people, and so on. Therefore, the UAV-Eagle dataset is a good indicator of the robustness of the detector in real-world applications and the ability to detect a previously unseen object of interest. The Eagle quadcopter was not seen at all during the training of our CNN and therefore the results on the UAV-Eagle dataset show a remarkable generalization of our network with mAP@0.5 of 84% on the previously unseen model of UAV. The UAV-Eagle dataset is available at https://github.com/larics/UAV-Eagle. Detecting the target UAV in the MBZIRC arena for the Challenge 1 was quite challenging for two reasons. The first reason is the large search area and small target, which means that the target often occupies only a small portion of the image, making it difficult to detect. The second reason is the resemblance of the environment to the target. The scaffolding around the arena is very similar in appearance to the airframe of the UAV, so the target UAV cannot be detected if they overlap. As can be seen in Figure 8, the trained YOLOv3 Tiny is able to successfully detect the target, even though the target occupies on average only 0.07% of the pixels of the entire image in the two sequences of detection frames shown. Two false negative detections in the case of a partially occluded target and a target that is too far away are also shown in the figure.

3D position estimation
After simulation experiments, that showed a root mean squared error (RMSE) of ∼ 0.05 m and a mean absolute error (MAE) of ∼ 0.04 m for the estimation of the target position in the global coordinate system compared to the ground truth of the Gazebo simulator, we decided to execute indoor flights with a very precise ground truth to confirm the obtained results in the real-world conditions. For this purpose, the Optitrack motion capture system with an accuracy of up to 0.2 mm was used in the test area of 6 × 5 m. The experiments were conducted using an AscTec Neo hexacopter as target, completing a set of three different UAVs used as targets in real-world experiments. The detection runs at frequency of 7 Hz on the Jetson TX2, as computational resources are also needed by the ZED SDK for depth estimation. The depth mode in the SDK is set to ultra and the image size is 1280 x 720. Figure 9: Comparison of the proposed 3D position estimation (blue) and ground truth (red) from the Optitrack system. Based on the camera motion, two different experiments are presented to show the influence of the camera motion on the value of the error. The most difficult situation for our vision-based estimation is the abrupt motion of the target. The results from both experiments are presented in terms of position over time, RMSE over distance from the target, and total RMSE and MAE.
In terms of the position estimation of the target, the difficulty of the task increases as we introduce more rapid motion into the problem. The Challenge 1 scenario implies a moving target, and the proposed Followand-Intercept strategy implies a movement of the follower UAV while estimating the target position based on visual information. To show the impact of each component, the results of two experiments with different dynamic conditions are presented in Figure 9. In the first experiment, the target is moving and the camera on the follower UAV is stationary, while in the second experiment we add camera motion. In both experiments, the gap between simulation and real-world experiments can be observed as the RMSE value is significantly larger than the simulation results. This is to be expected in the real-world scenes due to the difficult imaging conditions and sensor noise. A more than twice smaller value of MAE indicates that the estimates are generally stable and occasional outliers are the result of movement. In the second experiment, the value of the errors increases because we introduced camera motion. In the presented experimental results, the sudden changes in the measurements (spikes and dips) are the result of the abrupt motion, either of the camera or of the object. This is later filtered by the Kalman filter during tracking. It is also observed that the value of the RMSE increases as the target is further away. The obtained results are considered to be extremely good (for comparison, the diagonal from motor to motor of the target UAV in the experiments is 0.5 m) as the multicopter is a well structured object, meaning that the measured depth can be obtained from different physical parts of the target, such as motors, body frame, on-board sensors or landing gear.

Performance analysis with respect to the target speed
In order to examine the limits of the complete proposed solution, a large number of simulation experiments were conducted. An important emphasis is placed on the maximum speed of the target at which we can successfully track and intercept. In the conducted experiments, the model of 3DR ArduCopter represents the target and executes the trajectory of Bernoulli's lemniscate with a focal distance of 20 m. All simulation parameters, such as the rate of the algorithms, image size, range of depth measurements and so on, are set to meet the constraints of on-board processing on the Eagle. The model of the Eagle was designed for Gazebo simulation, while the simulated environment corresponds to the dimensions of the Challenge 1 arena. In order to simulate signals and features of the actual autopilot running on the embedded hardware of the Eagle UAV, the software in the loop (SITL) simulation was set up. Using the SITL simulation, the behaviour of software components can be tested as in the real-world application, making it easy to verify new features and the stability of complex systems.
For the target speed ranging from 2 to 6 m/s, the results of the fully autonomous missions are presented in Figure 10. In both boxplots presented, the central red mark represents the median and the boundaries of the box represent the 25th and 75th percentiles. The whiskers indicate the maximum and minimum data points that are not considered outliers, and outliers are presented with a plus sign. The results are obtained from a total of 75 experiments, meaning 15 trials per each value of the target speed. The success rate of all experiments is 100%, meaning that the point of interception was successfully estimated in less than 3 loops of the target trajectory. For the first four speed values, the states of the Follow-and-Intercept state machine were sequentially executed in all experiments. As for the experiments for the target speed of 6 m/s, the 80% of the trials were also performed sequentially, while in the remaining ones the interruptions of the FOLLOW mode occurred (the follower lost the target) and the SEARCH mode was activated. At higher speeds than the ones presented, the more interruptions occur and the success of finding a suitable interception point cannot be guaranteed.
The maximum achievable speed of the follower while in FOLLOW mode is 4.5 m/s due to limitations of the control algorithm which is designed for more general purposes and is not the best choice for visual servoing at high speeds. The boxplot of the Euclidean distance between the estimated interception point and the closest point on the target trajectory is shown in Figure 10a. In cases where the target speed is below the value of the maximum follower speed, the interception point is estimated very accurately and the median is less than 0.3 m. If the target is faster than the follower, the depth measurements may fall outside the measurable range, which is the main reason for the increase in the Euclidean distance value for higher speeds, such as 5 and 6 m/s. However, for 75% of the trials at a speed of 5 m/s and more than 50% of the trials at a speed of 6 m/s, the error of the estimated interception point is less than 1.25 m, which means that no additional visual servoing is required. In the remaining trials, visual servoing can eliminate the error during the final approach of the incoming target on the straight part of the figure-eight. As can be seen in Figure  10b, the estimation of the focal distance of Bernoulli's lemniscate is generally very accurate, and positive error values indicate a tendency to expand the size of the lemniscate. A different behaviour is obtained in the experiments at a speed of 6 m/s, where the size of the lemniscate is underestimated due to the lack of collected trajectory points, which is due to the target being 30% faster than the follower. In the first iterations of the lemniscate estimation, the value of the bidirectional Hausdorff distance increases linearly with the number of obtained measurements, as shown in Figure 10c from the experiment with the target speed of 5 m/s. As the estimation of focal distance converges, the lemniscate estimation approaches the true trajectory and the value of the Hausdorff distance decreases. The trajectory estimation is deemed to be successful (the green area in the graph) when the condition in step 5 of Algorithm 2 is satisfied. The value of the threshold is a hyperparameter of the trajectory estimation.

Evaluation of the interception in field experiments
Finally, the field experiments simulating the challenge were performed at our test site shown in Figures 4 and 5. With simulation experiments validating the visual servoing algorithm and the state machine, the focus of the field experiments was on the ability to intercept the UAV by collecting enough measurements to correctly identify the interception point in real world conditions. For safety reasons 2 no interception was attempted during these experiments and the speed of the target UAV was limited to 1 m/s. With this limit introduced, the intercepting UAV is always capable of following the target (limiting its speed would require a complete overhaul of the low-level controllers). The target trajectory is generated as the Bernoulli's lemniscate with the focal distance of 10 m.
In Table 2, the estimated focal distance of the lemniscate and the error of the estimated interception point in the form of the Euclidean distance are shown for the 12 real-world experiments. The integration of localisation data of both UAVs is performed using GPS measurements, and the position of target in the global coordinate system of the follower is used as the ground truth. By analysing all the collected data from the experiments, the few false positive detections and occasional drops in the depth measurements are identified. Despite that, the error of the estimated focal distance of the Bernoulli's lemniscate is below 1 m (mean absolute error of 0.47 m). As for the interception point, the majority (75 %) of the experiments do not require additional servoing (average distance to the target trajectory of 0.8 m). The visual representation of the estimated Bernoulli's lemniscate (marked pink) compared to the ground truth of the target trajectory (marked red) is shown in the Figure 11. The yellow points are the raw measurements and the green arrow represents the position and orientation of the follower UAV in the estimated interception point. In the run 6, which is shown on the left image, a good amount of measurements is obtained in one loop of the trajectory and the estimated Bernoulli's lemniscate corresponds well to the ground truth trajectory, which is the desired outcome of the proposed strategy. The center image shows a case (Run 2) where half of the lemniscate figure is collected but estimated interception point still lies on the trajectory looking in the direction of the incoming target. Although more measurements generally mean a better estimation, the uneven distribution of measurements results in shifted estimation. This occurred in the run 11 where the largest error of the interception point was obtained. Occasional outliers do not affect the trajectory estimation, as can be seen in the figure. Video showcasing the experiments presented in this paper is available at https://www.youtube.com/ playlist?list=PLC0C6uwoEQ8Y9dg1SqZLomhuFOyfC_1t6.

Performance at the MBZIRC2020 and discussion
The results presented above are very promising for the research area of target tracking and interception of unfriendly UAV. Most of the results in this paper were obtained after the competition. During the MBZIRC2020 competition, we encountered several issues with our solutions at the time. Based on lessons learned during the competition, several improvements, both hardware and software, were deployed for this work. Instead of using the support vector regression model for depth estimation, the more robust and precise method of analysing histogram of depth was adopted. Although the detection results were extremely good in the field experiments conducted prior to the competition, the safety net and scaffolding surrounding the Challenge 1 arena made it difficult to reproduce the same results, as explained in the 7.1 subsection. As mentioned in section 4, the CNN was additionally trained to learn what is not a multicopter based on the unlabeled images of similar objects. The main drawback of our approach for the competition was the capture mechanism that extended on the topside of the UAV during takeoff to comply with the UAV size rules. Having the mechanism folded on the topside of the Eagle before takeoff would effect the consistency of the compass sensor which in turn resulted in several aborted attempts at the competition. Therefore, this paper does not discuss the ball-detaching mechanism and the only, but important, hardware improvement over the competition configuration is the gimbal. The introduction of the gimbal, along with providing mechanically stabilised stereo images reducing the noise in depth estimation, enabled us to simplify our control scheme by decoupling pitch and roll of the camera from the attitude of the UAV.
In general, the limitations of the proposed system mainly relate to detection. As shown in Figure 8, the detection fails when the target is too far away or when the target is densely surrounded by objects with similar appearance. The solution to the first problem would be to train on higher resolution images, but this would also require more powerful computational resources as the inference time would increase. As for the second problem, training on more data with occlusions present could improve the robustness of the detector. However, these problems do not pose a difficulty for the Challenge 1, as the search would continue and new detections would occur. In real-world applications, there is one specific situation where our system would fail, and that is the occlusion of the tracked UAV with another UAV. This would happen due to single object tracking and data association based on the IoU metric. Therefore, multiple object tracking or data association based on the deep features from the CNN would solve this situation. In terms of 3D position estimation, the only limitation is the measurable depth range of the sensor. The estimation of the trajectory and interception point is robust to occasional outliers, and therefore the main concerns relate to detection.
Guided by the motivation to introduce as little as possible information about the target UAV in the proposed system, a lot of effort has been put into developing and testing a visual perception module that is independent of target size, weather conditions, environment structure, and long distances from the target. Only the knowledge of target trajectory shape is introduced into the system to achieve the maximum results which resulted in the ability to track and intercept the target that is faster than us based on minimal knowledge of its trajectory. As already mentioned in the introduction, one can easily envision a scenario in which a target is in some form of a holding pattern of unknown shape, and the approach taken in this paper could be easily extended to incorporate several trajectory shapes as candidates and the similar approach could be taken to identify the best-fit shape and its parameters, generalizing our approach. As we mainly focused on the visual perception and the trajectory estimation, the control algorithms of UAV were not presented in detail. In the future work, the velocity controller for visual servoing at high speeds should be designed. As the success of the rest of the system has been experimentally confirmed, the higher value of traceable speed of the target is expected with the proposed improvement.