DESIGNING AND CONSTRUCTING SWARM ... - SGU Repository

12
DESIGNING AND CONSTRUCTING SWARM ROBOT SYSTEM CASE : INTERCOMMUNICATION SUBSYSTEM By Aaron Richard Wijaya 11110001 A thesis submitted to the Faculty of Engineering and Information Technology In partial fulfillment of the Requirements of the BACHELOR’S DEGREE in MECHATRONICS ENGINEERING SWISS GERMAN UNIVERSITY EduTown BSD City Tangerang 15339 Indonesia Revision after the thesis defense on 15 July 2014

Transcript of DESIGNING AND CONSTRUCTING SWARM ... - SGU Repository

DESIGNING AND CONSTRUCTING SWARM ROBOT SYSTEM

CASE : INTERCOMMUNICATION SUBSYSTEM

By

Aaron Richard Wijaya

11110001

A thesis submitted to the Faculty of

Engineering and Information Technology

In partial fulfillment of the

Requirements of the

BACHELOR’S DEGREE

in

MECHATRONICS ENGINEERING

SWISS GERMAN UNIVERSITY

EduTown BSD City

Tangerang 15339

Indonesia

Revision after the thesis defense on 15 July 2014

DESIGNING AND CONSTRUCTING SWARM ROBOT SYSTEM

CASE : INTERCOMMUNICATION SUBSYSTEM Page 2 of 140

Aaron Richard Wijaya

STATEMENT BY THE AUTHOR

I hereby declare that this submission is my own work and to the best of my

knowledge, it contains no material previously published or written by another person,

nor material which to a substantial extent has been accepted for the award of any

other degree or diploma at any educational institution, except where due

acknowledgement is made in the thesis.

Aaron Richard Wijaya

_____________________________________________

Student

Date

Approved by:

Dr. Rusman Rusyadi

_____________________________________________

Thesis Advisor

Date

Dipl.-Ing. Maralo Sinaga

_____________________________________________

Thesis Co-Advisor

Date

Dr. Ir. Gembong Baskoro, M.Sc

_____________________________________________

Dean

Date

DESIGNING AND CONSTRUCTING SWARM ROBOT SYSTEM

CASE : INTERCOMMUNICATION SUBSYSTEM Page 3 of 140

Aaron Richard Wijaya

ABSTRACT

DESIGNING AND CONSTRUCTING SWARM ROBOT SYSTEM

CASE: INTERCOMMUNICATION SUBSYSTEM

By

Aaron Richard Wijaya

Dr. Rusman Rusyadi, Advisor

Dipl.-Ing. Maralo Sinaga, Co-Advisor

SWISS GERMAN UNIVERSITY

The purpose of this thesis project is to design communication system between

multiple robots for coordination in swarm robot system. This thesis project also

focuses on the use of Firmata protocol, a protocol that is used for communication

between the host computer and the microcontroller. Communication between the

members will utilize User Datagram Protocol (UDP) for a faster data transmission,

but with the cost of reliability. To coordinate with other members, informations are

being broadcasted by each robot rapidly.

This thesis project comes to a conclusion that the use of UDP as the protocol in data

transmission on local network is proven to be reliable and fast. The members are able

to communicate with each other with minimum error in data transmission.

Communication between the host computer and the microcontroller using Firmata

protocol is also successfully done.

Designing of swarm robot system is done together as a group project with Gandhi

Winata, Glenn Vialli, and Elmore Eleazar Sinurat in driver system, vision system, and

formation configuration system respectively.

Keywords: Swarm robotics, UDP, Firmata, Broadcast, Multicast, Formation

Coordination.

DESIGNING AND CONSTRUCTING SWARM ROBOT SYSTEM

CASE : INTERCOMMUNICATION SUBSYSTEM Page 4 of 140

Aaron Richard Wijaya

© Copyright 2014

by Aaron Richard Wijaya

All rights reserved

DESIGNING AND CONSTRUCTING SWARM ROBOT SYSTEM

CASE : INTERCOMMUNICATION SUBSYSTEM Page 5 of 140

Aaron Richard Wijaya

