A local path planning algorithm and device, used for path planning of a mobile device, the mobile device is loaded with a sensor, the algorithm includes: S1, judging whether the mobile device has reached the destination, if it has reached the destination, end, otherwise, execute step S2; S2, according to Sensor data, get the candidate gap set; S3, select a nearest gap from the candidate gap set as the target gap; S4, determine the moving direction of the mobile device according to the target gap; S5, use the improved dynamic window method to control the mobile device to move along the target direction ; S6, repeating steps S1-S5 until the mobile device reaches the destination or there is no feasible gap. Gap-based and improved dynamic window methods are used to plan mobile device paths to reduce local extrema and improve obstacle avoidance performance.