In this work, we address the real-time obstacle avoidance path planning and trajectory tracking control for fixed-wing drones during autonomous flight at cruising speed. The fixed-wing drone poses unique challenges due to its non-hovering capability and relatively high speed, requiring efficient online motion planning and precise control. We propose a collision‑force‑based real‑time path planning algorithm, a hybrid position control scheme combining L1 guidance with total energy control, and an attitude controller tailored for fixed‑wing dynamics. The entire system is validated through a software‑in‑the‑loop (SITL) simulation based on PX4, ROS, and Gazebo. The simulation results demonstrate the effectiveness of our planning strategy and the feasibility of the trajectory tracking controller.
1. Real‑Time Obstacle Avoidance Path Planning
We formulate the trajectory as a uniform B‑spline curve of degree \(P\) defined by control points \(\mathbf{Q} = \{\mathbf{Q}_1,\dots,\mathbf{Q}_N\}\) and a knot vector \(\{t_1,\dots,t_M\}\) with \(M=N+P\) and constant time interval \(\Delta t = D_c / V_C\). The position at any time is obtained via the recursive De‑Boor algorithm. During flight, an initial collision‑free trajectory is generated ignoring obstacles; when the onboard perception system detects an obstacle along the planned path, we perform local replanning using a set of \(\{\mathbf{p},\mathbf{v}\}\) pairs that impose repulsive forces on the control points.
The figure below illustrates the typical scenario of a fixed-wing drone navigating through obstacles.

