## 3 Offline Optimization and Adaptation Under Nonlinear Task Constraints
### Optimization and Adaptation Procedure
#### 3.3.2 Adaptation Procedure
We further obtain collision-free joint sets with Jacobian IK and set 35 basis functions to encode the 7 DoF joint distributions with ProMPs, as shown in Figure 6c. The task constraints include several critical factors: (1) Joint Range Limit: Ensures each joint operates within its specified range to prevent mechanical damage or errors expressed as follows: \(\mathbf{q}_{k,t}^{\min}<\mathbf{q}_{t}<\mathbf{q}_{k,t}^{\max}\), where \(k\) denotes the \(k\)th joint freedom, and \(\mathbf{q}_{k,t}^{\min}\) and \(\mathbf{q}_{k,t}^{\max}\) are the minimum and maximum of the joint positions from demonstration, respectively. (2) Waypoint Constraints: Guarantee precise start and end positions in task space. The forward kinematics (FK) function \(T\) maps joint configurations to end-effector positions, with a precision requirement of 1 mm: \(|T(\mathbf{q}_{1})-\overline{\mathbf{X}}_{1}|^{2}\leqslant 1,|T(\mathbf{q}_{30})- \overline{\mathbf{X}}_{30}|^{2}\leqslant 1\), where \(\overline{\mathbf{X}}_{1},\overline{\mathbf{X}}_{30}\) are the desired end-effector positions. (3) Hyperplane Constraints: Define spatial boundaries for the robot motion. For instance, the Z-direction not up to 575 mm is constrained by the following: \(\mathbf{n}_{z,t}^{\text{T}}(T(\mathbf{q}_{t})-\mathbf{b}_{z,t})\leqslant 0\), where \(\mathbf{n}_{z,t}=(0,0,-1),\mathbf{b}_{z,t}=(0,0,575)\). Similarly, all constraints of Y and Z are defined as \(100<Y<700,10<Z<575\). (4) Repeller Constraints: Prevent collisions between robot links 1 to 6 and obstacles. For example, a safe radius \(R_{\text{safe}}=36.23\) mm is enforced to avoid contact with a water bottle for the robot link 6: \(R_{\text{safe}}-d_{\min}\big{(}T^{6}(\mathbf{q}_{t})\big{)}\leqslant 0\), where \(d_{\min}\big{(}T^{6}(\mathbf{q}_{t})\big{)}\) denotes the minimum distance between the robot link 6 and obstacles, and \(T^{6}(\mathbf{q}_{t})\) represents the FK function of the robot link 6. For all constraints, we set \(\alpha_{k,t}=0.95\), considering the Gaussian nature of \(2\times\) standard deviation. To speed up convergence, we set \(\lambda_{k,t}^{0}=100\) for LBFGS and check the convergence conditions after each iteration. We determine the feature timesteps violating task constraints and merely optimize those timesteps. In this experiment, we discover that there are no task constraint violations for all timesteps of each skill; that is, the optimized ProMPs are the same as the initial ProMPs. The robot thus directly utilizes the generalized trajectory for task execution. During task execution, the robot selects randomly from three skills with via-points sampled from the original via-points range. We repeat 100 experiments with the robot task execution snapshots, as shown in Figure 6d. We run the offline movement adaptation algorithm for three skills parallelly. The total time is 1.64332 s with a 100% task success rate. The results demonstrate that the robot can generalize smooth trajectories and encode continuous ProMPs distributions with discrete feature via-points. During task execution, the robot exhibits flexibility with different skills to avoid obstacles. During the above experiment, for all timesteps, we discover that the probability satisfying the task constraints always equals 1. The reason is that the waypoint constraints are ensured by template trajectory generalization with the same start and end point; the hyperplane constraints, namely, the limit Y and Z constraints for the end-effector, are ensured by the feature via-points range for trajectory generalization; the repellers constraints for robot link6 to link1 are fulfilled with the bottle height, that is, the robot link6 to link1 will not collide at all timesteps. Meanwhile, for the above and left skills, if we generalize the collision-free end-effector trajectory sets, the robot link6 to link1 will not collide given the robot configuration.