# Kinematic Modeling of a Trepanation Surgical Robot System
## 2 Methods
### Inverse Kinematics  
In this section, the procedure for solving the inverse kinematics problem of the trepenation robot system is explained. In solving the inverse kinematics problem, we must find the values for joint displacements \(q_{1-4}\) when given the desired pose of the end-effector \(\frac{A}{E}T\)  
Figure 2: A view of the concept of the use of the trepenation robot with surgical table and patient. Since the kinematic chain construction limits the available degrees of freedom, we need to find the IK function of the following form:  
\[ \begin{bmatrix}q_{1}\\ q_{2}\\ q_{3}\\ q_{4}\end{bmatrix} =IK(^{A}x,^{A}z,^{A}r_{x},^{A}r_{y}) \tag{1}\]  
where \(x\) and \(z\) are the end-effector coordinates and \(r_{x}\) and \(r_{y}\) are the orientation, both expressed in the base \(\{A\}\) frame of reference. Since the proposed trepanation robot system consists of a parallel tripod mechanism attached in a series to a revolving frame, it is convenient to solve separately the inverse kinematics problem of the revolving frame and of the tripod effector. Let us first investigate the former. The diagram of the frame and effector chain is shown in Figure 3. In the diagram, the base frame of reference is denoted as \(\{A\}\), the tripod base frame is \(\{B\}\), the tripod platform frame is \(\{C\}\), and the end-effector frame is \(\{E\}\). We are therefore aiming to calculate the joint displacements \(q_{1-4}\) according to the desired end-effector transform \({}^{A}_{E}T\). In order to find the joint displacements, let us first find the position of point \(C_{1}\) in the \(\{A\}\) frame of reference:  
\[^{A}C_{1}={}^{A}_{C}T\cdot{}^{C}C_{1}={}^{A}_{E}T\cdot{}^{C}_{E}T^{-1}\cdot{}^ {C}C_{1} \tag{2}\]  
where \({}^{C}_{E}T\) denotes a transform between the tripod platform and the end-effector that is known and constant. From the \({}^{A}C_{1}\) coordinates, we can calculate the angle \(\alpha\):  
\[\alpha=\tan^{-1}\frac{{}^{A}x_{C1}}{{}^{A}z_{C1}} \tag{3}\]  
We can also now find the angle \(\gamma\):  
\[\gamma=\alpha-\beta=\alpha-\tan^{-1}\frac{d}{r_{d}} \tag{4}\]  
The coordinates of the point \(F\) are therefore:  
\[^{A}F=[R\sin\gamma,0,R\cos\gamma,1]^{T} \tag{5}\]  
Figure 3: Diagram of the frame kinematics. The base frame is \(\{A\}\) and the end-effector frame is \(\{E\}\). and the joint displacement \(q_{4}\) can be calculated as the distance between points \(F\) and \(G\):  
\[q_{4}=\sqrt{(R\sin\gamma+L)^{2}+(R\cos\gamma-h)^{2}} \tag{6}\]  
In order to find the joint displacements \(q_{1-3}\) we first need to establish the transform \(\frac{\beta}{C}T\) between the tripod base and the tripod platform. This can be found as:  
\[\frac{\beta}{C}T=\frac{A}{B}T^{-1}\cdot\frac{A}{E}T\cdot\frac{C}{E}T^{-1} \tag{7}\]  
In the equation above, \(\frac{A}{E}T\) is given and \(\frac{C}{E}T\) is known. \(\frac{A}{B}T\) can be found in the following way. The transform between any two frames \(\{1\}\) and \(\{2\}\) can be described using a translation vector and the orientation expressed in EAA (equivalent axis-angle) notation as:  
\[\frac{1}{2}T=\text{Trans}(x,y,z)\cdot\text{Rot}([k_{x},k_{y},k_{z}],\theta) \tag{8}\]  
where the \(\text{Rot}([k_{x},k_{y},k_{z}],\theta)\) is:  
\[\text{Rot}(k,\theta)= \begin{bmatrix}c\theta+k_{x}^{2}t&k_{x}k_{y}t-k_{x}s \theta&k_{x}k_{z}t+k_{y}s\theta&0\\ k_{x}k_{y}t+k_{z}s\theta&c\theta+k_{y}^{2}t&k_{y}k_{z}t-k_{x}s\theta&0\\ k_{x}k_{z}t-k_{y}s\theta&k_{y}k_{z}t+k_{x}s\theta&c\theta+k_{z}^{2}t&0\\ 0&0&0&1\end{bmatrix}  \tag{9}\]  
with \(c\theta=cos(\theta)\), \(s\theta=sin(\theta)\) and \(t=1-cos(\theta)\) and \(\text{Trans}(x,y,z)\) is:  
\[\text{Trans}(x,y,z)= \begin{bmatrix}1&0&0&x\\ 0&1&0&y\\ 0&0&1&z\\ 0&0&0&1\end{bmatrix}