## 1 Introduction
The authors in [27] addressed these two problems together using a mixed \(H_{2}/H_{\infty}\) approach; however, a smooth trajectory was approximated by a set of piece-wise lines. The potential field (PF) [28; 29; 30; 31] and virtual force field (VFF) [22, 32] methods were designed for obstacle avoidance guidance using heading direction vector fields. The PF-based method uses potential flow elements that result in a velocity vector; the velocity vector can be used to guide a vehicle to the desired goal while avoiding obstacles. VFF-based methods use artificial attractive forces to pull a UAV toward its goal, and use artificial repulsive forces to push the UAV away from obstacles. Neither PF and VFF can direct a UAV to converge back to the planned path after avoiding an obstacle [29, 30]. In [33], a gradient vector field (GVF) method was proposed for the path following and circular obstacle avoidance of UAVs. The center and size of the newly detected obstacle is required. The user has to evaluate this information from the sensor inputs. A neural network based method is presented in [34]; the control commands were calculated directly from the sensor inputs without the knowledge of the obstacle center and size. The application of the neural-network-based method is limited by the requirement of training samples. Another idea for obstacle avoidance during path following is replanning when new obstacles are discovered [2, 35; 36; 37]. Compared with the PF and VFF methods, replanning requires more calculation time. It is suitable for ground vehicles or quadrotors that can stop or hover during replanning. It is difficult to meet the real-time requirement of a fixed-wing UAV. In addition, the performance of the two-layer \"replanning-following\" structure still depends on the accuracy of the path following algorithms. Otherwise, there may be a large deviation between the actual and the planned path, which means that the generated path cannot be accurately tracked. The idea of replanning is often used in the exploration of an unknown environment. For example, a dynamic path planner was designed in [37] for aerial robots (typically multicopters) to explore underground mines. In the dynamic path planner, a sector-based obstacle avoidance algorithm was designed to avoid collisions and keep the robot more centered inside the tunnel. A similar obstacle avoidance algorithm based on open sectors [38] was proposed for aerial robot navigation through unstructured urban/suburban environments. These methods are successful in obstacle avoidance in unknown environments; however, they do not take the requirement of accurate path following into account. For the problem of path following and obstacle avoidance, in addition to cross-track error and the man-hours associated with the controller's implementation, other considerations, such as stability, computational costs, and execution times are some of the determining factors that a designer has to take into account at the moment of choosing or implementing a controller [39]. Considering these factors in this paper, we propose a novel virtual-force-based guidance law (VFGL) for path following and obstacle avoidance in UAVs inspired by a spring mass system. First, we designed a virtual spring force and a virtual drag force for straight-line following; the dynamic of the closed-loop of the cross-track error is equivalent to a spring mass system, which is easy to tune and to acquire stability and non-overshoot convergence. Then, an additional virtual centripetal force was designed to counteract the influence of the curvature of the planned path so that a general curve with time-varying curvature could be accurately tracked. To avoid the obstacles detected in the planned path, an extra virtual repulsive force was designed to push the vehicle away from the planned path to move around the obstacles. The virtual repulsive force directly relies on the sensor inputs; there is no need to estimate the central position and size of the newly detected obstacle.