## 3 Offline Optimization and Adaptation Under Nonlinear Task Constraints
### Optimization and Adaptation Procedure
#### 3.3.2 Adaptation Procedure
As a result, to testify the performance of ProMPs optimization and adaptation, we elevate the obstacle height with a danger scene (see Figure 7a) and constrain the robot to move right around the obstacle. We set the proper feature via-points range so that partial collision-free end-effector trajectory sets will clearly collide with the bottle at other robot links (see Figure 7b). We define the same task constraints mentioned above; the difference is that there are timesteps violating the repellers constraints where the robot link6 and link5 may collide. We generalize the collision-free end-effector trajectory sets with 40 discrete feature via-points by fixing the X-, Y- and descend Z-positions, and encode the original 7 DoF ProMPs distributions \(p\big{(}\mathbf{w}^{0}\big{)}=\mathcal{N}\big{(}\mathbf{w}^{0};\mathbf{\mu}^{0}_{\mathbf{w}}, \mathbf{\Sigma}^{0}_{\mathbf{w}}\big{)},p(\mathbf{q}_{t})=\mathcal{N}\big{(}\mathbf{q}_{t}; \mathbf{\mu}^{0}_{t},\mathbf{\sigma}^{0}_{t}\big{)}\). For the repellers constraints, we find the minimum distance from three segments in four directions and perform moment-based distribution estimation of the danger distance (see Section 3.2.4). Utilizing double-loop LBFGS and EMM optimization in Algorithm 1, we obtain the optimized ProMPs distributions \(p(\mathbf{w}^{*})=\mathcal{N}(\mathbf{w}^{*};\mathbf{\mu}^{*}_{\mathbf{w}^{*}},\mathbf{\Sigma}^{*} _{\mathbf{w}})\), \(p(\mathbf{q}_{t})=\mathcal{N}(\mathbf{q}_{t};\mathbf{\mu}^{*}_{t},\mathbf{\sigma}^{*}_{t})\) satisfying task constraints, as shown in Figure 6c. The joint limit range \(\mathbf{q}^{\text{safe}}_{t}\in(\mathbf{\mu}^{*}_{t}-2\mathbf{\sigma}^{*}_{t},\mathbf{\mu}^{*} _{t}+2\mathbf{\sigma}^{*}_{t})\) and initial joint value \(\mathbf{q}^{0}_{t}=\mathbf{\Upsilon}^{T}_{t}\mathbf{w}^{*}\) are passed to the Jacobian IK to test the succeed number of the feature timesteps. To determine the threshold, we select the same via-points from the original range with the succeed number and obstacle avoidance result (success or failure) recorded; the corresponding relation is shown in Figure 6d. During task execution, we choose 100 uniform via-points to testify the optimized ProMPs; that is, if the succeed IK number of the generalized trajectories is more than a threshold, the robot will run the

Figure 6: Offline movment adaptation experiment with a new big bottle. (**a**) Experimental setup. (**b**) End-effector collision-free trajectory sets for three skills with via-point trajectory generalization. (**c**) Joint ProMPs distributions given discrete collision-free joint sets (taking the move above skill as an example). Solid lines denote mean values with shaded areas denoting \(\pm\)2 standard deviations. (**d**) Robot task execution snapshots: the first, middle, and last rows denote move above, left, and right around the obstacle. trajectory, otherwise, the robot will stop until success. The task execution result is shown in Figure 7e,f. We run Algorithm 1 with a total time of 126.45 s. There are a total of 8 out of 30 timesteps violating the task constraints and the succeed number threshold is 7 given the optimized ProMPs distributions. The robot executes 39 trajectories from 100 feature via-points with a 100% success rate. The results illustrate that the robot can optimize ProMPs distributions under integrated nonlinear task constraints analytically. Considering the probability distribution essence, specific regions are excluded from the original ProMPs at the cost of losing some distributions satisfying the task constraints. Consequently, we determine the threshold with the same sparse and discrete via-points during trajectory generalization. The threshold and optimized ProMPs are then directly used for robot task execution by sampling from the continuous via-points range with Gaussian distributions. In a word, we provide a robot with the ability to perform tasks under multiple nonlinear constraints in a generic way; that is, there is no need to determine that the task constraints are satisfied each time when generalizing a new trajectory.