## Materials and Methods
### Robot Motion Control
#### 2.5.4 Manipulation  
In the manipulation state, it was assumed that the forceps tip was situated in the target area. The multi-DOF forceps and the robot arm motion were controlled simultaneously by the 7-DOF serial-link interface. To match the workspace, the reference frame of the interface \({}^{B}p_{h_{ref}}={}^{B}R^{1I}p_{h_{ref}}+{}^{B}p_{r_{ref}}\) and the target position \({}^{B}p_{t}\) were registered during the transition \(T_{3}\) by pressing the push button located at the top of the interface gripper and using the EE position as a reference \({}^{B}p_{g}={}^{B}p_{ee}\). Figure 10 depicts the block diagram of the master-slave controller achieving simultaneous control of the robot arm and the forceps tip by the serial-link interface for the manipulation state. The surgeon's hand pose \({}^{B}X_{h}=\{{}^{B}p_{h},{}^{B}R_{h}\}\) was obtained from the interface, and the robot kinematics was computed at each control cycle. The master-slave controller scaled the surgeon's hand displacement \(\Delta X_{h}\) by a factor of \(K_{s}\) and generated the desired displacement of the forceps tip pose \(\Delta X_{ee}\) with respect to the target reference. We then obtained the desired EE pose, described as:  
\[{}^{B}p_{ee}={}^{B}p_{g}+K_{s}[{}^{B}R^{I}({}^{I}p_{h}-{}^{I}p_{h_{ref}})+({}^ {B}p_{r}-{}^{B}p_{r_{ref}})] \tag{14}\]  
\[{}^{B}R_{ee}={}^{B}R^{I}({}^{I}R_{h}{}^{I}R_{h_{ref}})^{\top}{}^{B}R^{I}{}^{B} R_{g}. \tag{15}\]  
To ensure the safety of the robot motion, two active constraints were implemented: workspace boundaries (virtual walls) and a VRCM. Workspace Virtual Walls  
With the workspace virtual walls, the forceps tip workspace was constrained within a cuboid with dimensions 40 \(\times\) 25 \(\times\) 40 mm, as shown in Figure 11a. Compared to other common workspace constraints (e.g., sphere or prism), a cuboid was simple to implement for faster computation and could provide a wider workspace for a knot tying task, in which the thread must be tightened by pulling  
Figure 10: Block diagram of the master-slave controller. the end of the suture using the forceps. The desired position of the forceps tip in the target frame \({}^{G}p_{ee}={}^{G}R^{BB}p_{ee}+{}^{G}p_{b}\) was projected inside the cuboid as:  
\[ \begin{split}{}^{G}p_{ee}&={}^{G}R^{BB}p_{ee}+{}^{G}p_ {b}\end{split} =\begin{cases}\begin{split}\begin{split} \begin{split}&\begin{split}&\begin{split}  
The implementation of the VRCM was experimentally verified by a tracing task in which the forceps tip followed a trajectory defined by a circumference with a diameter of 2 cm. A magnetic motion capture (Aurora, Northern Digital Inc., Ontario, Canada) was used to track the position of a magnetic sensor placed over the forceps shaft where the VRCM was defined. We measured the RMS error between the position of the sensor and the VRCM, and we obtained a maximum RMS error of 1.59 mm and a median of 0.35 mm. Online Trajectory Generation  
The robot arm desired pose \({}^{B}X_{a}=\{{}^{B}p_{a},{}^{B}R_{a}\}\) is computed by frame transformations as:  
\[{}^{B}p_{a}={}^{B}p_{ae}-{}^{B}R^{AA}p_{ee} \tag{20}\]  
and:  
\[{}^{B}R_{a}={}^{B}R_{ae}{}^{B}R^{EE}{}^{\top}. \tag{21}\]  
A smooth Cartesian EE trajectory was generated online by using the Reflexxes Type II Motion Library [31]. This online trajectory generator (OLT) provides commands for low-level motion control in real-time with position and velocity constraints. The TRAC-IK library [32] was used to enforce minimal configuration change combining two inverse kinematics approaches, pseudo-inverse Jacobian (22) and SQP-SS (23), which can be computed within the control loop of 500 Hz as:  
\[q_{[k]}=q_{[k-1]}+J^{\dagger}p_{err} \tag{22}\]  
\[ \begin{split}\arg\min_{q\in R^{6}}p_{err}^{\top}\ p_{err}\\ s.t.\quad q\leq b_{i},\quad i=1,...,6\end{split}  \tag{23}\]  
where \(q\) represents the joint position, \(p_{err}\) the Cartesian error vector, and \(b_{i}\) the joint limits. For the transition to a halt state (\(S_{5}\)), we used the current robot pose and null velocity as a target for the OLT.