DEDICATION

I dedicate this work to my parents, friends and the future of Mechatronics

Engineering, Faculty of Engineering and Information Technology in Swiss German

University.

DESIGNING AND CONSTRUCTING SWARM ROBOT SYSTEM

CASE : INTERCOMMUNICATION SUBSYSTEM Page 6 of 140

Aaron Richard Wijaya

ACKNOWLEDGEMENTS

I wish to express my gratitude for my advisor and co-advisor, Dr. Rusman Rusyadi

and Dipl.-Ing. Maralo Sinaga. Their humble guidance throughout the completion of

the thesis project was most helpful.

Amarendra Putra Wijaya, Gandhi Winata, Elmore Eleazar, and Glenn Vialli, as the

members of my group project, had been really supportive and cooperative during all

sorts of the process.

Special thanks to Stevie Andrea Lucardi, Jonathan Marshell Kevin, Linda Wijaya,

Evan Petra, Victorino, Tommy Gunawan, Jeffrey Ardi Santoso, and all of MT friends

who have helped me in completing this thesis work.

DESIGNING AND CONSTRUCTING SWARM ROBOT SYSTEM

CASE : INTERCOMMUNICATION SUBSYSTEM Page 7 of 140

Aaron Richard Wijaya

TABLE OF CONTENTS

STATEMENT BY THE AUTHOR ............................................................................... 2

ABSTRACT ................................................................................................................... 3

DEDICATION ............................................................................................................... 5

ACKNOWLEDGEMENTS ........................................................................................... 6

TABLE OF CONTENTS ............................................................................................... 7

LIST OF FIGURES ..................................................................................................... 10

LIST OF TABLES ....................................................................................................... 12

CHAPTER 1 – INTRODUCTION ........................................................................... 13

1.1 Background .................................................................................................. 13

1.2 Thesis Purpose ............................................................................................. 13

1.3 Thesis Scope ................................................................................................ 14

1.4 Limitation ..................................................................................................... 14

1.5 Thesis Structure ........................................................................................... 14

1.6 Thesis Division ............................................................................................ 15

CHAPTER 2 – LITERATURE REVIEW ................................................................ 17

2.1 Introduction .................................................................................................. 17

2.2 Swarm Robotics ........................................................................................... 17

2.3 Data Communication ................................................................................... 17

2.3.1 IP Address .............................................................................................. 18

2.3.2 User Datagram Protocol ......................................................................... 19

2.4 Review of Existing Research and Project .................................................... 21

2.4.1 Firmata: Towards making microcontrollers act like extensions of the

computer .......................................................................................................... 21

CHAPTER 3 - METHODOLOGY ......................................................................... 24

3.1 System Features ........................................................................................... 24

3.2 System Design Overview ............................................................................. 26

3.2.1 Camera ................................................................................................... 26

3.2.2 Rotary Encoder ...................................................................................... 27

3.2.3 Ultrasonic Ranging Module ................................................................... 29

3.2.4 Mini-PC.................................................................................................. 30

DESIGNING AND CONSTRUCTING SWARM ROBOT SYSTEM

CASE : INTERCOMMUNICATION SUBSYSTEM Page 8 of 140

Aaron Richard Wijaya

3.2.5 DC Motor ............................................................................................... 36

3.2.6 Motor Driver .......................................................................................... 37

3.2.7 Servomotor ............................................................................................. 38

3.3 Mechanical System Design .......................................................................... 39

3.3.1 Chassis and Body ................................................................................... 39

3.3.2 Driving Wheel Mounting ....................................................................... 40

3.4 Electrical Design .......................................................................................... 41

3.4.1 Motor Selection ...................................................................................... 41

3.4.2 Power Supply Selection ......................................................................... 41

3.5 Software Design ........................................................................................... 43

3.5.1 Installing XUBUNTU Operating System .............................................. 43

3.5.2 Installing Qt and OpenCV ..................................................................... 43

3.5.3 Configuring Qt and OpenCV ................................................................. 44

3.5.4 Arduino IDE and Firmata ...................................................................... 44

3.5.5 UDP........................................................................................................ 51

