## 3 Offline Optimization and Adaptation Under Nonlinear Task Constraints
### Optimization and Adaptation Procedure
#### 3.3.2 Adaptation Procedure
We discover that the modulation remains consistent for both methods if the init 3D positions before modulation will not collide with the obstacle. However, if the collision occurs for the init positions (see Figure 10b,c),SEDS-GMR modulation will not ensure the process is collision-free despite the modulation matrix influence. In contrast, our method iteratively performs modulation until collision-free; that is, if the modulated positions will collide, we treat them as init positions and modulate them until safe. Note that our method may fail in specific danger cases: if the robot iterates many times for modulation, during the motion process from the current position to the modulated position, collision will occur. However, in most cases, our method ensures a high success rate. Table 3 shows several benchmarks for both methods. Our method exhibits a higher success rate. In addition, since SEDS-GMR modulation requires obtaining precise GMM parameters before task execution, the offline training time is longer. Our method generalizes the trajectories in real-time without training parameters (see Section 2.1) and computes the velocities via position differencing. Although our method involves iterating the modulation when encountering collisions, resulting in a relatively longer time for single-step modulation, it still meets real-time requirements. Moreover, our method outperforms SEDS-GMR modulation in total task execution time, requiring fewer convergence timesteps and exhibiting a lower collision rate. The final position error effectively reflects the accuracy of the modulation in achieving the desired end-effector position while ensuring obstacle avoidance. Both methods achieve comparable final position accuracy, confirming that our approach maintains accuracy while ensuring obstacle avoidance. The results indicate that our method can complete real-time end-effector modulation while ensuring safety, and quickly generalize trajectories preserving human skill characteristics. \begin{table}
\begin{tabular}{c c c} \hline \hline  & **SEDS-GMR Modulation**[30; 31] & **Our Method** \\ \hline Task Success Rate & 73.33\% & 93.33\% \\ Offline Parameters Learning Time (s) & 24.6856 \(\pm\) 0.1546 & 0.0904 \(\pm\) 0.0148 \\ Average Real-time Modulation Time (s) & 0.1238 \(\pm\) 0.0167 & 0.1465 \(\pm\) 0.0285 \\ Total Task Execution Time (s) & 23.2 \(\pm\) 1 & 16.8 \(\pm\) 0.4 \\ Collision Rate & 26.67\% & 6.67\% \\ Final Position Error (mm) & 0.52 \(\pm\) 0.13 & 0.55 \(\pm\) 0.09 \\ Convergence TimeSteps & 116 \(\pm\) 5 & 84 \(\pm\) 2 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Robot end-effector modulation comparision. Figure 10: Robot end-effector modulation comparison between SEDS-GMR and our method. Green and purple lines denote SEDS-GMR and our method, respectively. (**a**) Modulated 3D trajectories when the robot moves right. Arrows illustrate obstacle motion trends with cylinders denoting obstacle positions at different time, for instance, the emergency stop (the red cylinder) is moved to the new position at t = 8.4 s from the init position at t = 0.2 s. (**b**) End-effector trajectories when the robot moves left. (**c**) End-effector trajectories when the robot moves above. The snapshots show collision cases for SEDS-GMR during task execution. The aforementioned comparison experiments with SEDS-GMR only consider the robot end-effector given that the other robot links will not collide during task execution. To further evaluate the robot whole-body movement adaptation performance, we conduct comparison experiments under the scene in Figure 9. We select a commonly-used trajectory planner named Covariant Hamiltonian Optimization for Motion Planning (CHOMP) which iteratively optimizes the cost function including trajectory smoothness and collision cost; meanwhile, a null space velocity control method [36] similar to ours is involved. As in Figure 9, we obtain the modulated robot end-effector trajectory with 69 timesteps.