# Optimization Algorithm for 3D Smooth Path of Robotic Arm in Dynamic Obstacle Environments
## 3 Method Description
### Dynamic Path Planning Module
This study introduces obstacle tracking and detection, local path replanning methods, and the design of weight functions in sequence. During task execution, the robotic arm moves along the initial path to avoid static obstacles. However, if dynamic obstacles appear near the initial path, the path must be modified to avoid them. In this work, only the dangerous regions of the initial path are replanned, while other parts of the static obstacle remain unchanged. For the dangerous regions of the initial path, a new local path is planned using the local starting and target points of the danger zone. This local path avoids both dynamic and static obstacles. By merging the new local path with the initial static path, a new global path is obtained, successfully avoiding both static and dynamic obstacles. Design of Protection Zones for Obstacle Nodes: A protection zone is created around the point cloud of dynamic obstacles, defined as a sphere with a radius of \(r\). If a node on the path enters this protection zone, the obstacle node that necessitates replanning is identified. The nodes before and after this local path segment are defined as the start node \(Q_{\text{start}}\) and the end node \(Q_{\text{end}}\) for local path replanning. Considering that the dynamic obstacle closest to the initial node is most likely to conflict with the initial path, to reduce computational complexity, only the point cloud of this obstacle node will have a protection zone created around it. As shown in Figure 5, the design for detecting the initial path and obstacle protection zones is illustrated. Figure 6 demonstrates the process of local path replanning. This algorithm examines the nodes in the initial path from the current target node to the last node, reducing the computational load as the robot approaches the target. When the distance between a node and a dynamic obstacle is less than the radius \(r\) of the protection zone sphere, the node is considered to have entered the protection zone, and the previous node is designated as \(Q_{\text{start}}\). Conversely, if the distance between a node and a dynamic obstacle is greater than \(r\), the node is considered to be outside the protection zone and is designated as \(Q_{\text{end}}\). Design of Local Path Replanning for Dynamic Obstacles: As shown in Figure 6, local path replanning is an online replanning process for the area between \(Q_{\text{start}}\) and \(Q_{\text{end}}\). Therefore, local replanning must be fast and convergent to allow the robotic arm to avoid obstacles in real-time. This section proposes a local path replanning method combining artificial potential fields (APF) and rapidly exploring random tree (RRT), as illustrated in Figure 7. In this figure, \(Q\) represents a node in the RRT search tree, and \(P\) is a point in Cartesian coordinates. The distance vector \(\vec{d}(P^{\prime},P)\) is defined as shown in Equation (4). \[\vec{d}(P^{\prime},P)= \begin{bmatrix}d_{x}&d_{y}&d_{z}\end{bmatrix} ^{\intercal}, \begin{cases}d_{x}=P^{\prime}_{x}-P_{x},\\ d_{y}=P^{\prime}_{y}-P_{y},\\ d_{z}=P^{\prime}_{z}-P_{z}.\end{cases}  \tag{4}\]  
Figure 5: Initial path and obstacle protection zone detection. Figure 6: Local path replanning effect. Figure 7: Local path replanning method. Local path replanning utilizes artificial potential fields (APF) to guide the rapidly exploring random tree (RRT) search tree, ensuring stable convergence in path planning. This results in shorter avoidance paths and reduces planning time. For the original RRT method, a new node is created as shown in the following equation, where \(\vec{d}_{\text{rand}}\) represents the distance vector \(\vec{d}(Q_{\text{rand}},Q_{\text{near}})\). \(Q_{\text{rand}}\) and \(Q_{\text{near}}\) represent the randomly selected path node and the nearest node to the random point, respectively, while \(Q_{\text{new}}\) is the newly generated path node, as shown in Equation (5).