bilateral control of a continuum robot for targeted drug ...declaration of authorship i, omar s....

97
German university in Cairo Master Thesis Bilateral Control of a Continuum Robot for Targeted Drug Delivery Author: Omar S. Abdellatif Supervisor: Islam S. M. Khalil A thesis submitted in fulfillment of the requirements for the degree of Master in the field of Mechatronics Engineering in the Engineering Department German university in Cairo June 2015

Upload: others

Post on 11-Sep-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

German university in Cairo

Master Thesis

Bilateral Control of a Continuum Robot

for Targeted Drug Delivery

Author:

Omar S. Abdellatif

Supervisor:

Islam S. M. Khalil

A thesis submitted in fulfillment of the requirements

for the degree of Master in the field of Mechatronics Engineering

in the

Engineering Department

German university in Cairo

June 2015

Page 2: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Declaration of Authorship

I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum

robot for targeted drug delivery’ and the work presented in it are my own. I confirm

that:

This work was done wholly or mainly while in candidature for a master degree at

this University.

Where any part of this thesis has previously been submitted for a degree or any

other qualification at this University or any other institution, this has been clearly

stated.

Where I have consulted the published work of others, this is always clearly at-

tributed.

Where I have quoted from the work of others, the source is always given. With

the exception of such quotations, this thesis is entirely my own work.

I have acknowledged all main sources of help.

Where the thesis is based on work done by myself jointly with others, I have made

clear exactly what was done by others and what I have contributed myself.

Signed:

Date:

i

Page 3: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

German University In Cairo (GUC)

Abstract

Faculty of Engineer

Department of Mechatronic Engineer

Master in Mechatronics Engineer

Bilateral Control of a Continuum Robot for Targeted Drug Delivery

By Omar S. Abdellatif

Bilateral tele-operation control systems have a wide range of applications such as space

missions, deep-sea operations, and tele-surgery. These systems are developed to transmit

a tactual sense to the operator. In this study, a design of master-slave tele-operation sys-

tem is implemented for an end-effector maneuverability control. Continuum robots have

nimble nature and flexibility due to the absence of discrete joints. We develop a kine-

matical model of the continuum robot based on the constant curvature principle. This

continuum robot, which represents module 1 in a micro-robotic surgical system,consists

of a flexible backbone with four disc-shaped tendon guides that are fixed equidistantly to

each other. Four tendons (wires) actuate the continuum robot using four stepper motor.

The stepper motors pull the tendons to control the orientation of the flexible needle.

We experimentally demonstrate that the deviation between the kinematical model and

the continuum robot is 4.3 %. We also analyze the maneuverability of our robot by

performing and plotting geometrical shapes within a circular work-space of 213.8 cm2

at an average speed of 2.5 cm/s knowing that the holding torque of the stepper motors

is 4.8 kg.cm.

ii

Page 4: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Acknowledgements

I would like to express my deep gratitude to my master thesis advisor Dr. Islam S. M.

Khalil. I have learnt many things since I became Dr. Islam’s student. Spending a lot

of time directing me in our Medical Micro and Nano Robotics lab was a great push to

achieve and deliver remarkable work and results.

Special thanks to the department of Mechatronics in the German University in Cairo

which gave me the opportunity to enhance and improve my academic and personal skills

in both Bachelor and Master Degree. I am also grateful to the Engineers and technicians

at the GUC DMG and Workshop who assisted me in manufacturing my designs. Special

Thanks to Eng. Mohamed Esbitan and Eng. Ashmawy who spent a lot of time following

up the DMU machine during the manufacturing process. Thanks to all my friends and

all my colleagues who supported me through the way academically and spiritually.

Last but the most important, I owe more thanks to my family member, my parents for

their continuous spiritual and financial support, my elder brother and sisters for their

encouragement, my wife who assisted and stood behind me to finish this work, and my

parents in law who did not give up supporting and encouraging me through to way.

Without their support, it is impossible for me to finish my masters. I present the fruit

of his diligent and tolerant help to Dr. Islam S. M. Khalil.

iii

Page 5: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Contents

Declaration of Authorship i

Abstract ii

Acknowledgements iii

Contents iv

List of Figures vi

List of Tables viii

Symbols ix

1 Introduction 1

1.1 Definition and Background . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 Continuum Robots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.3 Master and Slave Manipulators . . . . . . . . . . . . . . . . . . . . . . . . 3

2 The Kinematical Model of the Continuum Robot 6

2.1 Objectives of the Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.2 Forward Kinematics of the Continuum Robot . . . . . . . . . . . . . . . . 7

2.3 Inverse Kinematics of the Continuum Robot . . . . . . . . . . . . . . . . . 13

3 Design of the Continuum Robot 15

3.1 Mechanical Design of the Continuum Robot . . . . . . . . . . . . . . . . . 16

3.1.1 Requirements of Building the Continuum Robot . . . . . . . . . . 16

3.1.1.1 Continuum Manipulator . . . . . . . . . . . . . . . . . . . 17

3.1.2 Structure of the Continuum Manipulator . . . . . . . . . . . . . . 17

3.1.2.1 Flexible Needle . . . . . . . . . . . . . . . . . . . . . . . . 17

3.1.2.2 Tendon Guides . . . . . . . . . . . . . . . . . . . . . . . . 18

3.1.3 Actuator Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

3.2 Electronic Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

3.2.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

3.2.2 Electronic Components . . . . . . . . . . . . . . . . . . . . . . . . 21

iv

Page 6: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

3.3 Control Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3.3.1 Open-Loop System . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3.3.2 Closed-Loop Control System . . . . . . . . . . . . . . . . . . . . . 23

4 Experimental Results 24

5 Conclusions 31

5.1 Future Recommendation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

Appendix A The CAD Drawings 34

A.1 The First Mechanical Design . . . . . . . . . . . . . . . . . . . . . . . . . 35

A.2 The Final Mechanical Design . . . . . . . . . . . . . . . . . . . . . . . . . 45

Appendix B Electronic Components 54

B.1 Stepper Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

B.1.1 Stepper Motor Features . . . . . . . . . . . . . . . . . . . . . . . . 55

B.2 Stepper Motor Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

B.2.1 Stepper Motor Driver Features . . . . . . . . . . . . . . . . . . . . 56

B.2.2 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

B.2.3 Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

B.3 SMPS Power Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

B.3.1 Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

B.3.1.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

B.4 Wiring System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

Appendix C Codes 65

C.1 Matlab Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

C.2 Arduino Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

C.3 Feature Tracking Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

v

Page 7: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

List of Figures

1.1 The da Vinci surgical robot features . . . . . . . . . . . . . . . . . . . . . 2

1.2 Types of continuum manipulator . . . . . . . . . . . . . . . . . . . . . . . 3

1.3 The experimental setup represents module 1 in micro-robotic surgicalsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.1 The tendon actuated continuum robot . . . . . . . . . . . . . . . . . . . . 6

2.2 The xyz-coordinate system of the continuum robot . . . . . . . . . . . . . 8

2.3 The radius of the curvature ρ and angle θ when the robot bends towardsthe negative x-axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.4 A bent division of the continuum robot . . . . . . . . . . . . . . . . . . . 9

2.5 The xy-plan of a bending continuum robot rotating with angle θ over thez-axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

3.1 The continuum robot integrates with magnetic field that control themicro-robots inside the human body . . . . . . . . . . . . . . . . . . . . . 15

3.2 The mechanical design of the continuum robot . . . . . . . . . . . . . . . 16

3.3 A segment of the continuum needle . . . . . . . . . . . . . . . . . . . . . . 19

3.4 Open-loop control diagram of the continuum robot . . . . . . . . . . . . . 22

3.5 A closed-loop control diagram of the continuum robot . . . . . . . . . . . 23

4.1 A representative open-loop control experiment of the continuum robot . . 26

4.2 A representative open-loop control experiment of the continuum robot inthe xy-plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

4.3 A representative open-loop control experiment of the continuum robotplotting a rectangular shape . . . . . . . . . . . . . . . . . . . . . . . . . . 28

4.4 A representative open-loop control experiment of the continuum robotplotting an infinity shape . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

4.5 A representative open-loop control experiment of the continuum robotperforming GUC letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

5.1 A 3D prospect of a continuum robot with more degrees of freedom . . . . 33

A.1 Tendon guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

A.2 Base plate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

A.3 Motor housing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

A.4 Carriage front face . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

A.5 All 3D printed parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

A.6 Assembled 3D printed carriage . . . . . . . . . . . . . . . . . . . . . . . . 40

A.7 3D drawing of the continuum robot . . . . . . . . . . . . . . . . . . . . . . 41

vi

Page 8: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

A.8 the expected three dimensional drawing of first prototype of the contin-uum robot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

A.9 The experimental setup of the continuum robot . . . . . . . . . . . . . . . 43

A.10 3D drawing top view of the continuum robot . . . . . . . . . . . . . . . . 43

A.11 The top view of the continuum robot . . . . . . . . . . . . . . . . . . . . . 44

A.12 Tendon guide base plate . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

A.13 First drawing of motor housing . . . . . . . . . . . . . . . . . . . . . . . . 46

A.14 Second drawing of motor housing . . . . . . . . . . . . . . . . . . . . . . . 47

A.15 Final design assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

A.16 3D drawing for the final design of continuum robot . . . . . . . . . . . . . 49

A.17 3D drawing for the final design of continuum robot . . . . . . . . . . . . . 50

A.18 The experimental setup of the continuum robot of the final design . . . . 50

A.19 Front view 3D drawing for the final design of continuum robot . . . . . . 51

A.20 The experimental setup of the continuum robot front view of the finaldesign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

A.21 3D drawing for the final design of continuum robot . . . . . . . . . . . . . 52

A.22 The experimental setup of the continuum robot of the final design . . . . 52

A.23 3D drawing for the final design of continuum robot . . . . . . . . . . . . . 53

A.24 The experimental setup of the continuum robot of the final design . . . . 53

B.1 Nema 17 stepper motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

B.2 Hybrid stepping motor modulation . . . . . . . . . . . . . . . . . . . . . . 55

B.3 Micro step driver XAL-42 . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

B.4 Connections between the Arduino and the micro-stepper driver . . . . . . 59

B.5 Power Supply (SMPS 24V-10A, Egypt, RAM electronics) . . . . . . . . . 60

B.6 Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

B.7 The wiring system and the color code of the stepper motor . . . . . . . . 63

B.8 Electric circuit of the stepper motor and the stepping driver . . . . . . . . 64

vii

Page 9: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

List of Tables

2.1 Description of the variables used in the kinematical model . . . . . . . . . 7

4.1 The comparison between the expected kinematical model and the contin-uum robot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

B.1 Electronic specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

B.2 Micro step settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

B.3 Current micro step settings . . . . . . . . . . . . . . . . . . . . . . . . . . 58

B.4 Pin assignment description . . . . . . . . . . . . . . . . . . . . . . . . . . 58

B.5 Power connector P2 pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

viii

Page 10: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Symbols

A The deflection in the plane of bending

α Angle of the circular arc described by a segment of the robot

hb Length of the backbone of the continuum robot

hc Center point distance in a segment

hi Length of the ith tendon

hlin The position of the linear stage

hy The length of the robot in the z-direction

i Number of the tendon

l Length measured from backbone to tendon guide hole

lmid protrusion radius

lo Length of the outer radius of the tendon

n Number of segments of the robot

µbase The thickness of the base plate

θ Angle at which the robot is bending in the xy-plane

θi Angle of the ith tendon hole in relation to θ

ρ Radius of the circular arc described by the robot

ρi Radius of the circular arc in relation to the ith tendon hole

Xe, Ye, Ze The coordinates of the position of the end-effector

ix

Page 11: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

