## 2 Method  
Machine-learning-based approaches are currently the most common approach for obstacle detection in vehicles, particularly road-bound ones. In a railway environment, obstacle detection is, by itself, less common than in a road environment, and thus, there are no open datasets that can be used. This, allied with the fact that obtaining good quality data on the railway is significantly more challenging, made a data-heavy solution like machine learning unfeasible. An alternative to using lots of data to train a model is a map-based approach, where previous knowledge of the train's route, which is predetermined and limited by the rails, can be leveraged to determine the target volume relative to the train's location. Figure 1 shows an overview of the solution, which is based on two live data sources: the GNSS/GPS (Global Navigation Satellite System/Global Positioning System) coordinates and the LiDAR point cloud. The GPS coordinates are used to determine the train's position in its scheduled path and orient the point cloud data on the same coordinate system. This enables the definition of a target volume at a predefined distance on the LiDAR point cloud, where obstacles on the track will be searched. A commonly used [27; 28] clustering algorithm by [PERSON] et al. [29] and known as DBSCAN, or Density-Based Spatial Clustering of Applications with Noise, was employed for the obstacle identification phase, as shown in Figure 2.  
The relevant parameters for implementing DBSCAN include the eps, which is the maximum distance between two neighboring points, and the minimum number of samples that are required to form a dense region. The final parameter relates to post-processing and is the number of points that are required for a dense region to be considered as an obstacle. Figure 1: Proposed solution overview. CC BY 4.0 [26]. As previously stated, the fact that the train follows a pre-determined path is one of the pillars for the development of the proposed method. This means that it is necessary to define this path in a descriptor file, which will be used as a reference for the real-time processing of LiDAR data. It includes a sequence of track coordinates, i.e., latitude, longitude, and altitude, along the path at periodic intervals that will be used to calculate the location of the search region. Figure 3 presents a high-level overview of the processing cycle of the proposed solution. After acquiring LiDAR and GPS data, the first step is determining the GPS train position in the predefined path. This is performed by selecting the closest point on the train's path to the train's actual location using the Haversine formula. The Haversine formula, Equation (1), determines the great circle distance between two points in a sphere given their longitudes and latitudes (the shortest distance over the Earth's surface). It is a special case of a more general formula in spherical trigonometry, the Law of Haversines, which relates the sides and angles of spherical triangles. If we consider two points A and B according to their respective latitudes \(\phi\) and longitude \(\lambda\), as A = (\(\phi_{A}\), \(\lambda_{A}\)) and B = (\(\phi_{B}\), \(\lambda_{B}\)) (in radians), the great circle distance between A and B is \(d_{AB}\). This \(d_{AB}\) has a radius of \(r\) and a central angle of \(\Theta\), which leads to \(d_{AB}=r\times\Theta\). The law of haversine \(\mathrm{hav}(\Theta)\) corresponding to the central angle \(\Theta\) is then  
\[\mathrm{hav}(\Theta)=\mathrm{hav}(\phi_{B}-\phi_{A})+\cos(\phi_{B})\cos(\phi_ {A})\mathrm{hav}(\lambda_{B}-\lambda_{A}). \tag{1}\]  
Figure 3: Processing cycle. Figure 2: Obstacle detection algorithm. CC BY 4.0 [26].