Navigation and obstacle avoidance are critical for the successful completion of UAV tasks. However,traditional autonomous flight systems face limitations in complex environments,prompting researchers to explore alternative frameworks such as deep reinforcement learning (DRL). This paper proposes a novel DRL⁃based autonomous control algorithm for UAVs,which integrates the Deep Deterministic Policy Gradient (DDPG) algorithm to self⁃learn an optimal Proportional⁃Integral⁃Derivative (PID) controller.The performance of the proposed algorithm is evaluated through simulations in the Gazebo 3D robotic simulator to validate its effectiveness under complex conditions. Results indicate that the proposed method outperforms numerous existing methods in dynamic environments,particularly in terms of improved stability, faster response speed,and higher success rates.