This thesis work is dedicated to my Parents, Salahudin Abdellatifand Wafaa Selim, who have always loved me unconditionally andwhose good examples have taught me to work hard for the thingsthat I aspire to achieve. This work is also dedicated to my wife

MennaTullah Seraj , siblings and my parents in law who have beena constant source of support and encouragement during the

challenges I have faced during those two years. I am truly thankfulfor having you in my life.

x

Page 12: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 1

Introduction

1.1 Definition and Background

Minimally invasive surgery has been developed to decrease the scars, any marks on

the skin, and patient recovery time [1]. Natural orifice surgery is a type of minimally

invasive surgery in which the surgical instrument is inserted through an already existing

opening in the body. Natural orifice transluminal endoscopic surgery is an example of

natural orifice surgery, in which an abdominal operation is performed where the surgical

instrument is inserted through a natural orifice, such as the mouth [2]. Robots can play

an important role in performing minimally invasive surgery where they are controlled

and used by surgeon to perform operations. The da Vinci Surgical robot [3], (figure 1.1)

is an example of a commercially available robot that can be used to perform minimally

invasive surgeries. These robots are not fully autonomous yet and need to be controlled

by the surgeon. It is an advantage for the surgeon to be completely in control during

the whole operation, but it can also be considered as a disadvantage as surgeons can

make mistakes. Hence, a robot can help the surgeon to be accurate and precise during

the surgery if necessary. This robot must be accurate and precise to avoid any harm to

the patient or minimize any potential risk. Continuum robots are considered as a part

of surgical robots, their unique flexible structure makes them suitable for natural orifice

surgeries.

1

Page 13: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 1. Introduction 2

(a) The da Vinci surgical robot. (b) The surgeon manipulates the robot usinghis fingers.

Figure 1.1: The da Vinci surgical robot features a magnified three-dimensional high-definition vision system and laparoscopic instruments with greater movement capabil-ities than the human wrist would normally allow. As a result, da Vinci robot enablesthe surgeon to operate with enhanced vision, precision, dexterity and control. Image

courtesy of davincisurgery.

1.2 Continuum Robots

The evolution and growth of the continuum robots that are considered as a part of

surgical robots are shown in this study. Continuum robots have unique characteristics

because of their continues shape and elastic structure [4]. Those features make them

flexible and can be easily bent over and over which is very useful for minimally inva-

sive surgery and also for minimal damage risk. They are relatively light and can be

controlled to perform precise movements [5]. Different types of continuum robots exist

such as tendon actuated robots [6–8], pneumatic muscle actuated robots [9] and others.

(Figure 1.2) shows two different types of continuum robots. The robot manipulator Oct-

Arm is constructed using air muscle ex-tensors with three control passages per section

that deliver two axis bending and extension. Within each section, mesh and plastic

coupler constraints prevent ex-tensor buckling. Oct-Arm IV is included of four sections

connected by end-plates, providing twelve degrees of freedom manipulator [4, 10, 11].

Page 14: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 1. Introduction 3

(a) The Oct-Arm continuum manipulator [10]. (b) The pediatric cardiac concentric tube [11].

Figure 1.2: Types of continuum manipulator. (a) The Oct-Arm continuum robotundergoes a series of trials in a challenging environment. (b) Researchers at VanderbiltUniversity have developed a steerable needle called the active cannula that can navigate

through the brain. Image courtesy of micromanufacturing.

1.3 Master and Slave Manipulators

Since 1960 when the first master-slave manipulator is developed, master and slave sys-

tems have been applied to many areas. Tele-operations represent one of the first most

challenging domains of master-slave robotics [12], where a human operator is required

to perform a task in a remote environment through master and slave manipulators. En-

abling the operator to feel the force acting on the slave manipulator can improve the

task performance. When the motion of the human operator is ”reflected” to the slave

manipulator and when the measured force acting on the slave is ”reflected” directly to

the master actuators providing the human operator to feel it, this is called bilaterally

controlled robot [13, 14]. Meanwhile the maneuverability of this system depends on

the mechanical design of both master and slave actuation. The maneuverability of the

system can be considered as an intuitive property for human operators and it would be

difficult to evaluate such an intuitive matter quantitatively. Raju [15] evaluates the ma-

neuverability of master-slave system through practical experiments. He also points out

that there are various aspects evaluate the performance of the system. Meanwhile, the-

oretical analysis of master-slave system is complex since dynamics of both the operator

and manipulated object should be taken into account. Hanna-ford [16] also points out

the importance of considering the whole system including not only the arm dynamics

but also the object and operator dynamics for system performance analysis. In order

to enable the operator, who is the surgeon in our case, to distinguish the remote object

”flexible needle” as if he is manipulating it directly, the system must be coupled with the

operator to give and ideal kinesthetic sense. The system should give a response to the

operator as if he is connected to a virtual rod, as Dudragne et Al. [17] mentions. This

Page 15: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 1. Introduction 4

means that tele-operated systems present a technical alternative for intelligent robotic

systems performing dexterous tasks in unstructured environments. Since tele-operated

bilateral control systems include continuous human intervention into the control loop,

it is important to transmit realistic motion proportional to the operator’s master ma-

nipulation and to provide a realistic sensory feedback of the environmental interactive

forces to the operator [18].

The goal of this study is to build a superior master-slave system that can provide good

and precise maneuverability, this study focuses on a simple dynamic and kinematical

modeling of continuum robots that depends on the constant curvature principle, which

characterizes the actions and the behaviors of the continuum robots. It also concen-

trates on controlling a wide range of maneuverability through three-dimensional (3D)

joystick. Those principles presume that the beam will be bent in a circular arc if a

constant moment is applied along the beam. Continuum robots have been controlled by

models depend on this presumption. Though, it is hard to come up with an ideal model,

due to some undesirable features and defectiveness inside the continuum robot such as

fabrications and frictions flaws that differ from one case to another, more complicated

models are being developed that put in consideration those factors. Despite the fact

that there are some complex kinematical and dynamical models showing signs of future

success, none of these models have been demonstrated in an experimental setup. Feed-

back control is being used in order to enhance the execution of these kinematical models

robots, by using a camera to track the two dimensional tip position. As an expansion,

the optical 3D tracking system is used. Force feedback is not implemented due to the

lack of joystick with force feedback.

Most research concentrates on capturing all the effects of the continuum robot by im-

proving its complex kinematical model, driving the robot using a simple kinematical

model, and using a 3D joystick to control the robot are the areas of interest in this

study. Steps used to have this result are as follow:

1. Design of a suitable continuum robot, actuator and controller.

2. Design of a suitable feedback system.

3. Bilateral tele-operation of continuum robot.

4. Comparison between the model and experimental results.

The derivations of the kinematical model are in chapter 2 which depends on the constant

curvature assumptions. Continuum robots have different shapes and sizes. A tendon

actuated robot is chosen in this study because of being easy to manufacture and actuate.

Page 16: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 1. Introduction 5

An actuation device is first designed and built to actuate the robot which is discussed in

section 3.1. In section 3.3, the controller design and implementation is being discussed.

The experiments used to evaluate the performance are being discussed in chapter 4.

Chapter 5 contains the reviews and recommendations.

This study contains contributions that have been made as follow:

1. Continuum robot has been designed;

2. Designed actuator that has the ability to drive different continuum robot designs;

3. Created a matlab code for open-loop control of the continuum robot;

4. 3D position control of a continuum robot using a 3D joystick.

Figure 1.3: The experimental setup 1 represents module 1 in micro-robotic surgicalsystem as the flexible needle injects and deliver micro robots to a point inside the

human body where a magnetic field, module 2 , takes the lead in controlling thesemicro-robots.

Page 17: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 2

The Kinematical Model of the

Continuum Robot

Continuum robot kinematics that has elastic backbone is discussed in this chapter.

Section 3.1.2 illustrates the reason of choosing this design. In this study the robot is

designed with four tendons set at 90° from each other to give the robot the ability of

bending in all directions as shown in (figure 2.1). In this model the layout of four elastic

tendons is presumed with other variables that can be diverse such as tendons guides’

number or radius and the length of the device.

Figure 2.1: The tendon actuated continuum robot consists of four tendons which pullfour tendon guides, which controls the flexible needle with the end-effector co-ordinates

(Xe, Ye, Ze).

6

Page 18: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 2. The Kinematical Model of the Continuum Robot 7

2.1 Objectives of the Design

This kinematical model is chosen to come up with the right equations that link the

length of the tendons and the end-effector. The center of the last tendon guide is

the end-effector of the continuum robot. The next section shows the derivations of

the equations that relates the tendon lengths and the position of the end-effector in

(Xe, Ye, Ze) directions. Section 2.3 discusses the inverse kinematics that is needed to

derive the continuum robot. The model shown in this chapter is the constant curvature

model that is presuming that the backbone will bend if the robot is operated. The way

that this type of continuum robots acts can be captured by the constant curvature model

[6, 19, 20]. Because of the imperfection of fabrications, as a result of misplacement of the

tendon guides as an example, or the fact that the tendons or frictions can be stretched,

the constant curvature models has limitations ,as in real life we are not dealing with the

ideal case anymore. On the other hand, a simple kinematical model can be combined

with a feedback system which is suitable for this study to be shown. The Table 2.1

below shows all variables that is used in this model.

Table 2.1: Description of the variables used in the kinematical model.

Variable Definition Figure

A The deflection in the plane of bending 2.5α Angle of the circular arc described by a segment of the robot 2.4hb Length of the backbone of the continuum robot 2.3ahc Center point distance in a segment 2.4hi Length of the ith tendon 2.4hlin The position of the linear stagehy The length of the robot along the z-direction 2.5i Number of the tendon 2.3bl Length measured from backbone to tendon guide hole 2.4

lmid protrusion radius 3.3lo Length of the outer radius of the tendon 3.3n Number of segments of the robotθ Angle at which the robot is bending in the (x, y) plane 2.3bθi Angle of the ith tendon hole in relation to θ 2.3bρ Radius of the circular arc described by the robot 2.3aρi Radius of the circular arc in relation to the ith tendon hole 2.4

Xe, Ye, Ze The coordinates of the position of the end-effector 2.3

2.2 Forward Kinematics of the Continuum Robot

The relations between the length of the tendon, the shape of the continuum robot and

the end-effector position are being described by the forward kinematics. The fleck where

the continuum robot leaves the insertion phase is known as the coordinate system origin

Page 19: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 2. The Kinematical Model of the Continuum Robot 8

as we can see it in (figure 2.2). Chapter 3 illuminates the real design and the actuator

of the continuum robot. The continuum robot is attached to the carriage that is a part

of actuator. Pulling tendons is being done by using four motors that are connected to

the carriage, which is placed on a linear platform that moves the continuum robot in

the z-direction during the insertion process.

Figure 2.2: The xyz-coordinate system of the continuum robot. hb defines the lengthof the flexible needle and Xe, Ye, Ze represent the position of the end-effector .

The end-effector of the robot moves as the length of the tendon changes (h1, h2, h3 and

h4). The robot is bent as a circular arc shape that has a hb length, radius ρ and forms

angle. The backbone represents the radius ρ of the circular arc. The length of the

circular arc is the length of the backbone of the robot hb. The backbone curves in the

xy-plane which forms θ angle. (Figure 2.3) shows the (Xe, Ye, Ze) that is the end-effector

positions. The backbone projecting an angle θ from the base of the robot which is related

to the tendon. As illustrated in (Figure 2.3b) θi is determined per tendon where i refer

to the number of the tendon. The relation between θi and θ is described by equation

(2.1).

θ1 = θ, θ2 =π

2− θ, θ3 = π − θ, θ4 =

2− θ. (2.1)

Page 20: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 2. The Kinematical Model of the Continuum Robot 9

(a) The radius of the curvature ρ. (b) Schematic representation of the anglesof the continuum robot, θ is the angle atwhich the robot is bending in the xy-plane.

