PurposeThe purpose of this paper is to address two major challenges faced by robotic fish when operating in underwater environments: insufficient path planning capabilities and difficulties in avoiding dynamic obstacles. To achieve this, a method is proposed that combines the Improved Rapid Randomized Tree Star (IRRT*) with the dynamic window approach (DWA).Design/methodology/approachThe RRT-connect algorithm is used to determine an initial feasible path quickly. The quality of sampling points is then improved by dividing the regions and selecting each region’s probability based on its fitness value. The fitness function and roulette wheel method are introduced for region selection. Subtarget points of the DWA algorithm are extracted from the IRRT* algorithm to achieve real-time dynamic path planning.FindingsIn various maps, the iteration count for the IRRT* algorithm decreased by 61%, 35% and 51% respectively, compared to the RRT* algorithm, whereas the iteration time was reduced by 75%, 34% and 57%, respectively. In addition, the IRRT*-DWA algorithm can successfully navigate through multiple dynamic obstacles, and the average time, path length, etc. do not change much when parameters change, and the stability is high.Originality/valueA novel IRRT*-DWA algorithm is proposed, which, by refining the sampling strategy and updating sub-target points in real time, not only addresses the limitations of existing algorithms in terms of path planning efficiency in complex environments but also enhances their capability to avoid dynamic obstacles. Ultimately, experimental results indicate a high level of similarity between the actual and ideal paths.