3.6 Formation Coordination ............................................................................... 53

3.6.1 Column Formation ................................................................................. 54

3.6.2 Line Formation....................................................................................... 56

3.6.3 Reverse-V Formation ............................................................................. 60

CHAPTER 4 – RESULTS AND DISCUSSIONS ................................................... 62

4.1 Subsystem Test ............................................................................................ 62

4.1.1 Firmata Protocol Testing........................................................................ 62

4.1.2 UDP Reliability Testing ......................................................................... 65

4.1.3 Odometry Testing .................................................................................. 68

4.2 Integration Test ............................................................................................ 69

4.2.1 Robot Detection and Following by Colour Detection Testing .............. 69

4.2.2 Information Sending Testing ................................................................. 70

CHAPTER 5 – CONCLUSIONS AND RECOMENDATIONS ............................. 73

5.1 Conclusions .................................................................................................. 73

5.2 Recommendation and Further Development ............................................... 73

GLOSSARY ................................................................................................................ 74

DESIGNING AND CONSTRUCTING SWARM ROBOT SYSTEM

CASE : INTERCOMMUNICATION SUBSYSTEM Page 9 of 140

Aaron Richard Wijaya

REFERENCES ............................................................................................................ 75

APPENDICES ............................................................................................................. 76

APPENDIX A – Data Sheet .................................................................................... 76

A.1 ODROID U3 ............................................................................................. 76

A.2 Towerpro MG945 ..................................................................................... 78

APPENDIX B – Programming Code ....................................................................... 79

B.1 Controller.h ............................................................................................... 79

B.2 Encoder.h................................................................................................... 81

B.3 Firmata.h ................................................................................................... 82

B.4 kamera.h .................................................................................................... 84

B.5 Keiptur.h .................................................................................................... 86

B.6 Mainwindow.h........................................................................................... 87

B.7 Serial.h....................................................................................................... 88

B.8 Socket.h ..................................................................................................... 89

B.9 Controller.cpp ............................................................................................ 91

B.10 Encoder.cpp ........................................................................................... 103

B.11 Firmata.cpp ............................................................................................ 104

B.12 Kamera.cpp ........................................................................................... 110

B.13 keiptur.cpp ............................................................................................. 115

B.14 Main.cpp ................................................................................................ 116

B.15 mainwindow.cpp ................................................................................... 117

B.16 Serial.cpp ............................................................................................... 118

B.17 Socket.cpp ............................................................................................. 124

B.18 StandardFirmata.ino .............................................................................. 126

APPENDIX C – Bill of Materials.......................................................................... 139

CURICULUM VITAE............................................................................................... 140

DESIGNING AND CONSTRUCTING SWARM ROBOT SYSTEM

CASE : INTERCOMMUNICATION SUBSYSTEM Page 10 of 140

Aaron Richard Wijaya

LIST OF FIGURES

Figure Page

Figure 2.1 The seven layers of OSI ............................................................................. 20

Figure 2.2 UDP Datagram Composition ...................................................................... 21

Figure 2.3 Some devices that work with Firmata ........................................................ 22

Figure 3.1 Mobile Robot System Block Diagram ....................................................... 24

Figure 3.2 Swarm Robotics System Design ................................................................ 26

Figure 3.3 Logitech HD Webcam c270h ..................................................................... 27

Figure 3.4 Rotary Incremental Encoder with 64 CPR ................................................. 28

Figure 3.5 HC-SR04 Ultrasonic Distance Sensor ........................................................ 30

Figure 3.6 ODROID-U3 .............................................................................................. 31

Figure 3.7 Detailed information of ODROID-U3 board ............................................. 33

Figure 3.8 ODROID-U3 Block Diagram ..................................................................... 33

Figure 3.9 ODROI-U3 I/O Shield ................................................................................ 34

Figure 3.10 Two blocks of ODROID-U3 IO expander ............................................... 34

Figure 3.11 HardKernel Wi-Fi Module and Board Details ......................................... 35

Figure 3.12 30:1 Metal Gear-Motor 37Dx52Lmm with 64 CPR Encoder .................. 36