Figure 2.3: The radius of the curvature ρ and angle θ when the robot bends towardsthe negative x-axis. (a) The end-effector position is defined using the xyz-coordinates.hb defines the length of the flexible needle. (b) The relation of the tendon angles θ1, θ2

,θ3 ,θ4 to the angle θ.

If the continuum robot is put linearly then the tendon length hi will be equal to the

backbone length hb. There is a case where θis=θ that is when only one tendon is

stimulated, as we can see it in (figure 2.4) which shows a cut of a bending continuum

robot.

Figure 2.4: A bent division of the continuum robot. hc defines the center pointdistance in a segment, and hi defines the length of the ith tendon. Further, n denotesthe number of segments of the robot. ρ defines the radius of the circular arc describeby the robot. ρi defines the radius of the circular arc in relation to the ith tendon hole.

Page 21: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 2. The Kinematical Model of the Continuum Robot 10

From tendon guide to another the tendons are carried out as a straight line. This model

didn’t put in consideration the thickness of the guide tendons as it is assumed to be very

thin and immeasurably. The direct line which is aligned from the hole of the backbone

to the other hole of the tendon guide is defined as hc. This line can be known by getting

the average tendon lengths within a division. Equation of the center point distance in a

segment hc in terms hi and n is given by

hc =h1 + h2 + h3 + h4

4n, (2.2)

where hi is the length of the ith tendon and n is the number of the robot’s segments.

Equation of hc in terms of α and ρ is given by

hc = 2ρsin(α

2

), (2.3)

where α is the angle of the circular arc described by a segment of the robot and ρ is the

radius of the circular arc described by the robot.

We can get another equation for the tendon length within a division by relate it to the

ρi, which is defined as the radius from the center of the circle to the ith hole of the

tendon. Equation of ρi in terms of l and θi is given by

ρi = ρ− lcos(θi), (2.4)

where l is the length measured from backbone to tendon guide hole and θi is the angle

of the ith tendon hole in relation to θ. Equation of hi in terms of ρi is given by

1

nhi = 2ρisin

(α2

). (2.5)

From (2.4) and (2.5) we get

1

nhi = 2[ρ− lcos(θi)]sin

(α2

)= 2ρsin

(α2

)− 2lcos(θi)sin

(α2

). (2.6)

From (2.3) and (2.6) we get

hc =1

nhc + 2lcos(θi)sin

(α2

). (2.7)

Page 22: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 2. The Kinematical Model of the Continuum Robot 11

Know we can relate h1 and h3 as follows

1

nh1 + 2lcos(θ1)sin

(α2

)=

1

nh3 + 2lcos(θ3)sin

(α2

). (2.8)

Rewriting equation (2.8) we get

h1 − h3n[cos(θ3) − cos(θ1)]

= 2lsin(α

2

). (2.9)

The same is done for h2 and h4

h2 − h4n[cos(θ4) − cos(θ2)]

= 2lsin(α

2

). (2.10)

Using θi defined in equation (2.1) and equating (2.9) and (2.10) equations we get

h2 − h4h1 − h3

=cos(θ4) − cos(θ2)

cos(θ3) − cos(θ1)=sin(θ)

cos(θ)= tan(θ), (2.11)

where θ is the Angle at which the robot is bending in the xy-plane. The angle of

curvature θ now can be defined in terms of hi as follows

θ = tan−1

(h2 − h4h1 − h3

). (2.12)

Relating ρ with tendon lengths h we get

ρ

ρ i

= nhchi. (2.13)

Rewriting equation (2.13) to get an expression for ρ

ρ = nhchiρi. (2.14)

By substituting (2.4) equation in (2.14) we get

ρ = nhchi

(ρ− lcos(θi)) = nhchiρ− n

hchilcos(θi). (2.15)

ρ− nhchiρ = ρ(1 − n

hchi

) = −nhchilcos(θi). (2.16)

Page 23: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 2. The Kinematical Model of the Continuum Robot 12

Figure 2.5: The xy-plan of a bending continuum robot rotating with angle θ over thez-axis. A defines the deflection in the plane of bending. hy defines the length of therobot in the z-direction. α defines the angle of the circular arc described by a segment

of the robot. n defines the number of segments of the robot.

ρ = nhclcos(θi)

hc − hi. (2.17)

The spotted tendon lengths of continuum robot are presented by (2.2), (2.12) and (2.17)

equations. The xy-plane of the curvature of the continuum robot is presented in (figure

2.5) and is rotated over the z-axis by α.

Getting αn in terms of ρ and h as follows

hb = 2πραn

2πtherefore αn =

hbρ, (2.18)

where hb is the length of the backbone of the continuum robot.

The space between the existing position of the end-effector and its original position in

xy-plane is calculated using trigonometry and defined as A and is given by

A = ρ− ρcos(αn). (2.19)

Page 24: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 2. The Kinematical Model of the Continuum Robot 13

Bending the robot in z-direction he projection of the continuum robot will be shorter

and the equation of device length hy is as follows

hy = ρsin(αn), (2.20)

where hy is the length of the robot in the z-direction.

Adding the thickness of the base-plate µbase (is illustrated in details in section ??) and

hlin in z-direction which is defined as the calculated length of the base from the origin,

are needed to get the (Xe, Ye, Ze) relations. These relations are used to know the end-

effector position by knowing the linear stage position and the lengths of the tendons.

Equation of the position of the end-effector (Xe, Ye, Ze) position of the end-effector

Xe = Acos(θ) Ye = Asin(θ) Ze = hlin + hy + µbase, (2.21)

where µbase is the thickness of the base plate.

2.3 Inverse Kinematics of the Continuum Robot

The inverse kinematics is needed to be steered for getting the derivations of the position

of the end-effector. The following shows the steps of getting (h1, h2, h3, h4 and hlin).

From section 2.2 we knew that ρ and θ can describe the continuum robot, getting θ in

terms of (Xe and Ye)

θ = tan−1

(YeXe

). (2.22)

Calculate A to get ρ

A =√X2 + Y 2. (2.23)

We conmine equations (2.18) with (2.19) we obtain

A = ρ− ρcos

(hbρ

). (2.24)

The equation (2.24) is solved numerically as getting a closed form expression of it cannot

be done. Calculating αn in terms of ρ and hb as follows

hb = 2πραn

2πtherefore α =

hbnρ. (2.25)

Page 25: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 2. The Kinematical Model of the Continuum Robot 14

Rewriting equation (2.3)

hc = 2ρsin

(hb

2nρ

), (2.26)

Getting the tendon length hi from (2.7) and (2.26) equations

hi = n[hc − 2lcos(θi)sin

(hb

2nρ

)]. (2.27)

We get hlin by rewriting equation (2.21) using (2.20 and 2.25) equations and Putting hy

and µbase in consideration as the robot is getting shorter when bent. Also setting the

linear stage in a position based on Ze, we get the mapping of the lengths of the tendons

and linear stage position from (Xe, Ye, Ze) as follows

hlin = Z − ρsin(nρhb) − µbase, (2.28)

where hlin is the position of the linear stage. After comparing the kinematical model

with the experimental continuum robot at different bending angles αn , we get that the

maximum error is 4.3 % at αn = 45°.

Page 26: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 3

Design of the Continuum Robot

This chapter discusses the mechanical and the electronic design of module one in a

micro-robotic surgical system as follows in sections 3.1 and 3.2. Section 3.3 clarifies

the continuum robot control design of the open loop system. the mechanical design of

the continuum robot is based on the constant curvature principle that assumes that the

flexible needle bends in a circular arc. The flexible needle is attached to a carriage which

has the ability to be assembled and disassembled easily.

(a) The continuum robot (module 1 ) in itsway to merge with the magnetic fields (module

2 ).

(b) The continuum robot penetrates the mag-netic field with the flexible needle.

Figure 3.1: The continuum robot which represents module 1 integrates with mag-

netic field which represents module 2 that control the micro-robots inside the humanbody.

15

Page 27: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 3. Design of the Continuum Robot 16

3.1 Mechanical Design of the Continuum Robot

Figure 3.2: The mechanical design of the continuum robot. The tendon guide 1

are connected to the tendons 2 controlling the flexible needle (backbone) 3 . The

stepper motors 4 are responsible for tendons’ actuation (where they are fixed on the

carriage 5 ), as well as linear stage actuation 6 .

This section interprets the mechanical design of the continuum robot and goes into its

actuation process. The dexterous nature and flexibility of the continuum robot is a

major reason to choose this type of mechanism. The absence of any discrete joints helps

the robot to travel through the body with minimum resistance and makes it ideally

suitable for Natural Orifice Surgery (NOS). (Figure 3.2) shows the final complete setup

of the system.

3.1.1 Requirements of Building the Continuum Robot

In this study we build a continuum robot with simple kinematic mechanism. The aim

is to control the robot using a 3D joystick, get a position feedback and to get the acting

force on the end-effector of the robot. We focus on improving the control of a simple

dynamic and kinematical modeling of continuum robots that depends on the constant

curvature principle, which characterizes the actions and the behaviors of the continuum

robots, it also concentrates on controlling a wide range of maneuverability through 3D

joystick. Continuum manipulator, simple construction, and simple method of actuation

are the requirements to build the continuum robot.

Page 28: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 3. Design of the Continuum Robot 17

3.1.1.1 Continuum Manipulator

The system is actuated by tendons, which are attached to four tendon guides, the needle

is fixed inside those four tendon guides that has the ability to fit inside a natural orifice

in the human body, Pulling the tendons is an easily implemented actuation method that

enables a smooth control the end-effector through a wide range of angles in all directions

at a minimum range of 45°. We use 3D printing for the tendon guides manufacturing.

These items allow us to build a simple kinematic mechanism of the continuum robot

with relatively low cost.A linear stage allows us to move the continuum robot in a linear

movement for insertion. A pulling forces to bend the backbone (flexible needle) of the

continuum robot through the tendons. The actuator controls almost every expected

angle of the end-effector in a low speed.

3.1.2 Structure of the Continuum Manipulator

Snake-Arm robot is the type of our continuum robot model. It consists of a flexible

Needle (Backbone) with a number of tendon guides, supporting the flexible backbone,

fixed at a constant distances from each other. Tendons are attached through the tendon

guides to control the flexible needle through a wide range of bending angles and rotations.

All the following components are found in Appendix A.

3.1.2.1 Flexible Needle

The needle needs to be flexible to withstand the plastic deformations when it bends more

than 90°. A super elastic material should be chosen to match these specific properties.

Nitinol tubing has been chosen as the flexible needle to the continuum robot. Nitinol

tubes (Ni-Ti) meets the requirements we need. The processing and availability of nitinol

tubing have excessively increased allowing its use across a wide variety of medical device

specialties. The most important and relevant properties of super elastic nitinol can be

listed as follows:

Advantages relating to the super elastic behavior:

– Large recoverable deformation;

– Low permanent set or residual deformation;

– High plateau stresses and ultimate tensile strength;

– Body temperature within super elastic temperature range;

– High potential energy storage capability.

Page 29: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 3. Design of the Continuum Robot 18

;

Corrosion resistance similar to stainless steel and titanium alloys.

The work space of the flexible needle depends on its bending angle and its length. Using

the equations in section 2.2 allows us to get the area of the work-space. The flexible

needle needs to bend 45° as a minimum bending angle. The work-space is determined by

An equation (2.19) and hy equation (2.20). These variables define a cylindrical shaped

work-space. A length of 160 mm is chosen for our model. If we combine (2.19) and

(2.25) equations we can calculate the work-space and the device length.

A =hbαn

(1 − cos(αn)) =160

π/4

(1 − cos

(π4

))= 59.67 ≈ 60mm. (3.1)

Combining (2.20) and (2.25) equations

hy =hbαn

sin(αn) =160

