# Research on the Path Planning Algorithm of a Manipulator Based on GMM/GMR-MPRM
## 3 GMM/GMR Module  
The GMM/GMR module is used to generate the sampling space based on the teaching data. Figure 2 gives the flowchart for generating the sampling space based on the GMM/GMR algorithm. First, according to the teaching path data, the GMM algorithm is used to obtain the Gaussian conditional distribution of the data of the teaching path, and then, the GMR algorithm is used to generate the task path and sampling space.  
Usually, the dataset of the teaching path consists of \(N\) teaching paths, so it can be represented by \(x=\{x^{i}\},i=1,2,\ldots,N\), where \(x^{i}=\{x_{j}^{i}\},j=1,2,\ldots,M\) is one-time teaching path data. The teaching trajectory data are a sequence of random variables that obey the multivariate normal distribution. The GMM of the teaching data can be expressed as:  
\[P(x|\theta)=\sum_{k=1}^{K}\alpha_{k}\phi(x|\theta_{k}) \tag{1}\]  
Figure 1: The GMM/GMR-MPRM path planning framework.  
Figure 2: The GMM/GMR-MPRM path planning framework.  
where \(\alpha_{k}\) stands for the coefficient of the \(k\)-th Gaussian component and \(\alpha_{k}\geq 0\), \(\sum\limits_{k=1}^{K}\alpha_{k}=1\), \(\phi(x|\theta_{k})\) stands for the distribution density of the \(k\)-th Gaussian component of dimensionality \(D\), which can be defined as:  
\[\phi(x|\theta_{k})=\frac{1}{\sqrt{2\pi^{D}|\Sigma_{k}|}}e^{-\frac{1}{2}\left( (x-\mu_{k})^{T}\Sigma_{k}^{-1}(x-\mu_{k})\right)} \tag{2}\]  
where \(\theta_{k}=(\mu_{k},\Sigma_{k})\), \(\mu_{k}\), and \(\Sigma_{k}\) stand for the mean and variance of the \(k\)-th Gaussian component, respectively, and \(\Sigma_{k}\) can be expressed as:  
\[\Sigma_{k}=\left[\begin{array}{cc}\Sigma_{k}^{TT}&\Sigma_{k}^{TS}\\ \Sigma_{k}^{ST}&\Sigma_{k}^{SS}\end{array}\right] \tag{3}\]  
The parameters of the GMM are solved using the EM algorithm. The solution steps are as follows: Firstly, the \(k\)-means clustering algorithm is used to obtain the initial estimated value of the EM algorithm to prevent the solution from falling into the local minima; secondly, the GMM infinitely approaches the optimal solution through the iteration of the E steps and M steps; finally, the parameters of the GMM that meet the requirements are obtained.  
After using the GMM to obtain the distribution of the teaching trajectory, the GMR algorithm is used for regression to obtain a continuous path, and the path contains the mean and the covariance of each point on the path. Using time series as the index variables, the corresponding space vector is:  
\[s=\arg\max p(s|t) \tag{4}\]  
For a GMM \(\theta_{k}=(\mu_{k},\Sigma_{k})\), the GMM is transformed into a continuous model by varying \(t\), according to the linear transformation properties of the Gaussian distribution, that is:  
\[P(s|t,k)\sim\mathcal{N}\Big{(}s;\hat{\mu}_{k}^{S},\hat{\Sigma}_{k}^{SS}\Big{)} \tag{5}\]  
where,  
\[\hat{\mu}_{k}^{S}=\mu_{k}^{S}+\Sigma_{k}^{ST}\big{(}\Sigma_{k}^{TT}\big{)}^{- 1}\big{(}t-\mu_{k}^{T}\big{)}\]  
\[\hat{\Sigma}_{k}^{SS}=\Sigma_{k}^{SS}-\Sigma_{k}^{ST}\big{(}\Sigma_{k}^{TT} \big{)}^{-1}\Sigma_{k}^{TS}\]  
For the totality component, the expected distribution is:  
\[p(s|t)=\sum\limits_{k=1}^{K}\beta_{k}\mathcal{N}\Big{(}s;\hat{\mu}_{k}^{S}, \hat{\Sigma}_{k}^{SS}\Big{)} \tag{7}\]  
where \(\beta_{k}\) is the prior probability of each component and can be expressed as:  
\[\beta_{k}=\frac{p(k)p(t|k)}{\sum\
olimits_{i=1}^{K}p(i)p(t|i)} \tag{8}\]  
For the \(k\)-th component, the mean and covariance matrices of each time point can be computed as:  
\[\mu=\sum\limits_{k=1}^{K}\beta_{k}\hat{\mu}_{k}^{S} \tag{9}\]  
\[\Sigma=\sum\limits_{k=1}^{K}\beta_{k}^{2}\hat{\Sigma}_{k}^{SS} \tag{10}\]  
Then, a continuous trajectory \(\Gamma=\{t,s\}\) can be generalized by calculating \(\{\mu,\Sigma\}\). The feasible space of the trajectory is used as the sampling space of the MPRM algorithm.