# LSTM-DQN-APF Path Planning Algorithm Empowered by Twins in Complex Scenarios
## 3 Method
### Improved Gravity and Repulsion Functions  
In contrast to traditional artificial potential field methods, which only drive the UAV's motion through static attractive and repulsive fields without considering the UAV's own motion state, this leads to path oscillations or delayed responses. Especially when obstacles and UAVs are moving towards each other, traditional repulsive fields cannot predict or avoid collision risks in advance, failing to effectively handle changes in a dynamic environment. Therefore, the improved method introduces velocity and acceleration compensation terms, combining the effects of attractive and repulsive forces. This optimization enhancesthe traditional artificial potential field method, and the improved function provides support for the collaborative decision-making ability of DQN-APF, enabling better adaptation to changes in dynamic environments. (1) Gravitational potential field and gravitational function  
In the dynamic environment, the gravitational potential field should not only consider the relative position factor between the UAV and the target point, but also the relative velocity factor, which yields the improved equation as:  
\[\overset{\rightarrow}{U}_{att}(X_{R},V_{R})=\overset{\rightarrow}{U}_{att}(X _{R})+\overset{\rightarrow}{U}_{att}(V_{R}), \tag{3}\]  
where \(\overset{\rightarrow}{U}_{att}(X_{R})\) is the gravitational force generated by the location factor, expressed as a tendency towards the location of the target point:  
\[\mathrm{U}_{att}(V_{R})=\frac{1}{2}\mathrm{K}_{v}(\overset{\rightarrow}{V}_{ R}-\overset{\rightarrow}{V}_{C})^{2} \tag{4}\]  
where \(K_{v}\) is the gravitational potential field velocity gain parameter; \(V_{R}\) is the UAV velocity and \(V_{c}\) is the dynamic obstacle velocity, then the combined gravitational force is:  
\[\left\{ \begin{array}{l}\overset{\rightarrow}{F}_{att}(X_{R},V_{R})= \overset{\rightarrow}{F}_{att}(X_{R})+\overset{\rightarrow}{F}_{att}(V_{R}) \\ \overset{\rightarrow}{F}_{att}(X_{R})=K_{v}d(X_{R},X_{G})\\ \overset{\rightarrow}{F}_{att}(V_{R})=K_{v}\parallel\overset{\rightarrow}{V }_{R}-\overset{\rightarrow}{V}_{G}\parallel\end{array} \right., \tag{5}\]  
where the direction of \(\overset{\rightarrow}{F}_{att}(X_{R})\) is the direction of the UAV pointing to the dynamic obstacle, and the direction of \(\overset{\rightarrow}{F}_{att}(V_{R})\) is the direction of the relative velocity between the UAV and the target point. (2) Repulsive potential field and repulsive function  
In the dynamic environment, the repulsive effect of the obstacle on the UAV should not only consider the position factor, but also the velocity factor and acceleration factor, and the repulsive potential field function applicable to the dynamic environment is:  
\[\overset{\rightarrow}{U}_{rep}(X_{R},V_{R},A_{R})= \begin{cases}\overset{ \rightarrow}{U}_{rep}(X_{R})+\overset{\rightarrow}{U}_{rep}(V_{R})+ \overset{\rightarrow}{U}_{rep}(A_{R})&d(X_{R},X_{O})\leq d_{n}\cap V_{RO} \geq 0\\ \overset{\rightarrow}{U}_{rep}(X_{R})&d(X_{R},X_{O})\leq d_{n}\cap V_{RO}<0,\\ 0&d(X_{R},X_{O})>d_{n}\end{cases}  \tag{6}\]  
where \(\overset{\rightarrow}{U}_{rep}(X_{R},V_{R},A_{R})\) is the repulsive potential field used in the dynamic environment; \(\overset{\rightarrow}{U}_{rep}(V_{R})\) is the repulsive potential field generated by the velocity factor of the obstacle; \(\overset{\rightarrow}{U}_{rep}(A_{R})\) is the repulsive potential field generated by the acceleration factor of the obstacle; \(\mathrm{d}_{n}\) is the critical value of the range of the repulsive potential field; \(\overset{\rightarrow}{V}_{R}=\left|\overset{\rightarrow}{V}_{R}-\overset{ \rightarrow}{V}_{O}\right|\overset{\rightarrow}{e}_{RO}\) is the component of the relative velocity of the UAV and the obstacle on the line between the two; \(\overset{\rightarrow}{V}_{RO}>0\) is the obstacle approaching to the UAV; \(\overset{\rightarrow}{V}_{RO}<0\) is the obstacle leaving the UAV.