π/4sin(π

4

)= 144.1 ≈ 145mm. (3.2)

3.1.2.2 Tendon Guides

Our tendon guides support the flexible needle. They are fixed at a constant distance

from each other. Tendons are attached through these tendon guides enabling the flexible

needle to potentially move through the work-space area. The outer diameter has to be

of a size such that the robot fits inside a natural orifice of the body. The diameter of

the rectum is on average 21 mm [1, 21], therefore a design with a tendon guide diameter

of 20 mm is chosen. The tendons should be as far away from the flexible needle as

possible. This increases moment and reduces the forces needed to manipulate the robot,

although, if the holes are too close to the outer rim of the tendon guides the tendon will

protrude from the robot when it bends. In this case, the tendons will run from guide to

guide in a straight line. The distance of protrusion is also dependent on the number of

tendon guides on the backbone. If the robot bends at radius ρ and we take a segment of

a continuum robot which has n segments, length hb, outer radius lo, protrusion radius

lmid and tendon radius l shown in (figure 3.3).

If the device is twisted and is hardly bulged, then the relation between the maximum

length calculated from the backbone to the tendon holes and the radius of the outer guide

can be measured. From information illustrated in section 3.1.1.1, 45° is the maximum

degree the device can reach when it is twisted. The maximum middle point between the

two guides of the tendons is bulged by the tendon. The tendon will not be more distant

Page 30: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 3. Design of the Continuum Robot 19

away from the backbone than the diameter of the outer tendon guide, hence lmid 6 lo.

In this case the line lmid and the tendon guide are at an1/4π

2nangle. From this we can

use a trigonometric equation where the hypotenuse is (ρ−1) and the adjacent is (ρ− lo).

The trigonometric equation

cos

(1/4π

2n

)=

(ρ− lo)

(ρ− 1). (3.3)

By substituting (2.18) equation ρ =hbαn

and αn = 1/8π in (3.3) equation.

(hbαn

− lo

)cos

(1/4π

2n

) =

(hbαn

− l

). (3.4)

Rewriting 3.4 equation we get

l =hbαn

(hbαn

− lo

)cos

(1/4π

2n

) . (3.5)

Figure 3.3: A segment of the continuum needle where lmid is the protrusion radius,lo is the length of the outer radius of the tendon, further l defines the length measured

from backbone to tendon guide hole.

Page 31: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 3. Design of the Continuum Robot 20

From the above equations and by setting hy = 160 mm and n=4, we get lo = 10.0 mm

and l = 8.0 mm.

3.1.3 Actuator Structure

The actuation of the continuum robot consists of four main parts; the carriage, where

the actuators (stepper motors) are attached, the Stepper motors, responsible for the

manipulation of the continuum robot, the pulleys, which are fixed to the shaft of the

stepper motor and where the tendons are attached, and lastly the linear stage, which is

responsible for the insertion motion.

The carriage connects all the parts of the robot together, it lies on the linear stage

carrying the four stepper motors which control the continuum needle. The first design

of the carriage has more than one problem, it was hard to loosen the assembled parts for

maintenance and there was not enough space to work and fix any tendon malfunction.

Several designs are presented where each has its own advantages while having the same

function, some has easy access to motors’ tuning while lacking enough space to carry

more tasks, while other designs share the same perk of easy tuning however are larger

in size, finally the most efficient design that has more capability to carry more side

functions other than the main one is chosen for future research and implementations.

Some experiments have been performed to determine how strong the motors needed to

be able pull the tendons, stepper motors (Nema 17), which have a holding torque with

4.8 kg.cm, matches the requirements we need.

The pulleys are chosen to be as small as possible, they connect the tendons to the shaft,

transmitting the rotational motion from the motor to the end-effector of the flexible

needle. GT2 Pulley matches the requirements we need with some amendments, two

holes with a diameter 1.5 mm have been made to the pulleys to be able fix the tendons

within the pulley. 3D printing is another way to produce similar pulleys for the same

purpose.

The linear stage is used for insertion motion. Misumi LX30 is used as our linear stage, a

single axis linear actuator is connected to a stepper motor, controlling the forward and

backward motion of the whole carriage.

3.2 Electronic Design

This chapter shows the electronic design and the wiring system to control the flexible

needle. It discusses the connections starting from the power supply passing through

Page 32: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 3. Design of the Continuum Robot 21

the stepper drivers which take its signals from the Arduino then actuating the stepper

motors.

3.2.1 Requirements

In this section we build an efficient electronic system that is easy to implement, to

modify and to update.

3.2.2 Electronic Components

This section indicates the electronic devices that have been used in the system and their

functions. Appendix B contains all data sheets.

Stepper motors are great when positioning accuracy is required such as CNC applica-

tions. This is a good quality stepper motor, NEMA 17 Standard with torque of 4.8

kg.cm.

Stepping driversXAL-42 is an economical high performance driver based on one of the

most advanced technologies in the world today. It is suitable for driving any 2-phase and

4-phase hybrid stepping motors. By using advanced bipolar constant-current chopping

technique, it can output more speed and power from the same motor, compared with

traditional technologies such as L/R drivers. Its 3-state current control technology allows

coil currents to be well controlled, with relatively small current ripple and therefore less

motor heating.

Switched Mode Power Supply (SMPS) is an electronic power supply that incorporates a

switching regulator to convert electrical power efficiently. In this project we need SMPS

with an input 220 AC voltage and convert it to 12 DC voltage with a 20 A current. To

supply power to the four drivers and four stepper motors.

The Arduino Mega 2560 is a micro-controller board based on the ATmega2560. It has 54

digital input/output pins (of which 14 can be used as PWM outputs), 16 analog inputs, 4

UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power

jack, an ICSP header, and a reset button. It contains everything needed to support the

micro-controller, simply connect it to a computer with a USB cable or power it with a

AC-to-DC adapter or battery to get started.

The wiring system between the controller (Arduino), the micro step driver (XAL-42),

the stepper motors, and the power supply. The (figure B.7) in Appendix B shows the

wiring system and the color code of the stepper motor in a simple way.

Page 33: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 3. Design of the Continuum Robot 22

The input of the power supply is the main electricity line 220 [V], it gives 12 volts as an

output transferring it to the micro step driver which is connected to the stepper motor’s

stators A and B. when the Arduino sends a signal to the Pulse and direction pins the

motor starts to move.

3.3 Control Design

This section illustrates the criteria of controlling the continuum robot.

3.3.1 Open-Loop System

This section shows the system we use to control the continuum robot and discusses its

purposes. Open-loop system is our choice to control the flexible needle, as there is a

micro cam at the tip of the needle to monitor the whole journey inside the human body

on a screen during the surgery. The surgeon is able to control the needle in a wide range

of angles and positions while he is monitoring the screen. (Figure 3.4) shows the block

diagram of the open-loop system. The input signal in this system is taken from a 3D

joystick, the controller (Arduino Mega 2560) receives these signals and transfers it to the

actuators, translating these signals into motion. The diagram below shows a detailed

block for the continuum robot open-loop system.

Figure 3.4: Open-loop control diagram of the continuum robot.

3.3.2 Closed-Loop Control System

This section discusses the usage of a closed-loop control in this study, as mentioned in

section 1.1 that these robots are not fully autonomous yet and need to be controlled

by the surgeon. Closed-loop control can be used for autonomous applications. As the

Page 34: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 3. Design of the Continuum Robot 23

desired input signal (Xin, Yin, Zin) is sent, the controller actuator the robot. Two

cameras are used to monitor the flexible needle using image processing techniques with

in the work space area of the robot (Mapping), then the system translates this motion

into a three dimensional coordinate system (localization) to get (Xe, Ye, Ze). The system

calculates the error between the desired input and the output. PID controller might be

used to reduce the error between the desired input and the output.

Figure 3.5: A closed-loop control diagram of the continuum robot.

Page 35: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 4

Experimental Results

The effect of the 3D joystick on the motion of the flexible needle is experimentally ex-

amined. First, we investigated the positioning of end-effector compared to the expected

kinematical model in chapter 2, as shown in table 4.1.

This experiment tests the localization of the end-effector at arc bending angle αn = 45°,

60° and 80° with flexible needle length hb = 140 mm, by substituting in (2.18), (2.19)

and (2.20) equations respectively.

hb = 2πραn

2πtherefore ρ =

hbαn

, A = ρ− ρcos(αn), and hy = ρsin(αn).

24

Page 36: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 4. Experimental Results 25

Table 4.1: The comparison between the expected kinematical model and the contin-uum robot at bending angle αn = 45°, 60° and 80° with flexible needle length hb = 140

mm.

(1) At angle 45°

ρ = 178.25 mm ρ = 186 mm

A = 52.2 mm A = 54.6 mm

hy = 126 mm hy = 158.26 mm

(2) At angle 60°

ρ = 133.69 mm ρ = 128.4 mm

A = 66.8 mm A = 64.2 mm

hy = 115.78 mm hy = 111.2 mm

(3) At angle 80°

ρ = 100.2 mm ρ = 96.8 mm

A = 82.85 mm A = 80 mm

hy = 98.67 mm hy = 95.3 mm

After comparing the kinematical model to our experimental continuum robot at different

bending angles αn, we get that the maximum error is 4.3% at αn = 45°.

We also investigated the trajectory control of the flexible needle by performing geomet-

rical shapes and Latin letters. (Figure 4.1) and 4.2 provide a representative open-loop

control of the flexible needle using the 3D joystick where the tip of the needle is moni-

tored using feature tracking.

Page 37: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 4. Experimental Results 26

Figure 4.1: A representative open-loop control experiment of the continuum robotusing a 3D joystick. The tip of the needle is detected in the xy-plan using high definitioncamera. The flexible needle and the tendons show unwanted vibrations during this

experiment when they face a high tensile forces.

Page 38: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 4. Experimental Results 27

(a) Tracking experiment of the flexible needle tip.

(b) Position of the end-effector.

Figure 4.2: A representative open-loop control experiment of the continuum robotusing a 3D joystick, performing a ’G’ shape in a rectangular work space area of 187.5cm2, knowing that the maximum work space area on the xy-plan is Π ∗ 8.252 = 230.8cm2. The tip of the needle is detected in the xy-plan using high definition camera by

which the path is plotted on the xy-plan.

Page 39: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 4. Experimental Results 28

(a) Tracking experiment of the flexible needle performing geometrical shapes.

(b) Position of the end-effector.

Figure 4.3: A representative open-loop control experiment of the continuum robotusing a 3D joystick with instant plotting of a rectangular shape with length and width

of 160 mm and 125 mm respectively.

Page 40: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 4. Experimental Results 29

(a) Tracking experiment of the flexible needle performing infinity shape.

(b) Position of the end-effector.

Figure 4.4: A representative open-loop control experiment of the continuum robotusing a 3D joystick with instant plotting of an infinity shape.

Page 41: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 5. Experiments 30

The continuum robot maneuverability is also examined through performing some En-

glish letters. (Figure 4.5) provide a representative open-loop control experiments of the

continuum robot as it performs ”G”, ”U” and ”C” letters.

Figure 4.5: A representative open-loop control experiment of the continuum robotusing a 3D joystick. The tip of the needle is detected in the xy-plan using high definitioncamera by which the path is plotted instantaneously on the xy-plan by which it performs

GUC letters.

Page 42: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 5

Conclusions

This work investigates the utilization of a simple kinematical model to drive a flexible

needle inside the human body using 3D joystick with accuracy of 95.7 %. This work

includes the mechanical design of the experimental setup, design of the continuum robot

and actuator. The continuum robot consists of the flexible needle, tendons, tendon

guides, base plate and the main carriage which is the link between the actuators and the

flexible needle. Four stepper motors are the actuators for the flexible needle assembled

on the carriage. The whole setup is fixed on a linear stage for the needle axial motion.

The kinematical model and equations discuss how this mechanism works, the main idea

