# Optimization Algorithm for 3D Smooth Path of Robotic Arm in Dynamic Obstacle Environments
## 3 Method Description
### Dynamic Path Planning Module  
In the problem analysis, it is mentioned that to avoid obstacles in complex states, using only the APF (artificial potential field) or RRT (rapidly exploring random tree) trajectory planning method is insufficient to cope with complex dynamic environments. Trajectory planning must dynamically change its strategy by combining APF and RRT. When dynamic obstacles threaten the static initial path of the cooperative robot, how to efficiently replan a collision-free path deserves urgent attention. By appropriately strengthening or weakening the APF component in RRT-based replanning, an optimized path can be efficiently generated in dynamic environments. Therefore, this paper uses an RGB-D camera to track static and dynamic obstacles in the environment, enabling real-time recognition of obstacles in the current environment and dynamic adjustment of the planned path. When dynamic obstacles endanger the initial path, a safe path is replanned using a hybrid approach that combines APF and RRT, with a recursive replanning method and dynamic adjustment of the ratio between APF and RRT to optimize the replanning process. The point cloud information of dynamic obstacles is obtained by subtracting the online image from the offline background, which can be divided into two steps. The first is to obtain the offline background: during the offline stage, the depth image of the workspace without dynamic objects is recorded as a background reference. The second is background subtraction: during online task execution, the current depth image is obtained and subtracted from the background image to highlight moving objects, thereby obtaining the point cloud of dynamic obstacles. After obtaining the point cloud information of dynamic obstacles, the URDF filter is further used to filter out the interference information of the robotic arm itself in the image information, ensuring that only the point cloud of the dynamic obstacles themselves is retained. Then, a k-d tree is used to classify and track different dynamic obstacles. The k-d tree is commonly used for rapid search and classification of point cloud data, which can significantly accelerate the process of finding the nearest neighbor points or regions in three-dimensional space. It completes the work through the following steps. Figure 4: Comparison between interpolated original path and Catmull–Rom interpolated path. Construct the k-d tree: Organize the point cloud data of dynamic obstacles into a k-d tree structure, dividing the dataset of each layer of nodes into two subsets according to the median value. Classify and track: When new point cloud data of dynamic obstacles is obtained, the constructed k-d tree is used for classification to quickly find points belonging to a certain dynamic obstacle. Then, the positions and changes of different dynamic obstacles are identified and tracked through the differences between the point clouds of consecutive frames. Update dynamic obstacle information: After searching and classifying with the k-d tree, the position, size, and shape of the obstacles are updated, and the motion trend of dynamic obstacles is predicted using a Kalman filter [43]. The specific process is as follows: First, the initial motion path of the robotic arm is generated using the random tree-guided path source update algorithm. This initial path is executable after being refined through sharp corner trimming and path smoothing. Then, the obstacle tracking module employs an RGB-D camera to track point clouds of static and dynamic obstacles, thus acquiring their positional information. The local path replanning module examines the distance between dynamic obstacles and the initial path. If the distance is too small, the dangerous nodes in the initial path are identified, and a new local path is planned online to avoid obstacles in real time. Subsequently, it determines whether the robotic arm continues along the newly planned local path or returns to the initial static path.