By William Irawan
11112043
BACHELOR’S DEGREE in
MECHANICAL ENGINEERING – MECHATRONICS CONCENTRATION FACULTY OF ENGINEERING AND INFORMATION TECHNOLOGY
SWISS GERMAN UNIVERSITY EduTown BSD City
Tangerang 15339 INDONESIA
August 2016
Revision after Thesis Defense on 18th July 2016
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.
William Irawan
____________________________________________
Student Date
Approved by:
Dr. Eka Budiarto, S.T, M.Sc
____________________________________________
Thesis Advisor Date
Dr. Rusman Rusyadi, B.Eng, M.Sc
____________________________________________
Thesis Co-Advisor Date
Dr. Ir. Gembong Baskoro, M.Sc
____________________________________________
Dean Date
William Irawan ABSTRACT
DESIGNING AND CONSTRUCTING A CAR SIMULATOR:
INTEGRATION OF VISUALIZATION TO CAR SIMULATOR
By William Irawan
Dr. Eka Budiarto, S.T, M.Sc, Advisor Dr. Rusman Rusyadi, B.Eng, M.Sc, Co-Advisor
SWISS GERMAN UNIVERSITY
The main purpose of this thesis project was to design and develop a program to extract and communicate telemetry data from racing games to the car simulator in real time.
To achieve this objective, software to extract the telemetry data from the game was created using Qt Creator in C++. The code was written based on existing program called SimTool. Game raw data will be sent to port and IP that are specified in the configuration file of the game. The game used in this thesis project is Dirt 3 and it communicates with the program via UDP communication. Qt program listens to data that are sent by the game and the data will be sent to Arduino Mega via Firmata protocol for motion control. Dirt3 and the Qt programs were installed on one computer. There are two monitors for this project, one for the game visualization and the other is for the game dashboard and motion simulator configuration. The other objective of this thesis is to make a user friendly HMI that provides the user ability to configure the simulator and reading sensor and telemetry data. The interface is responsive enough to be used for configuring the motion simulator and reading the data with the 6% ± 2% average error of the simulation motion control and below 1%
data loss for reading the game telemetry data.
Keywords: Car Simulator, UDP, Telemetry Data, Qt Framework, Firmata.
© Copyright 2016 by William Irawan All rights reserved
William Irawan DEDICATION
I dedicate this work to Jesus Christ,
My family, who have support me through this thesis projects, My friends and teachers who have been my source of inspiration,
My country, Indonesia,
, and to all car simulator researchers for their help, support, and time throughout my thesis work.
ACKNOWLEDGEMENTS
The author would like to express my gratitude first and foremost to my advisor, Dr.
Eka Budiarto, S.T, M.Sc., for his guidance during my thesis project and Dr. Rusman Rusyadi, B.Eng, M.Sc., for being my co-advisor and for the continuous support, encouragement, and help throughout this research.
Furthermore, the author would give special thanks to my team partner that has always been supportive and encouraging throughout this project: Dennis Adrian, Johan Soegiharto, and Nicolas Aditya.
The author would also thank my best friends that have been my source of inspiration, and have been really helpful throughout this research: Charles Logis, Ivan Surya, Kevin Tirtaatmadja, Kevin Susanto, and Samuel Loanka.
William Irawan TABLE OF CONTENTS
Page
STATEMENT BY THE AUTHOR ... 2
ABSTRACT ... 3
DEDICATION ... 5
ACKNOWLEDGEMENTS ... 6
TABLE OF CONTENTS ... 7
LIST OF FIGURES ... 11
LIST OF TABLES ... 17
CHAPTER 1 - INTRODUCTION ... 19
1.1 Background... 19
1.2 Thesis Purpose ... 20
1.3 Thesis Problem ... 21
1.4 Thesis Scope ... 21
1.5 Thesis Limitation ... 22
1.6 Significance of Study ... 22
1.7 Thesis Organization ... 23
CHAPTER 2 - LITERATURE REVIEW ... 24
2.1 Driving Simulator ... 24
2.2 Telemetry Data ... 25
2.2.1 Game Telemetry ... 25
2.3 Car Motion... 25
2.3.1 Vertical Axis ... 26
2.3.2 Lateral Axis ... 26
2.3.3 Longitudinal Axis ... 26
2.3.4.1 Tait-Bryan Angles ... 27
2.3.4.2 Roll ... 28
2.3.4.3 Pitch ... 29
2.3.4.4 Yaw ... 29
2.3.5 Translational Motion ... 29
2.3.5.1 Heave ... 30
2.3.5.2 Sway ... 30
2.3.5.3 Surge ... 30
2.4 UDP Protocol ... 31
2.5 Serial Communication ... 32
2.6 Microcontroller ... 32
2.7 Arduino IDE ... 33
2.8 Qt IDE ... 34
2.9 Firmata Protocol ... 35
CHAPTER 3 – RESEARCH METHODS ... 36
3.1 System Design Overview ... 36
3.2 Electrical Design ... 38
3.2.1 Microcontroller ... 39
3.2.2 PC ... 39
3.2.3 Monitor ... 40
3.2.4 Steering Wheel and Pedal ... 40
3.2.5 Arduino Connection ... 41
3.3 Software Design ... 42
3.3.1 Dirt3 Configuration ... 43
3.3.2 SimData ... 45
3.3.2.1 Qt Multithreading ... 46
3.3.2.2 Main Thread ... 47
3.3.2.3 Firmata Communication Protocol ... 48
3.3.2.4 UDP ... 48
William Irawan
3.4 Mechanical Design ... 58
3.5 Development Tools ... 60
3.5.1 Qt Creator IDE ... 60
3.5.1.1 QThread Class ... 61
3.5.1.2 QUdpSocket Class ... 61
3.5.1.3 QWidget Class ... 62
3.5.2 Arduino IDE ... 62
3.5.3 SimTools ... 63
CHAPTER 4 – RESULTS AND DISCUSSIONS ... 64
4.1 Introduction ... 64
4.2 Software Testing and Result ... 64
4.2.1 Firmata Protocol Testing ... 64
4.2.2 UDP Protocol ... 68
4.2.3 SimData Test and Result ... 73
A. UDP Telemetry Data Comparison with SimTools ... 73
B. Sensor Code Integration Test and Result ... 74
C. Motion control code integration test and result. ... 83
4.3 HMI integration test and result. ... 89
4.3.1 Arduino connection interface ... 89
4.3.2 Roll and Pitch Limit LED Interface ... 91
4.3.3 Sensor and PID Settings Interface ... 95
4.3.4 SimData Settings Interface ... 102
4.3.5 Dashboard Interface ... 106
4.3.6 Motion testing and Configuration interface ... 108
4.4 Discussion... 110
4.4.1 System Integration Result ... 110
4.4.2 Problems and solutions ... 115
CHAPTER 5 – CONCLUSIONS AND RECCOMENDATIONS ... 118
5.1 Conclusions ... 118
GLOSSARY ... 120
REFERENCES ... 121
APPENDICES ... 123
APPENDIX A - Data Sheet... 123
A.1 Arduino Mega 2560 ... 123
A.2 Motor Shield – VNH2SP30-E ... 129
APPENDIX B - Programming Code ... 135
B.1 mainwindow.h ... 135
B.2 mythread.h... 138
B.3 dashboard.h ... 140
B.4 dashboard_ui.h ... 141
B.5 mainwindow.cpp ... 142
B.6 mythread.cpp ... 160
B.7 dashboard.cpp ... 163
B.8 dashboard_ui.cpp ... 164
B.9 SimData_Firmata.ino ... 165
APPENDIX C - Bill of Materials ... 186
CURRICULUM VITAE ... 187