in the bending motion of the flexible needle depends on controlling the tendon lengths.

Relating the tendon lengths to the projected angle by which the robot is bending in the

xy-plan, to the radius of the circular arc described by the flexible needle, to the deflection

of the flexible needle in the plane of bending and to the projection of the on the z-axis,

is the key factor to get the end-effector position (Xe, Ye, Ze). The electronic design

reveals the electronic components and their function to be able to send an input signal

through 3D joystick that can be reflected on the end-effector. The control criteria needs

to achieve a smooth needle stimulation inside the human body, as the surgeon controls

the needle by a 3D joystick with simultaneous detection through an attached camera on

the tip of the needle, we use an open-loop control system which allows the surgeon to be

in complete control of the end-effector in a remote environment. Experiments have been

made to evaluate the performance of the flexible needle. We are able to track the tip of

the needle using image processing techniques. The continuum robot has the capability

to perform different geometrical shapes within a circular work-space of 213.8 cm2 with

an average speed of 2.5 cm/s knowing that the holding torque of the stepper motors is

4.8 Kg.cm. During experiments the tendons show unwanted vibrations when they face

a high tensile forces because of their poor quality. Force feedback is not implemented

due to the lack of joystick with force feedback.

31

Page 43: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 5. Conclusions 32

5.1 Future Recommendation

After experimenting the setups we have made during this study, some amendments and

changes will improve the performance of the system. The following sections illustrate

some ways in the current design that can be improved.

Plastic wire tendons (fish line) shows good work during experiments but it is not the

ideal choice for the best performance. Plastic deformation appears when the torque is

high. Stainless steel or titanium medical wires can be better options to achieve this

mission.

The tendons guides were 3D printed objects fixed to the nitinol backbone. The super

glue is not an ideal method of fixing the backbone. A specific type of glue that is more

suited for gluing nitinol and the acrylic based 3D printed material together may improve

the connection. Decreasing the tendon guide dimensions is a better solution and more

liable than the dimensions we use in this study.

Logitech 3D joystick shows great job when it comes to maneuverability, it Controls

the flexible needle in a wide range of angles as if the operator is in direct contact

with the needle, however to provide the operator with extra feeling to the environment

and to reflect the forces facing the needle, another type of joystick must be used or

manufactured.

More tendon guides and more stepper motors will increase the maneuverability of the

system and the degrees of freedom of the flexible needle. However, adding more tendon

guides and more actuators will add some complexity to the kinematical model.

Page 44: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Chapter 5. Conclusions 33

(a) 3D drawing of the future prospect of the continuum robot.

(b) Tendons are attached at the middle tendon guide which allows double bend.

Figure 5.1: A 3D prospect of a continuum robot with more degrees of freedom, eighttendons, eight tendon guides and eight motor. Four tendons are attached to the middleof the flexible needle which allows sharp bending and another four tendons are attached

to the end-effector.

Page 45: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A

The CAD Drawings

In this appendix the CAD drawings of the 3D printed and machined parts for both the

first and the final designs.

34

Page 46: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 35

A.1 The First Mechanical Design

Figure A.1: Tendon guide.

Page 47: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 36

Figure A.2: Base plate.

Page 48: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 37

Figure A.3: Motor housing.

Page 49: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 38

Figure A.4: Carriage front face.

Page 50: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 39

Figure A.5: All 3D printed parts.

Page 51: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 40

Figure A.6: Assembled 3D printed carriage.

Page 52: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 41

Figure A.7: 3D drawing of the continuum robot.

Page 53: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 42

(a) Isometric 3D view which shows the pulleys.

(b) 3D drawing of the continuum robot.

Figure A.8: The expected three dimensional drawing of first prototype of the contin-uum robot.

Page 54: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 43

Figure A.9: The experimental setup of the continuum robot.

Figure A.10: 3D drawing top view of the continuum robot.

Page 55: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 44

Figure A.11: The top view of the continuum robot.

Page 56: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 45

A.2 The Final Mechanical Design

Figure A.12: Tendon guide base plate.

Page 57: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 46

Figure A.13: First drawing of motor housing.

Page 58: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 47

Figure A.14: Second drawing of motor housing.

Page 59: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 48

Figure A.15: Final design assembly.

Page 60: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 49

Figure A.16: 3D drawing for the final design of continuum robot.

Page 61: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 50

Figure A.17: 3D drawing for the final design of continuum robot.

Figure A.18: The experimental setup of the continuum robot of the final design.

Page 62: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 51

Figure A.19: Front view 3D drawing for the final design of continuum robot.

Figure A.20: The experimental setup of the continuum robot front view picture ofthe final design.

Page 63: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 52

Figure A.21: 3D drawing for the final design of continuum robot.

Figure A.22: The experimental setup of the continuum robot of the final design.

Page 64: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix A. The CAD Drawings 53

Figure A.23: 3D drawing for the final design of continuum robot.

Figure A.24: The experimental setup of the continuum robot of the final design.

Page 65: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix B

Electronic Components

All the electronic components and their data sheets are included in this appendix.

B.1 Stepper Motor

Figure B.1: Nema 17 stepper motor (MOTSTP048, Egypt, Future Electronics).

54

Page 66: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix B. Electronic Components 55

B.1.1 Stepper Motor Features

The stepper motor features are:

Step Angle: 1.8°;

Phases: 2-Phases;

Voltage: 12 V;

Rated Current: 1.7 A/Phase;

Diameter Drive Shaft: 5 mm;

Holding Torque: 4.8 Kg.cm;

NEMA factor number: NEMA 17;

Wire Leads: 4 Wires.

Figure B.2: Hybrid stepping motor modulation.

Page 67: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix B. Electronic Components 56

B.2 Stepper Motor Drivers

Figure B.3: Micro step driver (XAL-42, Egypt, RAM electronics).

B.2.1 Stepper Motor Driver Features

The stepper driver features are:

Low cost, high torque under high speed condition;

Supply voltage from AC 14 V to AC 35 V or DC 20 V to DC 50 V, peak current

up to 4.2 A;

Automatic idle-current reduction;

Suitable for 2-phase and 4-phase stepper motors;

Optically isolated input signals;

15 select-able resolutions, up to 25,600 steps/rev;

PUL/DIR and CW/CCW mode optional;

Small size 118*75.5*33 mm.

Page 68: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix B. Electronic Components 57

B.2.2 Applications

Suitable for a wide range of stepping motors of Nema 17 and 23, and usable for various

kinds of machines, such as (X-Y)-tables, labeling machines, laser cutters, engraving

machines, and pick-place devices. Extremely suitable for applications, this expected to

be low vibration, high speed and high precision.

B.2.3 Specifications

ParametersXAL-42

Min. Typical Max. Unit

Output Current 1.0 - 4.20 A

Supply Voltage14 - 35 VAC

+15 +24 50 VDC

Logical signal current 7 10 16 mA

Pulse input frequency 0 - 300 KHz

Isolation resistance 500 - - MΩ

Table B.1: Electronic specification.

Micro-step steps/rev (1.8°/rev) SW5 SW6 SW7 SW8

2 400 OFF ON ON ON

4 800 ON OFF ON ON

8 1600 OFF OFF ON ON

16 3200 ON ON OFF ON

32 6400 OFF ON OFF ON

64 12800 ON OFF OFF ON

128 25600 OFF OFF OFF ON

5 1000 ON ON ON OFF

10 2000 OFF ON ON OFF

20 4000 ON OFF ON OFF

25 5000 OFF OFF ON OFF

40 8000 ON ON OFF OFF

50 10000 OFF ON OFF OFF

100 20000 ON OFF OFF OFF

125 25000 OFF OFF OFF OFF

Table B.2: Micro step settings.

Page 69: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix B. Electronic Components 58

Micro-step steps/rev (1.8°/rev) SW5 SW6 SW7 SW8

2 400 OFF ON ON ON

4 800 ON OFF ON ON

8 1600 OFF OFF ON ON

16 3200 ON ON OFF ON

32 6400 OFF ON OFF ON

64 12800 ON OFF OFF ON

128 25600 OFF OFF OFF ON

5 1000 ON ON ON OFF

10 2000 OFF ON ON OFF

20 4000 ON OFF ON OFF

25 5000 OFF OFF ON OFF

40 8000 ON ON OFF OFF

50 10000 OFF ON OFF OFF

100 20000 ON OFF OFF OFF

125 25000 OFF OFF OFF OFF

Table B.3: Current micro step settings.

Pin functions Details

PUL+

Pulse signal: In signal pulse (pulse/direction)mode, this input represents the pulse signal, ef-fective for each rising or falling edge(set by in-side jumperJ1), 4-5 V when PUL-HIGH,0-0.5 V

PUL-

when PUL-LOW. For reliable response, pulsewidth should be longer than 1.5 µs. Series con-nect resistors for current-limiting when +12 Vor +24 V used.

DIR+

DIR signal: In signal-pulse mode, this signalhas low/high voltage level representing two di-rections of motor rotation, for reliable motionresponse, DIR signal should be ahead of PULsignal by 5 µs at least, 4-5 V when DIR-HIGH,

DIR-

0-0.5 V when DIR-LOW. Please note that mo-tion direction is also related to motor-droverwiring match. Exchange the connection of twowires for a coil to the driver will reverse motiondirection.

ENA+Enable signal: This signal is used for en-able/disabling the driver. High level(NPN con-trol signal, PNP and different control signals are

ENA-on the contrary, namely low level for enabling)for enabling the driver, usually left unconnected(enable).

Table B.4: Pin assignment description.

Page 70: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix B. Electronic Components 59

Pin functions Details

Gnd DC power ground

+V DC power positive, typical value 24 V or AC 14-35 V

Phrase A motor coil A (leads A+ and A-)

Phrase B motor coil B (leads B+ and B-)

Table B.5: Power connector P2 pins.

Figure B.4: Connections between the Arduino and the micro-stepper driver, wherethe Arduino sends a signal to the stepper driver which controls the polarity and the

speed of the stepper motors.

Page 71: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix B. Electronic Components 60

B.3 SMPS Power Supply

Figure B.5: Power Supply (SMPS 24V-10A, Egypt, RAM electronics).

B.3.1 Arduino

Arduino is a popular open-source single-board micro-controller, descendant of the open-

source Wiring platform, designed to make the process of using electronics in multidis-

ciplinary projects more accessible. The hardware consists of a simple open hardware

design for the Arduino board with an Atmel AVR processor and on-board input/output

support. The software consists of a standard programming language compiler and the

boot loader that runs on the board. It was used to do the control system of the project.

Arduino hardware is programmed using a wiring-based language (syntax and libraries),

similar to C++ with some slight simplifications and modifications, and a Processing-

based integrated development environment. The project began in Ivrea, Italy (the site of

the computer company Olivetti), in 2005 to make a device for controlling student-built

interaction design projects less expensive than other prototyping systems available at

the time. As of May 2011, more than 300,000 Arduino units are ”in the wild”. Founders

Massimo Banzi and David Cuartielles named the project after Arduino of Ivrea, the

main historical character of the town. ”Arduino” is an Italian masculine first name,

meaning ”strong friend”. The English version of the name is ”Hardwin”. The Arduino

project is a fork of the open-source wiring platform. Wiring was created by Colombian

artist and programmer Hernando Barragan as a master’s thesis at the Interaction design

Institute Ivrea under the supervision of Massimo Banzi and Casey Reas. Furthermore,

Page 72: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix B. Electronic Components 61

wiring is based on processing and its integrated development environment created by

Casey Reas and Ben Fry.

Current versions can be purchased pre-assembled, hardware design information is avail-

able for those who would like to assemble an Arduino by hand. Additionally, variations

of the Italian-made Arduino with varying levels of compatibility have been released by

third parties, some of them are programmed using the Arduino software. The origi-

