## 4 Collision Avoidance Algorithm
### Gaussian-Based Virtual Repulsive Force Model  
This algorithm processes data from all eight ToF sensors mounted around the drone, enabling 360-degree horizontal detection. Based on the computed minimum distances in each direction, the system generates repulsive forces that adjust the drone's flight direction and speed to prevent collisions. The system continuously collects distance data from multiple ToF distance sensors mounted on the drone to achieve 360-degree coverage. Each  
Figure 13: General model of obstacle detection. sensor provides distance measurements across multiple zones (e.g., 4 \(\times\) 4 = 16 zones in low-resolution mode). As illustrated in Figure 14, the geometric diagram presents the workflow of obstacle detection and repulsive force generation from each angular segment corresponding to detected obstacles. Red points represent detected obstacles, while green points indicate free or safe space for navigation. When obstacles \(O_{1}\) and \(O_{2}\) enter the safety zone, the system calculates the individual repulsive force \(f_{1}\) to \(f_{4}\) for \(O_{1}\) and \(f_{5}\) to \(f_{8}\) for \(O_{2}\), using Equation (5) at their respective angular direction \(\Theta_{n}\). These forces are then summed vectorially to produce the intermediate repulsive forces \(F_{1}\) and \(F_{2}\), which represent the overall repulsive effects of obstacles \(O_{1}\) and \(O_{2}\), respectively. These intermediate forces are used solely to clarify how the total force is generated from multiple angular segments, but they are not used directly in the collision avoidance algorithm. The repulsive force model transforms each detected distance value into a virtual force vector that influences drone movement. The model uses a Gaussian decay function, which smoothly increases the force magnitude as the distance to the obstacle decreases. For each detected point \(D_{n}\) at an angle \(\Theta_{n}\), the corresponding repulsive force \(f_{n}\) is computed as  
\[f_{n}=Kexp\left(-\frac{D_{n}^{2}}{2\sigma^{2}}\right) \begin{bmatrix}cos(\Theta _{n}+\pi)\\ sin(\Theta_{n}+\pi)\end{bmatrix}  \tag{5}\]  
where \(D_{n}\) is the minimum distance data from a given column distance data of the \(n\)-th angular segment in the 2D point cloud, \(f_{n}\) is the virtual repulsive force due to distance \(D_{n}\), \(\Theta_{n}\) is the direction of the angular segment where the distance \(D_{n}\) is measured (direction of the detected obstacle), \(K\) is a tuning gain constant (controls maximum repulsion strength), and the parameter \(\sigma\) represents the standard deviation in the Gaussian function and controls the decay width of the repulsive force. A larger \(\sigma\) results in a broader influence range or a large threshold, allowing the drone to respond to obstacles that are farther away with a gradual decrease in force. In contrast, a smaller \(\sigma\) produces a sharper and quicker drop-off, causing the repulsive force to act more strongly only when objects are in close proximity. This tighter response makes the system more responsive in constrained environments and helps prevent sudden or abrupt changes in control behavior. \(\pi\) is used to reverse the virtual repulsive force directly opposite to the obstacle. Figure 14: Obstacle detection (red points represent obstacle detected and green points represent safe space) and collision avoidance algorithm. This Gaussian model offers a smooth and continuously differentiable repulsive force, which is beneficial for generating stable avoidance maneuvers. It also prevents overreaction to distant objects, reducing unnecessary control input and enabling the drone to maintain efficient flight paths in cluttered environments. This approach enables a flexible, responsive, and computationally efficient collision avoidance behavior suitable for indoor inspection tasks. The magnitude of the virtual repulsive force is scaled and mapped to this control range using a Gaussian model. The scaling constant \(K\) in the Gaussian equation defines the maximum repulsive influence.