Figure 3.13 Double H Driver Module.......................................................................... 37

Figure 3.14 TowerPro MG945 Servomotor ................................................................. 39

Figure 3.15 Mechanical 3D Design of Mobile Robot.................................................. 40

Figure 3.16 Pololu Wheel 80x10mm Pair - Black ....................................................... 40

Figure 3.17 Hi-Rice PowerBank .................................................................................. 42

Figure 3.18 Turnigy 2200mAh 3S 30C Battery Pack .................................................. 42

Figure 3.19 Win32 Disk Imager Window.................................................................... 43

Figure 3.20 Arduino IDE with StandardFirmata Library ............................................ 45

Figure 3.21 Firmata Program Flowchart ...................................................................... 47

Figure 3.22 Firmata Initialization Process Flowchart .................................................. 48

Figure 3.23 Firmata Do Message Flowchart ................................................................ 49

Figure 3.24 Pulse Width Modulation (PWM) Duty Cycle .......................................... 50

Figure 3.25 Unicast, Broadcast, and Multicast Service ............................................... 51

Figure 3.26 Swarm Network Topology ....................................................................... 52

DESIGNING AND CONSTRUCTING SWARM ROBOT SYSTEM

CASE : INTERCOMMUNICATION SUBSYSTEM Page 11 of 140

Aaron Richard Wijaya

Figure 3.27 Swarm Message Format ........................................................................... 52

Figure 3.28 Example of UDP message received from robot number 1 (leader) .......... 53

Figure 3.29 Information flow from leader to members ............................................... 53

Figure 3.30 Swarm Robot Formation Flowchart ......................................................... 54

Figure 3.31 Column Formation.................................................................................... 55

Figure 3.32 Swarm Member Follower Column Formation Flowchart ........................ 56

Figure 3.33 Line Formation ......................................................................................... 57

Figure 3.34 Swarm Member Follower Line Formation Flowchart.............................. 58

Figure 3.35 Follower Camera Red and Green Detection ............................................. 59

Figure 3.36 Reverse-V Formation ............................................................................... 60

Figure 4.1 Pin connection from I/O Shield pin D3 to COM3LAB oscilloscope ......... 63

Figure 4.2 PWM output of pin 3 .................................................................................. 64

Figure 4.3 Digital output of pin 11 .............................................................................. 65

Figure 4.4 Received message count on the receiver side ............................................. 67

Figure 4.5 Sent data count on the sender side .............................................................. 67

Figure 4.6 Mobile robot trajectory ............................................................................... 69

Figure 4.7 Robot following process ............................................................................. 70

Figure 4.8 Received command from the leader ........................................................... 72

DESIGNING AND CONSTRUCTING SWARM ROBOT SYSTEM

CASE : INTERCOMMUNICATION SUBSYSTEM Page 12 of 140

Aaron Richard Wijaya

LIST OF TABLES

Table Page

Table 1.1 Task Division of Swarm Robot Project ....................................................... 16

Table 2.1 IP address classification ............................................................................... 19

Table 3.1 Encoder Wires Functions ............................................................................. 28

Table 3.2 HC-SR04 Ultrasonic Distance Sensor Specifications ................................. 30

Table 3.3 ODROID-U3 specification .......................................................................... 31

Table 3.4 Board Details Specification ......................................................................... 32

Table 3.5 I/O Shield Pin Configuration ....................................................................... 35

Table 3.6 30:1 Pololu DC Motor Specification ........................................................... 36

Table 3.7 TowerPro MG945 Servomotor Specification .............................................. 38

Table 3.8 Firmata Message Header ............................................................................. 46

Table 4.1 Output Pin Configuration............................................................................. 62

Table 4.2 UDP reliability for broadcasting interval of 1 second ................................. 66

Table 4.3 UDP reliability for broadcasting interval of 500ms..................................... 66

Table 4.4 UDP reliability for broadcasting interval of 100ms..................................... 66

Table 4.5 UDP reliability for broadcasting interval of 50ms....................................... 66

Table 4.6 Odometry testing measurement ................................................................... 68