nal Arduino hardware is manufactured by the Italian company smart projects. Some

Arduino-branded boards have been designed by the American company Spark Fun Elec-

tronics. Thirteen versions of the Arduino hardware have been commercially produced

to date.

Versions of Arduino hardware are as follow:

The Serial Arduino, programmed with a DE-9 serial connection and using an

ATmega8;

The Arduino Extreme, with a USB interface for programming and using an AT-

mega8;

The Arduino Mini, a miniature version of the Arduino using a surface-mounted

ATmega168;

The Arduino Nano, an even smaller, USB powered version of the Arduino using a

surface-mounted ATmega168 (ATmega328 for newer version);

The LilyPad Arduino, a minimalist design for wearable application using a surface-

mounted ATmega168;

The Arduino NG, with a USB interface for programming and using an ATmega8;

The Arduino NG plus, with a USB interface for programming and using an AT-

mega168;

The Arduino Bluetooth, with a Bluetooth interface for programming using an

ATmega168;

The Arduino Diecimila, with a USB interface and utilizes an ATmega168 in a

DIL28 package (pictured);

The Arduino Duemilanove (2009), using the ATmega168 (ATmega328 for newer

version) and powered via USB/DC power, switching automatically;

The Arduino Mega, using a surface-mounted ATmega1280 for additional I/O and

memory;

Page 73: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix B. Electronic Components 62

The Arduino Uno, uses the same ATmega328 as late-model Duemilanove, but

whereas the Duemilanove used an FTDI chipset for USB, the Uno uses an AT-

mega8U2 programmed as a serial converter;

The Arduino Mega2560, uses a surface-mounted ATmega2560, bringing the total

memory to 256 KB. It also incorporates the new ATmega8U2 (ATmega16U2 in

revision 3) USB chipset.

Figure B.6: Controller (Arduino Mega 2560, Egypt, Future Electronics).

B.3.1.1 Features

Arduino Features are:

Micro-controller: ATmega2560;

Page 74: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix B. Electronic Components 63

Operating Voltage: 5 V;

Input Voltage (recommended): 7-12 V;

Input Voltage (limits): 6-20 V;

Digital I/O Pins: 54 (of which 15 provide PWM output);

Analog Input Pins: 16;

DC Current per I/O Pin: 40 mA;

DC Current for 3.3 V Pin: 50 mA;

Flash Memory: 256 KB of which 8 KB used by boot-loader;

SRAM: 8 KB;

EEPROM: 4 KB;

Clock Speed: 16 MHz.

B.4 Wiring System

Figure B.7: The wiring system and the color code of the stepper motor.

Page 75: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix B. Electronic Components 64

Figure B.8: Electric circuit of the stepper motor and the stepping driver.

Page 76: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C

Codes

This appendix contains the Matlab and Arduino codes that runs the continuum robot

via three-dimensional joystick.

C.1 Matlab Code

clc;

close all;

clear all;

%Define arduino input

ard=arduino(’COM4 ’);

joy = vrjoystick (1);

%Defining arduino pins (output pins to the motors)

pulse = 21;

direct = 20;

pulse2 =19 ;

direct2 =18 ;

pulse3 = 52;

direct3 = 50;

pulse4 = 48;

direct4 = 46;

pulse5 = 26;

direct5 = 25;

ard.pinMode(pulse ,’OUTPUT ’);

ard.pinMode(direct ,’OUTPUT ’);

ard.pinMode(pulse2 ,’OUTPUT ’);

ard.pinMode(direct2 ,’OUTPUT ’);

ard.pinMode(pulse3 ,’OUTPUT ’);

65

Page 77: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 66

ard.pinMode(direct3 ,’OUTPUT ’);

ard.pinMode(pulse4 ,’OUTPUT ’);

ard.pinMode(direct4 ,’OUTPUT ’);

ard.pinMode(pulse5 ,’OUTPUT ’);

ard.pinMode(direct5 ,’OUTPUT ’);

stopval =0;

while(stopval ==0)

Xratio=axis(joy ,1);

Yratio=axis(joy ,2);

if(Yratio >0&& button(joy , 1)==1)

ard.digitalWrite(pulse , 1);

ard.digitalWrite(direct , 0);

ard.digitalWrite(pulse , 0);

ard.digitalWrite(pulse4 , 1);

ard.digitalWrite(direct4 , 1);

ard.digitalWrite(pulse4 , 0);

else

if (Yratio <0&& button(joy , 1)==1)

ard.digitalWrite(pulse , 1);

ard.digitalWrite(direct , 1);

ard.digitalWrite(pulse , 0);

ard.digitalWrite(pulse4 , 1);

ard.digitalWrite(direct4 , 0);

ard.digitalWrite(pulse4 , 0);

end

end

if(Xratio >0 && button(joy , 1)==1)

ard.digitalWrite(pulse2 , 1);

ard.digitalWrite(direct2 , 0);

ard.digitalWrite(pulse2 , 0);

ard.digitalWrite(pulse3 , 1);

ard.digitalWrite(direct3 , 1);

ard.digitalWrite(pulse3 , 0);

else

if(Xratio <0 && button(joy , 1)==1)

ard.digitalWrite(pulse2 , 1);

ard.digitalWrite(direct2 , 1);

Page 78: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 67

ard.digitalWrite(pulse2 , 0);

ard.digitalWrite(pulse3 , 1);

ard.digitalWrite(direct3 , 0);

ard.digitalWrite(pulse3 , 0);

end

end

if(Yratio == 0 && Xratio ==0 )

ard.digitalWrite(pulse ,0);

ard.digitalWrite(pulse2 ,0);

ard.digitalWrite(pulse3 ,0);

ard.digitalWrite(pulse4 ,0);

end

if(button(joy , 3)==1)

ard.digitalWrite(pulse5 , 1);

ard.digitalWrite(direct5 , 1);

ard.digitalWrite(pulse5 , 0);

end

if(button(joy , 4)==1)

ard.digitalWrite(pulse5 , 1);

ard.digitalWrite(direct5 , 0);

ard.digitalWrite(pulse5 , 0);

end

end

Page 79: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 68

C.2 Arduino Code

/* Analog and Digital Input and Output Server for MATLAB */

/* Giampiero Campa , Copyright 2012 The MathWorks , Inc */

/* This file is meant to be used with the MATLAB arduino IO

package , however , it can be used from the IDE environment

(or any other serial terminal) by typing commands like:

0e0 : assigns digital pin #4 (e) as input

0f1 : assigns digital pin #5 (f) as output

0n1 : assigns digital pin #13 (n) as output

1c : reads digital pin #2 (c)

1e : reads digital pin #4 (e)

2n0 : sets digital pin #13 (n) low

2n1 : sets digital pin #13 (n) high

2f1 : sets digital pin #5 (f) high

2f0 : sets digital pin #5 (f) low

4j2 : sets digital pin #9 (j) to 50= ascii (2) over 255

4jz : sets digital pin #9 (j) to 122= ascii(z) over 255

3a : reads analog pin #0 (a)

3f : reads analog pin #5 (f)

5j : reads status (attached/detached) of servo on pin #9

5k : reads status (attached/detached) of servo on pin #10

6j1 : attaches servo on pin #9

8jz : moves servo on pin #9 of 122 degrees (122= ascii(z))

7j : reads angle of servo on pin #9

6j0 : detaches servo on pin #9

E0cd : attaches encoder #0 (0) on pins 2 (c) and 3 (d)

E1st : attaches encoder #1 on pins 18 (s) and 19 (t)

E2vu : attaches encoder #2 on pins 21 (v) and 20 (u)

G0 : gets 0 position of encoder #0

I0u : sets debounce delay to 20 (2ms) for encoder #0

H1 : resets position of encoder #1

F2 : detaches encoder #2

R0 : sets analog reference to DEFAULT

R1 : sets analog reference to INTERNAL

R2 : sets analog reference to EXTERNAL

X3 : roundtrip example case returning the input (ascii (3))

99 : returns script type (0 adio.pde ... 3 motor.pde ) */

#include <Servo.h>

/* define internal for the MEGA as 1.1V (as as for the 328) */

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

#define INTERNAL INTERNAL1V1

#endif

/* define encoder structure */

Page 80: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 69

typedef struct int pinA; int pinB; int pos; int del; Encoder;

volatile Encoder Enc[3] = 0,0,0,0, 0,0,0,0, 0,0,0,0;

/* create servo vector */

Servo servo [70];

void setup()

/* initialize serial */

Serial.begin (115200);

void loop()

/* variables declaration and initialization */

static int s = -1; /* state */

static int pin = 13; /* generic pin number */

static int enc = 0; /* generic encoder number */

int val = 0; /* generic value read from serial */

int agv = 0; /* generic analog value */

int dgv = 0; /* generic digital value */

/* The following instruction constantly checks if anything

is available on the serial port. Nothing gets executed in

the loop if nothing is available to be read , but as soon

as anything becomes available , then the part coded after

the if statement (that is the real stuff) gets executed */

if (Serial.available () >0)

/* whatever is available from the serial is read here */

val = Serial.read ();

/* This part basically implements a state machine that

reads the serial port and makes just one transition

to a new state , depending on both the previous state

and the command that is read from the serial port.

Some commands need additional inputs from the serial

port , so they need 2 or 3 state transitions (each one

happening as soon as anything new is available from

the serial port) to be fully executed. After a command

is fully executed the state returns to its initial

value s=-1 */

switch (s)

/* s=-1 means NOTHING RECEIVED YET ******************* */

case -1:

/* calculate next state */

if (val >47 && val <90)

Page 81: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 70

/* the first received value indicates the mode

49 is ascii for 1, ... 90 is ascii for Z

s=0 is change -pin mode;

s=10 is DI; s=20 is DO; s=30 is AI; s=40 is AO;

s=50 is servo status; s=60 is aervo attach/detach;

s=70 is servo read; s=80 is servo write;

s=90 is query script type (1 basic , 2 motor);

s=210 is encoder attach; s=220 is encoder detach;

s=230 is get encoder position; s=240 is encoder reset;

s=250 is set encoder debounce delay;

s=340 is change analog reference;

s=400 example echo returning the input argument;

*/

s=10*(val -48);

/* the following statements are needed to handle

unexpected first values coming from the serial (if

the value is unrecognized then it defaults to s=-1) */

if ((s>90 && s <210) || (s>250 && s!=340 && s!=400))

s=-1;

/* the break statements gets out of the switch -case , so

/* we go back and wait for new serial data */

break; /* s=-1 (initial state) taken care of */

/* s=0 or 1 means CHANGE PIN MODE */

case 0:

/* the second received value indicates the pin

from abs(’c’)=99, pin 2, to abs(’:’)=166, pin 69 */

if (val >98 && val <167)

pin=val -97; /* calculate pin */

s=1; /* next we will need to get 0 or 1 from serial */

else

s=-1; /* if value is not a pin then return to -1 */

break; /* s=0 taken care of */

case 1:

/* the third received value indicates the value 0 or 1 */

if (val >47 && val <50)

/* set pin mode */

if (val ==48)

pinMode(pin ,INPUT);

else

pinMode(pin ,OUTPUT );

Page 82: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 71

s=-1; /* we are done with CHANGE PIN so go to -1 */

break; /* s=1 taken care of */

/* s=10 means DIGITAL INPUT ************************** */

case 10:

/* the second received value indicates the pin

from abs(’c’)=99, pin 2, to abs(’:’)=166, pin 69 */

if (val >98 && val <167)

pin=val -97; /* calculate pin */

dgv=digitalRead(pin); /* perform Digital Input */

Serial.println(dgv); /* send value via serial */

s=-1; /* we are done with DI so next state is -1 */

break; /* s=10 taken care of */

/* s=20 or 21 means DIGITAL OUTPUT ******************* */

