# Algorithmic Modified Denavit-Hartenberg Modeling for Robotic Manipulators Using Line Geometry
## 4 Algorithmic MDH Parameter Extraction  
This section describes how to algorithmically extract MDH parameters using the line geometry blocks suggested in the previous Section 3.5. This method can be directly applied to the single-branched articulated robotic manipulators. To extract a set of four MDHparameters for each joint, three consecutive lines (joint axes) are needed. Thus, \(N+2\) line information is required with respect to the base frame \(\{0\}\) including tcf denoted by \(\{N+1\}\) for \(N\)-joint manipulators. Three coordinate axes of the base frame are defined by \(\hat{x}_{0}=[1,0,0]^{T}\), \(\hat{y}_{0}=[0,1,0]^{T}\) and \(\hat{z}_{0}=[0,0,1]^{T}\), respectively. Algorithm 1 summarizes the inputs and the outputs through the computations of intermediate variables. The inputs are listed as follows:  
\[\text{base frame (line)} :\{\hat{z}_{0},p_{0}\},\hat{x}_{0},\] \[1\text{st joint (line)} :\{\hat{z}_{1},p_{1}\},\] \[\vdots\] \[N\text{th joint (line)} :\{\hat{z}_{N},p_{N}\},\] \[\text{tcf (line)} :\{\hat{z}_{N+1},p_{N+1}\},\]  
where \(p_{0}=[0,0,0]^{T}\). The adjacent two lines are applied consecutively to the line geometry blocks for \(i\)th joint as follows:  
\[\{i^{-1}\alpha_{i},\,{}^{i-1}a_{i},\,{}^{i-1}\hat{n}_{i},\,{}^{i- 1}t_{i-1},\,{}^{i-1}t_{i}\} \leftarrow\mathcal{LG}(L_{i-1},L_{i}),\] \[\{i^{i}\alpha_{i+1},\,{}^{i}a_{i+1},\,{}^{i}\hat{n}_{i+1},\,{}^{ i}t_{i},\,{}^{i}t_{i+1}\} \leftarrow\mathcal{LG}(L_{i},L_{i+1}),\]  
for \(i=1,2,\cdots,N\). To extract four MDH parameters, we need to define \(\hat{x}_{i}\)-axis to be the common perpendicular direction denoted by \({}^{i}\hat{n}_{i+1}\) as shown in Figure 1. As a special case, the common perpendicular direction is not defined in the collinear case as suggested in Equations (32a)-(32d), and thus we assign the previous \(\hat{x}_{i-1}\)-axis to \(\hat{x}_{i}\) as follows:  
\[\hat{x}_{i}=\left\{ \begin{array}{ll}\hat{x}_{i-1}&\text{if $L_{i}$ and $L_{i+1}$ is collinear}\\ i\hat{n}_{i+1}&\text{otherwise,}\end{array} \right. \tag{37}\]  
where it is noted that the origin of frame \(\{i\}\) is specified as \({}^{i}t_{i}\). Once defining \(\hat{x}_{i}\)-axis through Equation (37), the sign of link twist \(\alpha_{i}\) and link length \(a_{i}\) can be determined by using the dot-product between \(\hat{x}_{i-1}\) and \({}^{i-1}\hat{n}_{i}\). To begin with, the sign is assigned into \(+1\) when two lines are parallel. Subsequently, if \(\hat{x}_{i-1}\cdot{}^{i-1}\hat{n}_{i}>0\), then the sign will be \(+1\), and if \(\hat{x}_{i-1}\cdot{}^{i-1}\hat{n}_{i}<0\), then the sign will be \(-1\). As a summary, the sign is determined as follows:  
\[s_{ix}=\left\{ \begin{array}{ll}1&\text{if}||\hat{z}_{i-1}\times\hat{z}_{i} ||<\sin(\varepsilon_{\theta})\\ \frac{\hat{x}_{i-1}\cdot{}^{i-1}\hat{n}_{i}}{|\hat{x}_{i-1}\cdot{}^{i-1}\hat{ n}_{i}|}&\text{otherwise.}\end{array} \right. \tag{38}\]  
The sign of the joint offset angle \(\theta_{i0}\) can be also determined by using the dot-product between \(\hat{z}_{i}\) and \((\hat{x}_{i-1}\times\hat{x}_{i})\) as follows:  
\[s_{iz}=\left\{ \begin{array}{ll}1&\text{if}||\hat{x}_{i-1}\times\hat{x}_{i} ||<\sin(\varepsilon_{\theta})\\ \frac{\hat{z}_{i}\cdot(\hat{x}_{i-1}\times\hat{x}_{i})}{|\hat{z}_{i}\cdot(\hat {x}_{i-1}\times\hat{x}_{i})|}&\text{otherwise,}\end{array} \right. \tag{39}\]  
where it is noted that the sign of joint offset distance \(d_{i0}\) does not have to be considered because it is obtained already by dot-product implying the projection onto the \(\hat{z}_{i}\)-axis. Using the signs of \(s_{ix}\) (38) and \(s_{iz}\) (39), four MDH parameters are determined in the following sections. ```
0:\(\{\hat{\varepsilon}_{0},p_{0}\},\{\hat{z}_{1},p_{1}\},\cdots,\{\hat{z}_{N},p_{N}\},\{ \hat{z}_{N+1},p_{N+1}\},\hat{x}_{0}=[1,0,0]^{\mathrm{T}}\).