## 3 Offline Optimization and Adaptation Under Nonlinear Task Constraints
### Optimization and Adaptation Procedure
#### 3.3.2 Adaptation Procedure
Considering \(\mathbf{J}\) is not a square matrix, given the expected end-effector velocity \(\mathbf{x}_{v}\), the joint velocity \(\mathbf{q}_{v}\) is derived by:

\[\dot{\xi}_{\text{all}}=\sum_{k=1}^{O}\exp\left(-\frac{1}{\rho_{k}}(\Gamma(\xi_{k })-1)\right)\mathbf{w}_{k}(\xi_{k})\Big{(}\dot{\xi}_{k}^{L}+\dot{\xi}_{k}^{R}\times \big{(}\dot{\xi}_{k}/\eta_{k}\big{)}\Big{)} \tag{45}\]2where \(\mathbf{J^{\#}}\) is the generalized inverse and \(\mathbf{N}\) is the null space matrix of \(\mathbf{J}\); that is, whatever the value of the 7-dimensional joint velocity vector \(\delta_{v}\), the resulted end-effector velocity \(N\delta_{v}\) remains 0. To derive \(\mathbf{J^{\#}}\), we minimize the norm error between \(\mathbf{J^{\#}x_{v}}\) and \(\mathbf{q_{v}}\) with the least square solution \(\mathbf{J}^{+}=\mathbf{J}^{T}\left(\mathbf{J}\mathbf{J}^{T}\right)^{-1}\) satisfying the Moor-Penrose inverse [45]. We rewrite Equation (54) with \(\mathbf{J}^{+}\) as follows:

\[\dot{\xi}_{\text{all}}=\sum_{k=1}^{O}\exp\left(-\frac{1}{\rho_{k}}(\Gamma(\xi_{k })-1)\right)\mathbf{w}_{k}(\xi_{k})\Big{(}\dot{\xi}_{k}^{L}+\dot{\xi}_{k}^{R}\times \big{(}\dot{\xi}_{k}/\eta_{k}\big{)}\Big{)} \tag{45}\]3

The term \(\left(\mathbf{I}-\mathbf{J}^{+}\mathbf{I}\right)\delta_{v}\) provides distinct joint velocity configurations resulting in the same end-effector velocity. Considering multiple solutions for the joint velocity vector \(\delta_{v}\) in Equation (54), we aim to ensure that \(\delta_{v}\) retains the joint velocity distributions of the 7 DoF ProMPs during offline optimization while minimizing the norm error between \(\mathbf{J^{\#}x_{v}}\) and \(\mathbf{q_{v}}\) in Equation (54). This allows us to integrate offline task-constrained optimization and real-time movement adaptation for robot whole-body control with Joint ProMPs. To derive the joint velocity distributions, at the current time step \(t\), the mean \(\mathbf{\mu_{q_{v}}}^{t}\) and standard deviation \(\mathbf{\sigma_{q_{v}}}^{t}\)of the joint velocities are computed based on the joint positions and are expressed in the form of ProMPs basis functions as follows:

\[ \begin{split}\mathbf{\mu_{q_{v}}}^{t}=\frac{1}{dt}*\left(\mathbf{\mu_{q}} ^{t+1}-\mathbf{\mu_{q}}^{t}\right)\\ \mathbf{\sigma_{q_{v}}}^{t}=\frac{1}{dt^{2}}*\left(\mathbf{\sigma_{q}}^{t+ 1}+\mathbf{\sigma_{q}}^{t}\right)\end{split}  \tag{56}\]

where

\[ \begin{split}\mathbf{\mu_{q}}^{t+1}=\mathbf{\
abla}_{t+1}^{T}\mathbf{\mu_{v} }^{*}\cdot\mathbf{\mu_{q}}^{t}=\mathbf{\
abla}_{t}^{T}\mathbf{\mu_{w}}^{*}\\ \mathbf{\sigma_{q}}^{t+1}=\mathbf{\
abla}_{t+1}^{T}\mathbf{\Sigma_{w}}^{*}, \mathbf{\sigma_{q}}^{t}=\mathbf{\
abla}_{t}^{T}\mathbf{\Sigma_{w}}^{*}\end{split}  \tag{57}\]

where \(\left(\mathbf{\mu_{q}}^{t},\mathbf{\sigma_{q}}^{t}\right)\) represents the optimized mean and standard deviation of the joint positions with \(\left(\mathbf{\mu_{w}}^{*},\mathbf{\Sigma_{w}}^{*}\right)\) denoting the optimized mean and covariance matrix of the 7 DoF Joint ProMPs. To simplify the notation, we omit the superscript \({}^{t}\). Given that the modulation is performed at each timestep, the mean and standard deviation of the joint velocities at each timestep are expressed with \(\mathbf{\mu_{q_{v}}}\) and \(\mathbf{\sigma_{q_{v}}}\).