case 20:

/* the second received value indicates the pin

from abs(’c’)=99, pin 2, to abs(’:’)=166, pin 69 */

if (val >98 && val <167)

pin=val -97; /* calculate pin */

s=21; /* next we will need to get 0 or 1 from serial */

else

s=-1; /* if value is not a pin then return to -1 */

break; /* s=20 taken care of */

case 21:

/* the third received value indicates the value 0 or 1 */

if (val >47 && val <50)

dgv=val -48; /* calculate value */

digitalWrite(pin ,dgv); /* perform Digital Output */

s=-1; /* we are done with DO so next state is -1 */

break; /* s=21 taken care of */

/* s=30 means ANALOG INPUT *************************** */

case 30:

/* the second received value indicates the pin

from abs(’a’)=97, pin 0, to abs(’p’)=112 , pin 15 */

if (val >96 && val <113)

pin=val -97; /* calculate pin */

agv=analogRead(pin); /* perform Analog Input */

Serial.println(agv); /* send value via serial */

Page 83: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 72

s=-1; /* we are done with AI so next state is -1 */

break; /* s=30 taken care of */

/* s=40 or 41 means ANALOG OUTPUT ******************** */

case 40:

/* the second received value indicates the pin

from abs(’c’)=99, pin 2, to abs(’:’)=166, pin 69 */

if (val >98 && val <167)

pin=val -97; /* calculate pin */

s=41; /* next we will need to get value from serial */

else

s=-1; /* if value is not a pin then return to -1 */

break; /* s=40 taken care of */

case 41:

/* the third received value indicates the analog value */

analogWrite(pin ,val); /* perform Analog Output */

s=-1; /* we are done with AO so next state is -1 */

break; /* s=41 taken care of */

/* s=50 means SERVO STATUS (ATTACHED/DETACHED) ******* */

case 50:

/* the second value indicates the servo attachment pin

from abs(’c’)=99, pin 2, to abs(’:’)=166, pin 69 */

if (val >98 && val <167)

pin=val -97; /* calculate pin */

dgv=servo[pin]. attached (); /* read status */

Serial.println(dgv); /* send value via serial */

s=-1; /* we are done with servo status so return to -1*/

break; /* s=50 taken care of */

/* s=60 or 61 means SERVO ATTACH/DETACH ************** */

case 60:

/* the second value indicates the servo attachment pin

from abs(’c’)=99, pin 2, to abs(’:’)=166, pin 69 */

if (val >98 && val <167)

pin=val -97; /* calculate pin */

s=61; /* next we will need to get 0 or 1 from serial */

else

s=-1; /* if value is not a servo then return to -1 */

Page 84: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 73

break; /* s=60 taken care of */

case 61:

/* the third received value indicates the value 0 or 1

0 for detach and 1 for attach */

if (val >47 && val <50)

dgv=val -48; /* calculate value */

if (dgv) servo[pin]. attach(pin); /* attach servo */

else servo[pin]. detach (); /* detach servo */

s=-1; /* we are done with servo attach/detach so -1 */

break; /* s=61 taken care of */

/* s=70 means SERVO READ ***************************** */

case 70:

/* the second value indicates the servo attachment pin

from abs(’c’)=99, pin 2, to abs(’:’)=166, pin 69 */

if (val >98 && val <167)

pin=val -97; /* calculate pin */

agv=servo[pin].read (); /* read value */

Serial.println(agv); /* send value via serial */

s=-1; /* we are done with servo read so go to -1 next */

break; /* s=70 taken care of */

/* s=80 or 81 means SERVO WRITE ******************** */

case 80:

/* the second value indicates the servo attachment pin

from abs(’c’)=99, pin 2, to abs(’:’)=166, pin 69 */

if (val >98 && val <167)

pin=val -97; /* calculate pin */

s=81; /* next we will need to get value from serial */

else

s=-1; /* if value is not a servo then return to -1 */

break; /* s=80 taken care of */

case 81:

/* the third received value indicates the servo angle */

servo[pin].write(val); /* write value */

s=-1; /* we are done with servo write so go to -1 next*/

break; /* s=81 taken care of */

/* s=90 means Query Script Type:

Page 85: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 74

(0 adio , 1 adioenc , 2 adiosrv , 3 motor) */

case 90:

if (val ==57)

/* if string sent is 99 send script type via serial */

Serial.println (2);

s=-1; /* we are done with this so next state is -1 */

break; /* s=90 taken care of */

/* s=210 to 212 means ENCODER ATTACH ***************** */

case 210:

/* the second value indicates the encoder number:

either 0, 1 or 2 */

if (val >47 && val <51)

enc=val -48; /* calculate encoder number */

s=211; /* next we need the first attachment pin */

else

s=-1; /* if value is not an encoder then return to -1*/

break; /* s=210 taken care of */

case 211:

/* the third received value indicates the first pin

from abs(’c’)=99, pin 2, to abs(’:’)=166, pin 69 */

if (val >98 && val <167)

pin=val -97; /* calculate pin */

Enc[enc].pinA=pin; /* set pin A */

s=212; /* next we need the second attachment pin */

else

s=-1; /* if value is not a servo then return to -1 */

break; /* s=211 taken care of */

case 212:

/* the fourth received value indicates the second pin

from abs(’c’)=99, pin 2, to abs(’:’)=166, pin 69 */

if (val >98 && val <167)

pin=val -97; /* calculate pin */

Enc[enc].pinB=pin; /* set pin B */

/* set encoder pins as inputs */

pinMode(Enc[enc].pinA , INPUT);

pinMode(Enc[enc].pinB , INPUT);

/* turn on pullup resistors */

digitalWrite(Enc[enc].pinA , HIGH);

digitalWrite(Enc[enc].pinB , HIGH);

Page 86: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 75

/* attach interrupts */

switch(enc)

case 0:

attachInterrupt(getIntNum(Enc [0]. pinA), isrPinAEn0 , CHANGE );

attachInterrupt(getIntNum(Enc [0]. pinB), isrPinBEn0 , CHANGE );

break;

case 1:

attachInterrupt(getIntNum(Enc [1]. pinA), isrPinAEn1 , CHANGE );

attachInterrupt(getIntNum(Enc [1]. pinB), isrPinBEn1 , CHANGE );

break;

case 2:

attachInterrupt(getIntNum(Enc [2]. pinA), isrPinAEn2 , CHANGE );

attachInterrupt(getIntNum(Enc [2]. pinB), isrPinBEn2 , CHANGE );

break;

s=-1; /* we are done with encoder attach so -1 */

break; /* s=212 taken care of */

/* s=220 means ENCODER DETACH *********************** */

case 220:

/* the second value indicates the encoder number:

either 0, 1 or 2 */

if (val >47 && val <51)

enc=val -48; /* calculate encoder number */

/* detach interrupts */

detachInterrupt(getIntNum(Enc[enc].pinA ));

detachInterrupt(getIntNum(Enc[enc].pinB ));

s=-1; /* we are done with encoder detach so -1 */

break; /* s=220 taken care of */

/* s=230 means GET ENCODER POSITION ****************** */

case 230:

/* the second value indicates the encoder number:

either 0, 1 or 2 */

if (val >47 && val <51)

enc=val -48; /* calculate encoder number */

/* send the value back */

Serial.println(Enc[enc].pos);

s=-1; /* we are done with encoder detach so -1 */

break; /* s=230 taken care of */

/* s=240 means RESET ENCODER POSITION **************** */

case 240:

/* the second value indicates the encoder number:

Page 87: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 76

either 0, 1 or 2 */

if (val >47 && val <51)

enc=val -48; /* calculate encoder number */

/* reset position */

Enc[enc].pos =0;

s=-1; /* we are done with encoder detach so -1 */

break; /* s=240 taken care of */

/* s=250 and 251 mean SET ENCODER DEBOUNCE DELAY ***** */

case 250:

/* the second value indicates the encoder number:

either 0, 1 or 2 */

if (val >47 && val <51)

enc=val -48; /* calculate encoder number */

s=251; /* next we need the first attachment pin */

else

s=-1; /* if value is not an encoder then return to -1*/

break; /* s=250 taken care of */

case 251:

/* the third received value indicates the debounce

delay value in units of approximately 0.1 ms each

from abs(’a’)=97, 0 units , to abs(’:’)=166, 69 units*/

if (val >96 && val <167)

Enc[enc].del=val -97; /* set debounce delay */

s=-1; /* we are done with this so next state is -1 */

break; /* s=251 taken care of */

/* s=340 or 341 means ANALOG REFERENCE *************** */

case 340:

/* the second received value indicates the reference ,

which is encoded as is 0,1,2 for DEFAULT , INTERNAL

and EXTERNAL , respectively. Note that this function

is ignored for boards not featuring AVR or PIC32 */

#if defined(__AVR__) || defined(__PIC32MX__)

switch (val)

case 48:

analogReference(DEFAULT );

break;

case 49:

analogReference(INTERNAL );

Page 88: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 77

break;

case 50:

analogReference(EXTERNAL );

break;

default: /* unrecognized , no action */

break;

#endif

s=-1; /* we are done with this so next state is -1 */

break; /* s=341 taken care of */

/* s=400 roundtrip example function (returns the input )*/

case 400:

/* the second value (val) can really be anything here */

/* This is an auxiliary function that returns the ASCII

value of its first argument. It is provided as an

example for people that want to add their own code */

/* your own code goes here instead of the serial print */

Serial.println(val);

s=-1; /* we are done with the aux function so -1 */

break; /* s=400 taken care of */

/* ******* UNRECOGNIZED STATE , go back to s=-1 ******* */

default:

/* we should never get here but if we do it means we

are in an unexpected state so whatever is the second

received value we get out of here and back to s=-1 */

s=-1; /* go back to the initial state , break unneeded */

/* end switch on state s */

/* end if serial available */

/* end loop statement */

/* auxiliary function to handle encoder attachment */

Page 89: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 78

int getIntNum(int pin)

/* returns the interrupt number for a given interrupt pin

see http :// arduino.cc/it/Reference/AttachInterrupt */

switch(pin)

case 2:

return 0;

case 3:

return 1;

case 21:

return 2;

case 20:

return 3;

case 19:

return 4;

case 18:

return 5;

default:

return -1;

/* auxiliary debouncing function */

void debounce(int del)

int k;

for (k=0;k<del;k++)

/* can ’t use delay in the ISR so need to waste some time

perfoming operations , this uses roughly 0.1ms on uno */

k = k +0.0 +0.0 -0.0 +3.0 -3.0;

/* Interrupt Service Routine: change on pin A for Encoder 0 */

void isrPinAEn0 ()

/* read pin B right away */

int drB = digitalRead(Enc [0]. pinB);

/* possibly wait before reading pin A, then read it */

debounce(Enc [0]. del);

int drA = digitalRead(Enc [0]. pinA);

/* this updates the counter */

if (drA == HIGH) /* low ->high on A? */

if (drB == LOW) /* check pin B */

Enc [0]. pos++; /* going clockwise: increment */

else

Enc [0].pos --; /* going counterclockwise: decrement */

else /* must be high to low on A */

if (drB == HIGH) /* check pin B */

Page 90: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 79

Enc [0]. pos++; /* going clockwise: increment */

else

Enc [0].pos --; /* going counterclockwise: decrement */

/* end counter update */

/* end ISR pin A Encoder 0 */

/* Interrupt Service Routine: change on pin B for Encoder 0 */

void isrPinBEn0 ()

/* read pin A right away */

int drA = digitalRead(Enc [0]. pinA);

/* possibly wait before reading pin B, then read it */

debounce(Enc [0]. del);

int drB = digitalRead(Enc [0]. pinB);

/* this updates the counter */

if (drB == HIGH) /* low ->high on B? */

if (drA == HIGH) /* check pin A */