For each colliding control point \(\mathbf{Q}_i\), we assign an anchor point \(\mathbf{p}_{ij}\) on the obstacle surface and a direction vector \(\mathbf{v}_{ij}\) pointing from \(\mathbf{Q}_i\) to \(\mathbf{p}_{ij}\). The signed distance is:
$$ d_{ij} = (\mathbf{Q}_i – \mathbf{p}_{ij})^T \mathbf{v}_{ij} $$
Only when \(d_{ij} > 0\) for all existing \(j\) do we consider the obstacle as new. To obtain reliable \(\{\mathbf{p},\mathbf{v}\}\) pairs, we employ an A*‑based method to generate a collision‑free path \(\mathcal{B}\) that tightly wraps the obstacle. For each control point \(\mathbf{Q}_k\) that lies inside the obstacle, we compute the tangent line to the original trajectory \(\mathcal{A}\) at \(\mathbf{Q}_k\), construct a plane \(\Phi\) normal to this tangent, and intersect \(\Phi\) with \(\mathcal{B}\) to obtain the anchor point \(\mathbf{p}_{kj}\). The vector \(\mathbf{v}_{kj}\) is the unit vector from \(\mathbf{Q}_k\) to \(\mathbf{p}_{kj}\).
Gradient‑Based Trajectory Optimization
We minimize a composite cost function defined on the control points:
$$ \min_{\mathbf{Q}} \; J = \lambda_s J_s + \lambda_c J_c + \lambda_d J_d $$
where the three terms represent smoothness, obstacle avoidance, and dynamic feasibility penalties. The smoothness penalty penalizes acceleration and jerk:
$$ J_s = \sum_{i=1}^{N-1} \|\mathbf{A}_i\|_2^2 + \sum_{i=1}^{N-2} \|\mathbf{J}_i\|_2^2 $$
with \(\mathbf{V}_i = (\mathbf{Q}_{i+1}-\mathbf{Q}_i)/\Delta t\), \(\mathbf{A}_i = (\mathbf{V}_{i+1}-\mathbf{V}_i)/\Delta t\), and \(\mathbf{J}_i = (\mathbf{A}_{i+1}-\mathbf{A}_i)/\Delta t\).
The obstacle avoidance penalty for control point \(\mathbf{Q}_i\) is built from the per‑pair penalty:
$$ j_c(i,j) =
\begin{cases}
0, & \Delta d_{ij} \le 0 \\[4pt]
\Delta d_{ij}^3, & 0 < \Delta d_{ij} \le d_s \\[4pt]
3 d_s \Delta d_{ij}^2 – 3 d_s^2 \Delta d_{ij} + d_s^3, & \Delta d_{ij} > d_s
\end{cases}
$$
where \(\Delta d_{ij} = d_s – d_{ij}\) and \(d_s\) is the safety distance. The total penalty \(J_c = \sum_i \sum_j j_c(i,j)\). Its gradient with respect to \(\mathbf{Q}_i\) is:
$$ \frac{\partial J_c}{\partial \mathbf{Q}_i} =
\begin{cases}
0, & \Delta d_{ij} \le 0 \\[4pt]
\sum_j \mathbf{v}_{ij}(-3\Delta d_{ij}^2), & 0 < \Delta d_{ij} \le d_s \\[4pt]
\sum_j \mathbf{v}_{ij}(-6d_s\Delta d_{ij} + 3d_s^2), & \Delta d_{ij} > d_s
\end{cases}
$$
Dynamic feasibility is enforced by:
$$ J_d = \sum_i \omega_v F_v(\mathbf{V}_i) + \sum_i \omega_a F_{aj}(\mathbf{A}_i) + \sum_i \omega_j F_{aj}(\mathbf{J}_i) $$
with
$$ F_{aj}(\mathbf{E}_i) = \sum_{r\in\{x,y,z\}} f_{aj}(E_{ir}) $$
$$ f_{aj}(E_{ir}) =
\begin{cases}
(-\lambda E_m – E_{ir})^2, & E_{ir} < -\lambda E_m \\
0, & -\lambda E_m \le E_{ir} \le \lambda E_m \\
(E_{ir} – \lambda E_m)^2, & E_{ir} > \lambda E_m
\end{cases}
$$
and the velocity penalty \(F_v\) is designed to keep the speed near the cruise velocity \(V_C\):
$$ F_v(\mathbf{V}_i) = \sum_{r\in\{x,y,z\}} f_v(V_{ir}) $$
$$ f_v(V_{ir}) =
\begin{cases}
k_v (V_{ir} – V_{Cr} – V_{Or})^2, & V_{ir} \ge V_{Cr} + V_{Or} \\
0, & V_{Cr} – V_{Or} < V_{ir} < V_{Cr} + V_{Or} \\
(V_{Cr} – V_{Or}) – V_{ir}^3, & V_{jr} \le V_{ir} < V_{Cr} – V_{Or} \\
a_1 V_{ir}^2 + b_1, & 0 \le V_{ir} < V_{jr}
\end{cases}
$$
| Parameter | Description | Typical Value |
|---|---|---|
| \(P\) | B‑spline degree | 3 |
| \(\Delta t\) | Time interval between knots | \(D_c/V_C\) |
| \(\lambda_s, \lambda_c, \lambda_d\) | Weights for smoothness, obstacle, dynamics | 1, 10, 0.5 |
| \(d_s\) | Safety distance | 3.8 m |
| \(V_C\) | Cruise speed | 15 m/s |
| \(\omega_v, \omega_a, \omega_j\) | Weights for velocity, accel., jerk | 1, 1, 0.1 |
| \(\lambda\) | Elastic coefficient for dynamic constraints | 0.9 |
Numerical Solution Using L‑BFGS
We solve the unconstrained optimization problem with the Limited‑Memory BFGS algorithm. The update rule is:
$$ \mathbf{x}_{k+1} = \mathbf{x}_k – \alpha_k \mathbf{H}_k \nabla f_k $$
$$ \mathbf{H}_{k+1} = \mathbf{V}_k^T \mathbf{H}_k \mathbf{V}_k + \rho_k \mathbf{s}_k \mathbf{s}_k^T $$
$$ \rho_k = (\mathbf{y}_k^T \mathbf{s}_k)^{-1}, \quad \mathbf{V}_k = \mathbf{I} – \rho_k \mathbf{y}_k \mathbf{s}_k^T $$
$$ \mathbf{s}_k = \mathbf{x}_{k+1} – \mathbf{x}_k, \quad \mathbf{y}_k = \nabla f_{k+1} – \nabla f_k $$
We store only the last \(m\) correction pairs to keep memory usage low. After optimization, we perform time reallocation: if on any interval \([t_i, t_{i+1}]\) the ratio
$$ r_e = \max\{ |V_{ir}|/v_{\max}, |A_{ir}|/a_{\max}, |J_{ir}|/j_{\max}, 1 \} $$
exceeds 1, we scale the time interval by \(\Delta t’ = \lambda_t r_e \Delta t\) with \(\lambda_t > 1\).
2. Trajectory Tracking Control
2.1 Position Control: L1 Guidance and TECS
The lateral guidance is based on the L1 distance algorithm. A target point on the desired trajectory is selected according to the UAV’s position and heading. The lateral acceleration command is:
$$ a_{sc} = 2 \frac{V^2}{L} \left( \frac{d}{L} + \frac{\dot{d}}{V} \right) $$
where \(L\) is the distance from the aircraft to the target point, \(d\) the cross‑track distance, and \(V\) the current airspeed. The commanded roll angle is \(\phi_c = \arctan(a_{sc}/g)\) and the commanded yaw angle \(\psi_c = \eta\) (the angle between velocity and line‑of‑sight).
The vertical and speed control use the Total Energy Control System (TECS). The specific total energy per unit mass is \(E_1 = V_n^2/(2g) + H\). Its rate of change satisfies:
$$ \dot{E}_1 / V_n = \dot{V}_n/g + \gamma = (T-D)/(mg) $$
The throttle control law is:
$$ \delta_T = K_{ET} \left[ (K_{Tp} + K_{Ti}/s) \Delta E_1 + K_{Td} \Delta \dot{E}_1 \right] + T_{\text{pre}} $$
where \(\Delta E_1 = E_{1s} – E_{1r}\), \(\Delta \dot{E}_1 = \dot{E}_{1s} – \dot{E}_{1r}\). The predicted throttle \(T_{\text{pre}}\) is computed from the current energy rate. The elevator control is derived from the energy balance:
$$ \delta_e = K_{Le} \left[ (K_{ep} + K_{ei}/s) \Delta E_{L1} + K_{ed} \Delta \dot{E}_{L1} + K_{et} L_{1s} \right] $$
with \(K_{Le} = (K_{et} V_n g)^{-1}\). The commanded pitch angle is set as \(\theta_c = \delta_e\).
| Symbol | Description | Value |
|---|---|---|
| \(K_{ET}\) | Energy‑to‑throttle gain | 1.0 |
| \(K_{Tp}\) | Proportional gain for throttle | 2.0 |
| \(K_{Ti}\) | Integral gain for throttle | 0.5 |
| \(K_{Td}\) | Derivative gain for energy rate | 0.1 |
| \(K_{ep}\) | Proportional gain for elevator | 1.5 |
| \(K_{ei}\) | Integral gain for elevator | 0.3 |
| \(K_{ed}\) | Derivative gain for elevator | 0.05 |
| \(K_{et}\) | Energy balance time constant | 2.0 |
2.2 Attitude Control
The desired angular rates in the body frame are obtained from the ground‑frame rates via the transformation:
$$ \dot{\phi}_s = \dot{\phi}_{sg} – \dot{\psi}_{sg} \sin\theta_r $$
$$ \dot{\theta}_s = \dot{\theta}_{sg} \cos\phi_r + \dot{\psi}_{sg} \sin\phi_r \cos\theta_r $$
$$ \dot{\psi}_s = -\dot{\theta}_{sg} \sin\phi_r + \dot{\psi}_{sg} \cos\phi_r \cos\theta_r $$
The roll rate control uses a cascade structure:
$$ \dot{\phi}_c = \left[ K_t(\phi_s – \phi_r) – \dot{\phi}_r \right] (K_{\phi p} + K_{\phi i}/s) + K_{\phi f} \phi_s $$
where the gains are scaled with airspeed: \((K_{\phi p},K_{\phi i}) \propto (V_c/V)^2\) and \(K_{\phi f} \propto V_c/V\). The pitch rate controller is analogous. The yaw rate command is derived from the coordinated turn equation:
$$ \dot{\psi}_s = \frac{g \tan\phi_s}{V \cos\theta_s} $$
and controlled with a PI plus feedforward:
$$ \dot{\psi}_c = (\dot{\psi}_s – \dot{\psi}_r)(K_{\psi p} + K_{\psi i}/s) + K_{\psi f} \psi_s $$
3. Simulation Results
3.1 Simulation Setup
We built a SITL simulation platform using PX4, ROS, and Gazebo. The fixed-wing drone has a wingspan of 1.2 m and cruises at 15 m/s. The perception sector is a 45° cone with 150 m range. The entire framework runs on a single computer, with the ground station (QGC), trajectory processor, and MATLAB control module communicating via ROS and MAVLink.
3.2 Online Obstacle Avoidance Performance
The planning process was tested with multiple obstacles. Table 3 summarizes the average planning time and speed during different phases of the mission.
| Phase | Duration (s) | Avg speed (m/s) | Max speed (m/s) | Avg planning time (ms) |
|---|---|---|---|---|
| ①→② | 9.4 | 14.7 | 15.8 | 0.89 |
| ②→③ | 10.1 | 14.5 | 16.1 | 1.24 |
| ③→④ | 4.6 | 14.7 | 15.2 | 0.62 |
The minimum distance between the planned trajectory and any obstacle was 11.48 m, which exceeds the safety threshold \(D_s = 3.8\) m (1.5 × wingspan + 2 m). The planning time never exceeded 1.3 ms, demonstrating the real‑time capability of the algorithm.
3.3 Trajectory Tracking Accuracy
We evaluate the tracking errors during the obstacle avoidance flight. Table 4 gives the statistical errors in the global frame and the attitude tracking performance.
| Error quantity | Max value | RMS value |
|---|---|---|
| \(e_x\) (m) | 1.21 | 0.47 |
| \(e_y\) (m) | 0.95 | 0.32 |
| \(e_z\) (m) | 0.78 | 0.25 |
| \(e_{\text{total}}\) (m) | 1.47 | 0.63 |
| Roll angle error (rad) | 0.13 | 0.04 |
| Pitch angle error (rad) | 0.09 | 0.03 |
| Yaw angle error (rad) | 0.11 | 0.04 |
| Roll rate error (rad/s) | 0.07 | 0.02 |
| Pitch rate error (rad/s) | 0.06 | 0.02 |
| Yaw rate error (rad/s) | 0.05 | 0.02 |
The total position error remains below 1.5 m, and the attitude errors quickly converge to within 0.02 rad after transients. The actual clearance to obstacles during flight is \(D_t = 11.48 – 1.47 = 10.01\) m, still safely above \(D_s\). These results confirm that the hybrid L1‑TECS control scheme, together with the attitude controller, can accurately follow the online generated trajectories.
4. Conclusion
We have presented a complete framework for real‑time motion planning and trajectory tracking of fixed‑wing drones. The collision‑force‑based path planner with A* anchor extraction and L‑BFGS optimization produces smooth, dynamically feasible, and collision‑free trajectories with computation times under 1.3 ms. The control architecture, combining L1 lateral guidance, TECS for speed/height decoupling, and cascade attitude controllers, achieves tracking errors below 1.5 m in position and 0.13 rad in attitude. SITL simulations validate the approach, demonstrating that our fixed‑wing drone can autonomously navigate through unknown obstacles while maintaining stable flight. Future work will extend the planner to handle moving obstacles and wind disturbances in real flight tests.
