## 2 Via-Point Trajectory Generalization and Initial Distributions Encoding  
### Learning New Skills in Cartesian Space with Via-Point Trajectory Generalization  
To endow the robot with skill diversity for obstacle avoidance, the human provides three modes, namely, moving above, left, and right around the obstacle. For each mode, only one human demonstration is required, and we utilize a markerless vision capture system, the Kinect FORTH [37], to track human hand centroid movements with position and orientation sets \(\left\{x,y,z,o_{x},o_{y},o_{z},o_{w}\right\}\) recorded in \(T\) timesteps. We adopt the Moving Average Filter (MAF) to ensure smoothness and transform to the robot base frame via hand-eye calibration. To learn skills denoted as positions and quaternions in Cartesian space, we express the demonstration trajectory as an integration of linear elementary trajectory \(h\) and nonlinear shape modulation \(f\), and the schematic diagram of the proposed via-point trajectory generalization is shown in Figure 1.  
For 3D positions, where each degree of freedom (DOF) is independent, we derive position sets \(\mathbf{p}\) with \(T\) timesteps in one DOF as follows:  
\[y(\mathbf{p})=h(\mathbf{p})+f(\mathbf{p}) \tag{1}\]  
The elementary trajectory \(h(\mathbf{p})\) is a line directly connecting the start point \(p_{1}\) and the end point \(p_{\text{end}}\), with the shape modulation \(f(\mathbf{p})\) defined as follows:  
\[f(\mathbf{p})=\mathbf{p}-\left(p_{1}+r\overline{p_{1}p_{\text{end}}}\right) \tag{2}\]  
Figure 1: The proposed via-point trajectory generalization schematic. (**a**) 3D via-point generalization with obstacles. \(\mathbf{p}\) and \(\mathbf{p}_{\text{new}}\) represent \(x,y\), and \(z\) values over \(T\) time steps, with one via-point shown as an example. The blue cylinder denotes the obstacle, and the new via-point can be selected from above, left, or right of the obstacle for safe avoidance. (**b**) Orientation generalization using SLERP. At new orientations \(\mathbf{o}_{1}\)new and \(\mathbf{o}_{1}\)end, the orientation is generalized based on the quaternion multiplication of \(h(\mathbf{o})\)new and \(f(\mathbf{o}_{1}),f(\mathbf{o}_{\text{end}})\). where \(r\) is the scale factor denoting the proportion of projective points on the line \(h(\mathbf{p})\),  
\[r=\frac{\overrightarrow{p_{1}}\overrightarrow{p_{1}p_{\text{end}}}}{p_{1}p_{ \text{end}}\cdot\overrightarrow{p_{1}p_{\text{end}}}} \tag{3}\]  
If no intermediate via-points are required to generalize, we directly generate new projective points between the new start point \(p_{1}^{\text{new}}\) and end point \(p_{\text{end}}^{\text{new}}\) according to \(r\), and add learned shape modulation \(f(\mathbf{p})\) to generalize new trajectory sets \(\mathbf{p}^{\text{new}}\):  
\[\mathbf{p}^{\text{new}}=p_{1}^{\text{new}}+r\overline{p_{1}^{\text{new}}p_{\text{ end}}^{\text{new}}}+f(\mathbf{p}) \tag{4}\]  
Once a via-point \((t_{\text{via}},p_{\text{via}})\) is needed, we scale the shape modulation with the coefficient \(k\):  
\[k=\Big{|}p_{\text{via}}-\Big{(}p_{1}^{\text{new}}+r\overline{p_{1}^{\text{ new}}p_{\text{end}}^{\text{new}}}\Big{)}\Big{|}|f(\mathbf{p})|^{-1} \tag{5}\]  
Subsequently, new trajectory sets \(\mathbf{p}^{\text{new}}\) are generalized upon:  
\[\mathbf{p}^{\text{new}}=p_{1}^{\text{new}}+r\overline{p_{1}^{\text{new}}p_{\text{ end}}^{\text{new}}}+kf(\mathbf{p}) \tag{6}\]  
For quaternion sets, considering dimensions are affected by each other in orientation, we define the trajectory with:  
\[y(\mathbf{o})=h(\mathbf{o})\times f(\mathbf{o}) \tag{7}\]  
where \(\mathbf{o}=\big{[}\mathbf{o}_{\text{w}},\mathbf{o}_{\text{x}},\mathbf{o}_{\text{y}},\mathbf{o}_{ \text{z}}\big{]}\) represents the quaternion sets, and \(\times\) denotes quaternion multiplication.