Enc [0]. pos++; /* going clockwise: increment */

else

Enc [0].pos --; /* going counterclockwise: decrement */

else /* must be high to low on B */

if (drA == LOW) /* check pin A */

Enc [0]. pos++; /* going clockwise: increment */

else

Enc [0].pos --; /* going counterclockwise: decrement */

/* end counter update */

/* end ISR pin B Encoder 0 */

/* Interrupt Service Routine: change on pin A for Encoder 1 */

void isrPinAEn1 ()

/* read pin B right away */

int drB = digitalRead(Enc [1]. pinB);

/* possibly wait before reading pin A, then read it */

debounce(Enc [1]. del);

int drA = digitalRead(Enc [1]. pinA);

/* this updates the counter */

if (drA == HIGH) /* low ->high on A? */

Page 91: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 80

if (drB == LOW) /* check pin B */

Enc [1]. pos++; /* going clockwise: increment */

else

Enc [1].pos --; /* going counterclockwise: decrement */

else /* must be high to low on A */

if (drB == HIGH) /* check pin B */

Enc [1]. pos++; /* going clockwise: increment */

else

Enc [1].pos --; /* going counterclockwise: decrement */

/* end counter update */

/* end ISR pin A Encoder 1 */

/* Interrupt Service Routine: change on pin B for Encoder 1 */

void isrPinBEn1 ()

/* read pin A right away */

int drA = digitalRead(Enc [1]. pinA);

/* possibly wait before reading pin B, then read it */

debounce(Enc [1]. del);

int drB = digitalRead(Enc [1]. pinB);

/* this updates the counter */

if (drB == HIGH) /* low ->high on B? */

if (drA == HIGH) /* check pin A */

Enc [1]. pos++; /* going clockwise: increment */

else

Enc [1].pos --; /* going counterclockwise: decrement */

else /* must be high to low on B */

if (drA == LOW) /* check pin A */

Enc [1]. pos++; /* going clockwise: increment */

else

Enc [1].pos --; /* going counterclockwise: decrement */

/* end counter update */

/* end ISR pin B Encoder 1 */

/* Interrupt Service Routine: change on pin A for Encoder 2 */

void isrPinAEn2 ()

Page 92: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 81

/* read pin B right away */

int drB = digitalRead(Enc [2]. pinB);

/* possibly wait before reading pin A, then read it */

debounce(Enc [2]. del);

int drA = digitalRead(Enc [2]. pinA);

/* this updates the counter */

if (drA == HIGH) /* low ->high on A? */

if (drB == LOW) /* check pin B */

Enc [2]. pos++; /* going clockwise: increment */

else

Enc [2].pos --; /* going counterclockwise: decrement */

else /* must be high to low on A */

if (drB == HIGH) /* check pin B */

Enc [2]. pos++; /* going clockwise: increment */

else

Enc [2].pos --; /* going counterclockwise: decrement */

/* end counter update */

/* end ISR pin A Encoder 2 */

/* Interrupt Service Routine: change on pin B for Encoder 2 */

void isrPinBEn2 ()

/* read pin A right away */

int drA = digitalRead(Enc [2]. pinA);

/* possibly wait before reading pin B, then read it */

debounce(Enc [2]. del);

int drB = digitalRead(Enc [2]. pinB);

/* this updates the counter */

if (drB == HIGH) /* low ->high on B? */

if (drA == HIGH) /* check pin A */

Enc [2]. pos++; /* going clockwise: increment */

else

Enc [2].pos --; /* going counterclockwise: decrement */

else /* must be high to low on B */

if (drA == LOW) /* check pin A */

Enc [2]. pos++; /* going clockwise: increment */

else

Enc [2].pos --; /* going counterclockwise: decrement */

Page 93: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 82

/* end counter update */

/* end ISR pin B Encoder 2 */

Page 94: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 83

C.3 Feature Tracking Code

This code is used to track the tip of the flexible needle and plots the path of the end-

effector on the xy-plan.

% Capture the video frames using the videoinput function

% You have to replace the resolution & your installed adaptor name.

vid = videoinput(’winvideo ’, 2);

% Set the properties of the video object

set(vid , ’FramesPerTrigger ’, Inf);

set(vid , ’ReturnedColorspace ’, ’rgb ’)

vid.FrameGrabInterval = 5;

%start the video aquisition here

start(vid)

path = [0 ,0];

% Set a loop that stop after 100 frames of aquisition

while(vid.FramesAcquired <=200)

% Get the snapshot of the current frame

data = getsnapshot(vid);

% Now to track red objects in real time

% we have to subtract the red component

% from the grayscale image to extract the red components in the image.

diff_im = imsubtract(data(:,:,1), rgb2gray(data ));

%Use a median filter to filter out noise

diff_im = medfilt2(diff_im , [3 3]);

% Convert the resulting grayscale image into a binary image.

diff_im = im2bw(diff_im ,0.18);

% Remove all those pixels less than 300px

diff_im = bwareaopen(diff_im ,300);

% Label all the connected components in the image.

bw = bwlabel(diff_im , 8);

% Here we do the image blob analysis.

% We get a set of properties for each labeled region.

stats = regionprops(bw, ’BoundingBox ’, ’Centroid ’);

% Display the image

imshow(data)

hold on

%This is a loop to bound the red objects in a rectangular box.

for object = 1: length(stats)

bb = stats(object ). BoundingBox;

bc = stats(object ). Centroid;

rectangle(’Position ’,bb,’EdgeColor ’,’r’,’LineWidth ’,2)

plot(bc(1),bc(2), ’-m+’)

Page 95: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 84

a=text(bc(1)+15 ,bc(2), strcat(’X: ’,

num2str(round(bc(1))), ’ Y: ’,

num2str(round(bc (2)))));

set(a, ’FontName ’, ’Arial ’, ’FontWeight ’,

’bold ’, ’FontSize ’, 12, ’Color ’, ’yellow ’);

% if(button(joy , 7)==1)

path(vid.FramesAcquired ,1) = bc(1);

path(vid.FramesAcquired ,2) = bc(2);

% end

%x=path (:,1);

%y=path (:,2);

plot(smooth(path (:,1)), smooth(path(:,2)),’k’,’Linewidth ’ ,10);

end

hold off

end

%%

figure , plot(smooth(path(:,1)), smooth(path(:,2)),’b’,’linewidth ’,5);

% Both the loops end here.

% Stop the video aquisition.

stop(vid);

% Flush all the image data stored in the memory buffer.

flushdata(vid);

% Clear all variables

clear all

Page 96: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Bibliography

[1] T. Benhidjeb, T. Wilhelm, J. Harlaar, G.-J. Kleinrensink, T. A. Schneider, and

M. Stark, “Natural orifice surgery on thyroid gland: totally transoral video-

assisted thyroidectomy (tovat): report of first experimental results of a new surgical

method,” Surgical endoscopy, vol. 23, no. 5, pp. 1119–1120, May 2009.

[2] S.-L. Yan and M. Thompson-Fawcett, “Notes: new dimension of minimally invasive

surgery,” ANZ Journal of Surgery, vol. 79, no. 5, pp. 337–343, May 2009.

[3] (2015) Intuitive surgical @ONLINE. http://www.davincisurgery.com/.

[4] R. J. Webster, III and B. A. Jones, “Design and kinematic modeling of constant

curvature continuum robots: A review,” Int. J. Rob. Res., vol. 29, no. 13, pp.

1661–1683, November 2010.

[5] G. Lum, S. Mustafa, H. Lim, W. Lim, G. Yang, and S. Yeo, “Design and mo-

tion control of a cable-driven dexterous robotic arm,” in Sustainable Utilization

and Development in Engineering and TECHNOLOGY (STUDENT), 2010 IEEE

Conference on, November 2010, pp. 106–111.

[6] K. Xu, R. E. Goldman, J. Ding, P. K. Allen, D. L. Fowler, and N. Simaan, “Sys-

tem design of an insertable robotic effector platform for single port access (spa)

surgery,” in Intelligent Robots and Systems, 2009. IROS 2009. IEEE/RSJ Interna-

tional Conference on. IEEE, 2009, pp. 5546–5552.

[7] D. B. Camarillo, C. F. Milne, C. R. Carlson, M. R. Zinn, and J. K. Salisbury,

“Mechanics modeling of tendon-driven continuum manipulators,” Robotics, IEEE

Transactions on, vol. 24, no. 6, pp. 1262–1273, 2008.

[8] I. A. Gravagne, C. D. Rahn, and I. D. Walker, “Large deflection dynamics and

control for planar continuum robots,” IEEE/ASME Transactions on Mechatronics,

vol. 8, no. 2, pp. 299–307, 2003.

[9] W. McMahan, V. Chitrakaran, M. Csencsits, D. Dawson, I. D. Walker, B. A. Jones,

M. Pritts, D. Dienno, M. Grissom, and C. D. Rahn, Field trials and testing of the

OctArm continuum manipulator, 2006, vol. 2006, pp. 2336–2341.

85

Page 97: Bilateral Control of a Continuum Robot for Targeted Drug ...Declaration of Authorship I, Omar S. Abdellatif, declare that this thesis titled, ’Bilateral Control of a continuum robot

Appendix C. Codes 86

[10] G. Robinson and J. B. C. Davies, “Continuum robots - a state of the art,” in

Proceedings 1999 IEEE International Conference on Robotics and Automation (Cat.

No.99CH36288C). IEEE, pp. 2849–2854.

[11] (2015) Miniature robot arms tackle blood clots in the brain — micro-

manufacturing @ONLINE. http://www.micromanufacturing.com/content/

active-cannulas-miniature-robot-arms-tackle-blood-clots-brain.

[12] J. Vertut and P. Coiffet, Teleoperations and Robotics: Evolution and Development,

Robot Technology. Englewood Cliffs: Prentice Hall, 1986, vol. 3A.

[13] J. Vertut, R. Fournier, B. Espiau, and G. Andre, “Advances in a computer aided

bilateral manipulator system,” in Robotics and remote handling in hostile environ-

ments. USA: American Nuclear Society, 1984, pp. 367–374.

[14] Bejczy, A.K. and Handlykken, M., “Generalization of bilateral force-reflecting con-

trol of manipulators,” in Proc. of the 4th RO.MAN.SY, 1981, pp. 242–255.

[15] G. J. Raju, “Operator adjustable impedance in bilateral remote manipulation,”

Ph.D. dissertation, Massachusetts Institute of Technology, 1988.

[16] B. Hannaford, “Stability and performance tradeoffs in bi-lateral telemanipulation,”

in Robotics and Automation, 1989. Proceedings., 1989 IEEE International Confer-

ence on. IEEE, 1989, pp. 1764–1767.

[17] J. Dudragne, C. Andriot, R. Fournier, and J. Vuillemey, “A generalized bilateral

control applied to master-slave manipulators,” in 20th ISIR, 1989, pp. 435–442.

[18] S. H. Ahn and J. S. Yoon, “A bilateral control scheme for 2-dof telemanipulators

with control input saturation,” Control Engineering Practice, vol. 10, no. 10, pp.

1081–1090, 2002.

[19] M. Hannan and I. Walker, “Theelephant trunk’manipulator, design and im-

plementation,” in Advanced Intelligent Mechatronics, 2001. Proceedings. 2001

IEEE/ASME International Conference on, vol. 1. IEEE, 2001, pp. 14–19.

[20] B. A. Jones and I. D. Walker, “Kinematics for multisection continuum robots,”

Robotics, IEEE Transactions on, vol. 22, no. 1, pp. 43–55, 2006.

[21] A. J. Klijn, M. Asselman, M. A. Vijverberg, P. Dik et al., “The diameter of the

rectum on ultrasonography as a diagnostic tool for constipation in children with

dysfunctional voiding,” The Journal of urology, vol. 172, no. 5, pp. 1986–1988,

2004.