Project of "Dead Reckoning" programmed in Java and displaying the results in 3D with OpenGL for mobile operating system "Android".



Tutor: Owen Mackessy  -  Ireland



            Introduction                                                                                                Page 3


            Idea                                                                                                              Page 3


            Overview                                                                                                     Page 4


            Developing                                                                                                   Page 5


                        Screen                                                                                               Page 5

                        Process                                                                                              Page 5

                        Data procesing                                                                                  Page 8


            Diagrams                                                                                                     Page 9


            Conclusions                                                                                                 Page 11

References                                                                                                   Page 11















1     Introduction


This project involved the implementation of a program that can save the route the mobile without the use of GPS, only with mobile sensors, in this case the acceleration sensor and the sensor inclination.
It has been programmed in Java with Android specific libraries and the track saved is displayed with the OpenGL ES library.
Currently, the latest generation mobile phones have new sensors and new features that will make the future of computing passing through these terminals. Currently you have in your hand a mobile phone with a processor and features of a standard desktop 10 years ago. The main problem was the length of the battery begins to be improved, and now, in addition to GPS, have numerous sensors such as: acceleration sensors, inclination sensors, light intensity sensors, temperature sensors .. ..
In addition, Google has entered the mobile phone market with its operating system called Android, based on the stability provided by Linux.
Has provided many tools that help programmers work and development of mobile applications, and most importantly, in a completely free. It also has an application called "Market" where you can share your programs.
These were the main reasons I decided to do a project for this platform.


2          The idea

After a first idea failed because it was based on the use of 3D interactive maps by Google and is currently not possible, my supervisor Owen Mackessy  suggested me several ideas, one of them was something about Dead Reckoning, words I had never heard before.

The idea was to make a program for mobile phone, who helped in the sensors of the phone, could determine and calculate the position and the route that makes the phone. This is a procedure performed in a simple manner in open spaces with the help of GPS, but no way to do it indoors or underground and it was an interesting idea. In addition, we had the idea to show the route in the phone in 3D perspective with the help of the OpenGL ES library that has the phone.

Although the idea was presumed very difficult to make because for me they are almost all new technologies used, in addition to having little time to work, I started working on the project .






3          Overview

In the main interface provides a quick and clear overview of key data read from the sensor.Shows two main buttons to start and stop reading data. Displays a button "Show" to display the list of tracks. Displays the list of tracks that have been stored in the phone memory card in a specific folder in text     file format. The text file can be copied to the computer, edited and sent back to the phone for later viewing in 3D.
Pressing the button "menu" of the phone is to display a menu of options to close the application, start a new reading and display a menu of application information.

Pressing the Start button, the application performs a first calibration data from the sensor to eliminate the force of gravity, the phone must maintain the same angle I had at the time of the calibration for reliable data 
.The display will show the results in real time, in addition to show the maximum and minimum values as statistics . Once chosen the file you want to display a new screen opens where you draw the route taken, the first item is the 0,0,0 and is shown in the center of the cube. The function of the cube is to make reference to know the slope and position of the line. It also shows a green plane parallel to the ground to improve the reference. The line can be rotated by tapping the screen with your finger, or the movement of the trackball.























4          Developing

The process of developing this project began with the reading of a book on Android recommended by my supervisor. Before you start thinking how to make the program was necessary to read information             about the phone's operating system that would work, to understand their operation and seek the most efficient solution to the problems I was going to be appearing.The operating system "Android" is based on Linux, which offers great stability and a large amount of documentation. Android provides several libraries for handling sensors, touch screens, etc. .

            4.1       The screen

            When developing the main screen there are two options in Android, you can do with java as usual or     you can make an XML interface. Android is optimized for XML interfaces so I decided to choose this option despite not having ever worked in XML. The main interface has been designed to          work with the data and be an interface designed in a technical work, is not intended to be a nice interface .




            4.2       The process

One of the major problems working with the sensor was working with the result of two different sensors simultaneously. To do this I had to create an intermediate object which is responsible for saving on each call the result of one of the two sensors. With this object the data is read and work with them. 
The acceleration sensor provides acceleration data in meters / second2. X and Y axes are the same as in the traditional representation system, but the Z axis is the vertical axis, the acceleration of gravity is provided in a negative sign. The force of gravity is essential for humans, but for this project has been one of the main problems. 
The main problem when calculating the movements of the phone, ongoing


acceleration of gravity distorts the data. The force of gravity is necessary to remove it because for example: if the phone besides having a horizontal motion, turns on itself, it is not possible to know the forces from which they come, so it is necessary to an orientation sensor to give me back tilting the phone and be able to break the force of gravity knowing that its value is always 9.8m/s2 and its vertical direction is always parallel to the axis Z of the phone . I have implemented two main alternatives to eliminate gravity. The first worked with the tilt sensor data to break the force of gravity. 



The code was implemented but the results were not expected, after much research and delve into the problem found its origin.
The orientation sensor is based on a gyroscope, the gyroscope when it has a horizontal displacement force to distort the values of tilt phone. That is, even if the phone remained in a horizontal, the tilt sensor data returned my phone erroneous inclination.
These data were mistakenly break the force of gravity acceleration situations, so it had to be discarded this idea.Below illustrates the results of tests with this method.









The movement shown here was in the horizontal axis X, the phone remained completely flat but the tilt sensor returned a wrong value me as you can see below:


The second alternative has been to calibrate the phone to start reading. The phone must remain in the same position throughout the movement to make that data are reliable, but the data go through several filters that help make information more reliable.













4.3         Data processing.


The first filter is the adjustment of the acceleration calculated by subtracting the initial error.
At first filter of the phone takes 200 samples of the acceleration in each axis by gravity, these values are constant in the execution of the process and will be subtracted from the acceleration defended later.

The second filter is done by calculating the average of the past data, doing so eliminates potential outliers point. Obtained a function of acceleration.

The third filter is low-value distinction, considering that these values are errors from the sensor.
The fourth filter is responsible for resetting the values of speed. The current speed is a core value when calculating the distance traveled, so has to be as reliable as possible. But when making the calculations always introduce errors that cause acceleration values are. This filter controls on each axis independently that the acceleration is not in the window of discrimination.
If the value of acceleration is in the window after X noise samples, the velocity of the axis is set to 0.

After the data processing, data is entered into the track and when you press the Stop button, the data passes to be turned into a text file.





Class diagram of the project:


Class hierarchy



















Flow Diagram of the main class:


























It was a difficult project, in addition to programming in Java to require much time for research in physics, forces, and how to break the force of gravity.
The language used is mostly java and helped me to further deepen the knowledge of this programming language.
I also worked with XML, which I found very interesting and intuitive.
The android development has required too much documentation because it is a very popular technology yet, but I really enjoyed the experience and I have a future intention to continue developing for Android.
The OpenGL 3D visualization also impressed me, I had never worked with OpenGL and the results are very spectacular sight.

The project does not work as well as wanted for the errors introduced by sensors in his reading, especially the tilt sensor. But I think could be improved and I have intention to continue working on the idea in the future as it would be a very interesting application. One possible improvement would be in cooperation with the record using GPS when the GPS signal lost program became operational this code and you could still record the route taken.
Profiles could also be adjusted depending on the type of movement to perform and the estimated length.
Ultimately, the idea has many applications in the future.
It was a project that has taken me many hours of development but I am very satisfied with the result and the knowledge learned in their development.




Hellow Android, 2Edition

Pro Android

Wrox Professional Android 2



Thinking in java