## 3 Offline Optimization and Adaptation Under Nonlinear Task Constraints
### Optimization and Adaptation Procedure
#### 3.3.2 Adaptation Procedure
Given the normal vector \(\mathbf{n}(\mathbf{\dot{\xi}}_{1}),\mathbf{n}(\mathbf{\dot{\xi}}_{2})\), we iteratively compute the modulation matrix \(\mathbf{M}(\mathbf{\dot{\xi}}_{1}),\mathbf{M}(\mathbf{\dot{\xi}}_{2})\) for each obstacle and derive the weighted magnitude \(\|\mathbf{Q}(\mathbf{\dot{\xi}})\|_{\text{all}}\) and direction \(\mathbf{q}(\mathbf{\dot{\xi}})\|_{\text{all}}\) from Equations (47)-(52) to obtain the modulated velocity \(\mathbf{\dot{\xi}}_{\text{mod}}\) until safe. New trajectory sets \(\left\{\mathbf{\dot{\xi}}_{\text{next}}\right\}\) are generalized and the next velocity \(\mathbf{\dot{\xi}}_{\text{next}}\) is computed. Note that if the emergency stop position changes, the robot can adapt in real-time with our trajectory generalization method. Figure 8b shows robot dynamic modulation snapshots with multiple dynamic obstacles and changing targets (the emergency stop). The total running time is 16.8 s with 84 timesteps, and the average modulation time for a single timestep is 0.1356 s. The results indicate that the robot exhibits real-time adaptation proficiency under dynamic environments. For the above end-effector modulation experiments, considering the minimum distances between the robot non-end-effector and obstacles are always larger than the safety margin \(\mathbf{d}_{m}=10\) mm, the non-end-effector adaptation proposed in Section 4.2 is not involved. Consequently, to further verify the mutual performance of end-effector and non-end-effector adaptation, we elevate the obstacle height and design a task scenario where the robot non-end-effector will collide with the big bottle at the beginning of task execution (see the first row of Figure 9a), and after the robot moves around, the human places the big bottle to a new position where the robot non-end-effector will collide when it tends to grasp the emergency stop (see the last row of Figure 9a). The robot selects the move above skill to generate the initial task trajectory; the typical modulation process is shown in Figure 9a with task execution snapshots shown in Figure 9b. The left, middle, and right columns in Figure 9a denote the initial joint configurations, the modulation process, and the modulated joint configurations, respectively. To achieve real-time efficiency, we utilize cylinders to envelop obstacles and robot links with minimum distance detected by the Flexible Collision Library (FCL). To balance offline-optimized Joint ProMPs and null-velocity control, we set \(\lambda=1,\gamma=0.2,\rho=0.8\) to formulate Equation (65), and we set \(\mathbf{d}_{m}=10,\mathbf{d}_{n}=5,v_{n}=10\) mm/s to formulate Equation (66). The first row illustrates the robot whole-body modulation at the beginning. Given the distance function \(\Gamma_{1}(\xi_{1})=1.7806,\Gamma_{2}(\xi_{2})=8.9839>4\), the robot is modulated under the big bottle normal vector \(\mathbf{n}(\xi_{1})\) with the expected end-effector modulated velocity \(\dot{\mathbf{\xi}}_{\text{mod}}\). We detect the collision at the current position. To ensure impenetrability of the obstacles, we set \(\|\mathbf{d}_{0}\|=0.01\) mm and iteratively apply null-space velocity control until safe. To be specific, we treat the robot collision link center as the control point \(C_{0}\) and derive the Jacobian matrix \(\mathbf{J}_{0}\) at \(C_{0}\). We compute the retreat velocity \(v_{0}\) from Equation (66) and obtain the enforced velocity \(\mathbf{x}_{v}^{0}\). We then utilize the control loop defined in Equation (69) to derive the modulated joint configuration \(\mathbf{q}_{\text{mod}}\) iteratively. Note that if the modulated joint configurations will collide, we increase the magnitude order of \(v_{0}\) until safe. The middle column shows the initial and modulated joint configurations colored in purple and green,

Figure 9: Robot whole-body online movement adaptation experiments. (**a**) Typical modulation cases for specific timesteps. The left, middle, and right columns denote the robot init joint configurations, modulation process, and modulated joint configurations.