## 3 Offline Optimization and Adaptation Under Nonlinear Task Constraints
### Optimization and Adaptation Procedure
#### 3.3.2 Adaptation Procedure
### Real-Time Whole-Body Movement Adaptation

Following offline robot movement adaptation under static scenarios, we further evaluate our real-time whole-body movement adaptation method presented in Section 4 under the dynamic environment manifested as multiple stationary or moving obstacles, new target points, etc. Specifically, we first perform Algorithm 1 with the presence of a single obstacle (blue painting) and the emergency stop. The robot then randomly selects from three skills, namely, moving above, left, and right around the obstacle to generate the initial task execution trajectory. During task execution, the human gets involved in the process by suddenly moving a big bottle towards the gripper (see Figure 8b at t = 1.8 s), changing the obstacle and emergency stop positions in real-time (see Figure 8b at t = 6 s, 7.2 s, and 10.0 s, etc.). Figure 7: Offline movement adaptation experiment under a danger scene with the elevated obstacle. (**a**) Experimental setup. (**b**) Evident collision for other robot links when generalizing collision-free end-effector trajectory with certain via-points. (**c**) Optimized ProMPs distributions under nonlinear task constraints with LBFGS and EMM. We choose typical joint 2 and 4 distributions with obvious changes, the line and shaded areas denote the original and optimized mean and standard deviations. (**d**) Threshold determination based on the relationship between via-point Z-position and obstacle avoidance result. The succeed number threshold is denoted with a blue solid circle. Blue and red areas denote success and failure results. (**e**) Generalized task execution trajectory sets with 100 discrete via-points; red and blue lines and areas denote success and failure results. (**f**) Robot task execution snapshots with the critical trajectory between success and failure. The first row and last rows show different motion views. We utilize YOLO to detect the object 3D positions and velocities at \(dt=0.2\) s intervals with an ellipsoid-shaped distance function \(\Gamma(\xi_{k})\) enveloped (see Equation (36)). We treat the emergency stop as the target object with other objects considered obstacles. To formulate \(\Gamma(\xi_{k})\), we set the curvature parameter \(p_{i}^{k}=10\) and derive the center \(\xi_{k}^{c}\), linear velocities \(\xi_{k}^{L}\), and angular velocities \(\xi_{k}^{R}\) from YOLO. We obtain the normal vector \(\mathbf{n}\big{(}\mathbf{\tilde{\xi}}_{k}\big{)}\) from Equation (39) and formulate the basis matrix \(E(\xi_{k})\) and the diagonal eigenvalue matrix \(\mathbf{D}(\xi_{k})\) from Equations (40) and (42). In this paper, we model the robot gripper with the same ellipsoid-function to derive equivalent \(\Gamma(\xi_{k})\) and \(\mathbf{n}\big{(}\mathbf{\tilde{\xi}}_{k}\big{)}\) from two ellipsoids. We set a 10 mm margin for each direction to compute the corresponding safety magnitude \(\eta_{k}\), define the reactivity parameter \(\rho_{k}=1\), and remedy the tail-effect via \(\mathbf{n}\big{(}\mathbf{\tilde{\xi}}_{k}/\eta_{k}\big{)}^{T}\mathbf{\tilde{\xi}}_{k}\) to formulate Equation (43). Meanwhile, we disregard the impact of obstacles when \(\Gamma(\xi_{k})>4.0\). Given the initial task execution trajectory as input, the robot performs whole-body adaptation for real-time modulation (see Figure 4). Concerning end-effector adaptation, we derive the modulation matrix \(\mathbf{M}(\mathbf{\tilde{\xi}}_{k})\in\mathbb{R}^{3\times 3}\) and weight coefficient \(\mathbf{w}_{k}(\mathbf{\tilde{\xi}}_{k})\) for each dynamic obstacle with weighted magnitude \(\|\mathbf{Q}\big{(}\mathbf{\tilde{\xi}}\big{)}\|_{\text{all}}\) and directions \(\mathbf{q}\big{(}\mathbf{\tilde{\xi}}\big{)}_{\text{all}}\) computed from Equations (46)-(52) to derive the modulated velocity \(\mathbf{\tilde{\xi}}_{\text{mod}}\). Regarding the non-end-effector adaptation, we detect the closest point \(C_{0}\) with \(\mathbf{x}_{v}^{0}\) defined to perform null-space velocity control (see Section 4.2). Figure 8: Robot end-effector real-time movement adaptation experiments.