ZATDROID. Satellite Tracking and Augmented Reality. App for Android
Abstract
Ingeniería Técnica en Informática de Gestión
Full text
Universidad de Valladolid E. U. de Informática (Segovia) Ingeniería Técnica en Informática de Gestión ZATDROID Satellite Tracking and Augmented Reality App for ANDROID Alumno: Rodrigo Santos Álvarez Tutores: Fernando Díaz Gómez Jesús Álvarez Gómez !"#$%&'#()(!(%*$)++)(,+#(* * * * %-*!-*./*#0123456789*:'/;2<79=* * >39.2*/0*#0;/07/3?9*#0123456789*./*'/3<7872@*A* )BC7898720/@* * * * * * DC7/06/*EFG*B939*)"(&,#(* * :EFG(&,#(=* * ! ! ! ! ! ! ! )CH402I*J9<7/3*K90@2*L/3390M* ** FH623I*E/3090.2*(?9M*>N4/M* !
FINAL PROJECT REPORT ZATDROID Satellite Tracking and Augmented Reality App for ANDROID
ZATDROID – Final Year Project 1. Abstract 1. ABSTRACT The purpose of ZATDROID is to offer the user the possibility of tracking any artificial satellite. It locates it in Google Maps together with its predicted trajectory and also it allows the user to see it in real time in the sky with augmented reality camera view. The application is implemented in Java for ANDROID devices (tablets or smartphones). Orbital mechanics calculations are developed following Newton equations and NORAD (North American Aerospace Defence Command) propagation models, firstly published in 1980 Spacetrack Report #3: Models for Propagation of the NORAD Element Sets [4] ZATDROID downloads information from a data base of satellites provided by CELESTRAK.COM, does the orbital mechanics calculations (NORAD models), gets the device sensors magnitudes, connects to the web service Google Maps Elevation to get the altitude of the user location, processes data in terms of XML language, creates a GOOGLE MAPS views with the updated position in real time of the satellite picked and shows the position in the sky in augmented reality using OPENGL for the camera view. The GUI (Graphical User Interface) manages to lead the users through an easy and friendly navigation to achieve their aims quickly, showing the results of the user picks with BreadCrumbs, supporting English and Spanish, showing icon-based menus and keeping the users informed of the longer processes by “progress bars”. Rodrigo Santos Álvarez 3
ZATDROID – Final Year Project 1. Abstract ABSTRACT El objectivo de ZATDROID es ofrecer la posibilidad al usuario de encontrar satélites artificiales. Posiciona en GOOGLE MAPS junto con su trayectoria y permite al usuario verlo en tiempo real en el cielo con la vista de la cámara en realidad aumentada. Los cálculos de mecánica orbital se han desarrollado siguiendo las ecuaciones de Newton y los modelos de propagación de NORAD (North American Aerospace Defence Command), publicados por primera vez en 1980 Spacetrack Report #3: Models for Propagation of the NORAD Element Sets [4] ZATDROID descarga información de una base de datos de satélites ofrecida por CELESTRAK.COM, realiza los cálculos de mecánica orbital (modelos NORAD), obtiene las magnitudes de los sensores del dispositivo, se conecta al servicio web Google Maps Elevation para obtener la altitud de la localización del usuario, procesa datos en lenguaje XML, crea una vista de GOOGLE MAPS con la posición del satélite elegido actualizada en tiempo real y muestra la localización en el cielo en realidad aumentada usando OPENGL para la vista de cámara. La GUI (Interfaz gráfica de usuario) gestiona la experiencia del usuario a través de una fácil y amigable interfaz de navegación para alcanzar los objetivos rápidamente, mostrando a los usuarios sus elecciones con un menú BreadCrumbs, ofreciendo todo en inglés y español, con menús basados en iconos y manteniendo a los usuarios informados de procesos largos con barras de proceso. Rodrigo Santos Álvarez 5
ZATDROID – Final Year Project 2. Acknowledgements 2. ACKNOWLEDGEMENTS Foremost, I would like to express my sincere gratitude to my advisors Fernando and Jesús for the continuous support of my project, for his patience, motivation, enthusiasm, and immense knowledge. Their guidance helped me all the time. Besides my advisors, I would like to thank my friend Rafael for all his expert advices, insightful comments and user experience knowledge. Thanks also to all those anonymous people writing full and documented answers on the internet, without their daily help, I could not have achieved this Project. My sincere thanks to “travis” from mybringback.com, author of the fantastic ANDROID video tutorials that introduced me into the Apps world, Maciej Grzegorczy, author of the SATFINDER app and T. S. Kelso webmaster of the fabulous celestrak.com for their generosity in spreading knowledge around the world. Last but not the least, I would like to thank my family for supporting me spiritually throughout my life and being an example of effort and perseverance, especially Julia, who has suffered from lack of attention during the time dedicated to this project. I wish this Project could help my future kid explore the world of physics and technology and wake up the sense of astonishment and surprise in Nature. Rodrigo Santos Álvarez 7
ZATDROID – Final Year Project Report 5. Introduction Figure 1. Description of the data flow and how the system manages to get the inputs, work with the data and export the two main outputs. ORBITAL MECHANICS: Longitude, latitude and altitude are magnitudes needed for the Google Maps positioning. Also azimuth and elevation of the satellite are essential for the augmented reality functionality. The method to calculate these magnitudes was first introduced in 1980, Spacetrack Report #3: Models for Propagation of the NORAD Element Sets [4] where SGP (Simplified general propagation model) and SGP4 / SPD4 (SGP version 4 for low and deep space orbits) were implemented. These models develop the Newton´s Gravitational equations and some more accuracy modifications that takes into account perturbations. It was written in FORTRAN. TXT to XML Parse – Searches “sat” Java object ORBITAL MECHANICS: Latitude – Longitude Azimuth – Elevation Altitude – Web Service Orbit prediction INPUTS TLE´s www.celestrak.com Orbit Data daily updated DATA MANAGEMENT OUTPUTS GOOGLE MAPS VIEW: Sat Icon & Trajectory AUGMENTED REALITY Camera View Surface Layers OpenGL view Device Sensors data HW & SW Android Versions Device Model English & Spanish Multi Screens Rodrigo Santos Álvarez 15
6. Orbital Mechanics ZATDROID – Final Year Project Report Some new developments have been achieved to improve the code using C language [6]. Nevertheless, the heart of the code remains the same. ZATDROID takes advantage of this implementation and develops all the calculations in Java for ANDROID. The orbital mechanics equations are explained in detail later on. ZatDroid implements SGP4/SDP4 NORAD prediction models, based on [4] and with some improvements of [6] Furthermore, longitude, latitude and altitude of the users location is required for the augmented reality feature. GPS sensor provides these magnitudes. In case GPS is not available, network positioning is used for latitude and longitude and for the altitude, Google Maps Elevation web service is asked, though USGS Elevation Query is also another possibility. OUTPUTS: GOOGLE MAPS VIEW: Once the application has all the parameters of the orbit and information of the satellite, it can be located inside a map view. The user is shown the latitude and longitude of the sat updated every second together with the name. In another layer, an icon is representing the satellite updated every second and finally the predicted trajectory for the next minutes. AUGMENTED REALITY: Taking advantage of a camera view, some layers are added to provide information concerning the position of the satellite in the sky where the user is. An icon must be drawn when the camera device is pointing at the azimuth and elevation of the satellite. Both azimuth and elevation of the satellite and the camera point of view need to known together with geographical coordinates (latitude and longitude) of the device. Azimuth and elevation of the camera, that is to say, where is the camera pointing at, is retrieved from the accelerometer sensor. After some matrix transformations of the vectors from the coordinate reference systems of the device and the Earth, using OPENGL to set the camera view properly taking into account both directions of the satellite and the device, all the data is ready to draw the completed view. While the user is rotating the device to find the satellite in the sky, information is being shown concerning the satellite and device parameters onto another layer. Also a line indicates the direction in which the user can find the satellite and finally the icon appear when the camera points at the right direction in the sky. The program gives information in case the satellite is not visible (under the horizon) and the time lasting until next overhead pass. ZATDROID has the chance to implement an option that retrieves a list of satellites that are visible (over the horizon) at the moment where the user is located. It is not useful though, since it lasts some minutes to do all the calculations. For every satellite, SPG4/SPD4 model must be run, so the calculus time really increases. HARDWARE AND SOFTWARE: ZATDROID is required to: • Run under ANDROID versions from 2.3 to 4.3 (newest version up to date). • Support Multilanguage (English and Spanish) • Support multiscreen sizes • Support different smartphones models • Tests have been carried out successfully with Sony Xperia Neo V, Samsung Note, Samsung Galaxy S4, Samsung Tablet 11’, Nexus 4, Samsung S3-Mini 16 Rodrigo Santos Álvarez
ZATDROID – Final Year Project Report 5. Introduction 5.5.2. SCREENS SEQUENCE DIAGRAM A more complete explanation of the diagram can be found in other technical documents. The GUI (Graphical User Interface) is based on icons with explanatory text, taking advantage of ANDROID multilingual support: English and Spanish, depending on the language of the device and making the user experience unique and easy. Figure 2. Explanation of the sequence of the screens through the application. • 1-2b: Firstly, the app checks if the device has internet connexion available. If not, a message pops up not to let the app execute. Internet is necessary. • 2a: Secondly, the user can choose between searching a satellite by its type or typing key words. • 3a – 3b - 4: Thirdly, after a progress bar to keep the user informed or some screens to decide the type, one specific satellite is finally picked. During this process, at the top of the screen the application implements Bread Crumbs. It allows the user to navigate through the types chosen. • 6: Once the satellite is picked, the screen shows the two functionalities of the application: Google Maps and Augmented reality with self-explanatory photos. • 7: For the Google Maps screen, it consists of the map view with two layers, indicating the latitude, longitude and name updated every second and the icon in the right placed also updated. • 8a – 8b: For the Augmented reality screen, in case the satellite is located under the horizon a message pops up with the time lasting until next overhead pass. Then the camera view is shown with some layers for the data of the satellite and data of the device updated every second, an arrow indicating the direction to follow in order to find the sat in the sky and the satellite icon when the device points at the right direction. Rodrigo Santos Álvarez 17
6. Orbital Mechanics ZATDROID – Final Year Project Report 6. ORBITAL MECHANICS This project makes sense since it involves a lot of knowledge in orbital mechanics. This section aims to be an introduction of the complex calculations used, as well as some general concepts concerning satellites. For a detailed description of the equations, processes and calculations, the technical manual is to be referenced. 6.1. COORDINATE SYSTEMS Orbital mechanics need some coordinate systems to develop all the calculations. Only a picture and the name is given below. Earth Centre Intertial - ECI Earth Centred Earth fixed - ECEF Topocentric Horizon c.s. Orbit c.s. Figure 3. Orbital mechanics coordinate systems An important coordinate system must be taken into account when working with devices such as smartphones or tables. Sensors (gravity, accelerometer and magnetic) give the magnitudes in terms of vectors, and every vector must be represented into a coordinate system, which is also used by OPENGL when working with 3D geometry or moving the camera in a camera view. The rotation matrix helps interpreting the vectors and their transformations. 18 Rodrigo Santos Álvarez
6. Orbital Mechanics ZATDROID – Final Year Project Report Sensors API c.s. OPENGL Camera positioning Figure 4. Device coordinate systems 6.2. NEWTON´S AND KEPLER´S LAWS It was Kepler who at the beginning of the 17th century stated the 3 laws that describes the movement of the planets around the Sun. Kepler took advantage of the experimental work and measurements made by Tycho Brahe to realize these laws that can also be applied to the movement of any object in space around a more massive object: • The orbit of every planet is an ellipse with the Sun at one of the two foci. • A line joining a planet and the Sun sweeps out equal areas during equal intervals of time • The square of the orbital period of a planet is proportional to the cube of the semi-major axis of its orbit. Later, Newton developed the fundamental laws of physics upon which the theory of orbital mechanics is based. Newton’s law of universal gravitation, self explained by the well-known formula [7.1] G = 6.67·10−11 Nm2/kg2 is the universal gravitational constant The vector goes from M to m and the force is on m. Newton’s law of motion: [7.2] Assuming that: • The mass of a satellite is and • The gravitational forces are the only forces acting on the two bodies and these two bodies are not under influence of any other gravitational force from any other body. And making use of Newton´s laws and some mathematical techniques, the three Kepler laws are proven in the next paragraphs: Rodrigo Santos Álvarez 19
6. Orbital Mechanics ZATDROID – Final Year Project Report 1st LAW: Solving the “two bodies problem” in polar coordinates and realizing the movement in such a central force is plain (the plane is determined by the position vector and the velocity ) we can achieve the final formula that defines the orbits: [7.3] [7.4] Depending of the value of e (eccentricity) the orbits will be: • Ellipses: • Parabolas: • Hyperbolas: Figure 5. Orbits type, according to the eccentricity value [2] 2nd LAW: Taking into consideration that the angular momentum of the motion is conserved since the gravitational force is a central force: [7.5] [7.6] [7.7] It is proven that “A line joining a planet and the Sun sweeps out equal areas during equal intervals of time”, meaning the area swept out. 20 Rodrigo Santos Álvarez
ZATDROID – Final Year Project Report 6. Orbital Mechanics 3rd LAW: [7.8] [7.9] [7.10] a: semimajor axis of the orbit. Final result for T (period) equation comes from [7.8] and [7.9] calculating the same magnitude through two different ways. 6.3. KEPLERIAN ELEMENTS With all the data retrieved from Newton´s laws it can be stated for ellipse orbits (the most common ones for satellites) that there are six constants that describes easier the orbit than using the equations. These so called keplerian elements are not constant if disturbance forces are considered and all of them become time-variant. (see next section) Figure 6. Keplerian elements diagram • Shape and size of the ellipse. 1) Eccentricity (e): already explained. 2) Semimajor axis: (a): the sum of the periapsis and apoapsis distances divided by two. • Orientation of the orbital plane in which the ellipse is embedded: 3) Inclination (i) vertical tilt of the ellipse with respect to the reference plane, measured at the ascending node 4) Longitude of the ascending node ( ): horizontally orients the ascending node of the ellipse with respect to the reference frame's vernal point Rodrigo Santos Álvarez 21
6. Orbital Mechanics ZATDROID – Final Year Project Report • Finally: 5) Argument of periapsis ( ): defines the orientation of the ellipse in the orbital plane, as an angle measured from the ascending node to the periapsis. 6) Mean anomaly at epoch (M0): defines the position of the orbiting body along the ellipse at a specific time (the "epoch"). 6.4. NORAD ORBIT PROPAGATION MODELS [2] Disturbance forces can be minute in comparison to the main gravitational force. Nevertheless, if we are to calculate a more accurate prediction, these forces must be taken into account. The North American Aerospace Defence Command (NORAD) developed some Perturbation models in SpaceTrack 3 [4], depending on its accuracy: • SGP (Simplified General Perturbation model): o Geopotential disturbances: the Earth is not spherical. It has a bulge at the equator and is flattened at the poles. o Perturbances due to Sun and the Moon: more tan only one object in space causes perturbations. • SGP4 (Simplified General Perturbation model version 4) adding: o Atmospheric drag: removes energy from the satellite. o Solar radiation: less important in lower orbits. • SDP4 (Simplified General Deep Space Perturbation model version 4) o It is based on SGP4 but for orbits with a period longer than 225 minutes, where additional deep-space perturbations have to be considered. ZatDroid implements SGP4/SDP4 perturbation models described in [4] and with some improvements of [6]. Code from C, FORTRAN or PASCAL has been migrated to JAVA for ANDROID NORAD maintains a set of elements needed to do the calculations for the propagation of the orbits. These elements are refined every day so that the model keeps its accuracy and can be found as txt files called TLEs (two line element sets). CELESTRAK.COM is the source from ZATDROID downloads these elements every time the user executes the app. 6.5. SATELLITES ORBITS Finally, a brief description of the orbits is explained, as it is written in [8] SYNCHRONOUS: EARTH SYNC. Also known as Geostationary. It allows the satellite to look always at the same point of the Earth. Therefore, it is highly demanded and there is a belt with a lot of satellites. Its altitude is roughly 35.876Km, flying at 3Km/s over the equator, inclination 0. In ZATDROID these satellites can be recognized easily as their latitude and longitude are constant and no trajectory line is drawn in the Google Maps view. Figure 7. Geostationary belt 22 Rodrigo Santos Álvarez
ZATDROID – Final Year Project Report 6. Orbital Mechanics SUN SYNC: These orbits allows a satellite to pass a section of the Earth at the same time of the day. The surface illumination angle will be nearly the same every time. This consistent lighting is a useful characteristic for satellites that image the Earth's surface in visible or infrared wavelengths (e.g. weather and spy satellites) and for other remote sensing satellites (e.g. those carrying ocean and atmospheric remote sensing instruments that require sunlight) POLAR: The satellite passes over the planet’s poles on each revolution. The inclination of these orbits therefore is i ≈ 90º. These orbits are the only ones that allows to pass the poles to search any information. Rodrigo Santos Álvarez 23
7. Breakthrough design features ZATDROID – Final Year Project Report 7. BREAKTHROUGH DESIGN FEATURES 7.1. MULTILANGUAGE SUPPORT Following ANDROID developers advices, all strings used in ZATDROID have been encoded inside the XML file strings.xml in English, which is the main language. This file is located in res/values There is also a file string-es.xml in res/values-es in which all strings are duplicated Spanish. Whenever the user runs ZATDROID, the language of the strings are shown in the language of the device automatically, as long as it is English or Spanish. English is by default. Figure 8. Multilanguage screen 7.2. MULTIPLE SCREENS SUPPORT: ICONS, TEXT Bearing in mind the wide range of devices it is mandatory to support different screen sizes. Although in the ANDROID help it is recommended the use of “dp” (density pixels) when defining pictures or text size in XML layouts, it has not been the solution this time. Many tests have been run with different devices (Sony Xperia Neo V, Samsung Note, Samsung Galaxy S4, Samsung Tablet 11’, Nexus 4, Samsung S3Mini) and using “dp” did not show the icons and text the same way in all devices. So another definition of the layouts was necessary. Finally, it was found out that using only xml layouts was not the right procedure. Instead, layouts definition inside Java code was selected. This option lets the programmer customize deeper the layout configuration. addView adds views (layouts) to other layouts. • On the one hand, icons needs to set height and width according to the size of the device. This is achieved by retrieving the device width and height with this piece of code: final float height=getResources().getDisplayMetrics().heightPixels final float width=getResources().getDisplayMetrics().widthPixels Every icon height and width can be configured as a certain percentage of total: int h = (int) (0.05 * height); // 5% int w = (int) (0.20 * width); // 20% • On the other hand, text size (setTextSize) and gap between letters (setTextScaleX) is something more complex. The text must adjust to the size of its box perfectly. Gap between letters: A new function has been created scaleButtonText. o A Paint object is created with 100% height and setTextScaleX = 1 o Ask the paint for the bounding rectangle if it were to draw this text. o Determine the width o Calculate the new scale in x direction to fit the text to the button width Text Size: It is set to a percentage of the total height of the box. 7.3. ASYNCTASK AND PROGRESS BAR: RUNNING CODE IN BACKGROUND. There are two events within the application when a connection through internet is established to download files. This happens when connecting to CELESTRAK.COM and downloading TLEs in a txt file. Such a process may last some seconds and give errors. It is also the moment when both XML and XSD file is created from txt. 24 Rodrigo Santos Álvarez
ZATDROID – Final Year Project Report 7. Breakthrough design features 7.15. SAX MANAGEMENT SAX (Simple API for XML) and DOM (Document Object Model) are the two methods to deal with XML data in ANDROID. A brief description is now given: [17] SAX: • Parses node by node • Doesn’t store the XML in memory • We can´t insert or delete a node • SAX is an event based parser • SAX is a Simple API for XML • Doesn’t preserve comments • SAX generally runs a little faster than DOM DOM: • Stores the entire XML document into memory before processing • Occupies more memory • We can insert or delete nodes • Traverse in any direction. • DOM is a tree model parser • Document Object Model (DOM) API • Preserves comments ZATDROID is: • Dealing with big documents • Not inserting nodes, just reading • Intending not to use a lot of memory • Not reading the whole document, just the node required. • Not needing to store the whole document and creating the DOM tree. So SAX was decided to be the method for the searches into XML. ZATDROID looks into the XML for the satellite picked by the user and read all the information of this certain satellite to create afterwards a “sat” JAVA object. Rodrigo Santos Álvarez 31
8. Planning and Budget ZATDROID – Final Year Project Report 8. PLANNING AND BUDGET 8.1. WORK ESTIMATION FUNCTION POINTS is considered a useful tool to make an estimation of the lines of code. But this project has some special characteristics that may not fit with a typical estimation, so that the results would not be coherent. • Only one person is in charge of the whole project • The training stage must be extremely large, as the programmer is untrained. • The orbital mechanics stage is out of the reach of the FUNCTION POINTS analysis • There is no routine in the time dedicated every week to the project because the programmer has a full time job. The project is being developed in his free time. • In any moment the project could be delayed due to any reason. So the planning is created from the stages and taking into account experts advices, self experience in other projects from other disciplines. 8.2. WORK FLOW AND TASKS The work flow defines the stages of the project. Figure 12. Figure 13. Work Flow Stages 32 Rodrigo Santos Álvarez
ZATDROID – Final Year Project Report 8. Planning and Budget Taking the stages definition as a starting point, a detailed tasks breakdown structure can be made. 1. Initial analysis 1.1. Objectives definition 1.2. Resources analysis 1.2.1. Human Resources 1.2.2. Technical resources 1.3. Schedule 1.3.1. Initial tasks definition 1.3.2. Initial requirements definition 1.3.3. Schedule estimated 2. Training 2.1. Android programming. SDK 2.1.1. Eclipse SDK 2.1.2. Activities flow 2.1.3. Layouts 2.1.3.1. Types 2.1.3.2. Components 2.1.3.3. Programmatically 2.1.3.4. Threads 2.1.4. Parameters 2.1.5. Classes 2.1.6. Sharing and passing information 2.2. GOOGLE MAPS View 2.2.1. MapView 2.2.2. Layers and Markers 2.2.3. Geometry 2.3. Augmented reality views 2.3.1. Camera View 2.3.2. Layers 2.3.3. Geometry 2.4. OpenGL 2.4.1. Coordinate systems 2.4.2. Transformation Matrix 2.4.3. Geometry 2.5. XML management 2.5.1. Understanding the language 2.5.2. Creating files 2.5.3. XSD scheme 2.5.4. Search: SAX, DOM 2.6. Orbital Mechanics calculations. TLEs. SGP4/SDP4. 2.6.1. Satellites orbits 2.6.2. Equations 2.6.3. Methods understanding 2.6.4. Programming code 2.7. State of the art: applications 3. Training Tests (carried out at the same time as the training) 3.1. Activities tests 3.2. Sensor tests 3.3. OPENGL tests Rodrigo Santos Álvarez 33
8. Planning and Budget ZATDROID – Final Year Project Report 3.4. Google Maps tests 3.5. XML Management 3.6. Augmented Reality tests: camera view and layers 3.7. Orbital Mechanics Calculations tests. 4. Design 4.1. Requirements. 4.1.1. Analysis of the estimated requirements 4.1.2. Set the final requirements 4.2. Classes diagram 4.2.1. Activities classes 4.2.2. Calculations Classes 4.3. Sequence Diagram 4.4. GUI Design 5. Implementation 5.1. Android core 5.1.1. Activities Structure 5.1.2. Sensors 5.1.3. Sharing and passing data 5.2. GUI 5.2.1. Screen definition 5.2.2. Icons and Text 5.2.3. Multilanguage support 5.3. XML files management 5.3.1. XML Parsing 5.3.2. XSD Creation 5.3.3. Search: SAX Handling 5.4. Google Maps Activity 5.4.1. MapView 5.4.2. Markers 5.4.3. Geometry 5.4.4. Layers 5.5. Augmented Reality 5.5.1. Camera View 5.5.2. Layers 5.5.3. OpenGL Geometry 5.5.4. Device orientation sync with sat icon 5.6. Orbital Mechanics Code. SGP4/SDP4 5.6.1. TLE download 5.6.2. Time calculations 5.6.3. SGP4/SDP4 Code 6. Final Tests 6.1. Activities structure 6.2. GUI 6.2.1. User experience 6.2.2. Activities 6.3. AR functionality 6.3.1. Layers 6.3.2. Icon movement with device orientation 6.4. GOOGLE MAPS functionality 6.4.1. Icon marker 34 Rodrigo Santos Álvarez
ZATDROID – Final Year Project Report 8. Planning and Budget 6.4.2. Trajectory line 6.5. Orbits propagation check 6.6. Devices compatibility 6.7. Android versions compatibility 7. Documentation 7.1. Final Year Project Report 7.2. Technical Manual 7.3. User Manual 8.3. SCHEDULE ESTIMATED Not all the tasks are written in the open project file, as they are too specific to give a general view. Figure 14. Estimated Schedule The total estimated time is 35 weeks, with one person working full time in the project, 5 days a week, 1400 hours. Rodrigo Santos Álvarez 35
8. Planning and Budget ZATDROID – Final Year Project Report 8.4. SCHEDULE ACHIEVED The beginning of 2012 was the start point of this project. After some months working, I was offered a new job, so from July 2012 until December 2012 the project stayed in stand-by. Then, in January 2013 it all begun again and in May 2013 I finally finished it. June was again dedicated to my job, and July and August has been the time to finish. So I had 13 months of actual work in three periods: January - June 2012 January January - May 2013 July-August 2013 6 Months 5 Months 2 Months 13 Months Figure 15. Actual Work periods Figure 16. Schedule achieved 36 Rodrigo Santos Álvarez
ZATDROID – Final Year Project Report 8. Planning and Budget Moreover, only 4 hours per day (at most) were available to go forward with the project, although weekends were also dedicated to the project. So, from the 8 months estimated, one person full time, the project has been developed in 13 months. It may be thought that 16 (double) months were needed, but if holidays and weekends are to be added to the schedule, 13 months are enough. It may be agreed that 1400 hours is a good estimation for the project. The main deviation noticed about technical issues has been that, after the first implementation of the GUI with ListViews, tests performed with users revealed that the GUI was not friendly and gave no information to the user about choices made in the satellite type. So a new process of improving the GUI was carried out: • Adding BreadCrumbs to the screens • Changing ListViews for icon based layouts. After June 2012, the implementation was started and most of the training finished. So the implementation in 2013 went forward quickly. The key point that was entirely performed in 2013 was the Orbital mechanics training and implementation. Actually, training and implementation was mixed and this feature was the last to be finished. 8.5. COSTS ESTIMATION Once again, there are some tools to estimate costs for a project. COCOMO may be one of the most used in the subjects of the degree. But for this case, no tool has been used to calculate an estimation, because the project is simple looking from the costs point of view. • Only one person is working on it. • Most of the time has been invested in training. Are these hours costs? • The material resources are easily measured. A final budget is detailed in the next section, which would be completely similar to the estimated one, except for little things. 8.6. DETAILED BUDGET Resource % Use Total Resource Cost Total cost for the project Computer 50% 1000€ 500€ MS Office 2010 Prof 25% 480€ 120€ Eclipse SW 100% 0 0 Start UML 100% 0 0 Printer & toner 10% 200€ 20€ Paper office material 100% 20€ 20€ ADSL (13 months) 25% 400€ 100€ Sony Ericson Neo V 75% 150€ 112€ 5 project copies printed and bookbound 100% 300€ 300€ TOTAL: 1.172€ Human resources € per Hours Hours Total cost for the project Computer Science Engineer 12€ 1.400€ 16.800€ TOTAL: 16.800€ Figure 17. Detailed Budget Rodrigo Santos Álvarez 37
8. Planning and Budget ZATDROID – Final Year Project Report So the final costs are 17.972€. This is a huge quantity for the project. • Half of the working hours have been training. These may be not taken into account as the programmer is supposed to have the skills before the contract. So the prize would reduce 8.000 €, and the app final cost would be 9000€. • Bearing in mind the idea of monetizing the App in the market, if we sell it in Google Play: o Costs are 25€ once to register. o The App. price: 70% for the seller, 30% for Google. Figure 18. Monetizing the App. Price Study. Figure 19. App Prices on the market Figure 18 explains how the rate of users downloading free apps is increasing. 38 Rodrigo Santos Álvarez
ZATDROID – Final Year Project Report 8. Planning and Budget Figure 20. Downloads per App Figure 19 shows how difficult is to gain more than 5.000 downloads. Only 20% (average) of the apps reach more than 5.000 downloads after 20 weeks in the market. With the comparison of the price and downloads needed to reach 9.000€, it is difficult for ZATDROID to be profitable. Rodrigo Santos Álvarez 39
ZATDROID – Final Year Project Report 9. Future Work 9. FUTURE WORK Once the initial objectives are achieved and after developing this project, there are some issues that could be improved or added to the requirements of ZATDROID. Here are some of them: 9.1. FULL DATABASE HOSTED IN SERVER It would be nice to the user experience that there is no need to choose a satellite to performed a GOOGLE MAPS View or an Augmented Reality View. Instead, a complete database with all satellites from CELESTRAK could be developed. Every satellite would have the real time parameters updated so that the device could show all of them (or just some with filters) when initializing the Google Maps View or the Augmented reality view. This new feature would require a large computational. Therefore, it would mean a change in the core of the project. The idea should be to implement the calculation modules in a server and let the device connect to the server to provide a wide range of options in the visualizations functionalities. 9.2. MIGRATION TO ANDROID 4.3 NEW FEATURES ZATDROID has been developed under ANDROID 2.3. and tested in a Sony Xperia Neo V. From the start of the project (January 2012) ANDROID has launched new versions with new features: OPENGL 3.0, Optimized Location and Sensor Capabilities, transparent overlays, fragments, Action Bar… 9.3. MIGRATION TO IOS It would be interesting to be able to migrate the whole app to IOS, as it will be an opportunity to expand the market. Nevertheless, this is complicate as it involves lot of modifications. 40 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 1. Table of Contents 1. TABLE OF CONTENTS 1. Table of Contents ........................................................................................................................ 3 2. List of Figures ........................................................................................................................... 5 3. List of Tables ........................................................................................................................... 7 4. Introduction ........................................................................................................................... 9 5. System Requirements Analysis .................................................................................................11 5.1. Introduction .......................................................................................................................11 5.2. Objectives .........................................................................................................................11 5.3. Requirements ....................................................................................................................12 5.3.1. Information Requirements ...........................................................................................12 5.3.2. Functional Requirements .............................................................................................17 5.3.2.1. Use Case Diagram ............................................................................................17 5.3.2.2. Actors ...............................................................................................................17 5.3.2.3. Use Cases .........................................................................................................18 5.3.3. Non-Functional Requirements .....................................................................................25 5.4. Traceability Matrix Objectives / Requirements ................................................................27 5.5. Summary ..........................................................................................................................28 6. Design System Analisys ..............................................................................................................29 6.1. Introduction .......................................................................................................................29 6.2. Data Management .............................................................................................................29 6.2.1. Conceptual Model: Entity-Relationship Model ...........................................................30 6.2.2. Logical Model .............................................................................................................31 6.2.3. Data Dictionary ...........................................................................................................31 6.3. Deployment Diagram ........................................................................................................32 6.4. Packages Diagram .............................................................................................................33 6.5. Classes Design ..................................................................................................................33 6.5.1. Classes Diagrams ........................................................................................................34 6.5.2. Classes Descritpion .....................................................................................................37 6.6. Behavior Model.................................................................................................................53 6.6.1. Use Cases Diagram......................................................................................................53 6.6.2. Sequence Diagrams .....................................................................................................54 6.7. Summary ..........................................................................................................................59 7. User Interface Design .................................................................................................................60 7.1. GUI Requirements ............................................................................................................60 7.2. Scenarios ..........................................................................................................................60 7.2.1. Scenario 1: Intro ..........................................................................................................61 7.2.2. Scenario 2a: Initial Search Menu .................................................................................62 7.2.3. Scenario 2b: Internet Connection Message .................................................................63 7.2.4. Scenario 3a: Search By Key Words (Name) ...............................................................64 7.2.5. Scenario 3b: Search By Type .....................................................................................65 7.2.6. Scenario 4: Downloading Progress Bar .......................................................................66 7.2.7. Scenario 5: Satellite Names List ..................................................................................68 7.2.8. Scenario 6: Functionalities Main Menu .......................................................................69 7.2.9. Scenario 7: GOOGLE MAPS View.................................................................................70 7.2.10. Scenario 8a: Next Overhead Pass ................................................................................71 7.2.11. Scenario 8b: Augmentd Reality View .........................................................................72 Rodrigo Santos Álvarez 3
1. Table of Contents ZATDROID – Technical Manual 8. Orbital Mechanics ...................................................................................................................... 74 8.1. Coord. Syst., newton`s & kepler`s laws. Keplerian elements. ............................................. 74 8.2. NORAD Orbit Propagation Models ..................................................................................... 75 8.2.1. NORAD TLEs ............................................................................................................ 75 8.2.2. NORAD Propagations Models SGP4/SPD4 ............................................................... 76 8.3. Implementation .................................................................................................................... 77 9. Breakthrough Design Features ................................................................................................. 79 9.1. Multilanguage Support ......................................................................................................... 79 9.2. Multiple Screens Support: Icons, Text ................................................................................. 79 9.3. Asynctask and Progress Bar: Running Code In Background. ........................................... 80 9.4. Sharing and Storing Information .......................................................................................... 81 9.5. Breadcrumbs Navigation Buttons ........................................................................................ 83 9.6. GOOGLE Search Activity ...................................................................................................... 83 9.7. Device Location Provider .................................................................................................... 84 9.8. Sensors Management ........................................................................................................... 85 9.9. Smooth Movements Filter .................................................................................................... 86 9.10. Migration of SGP4 Code from FORTRAN / C to JAVA for ANDROID ................................ 87 9.11. Augmented Reality View: Layers Over Camera View. .................................................... 87 9.12. OPENGL Usage ................................................................................................................. 88 9.13. GOOGLE MAPS View ......................................................................................................... 88 9.14. XML/XSD Management .................................................................................................. 89 9.15. SAX Management ............................................................................................................ 90 10. Testing And Validating ........................................................................................................ 91 11. List of References ................................................................................................................. 92 12. List of Abbreviations ............................................................................................................ 93 13. Appendices ............................................................................................................................ 94
ZATDROID – Technical Manual 2. List of Figures 2. LIST OF FIGURES Figure 1. Use Case Diagram ...........................................................................................................17 Figure 2. Actors ..............................................................................................................................17 Figure 3. Data Management Diagram .............................................................................................29 Figure 4. XML example ..................................................................................................................30 Figure 5. Entity – relationship model..............................................................................................30 Figure 6. Logical model ..................................................................................................................31 Figure 7. Deployment Diagram ......................................................................................................32 Figure 8. Package Diagram .............................................................................................................33 Figure 9. Colour meaning ...............................................................................................................33 Figure 10. General Classes Diagram...............................................................................................34 Figure 11. Satellite Explorer Classes Diagram ...............................................................................35 Figure 12. Augmented Reality Classes Diagram ............................................................................36 Figure 13. GOOGLE MAPS Classes Diagram ...................................................................................37 Figure 14. Use Cases Diagram ........................................................................................................53 Figure 15. Sequence Diagram 01: Creating sat JAVA Object from XML .......................................54 Figure 16. Sequence Diagram 02: UC-01: Download Satellite list (search by name) ....................55 Figure 17. Sequence Diagram 03: UC-03: GOOGLE MAPS View ...................................................56 Figure 18. Sequence Diagram 04: UC-05: Augmented Reality View (I) .......................................57 Figure 19. Sequence Diagram 05: UC-05: Augmented Reality View (II) ......................................58 Figure 20. Scenarios .......................................................................................................................60 Figure 21. Scenario 1: Intro ............................................................................................................61 Figure 22. Scenario 2: Initial search menu .....................................................................................62 Figure 23. Scenario 2b: Internet connection message .....................................................................63 Figure 24. Scenario 3a: Search by Key Words (name) ...................................................................64 Figure 25. Scenario 3b: Search by Type .........................................................................................65 Figure 26. Scenario 4: Downloading progress bar ..........................................................................66 Figure 27. Scenario 5: Satellite names list ......................................................................................68 Figure 28. Scenario 6: Functionalities main menu ..........................................................................69 Figure 28a. Scenario 6: Loading Spinner Dialog ............................................................................69 Figure 29. Scenario 7: GOOGLE MAPS View ...................................................................................70 Figure 30. Scenario 8a: Next Overhead Pass ..................................................................................71 Figure 31. Scenario 8b: Augmented Reality View .........................................................................72 Figure 32. Diagram for Orbit Prediction with Newton´s Equations. ..............................................74 Figure 33. TLEs Explanation ..........................................................................................................75 Figure 34. Orbital Mechanics Classes Diagram ..............................................................................78 Figure 35. Multilanguage Screen ....................................................................................................79 Figure 36. BreadCrumbs .................................................................................................................83 Figure 37. GOOGLE Search & Progress Bar ....................................................................................83 Figure 38. Augmented Reality View ..............................................................................................87 Figure 39. GOOGLE MAPS View......................................................................................................88 Rodrigo Santos Álvarez 5
6 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 3. List of Tables 3. LIST OF TABLES Table 1. OBJ 01: Download satellites .............................................................................................11 Table 2. OBJ 02: Augmented reality view ......................................................................................11 Table 3. OBJ 03: Google Maps view .........................................................................................12 Table 4. IRQ 01: Satellite data ........................................................................................................12 Table 5. IRQ 02: Satellite available list ..........................................................................................13 Table 6. IRQ 03: Device orientation and georeference data ...........................................................13 Table 7. IRQ 04: TLEs provider .....................................................................................................14 Table 8. IRQ 05: Satellite types picked by the user ........................................................................14 Table 9. IRQ 06: Location of XML and XSD files downloaded ....................................................15 Table 10. CRQ 01: Sat characteristics ............................................................................................15 Table 11. CRQ 02: Orbital parameters in TLEs ..............................................................................15 Table 12. CRQ 03: Sat orbital parameters calculated .....................................................................15 Table 13. CRQ 04: Sat Orientation Parameters ..............................................................................16 Table 14. CRQ 05: Sat Georeference Parameters ...........................................................................16 Table 15. CRQ 06: Device parameters............................................................................................16 Table 16. ACT-01: User ..................................................................................................................17 Table 17. ACT-02: Satellite TLEs provider ....................................................................................17 Table 18. ACT-03: Internet Service Provider .................................................................................18 Table 19. ACT-04: Device sensors .................................................................................................18 Table 20. ACT-05: Google Maps service provider .........................................................................18 Table 21. UC 01: Download Satellite TLEs ...................................................................................19 Table 22. UC 02: Pick a satellite .....................................................................................................20 Table 23. UC 03: Visualize satellite in Google Maps .....................................................................21 Table 24. UC 04: Retrieve device altitude with Google Maps Elevation web service ....................21 Table 25. UC 05: Point device at satellite with Augmented reality ................................................23 Table 26. UC 06: Read Georeference and orientation device sensors ............................................24 Table 27. UC 07: Validate internet connection ...............................................................................24 Table 28. NFR-01: Features delay limit ..........................................................................................25 Table 29. NFR-02: Download processes must be reliable ..............................................................25 Table 30. NFR-03: availability at any moment ...............................................................................25 Table 31. NFR-04: Compatibility with Android versions and devices ...........................................26 Table 32. NFR-05: Wifi and / or 3G (similar) ................................................................................26 Table 33. NFR-06: Friendly, usable, easy and beautiful GUI .........................................................26 Table 34. Traceability Matrix Objectives / Requirements ..............................................................27 Table 35. Requirements Summary ..................................................................................................28 Table 36. Device attributes .............................................................................................................31 Table 37. Satellite attributes ............................................................................................................32 Table 38. intro.java .........................................................................................................................37 Table 39. listaTipoSat.java ..............................................................................................................38 Table 40. searchActivity.java ..........................................................................................................39 Table 41. searchListaSatsSAXHandler.java ...................................................................................39 Table 42. listaTipoSat2.java ............................................................................................................40 Table 43. listaSats.java ....................................................................................................................41 Table 44. listaSatsSAXHandler.java ...............................................................................................41 Table 45. satElegidoSAXHandler.java ...........................................................................................42
3. List of Tables ZATDROID – Technical Manual Table 46. sat.java ............................................................................................................................ 42 Table 47. menuOpciones.java ......................................................................................................... 43 Table 48. MapsActivity.java........................................................................................................... 43 Table 49. MapsOverlay.java ........................................................................................................... 43 Table 50. ARIntro.java ................................................................................................................... 44 Table 51. ARCameraActivityOverlay.java ..................................................................................... 44 Table 52. ARCameraPreview_Overlay.java ................................................................................... 45 Table 53. AROurSurfaceOverlaySat.java ....................................................................................... 45 Table 54. AROurSurfaceOverlayCruz.java .................................................................................... 45 Table 55. AROurSurfaceOverlayFlecha.java ................................................................................. 45 Table 55a. ARGLRenderOverlayMovSat.java ............................................................................... 46 Table 56. ARGLRenderOverlayMovCruz.java .............................................................................. 46 Table 57. ARGLRenderOverlayMovFlecha.java ........................................................................... 47 Table 58. ARGLSat.java ................................................................................................................ 47 Table 59. ARGLCruz.java .............................................................................................................. 47 Table 60. ARGLFlecha.java ........................................................................................................... 48 Table 61. Vector.java ...................................................................................................................... 48 Table 62. DevicePositionProvider.java .......................................................................................... 49 Table 63. CalcualtionsSatPOS.java ................................................................................................ 49 Table 64. CalcualtionsSatTRACK.java .......................................................................................... 50 Table 65. CalcualtionsOrbit.java .................................................................................................... 50 Table 66. CalcualtionsOrbitSGP4.java ........................................................................................... 50 Table 67. CalcualtionsOrbitSDP4.java ........................................................................................... 51 Table 68. CalcualtionsOrbitSDP4_Deep.java ................................................................................. 51 Table 69. CalcualtionsVarSDP4.java ............................................................................................. 51 Table 70. CalcualtionsVarGlobal.java ............................................................................................ 51 Table 71. CalcualtionsTime.java .................................................................................................... 52 Table 72. CalcualtionsMaths.java ................................................................................................... 52 Table 73. k.java .............................................................................................................................. 52 Table 74. visibleSats.java ............................................................................................................... 52 Table 75. Design summary ............................................................................................................. 59 Table 76. Classes for Orbital Mechanics Calculations ................................................................... 77
ZATDROID – Technical Manual 4. Introduction 4. INTRODUCTION During the years I have been studying Computer Science, it has been always on my mind the idea of joining both of my study worlds: Space Engineering and Computers. At the moment I had to decide the purpose of my final work project, I realized that it was the time to finally develop my initial idea. After a lot of work thinking and asking friends that are working in computer science and space, I came up with this project, ZATDROID. It includes skills from both sides of my career, keeping me motived and offering me the possibility to learn topics that I have never worked. Moreover, I found that it could be a chance for many people interested in tracking artificial satellites from their devices: tablets and smartphones. Also this App brings closer to the non-expert user the satellites we are using every day whose identity is unknown for us. The code has been developed in JAVA for ANDROID, using Eclipse with ANDROID SDK and has been tested and designed for a Sony Xperia Neo V with ANDROID 2.3. It has been tested in other devices with ANDROID 4 and works perfectly. This technical manual pretends to be a guide concerning the analysis and design of the application and a detailed description of any of the processes and calculations carried out. Rodrigo Santos Álvarez 9
ZATDROID – Technical Manual 5. System Requirements Analysis 5. SYSTEM REQUIREMENTS ANALYSIS 5.1. INTRODUCTION ZATDROID offers the user the possibility of tracking any artificial satellite. It locates it in Google Maps together with its predicted trajectory and also it allows the user to see it in real time in the sky with augmented reality camera view. The application is implemented in Java for ANDROID devices (tablets or smartphones). Orbital mechanics calculations are developed following Newton equations and NORAD (North American Aerospace Defence Command) propagation models, firstly published in 1980 Spacetrack Report #3: Models for Propagation of the NORAD Element Sets [4] ZATDROID downloads information from a data base of satellites provided by CELESTRAK.COM, does the orbital mechanics calculations (NORAD models), gets the device sensors magnitudes, connects to the web service GOOGLE MAPS Elevation to get the altitude of the user location, processes data in terms of XML language, creates a GOOGLE MAPS views with the updated position in real time of the satellite picked and shows the position in the sky in augmented reality using OPENGL for the camera view. The GUI (Graphical User Interface) manages to lead the users through an easy and friendly navigation to achieve their aims quickly, showing the results of the user picks with BreadCrumbs, supporting English and Spanish, showing icon-based menus and keeping the users informed of the longer processes by “progress bars”. 5.2. OBJECTIVES OBJ-01 Download artificial satellites orbiting the Earth Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Description The system will download an updated list with all the satellites that are now orbiting the Earth, with name, characteristics and orbital parameters. Importance High Urgency High State Validated Stability High Comments The files that contain this information are called TLEs and has a defined format. They are txt files and can be found in www.celestrak.com using an internet connection Table 1. OBJ 01: Download satellites OBJ-02 Point the device at the updated azimuth and elevation of the satellite picked by the user with Augmented reality. Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Description The system will calculate the elevation and azimuth of the satellite picked by solving the NORAD propagation models once azimuth, elevation, altitude, latitude and longitude of the device are obtained from the sensors. All this information will be presented into layers and over the camera view. Importance High Urgency High State Validated Stability High Comments Accuracy is not a big issue, 2-3 degrees error is admissible. Some visual help must be offered to lead the user to the satellite when trying to find it in the sky Table 2. OBJ 02: Augmented reality view Rodrigo Santos Álvarez 11
5. System Requirements Analysis ZATDROID – Technical Manual OBJ-03 Locate the picked satellite in Google Maps, together with its past and predicted trajectory Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Sources - Description The system will take advantage of the G OOGLE M APS utility to show a surprising view of the satellite onto the Earth Map updated in real time. Latitude and longitude of the satellites will be calculated using NORAD propagation models. Importance High Urgency High State Validated Stability High Comments Internet connection is needed. Table 3. OBJ 03: Google Maps view 5.3. REQUIREMENTS 5.3.1. INFORMATION REQUIREMENTS IRQ-01 Information of the picked satellite with all its own data and orbital parameters Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Sources - Linked objectives OBJ-01, OBJ-02, OBJ-03 Linked requirements UC-03, UC-05 Description The system will store the updated information of the satellite picked by the user with all the information retrieved from TLEs and parameters calculated within the app. Specific data • Satellite characteristics • Orbital parameters in TLE • Orbital parameters calculated • Orientation Parameters • Georeference parameters Life time Average Max. Undefined Undefined Occurrences Average Max. Undefined Importance High Urgency High State Validated Stability High Comments The basics of this information will be first in an XML file and then all complete will be in a JAVA object “sat” Table 4. IRQ 01: Satellite data 12 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 5. System Requirements Analysis 6 With help of BufferReader and InputStreamReader the txt file is read. 7 While txt is being read, XML is being created (based on its XSD) 8 Progress bar is filled 100%. Conflictive download process finished 9 Once XML file is finished, a search is performed with SAX to retrieve only the names that are to be shown to the user. 10 DefaultHandler is inherited using its classes elementRoot and Element to search through the XML quickly, without creating a complete and large DOM, for the satellite names Post-condition A ListView with the names of the satellites from the satellite type picked by the user or the sat names that fit key words typed by the user Exception Step Action 1 If ACT-02 is not working, the process is cancelled and a message is shown Importance High Urgency High State Validated Stability High Comments Celestrak.com has the txt files in URL such as www.celestrak.com/…/weather.txt. These are URL which contains txt files with TLEs classified by satellite type. So it is needed to know the type to be able to download the file. Table 21. UC 01: Download Satellite TLEs UC-02 Pick a Satellite Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Sources - Linked objectives OBJ-01 Linked requirements IRQ-01, IRQ-02, IRQ-04, IRQ-05, UC-01 Description The user is required to pick a satellite given its name. The search can be performed in two ways: by key words or by type. Precondition • Internet connection available by ACT-03 Normal Sequence Step Action 1 There are two ways to pick a satellite: search by key words (a) or search by satellite type (b) 2a A G OOGLE Search is started with the default menu for A NDROID 3a Key words are typed by the user to search the name of the sat 4a The download process is performed as described in UC-01 5a A ListView with all satellites whose name fits the key words is shown. 2b The user picks one of the 6 icons with text (English or Spanish) that indicates general satellite types 3b The General Type is stored in SharedPreferences so that next activities can read it 4b Another screen is shown customized according the general type previously picked, retrieved from SharedPreferences 5b The user picks a specific sat type and it is stored again in SharedPreferences. 6b The download process is performed as described in UC-01 7b A ListView with all satellites from the type picked is shown. Rodrigo Santos Álvarez 19
5. System Requirements Analysis ZATDROID – Technical Manual end1 The User picks any of them end2 A SAX method searches the XML for the sat picked and retrieves the TLE information from this satellite. A “sat” JAVA object is created as Parcelable, so that other activities can access it. Post-condition A satellite picked by the user from a list with satellites names and a “sat” JAVA object created with information of the satellite picked Exception Step Action 1 If celestrak.com is not working, the process is cancelled and a message is shown Importance High Urgency High State Validated Stability High Comments - Table 22. UC 02: Pick a satellite UC-03 Visualize Satellite position in GOOGLE MAPS Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Linked objectives OBJ-03 Linked requirements IRQ-01, UC-02 Description Taking advantage of G OOGLE M APS View Z AT D ROID positions an icon representing the satellite picked in real time, together with its trajectory. Precondition • Internet connection available by ACT-03 • Sat JAVA object created with information of the satellite picked Normal Sequence Step Action 1 MapsActivity, which extends com.google.android.maps.mapView provides by ACT-05, starts the maps layout and retrieves “sat” object 2 Compass is added as a layer to the MapView 3 Also a MapOverlay class is created as a layer 4 Current time is obtained and modified by CalculationsTime 5 CalculationsSatPOS takes current time and sat object and calculate latitude, longitude and altitude of satellite, implementing NORAD propagation models SGP4 / SDP4. Firstly, current position and velocity, and then subsatellite point with latitude and longitude. Many classes are used, names starts with Calculations[…]. More detailed description of this step will be explained in section 8. 6 A GeoPoint is created with latitude and longitude and an icon is represented and added as a layer to the MapView 7 There is a loop calculating latitude and longitude of satellite from 10 minutes in the past and 10 minutes predicted for the future. A line is drawn with these points and added as a layer to the MapView 8 A TextView is also added as a layer, with name, latitude, longitude and altitude of the satellite. 9 The onDraw method is refreshed instantly and redraws the complete MapView, with all the layers: icon, trajectory and text. Trajectory is delayed to be refreshed only every second. All the calculations are too complicated to be refreshed instantly. The tests performed indicate the line is deformed in some seconds. 20 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 5. System Requirements Analysis Post-condition An icon representing the satellite is shown in G OOGLE M APS , updated instantly together with its past (10 min) and (10 min) predicted trajectory and text with name, latitude, longitude and altitude are shown to create a real time view. Exception Step Action 1 If the calculation takes more time than expected, it stops and shows a message 2 The trajectory is updated every second. This delay is due to tests carried out indicating that calculations cannot be developed quickly. The line would otherwise be deformed Importance High Urgency High State Validated Stability High Table 23. UC 03: Visualize satellite in GOOGLE MAPS UC-04 Use web service GOOGLE MAPS elevation to get device altitude Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Linked objectives OBJ-02 Linked requirements IRQ-03, UC-06 Description If GPS is not working, a web service is called to retrieve device altitude. It is needed to calculate azimuth and elevation of the satellite. Precondition • Internet connection available by ACT-03 • Device Sensors provide latitude and longitude of sat by ACT-04 • GPS not available. Network available Normal Sequence Step Action 1 If GPS is not available, then altitude is retrieved from web Service. Nevertheless, network must be available. Latitude and longitude are needed to send them to the web service. 2 HttpClient, HttpContext are called to establish the connection. URL is created with latitude and longitude from device http://maps.googleapis.com/maps/api/elevation/xml?locat ions= “latitude”,”longitude”&sensor=true 3 HttpGet sends this URL to the web service. HttpResponse and HttpEntity process the answer. It is a XML file and the altitude is written between <elevation> tags Post-condition Device altitude is retrieved and used to calculate azimuth and elevation of the satellite Exception Step Action 1 If web service is not working, a message is shown Importance High Urgency High State Validated Stability High Comments There are two web services that can provide altitude out of latitude and longitude: • USGS Elevation Query Web Service: http://gisdata.usgs.gov/xmlwebservices2/elevation_service.asmx • GOOGLE MAPS Elevation API Web Service: https://developers.google.com/maps/documentation/elevation/ GOOGLE MAPS elevation is used in ZATDROID Table 24. UC 04: Retrieve device altitude with Google Maps Elevation web service Rodrigo Santos Álvarez 21
5. System Requirements Analysis ZATDROID – Technical Manual UC-05 Point Device at satellite with Augmented Reality Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Sources - Linked objectives OBJ-02 Linked requirements IRQ-01, IRQ-03, IRQ-05, UC-06, UC-02 Description The device camera will show an icon in the right position in the sky (azimuth and elevation) representing the sat picked by the user. Layers over the camera view show information and allows the user to rotate the device to search the sat. It is indeed the largest of the use cases. Precondition • Device Sensors provide latitude, longitude, altitude, azimuth and elevation of device by ACT-04 • Sat Java object created with information of the satellite picked Normal Sequence Step Action 1 ARIntro runs DevicePositionProvider to get latitude, longitude and altitude of device. (UC-06) 2 LocationManager is used to retrieve latitude and longitude from GPS or network. 3 If GPS is available, altitude is known easily. If not, Web service is called as described in UC-04. 4 ARIntro continues running CalculationsSatTRACK to calculate Azimuth and elevation of satellite. 5 CalculationsSatTRACK takes current time, sat object and device georeference ad orientation and implements NORAD propagation models SGP4 / SDP4. Firstly, current position and velocity, and then position in the sky. Many classes are used, names starts with Calculations[…]. More detailed description of this step will be explained in section 8. 6 If sat elevation is less than 0, satellite picked is under the horizon. A loop runs to calculate next overhead pass. Then an alertDialog pops up with such information. 7 ARCameraActivityOverlay is executed 8 Here SensorManager and Sensor Classes retrieve all data from accelerometer, magnetic and gravity sensors to calculate the orientation (elevation and azimuth) of the device. RotationMatrix and OrientationMatrix are used. 9 Elevation and azimuth of the device are passed to the Sat, Cruz and Flecha Renders. Gravity vector is passed to sat Render. 10 Two TextViews are layers overlaying the camera view: One is showing azimuth, elevation and name of the satellite The other is showing elevation and azimuth of the device in real time, as the user rotates the device the textView is updated. 11 3 Layers that will overlay CameraView are created. Each layer consists of GLSurfaceView, Render and object class and it is set transparent. 12 CameraView: (SurfaceView) ARCameraPreview_Overlay. Initiates camera, where augmented reality makes sense. 22 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 5. System Requirements Analysis 13 GLSurfaceView: AROurSurfaceOverlaySat icon of the satellite. Render: ARGLRenderOverlayMovSat Using GL10 object (OPENGL), it customizes the virtual camera showing the icon (GLU.gluLookAt), refreshed the view with data coming from sensors, smooth the refreshing with a filter and calculates a transformation matrix from device coordinate system into Earth Coordinate system. J AVA Object: ARGLSat Creates textures, bitmaps, and geometry of satellite icon 14 GLSurfaceView: AROurSurfaceOverlayCruz. Central square. Render: ARGLRenderOverlayMovCruz Similar to previous render, using GL10 visualize the central square and it changes the colour and size when sat is just in the centre of the camera view. J AVA Object: ARGLCruz Creates textures, bitmaps, and geometry of the square. 15 GLSurfaceView: AROurSurfaceOverlayFlecha: Arrow indicating the direction of the satellite in the sky. Render: ARGLRenderOverlayMovFlecha Again, GL10 is used to update in real time the direction of the arrow, pointing always at the satellite. It helps the user to find the sat, as it tell information of how to rotate the device. J AVA Object: ARGLFlecha Creates textures, bitmaps, and geometry of the arrow Post-condition The icon, device information, sat information, arrow and textViews with information are shown over the camera view. The icon can be found only if the device is pointing at the elevation and azimuth of the sat. Exception Step Action 1 The OPEN GL does not support sometimes so many things and updates. Then the activity is reset. Importance High Urgency High State Validated Stability High Comments The accuracy is not high. Table 25. UC 05: Point device at satellite with Augmented reality UC-06 Read Georeference and orientation device sensors Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Sources - Linked objectives OBJ-02 Linked requirements IRQ-03, UC-04 Description Georeference (latitude, longitude, altitude) is implemented in class DevicePositionProvider and used to calculate elevation and azimuth of the sat. The sat orientation in the sky depends on the position of the device in the surface of the Earth. GPS and/or network are required. Orientation (elevation and azimuth) is implemented inside the ARCameraActivityOverlay and it is used to match device and sat orientation. Accelerometer, magnetic and gravity sensors are required Precondition Device with sensors accelerometer, Magnetic, Gravity, GPS and network (ACT-04) Rodrigo Santos Álvarez 23
5. System Requirements Analysis ZATDROID – Technical Manual Normal Sequence Step Action Georeference 1 DevicePositionProvider class is called 2 With LocationManager class, GPS and network are started 3 Firstly, latitude and longitude are retrieved from network provider. GPS is slower and consumes more battery. 4 Secondly, if GPS is available and active, latitude and longitude are again retrieved and refreshed, as GPS is usually more precise. 5 If GPS is active and available, altitude is easily found 6 If not, and network is active, UC-04 retrieves the altitude from a web service. 7 Altitude: [km], Latitude: [90º, -90º], Longitude: [-180º, 180º] Orientation 1 ARCameraActivityOverlay class is called 2 With SensorManager and Sensor classes, magnetic, accelerometer and gravity sensors are started 3 The onSensorChanged class notifies every change in the magnitude offered by each sensor. 4 RotationMatrix and OrientationMatrix are obtained to calculate elevation and azimuth in degrees with mathematical transformations 5 Elevation: [-90º, 90º], Azimuth: [-180º, 180º] Post-condition Georeference (latitude, longitude, altitude) and orientation (azimuth and elevation) of the device are available. Exception Step Action 1 If GPS is not available, a web service is connected (UC-04) 2 If GPS is not active, a message pops up to require its activation Importance High Urgency High State Validated Stability High Comments The accuracy is not high. Table 26. UC 06: Read Georeference and orientation device sensors UC-07 Validate internet connection Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Linked objectives OBJ-01, OBJ-03 Linked requirements IRQ-02, IRQ-04, UC-01, UC-03 Description Internet must be available so that all functions can work. Wifi or 3G or similar: ACT-03 Precondition - Normal Sequence Step Action 1 Starts ConnectivityManager 2 Checks that at least one internet connection is active Post-condition Internet is available and active Exception Step Action 1 If there is no internet connection, a message is shown and the app does not starts. Importance High Urgency High State Validated Stability High Table 27. UC 07: Validate internet connection 24 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 5. System Requirements Analysis 5.3.3. NON-FUNCTIONAL REQUIREMENTS Performance: NFR– < 01 Features delay must be less than 3 seconds Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Sources - Linked objectives OBJ-01, OBJ-02, OBJ-03 Linked requirements IRQ-01, IRQ-02, IRQ-03, IRQ-04, IRQ-05, UC-01, UC-03, UC-05 Description The application must be quick. Delays are not desirable when navigating. Downloads are the longest processes. Tests must be carried out with different versions and devices. Importance High Urgency High State Validated Stability High Comments Only one could be longer than 3 seconds (downloading all TLEs when performing a search by key words) Table 28. NFR-01: Features delay limit Reliability: NFR– < 02 Download processes must be reliable Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Sources - Linked objectives OBJ-01 Linked requirements IRQ-02, IRQ-04, UC-01 Description ASynctask must be used to assure the reliability of these processes Importance High Urgency High State Validated Stability High Comments - Table 29. NFR-02: Download processes must be reliable Availability: NFR– < 03 Availability at any moment Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Sources - Linked objectives OBJ-01, OBJ-02, OBJ-03 Linked requirements - Description ACT-02, ACT-03 and ACT-05 availability makes this app dependant. Usually there will be no problem at all and it will be used at any time, but if any of these actors does not give support, application cannot run. Importance High Urgency High State Validated Stability High Comments - Table 30. NFR-03: availability at any moment Rodrigo Santos Álvarez 25
5. System Requirements Analysis ZATDROID – Technical Manual Compatiblity: NFR– < 04 Compatibility with Android versions and devices Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Sources - Linked objectives OBJ-01, OBJ-02, OBJ-03 Linked requirements - Description The code must run on all devices types with ANDROID 2.3 and forward. Importance High Urgency High State Validated Stability High Comments - Table 31. NFR-04: Compatibility with Android versions and devices Compatibility: NFR– < 05 Wifi and / or 3G (similar) Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Sources - Linked objectives OBJ-01, OBJ-02, OBJ-03 Linked requirements - Description Wifi and/or 3G will be a must in order to work with this app. Importance High Urgency High State Validated Stability High Comments - Table 32. NFR-05: Wifi and / or 3G (similar) GUI (Graphical User Interface): NFR– < 06 Friendly, usable, easy and beautiful GUI Version V1.0 – 15/08/2013 Authors Rodrigo Santos Álvarez Sources - Linked objectives OBJ-01, OBJ-02, OBJ-03 Linked requirements UC-01, UC-03, UC-05 Description As it is the feature facing the user, GUI must fit all the requirements to make the app attractive. Importance High Urgency High State Validated Stability High Comments - Table 33. NFR-06: Friendly, usable, easy and beautiful GUI 26 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 5. System Requirements Analysis 5.4. TRACEABILITY MATRIX OBJECTIVES / REQUIREMENTS OBJ-01 OBJ-02 OBJ-03 IRQ-01 X X X IRQ-02 X X X IRQ-03 X IRQ-04 X IRQ-05 X X IRQ-06 X CRQ-01 X X X CRQ-02 X X X CRQ-03 X X X CRQ-04 X X X CRQ-05 X X X CRQ-06 X UC-01 X UC-02 X UC-03 X UC-04 X UC-05 X UC-06 X UC-07 X X NFR-01 X X X NFR-02 X NFR-03 X X X NFR-04 NFR-05 X X X NFR-06 X X X Table 34. Traceability Matrix Objectives / Requirements Rodrigo Santos Álvarez 27
5. System Requirements Analysis ZATDROID – Technical Manual 5.5. SUMMARY TYPE ID DESCRIPTION ACTORS ACT-01 User ACT-02 Satellite TLEs provider ACT-03 Internet Service provider ACT-04 Device sensors ACT-05 GOOGLE MAPS service provider OBJECTIVES OBJ-01 Download artificial satellites orbiting the Earth OBJ-02 Point the device at the updated azimuth and elevation of the satellite picked by the user with Augmented reality. OBJ-03 Locate the picked satellite in Google Maps, together with its past and predicted trajectory INFORMATION REQUIREMENTS IRQ-01 Information of the picked satellite with all its own data and orbital parameters IRQ-02 Information of the satellites available IRQ-03 Information of the device orientation and georeference data IRQ-04 Information of the TLEs provider IRQ-05 Information of the satellite types picked by the user IRQ-06 Information of the location of the files CRQ-01 Satellite characteristics CRQ-02 Orbital parameters in TLEs CRQ-03 Sat orbital parameters calculated CRQ-04 Sat orientation parameters CRQ-05 Sat Georeference parameters CRQ-06 Device Latitude, longitude, altitude, azimuth and elevation FUNCTIONAL REQUIREMENTS – USE CASES UC-01 Download Satellite list (TLEs) UC-02 Pick a Satellite UC-03 Visualize Satellite position in GOOGLE MAPS UC-04 Use web service GOOGLE MAPS elevation to get device altitude UC-05 Point Device at satellite with Augmented Reality UC-06 Read Georeference and orientation device sensors UC-07 Validate internet connection NONFUNCTIONAL REQUIREMENTS NFR-01 Features delay must be less than 3 seconds NFR-02 Download processes must be reliable NFR-03 Availability at any moment NFR-04 Compatibility with Android versions and devices NFR-05 Wifi and / or 3G (similar) NFR-06 Friendly, usable, easy and beautiful GUI Table 35. Requirements Summary 28 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 6. Design System Analysis Figure 11. Satellite Explorer Classes Diagram Rodrigo Santos Álvarez 35
6. Design System Analysis ZATDROID – Technical Manual Figure 12. Augmented Reality Classes Diagram Once the satellite has been picked, the AR view can be selected. Figure 12 Firstly ARIntro class: • Runs the calculations from NORAD propagations orbit, with all the complex process of predict the orbit for the satellite. This will be explained in later sections. • Also the device georeference parameters are retrieved with class devicePoitionProvider. GPS and network are used. Web service may be also needed. • In case that the satellite elevation is less than 0, the satellites is under the horizon. Then an alertDialog is shown with information of the next overhead pass.. Then ARCameraActivityOverlay class: • Manages the device orientation through Sensors management. • Implements the Surface layers of the AR view: “Flecha”, “Cruz”, “Sat” and “Camera”. • Implements the GLRenders of these surface layers, taking advantage of OPENGL features. • Implements the objects of shown in these layers. • Implements textViews with information about satellite and device orientation. 36 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 6. Design System Analysis Figure 13. Google Maps Classes Diagram The other functionality, locating the satellite in Google Maps: • Creates the mapView class inherited from the system. It allows to use GOOGLE MAPS. • There are also some other classes managing the characteristics of the current map. • textView that show satellite location coordinates overlaying the map • And again all the calculations where latitude, longitude and altitude of the satellite. 6.5.2. CLASSES DESCRITPION Object intro.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Welcome Screen, checks internet and shows logo Methods Name Inputs Outputs Description onCreate Bundle - Starts ZatDroid Welcome screen with logo Checks internet availability. Opens next Activity after 1 sec: ListaTipoSat isInternetOn - Boolean ConnectivityManager checks internet availability showAlert Title 2 messages - show an alertDialog Superclasses Activity, ConnectivityManager, AlertDialog, Intent Attributes Thread timer Table 38. intro.java Rodrigo Santos Álvarez 37
6. Design System Analysis ZATDROID – Technical Manual Object listaTipoSat.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Initial Menu that gives two options to search a sat: by type or by key words (name) Methods Name Inputs Outputs Description onCreate Bundle - Set Layout layoutCode width, height LinearLayout Creates adjustable Layout Components iconsLine 2 Buttons width, height, 2 Drawable 2 Strings 2 int LinearLayout Defines one line with two icons in a linearLayout breadCrumbs width, height LinearLayout Sets BreadCrumbs buttons at the top of the screen scaleButtnTxt width, height p, text XScale calculate text width size to fit into box onClick View - Stores SharedPreferences “tipoSatGeneral ” according to user selection starts listaTipoSat2 or searchActivity Activity onBAckPressed - - finishes activity Superclasses Activity, View.onClickListener, LinearLayout, ScrollView, Drawable, Button, Paint, SharedPreferences, Intent Attributes Buttons (bSpecial, bWeather, bCommunications, bNavigation, bScientific, bMisc, bBreadCrumbs, bBreadCrumbsEnd), String (“MyFile”) Table 39. listaTipoSat.java Object searchActivity.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description search by key words (name) activity manager Methods Name Inputs Outputs Description onCreate Bundle - Set Layout Handles query Intent onListItemClick listView,View position, id - Stores sharedPreferences “SatElegido” & “tipoSatEspecifico” of the sat picked runs satElegidoSAXHandler to search into XML for date from sat picked Creates “sat” Object with TLE data Calls MenuOpciones.java handleIntent intent - starts Android search interface calls doSearch method to perform search doSearch query - starts ProgressBar executes Asynctask “MiTarea calls “buscarSatsEnXML” and saves names in a list if second searches are retaken without download again txt 38 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 6. Design System Analysis scaleButtonText width, height p, text XScale calculate text width size to fit into box breadCrumbs width, height LinearLayout Sets BreadCrumbs buttons at the top of the screen breadCrumbsButton format variables Button sets format of breadCrumbs buttons mostrarAlerta Title 2 messages - show an alertDialog buscarSatsEnXML - ArrayList<String> Calls searchListaSatsSAXHandler. Using SAX parses XML and retrieves all sat names that fit query String (key words) loadUrlTLE - ArrayList<String> loads all URL from celestrack with txt files headerXML BufferWriter - writes the header of the XML file footerXML BufferWriter - writes the footer of the XML file writeXML BufferWriter BufferReader - reads txt files from URL in celestrack.com parses txt and writes XML file writeXSD BufferWriter - writes XSD Sheme MiTarea (CLASS) Asyntask that performs in background txt download and XML file creation. XML is created with all sats from all TLEs txt files. calls “buscarSatsEnXML” and saves names for the listView Superclasses listActivity, SAXParserFactory, SAXParser, XMLReader, ProgressDialog, Resources, LinearLayout, ScrollView, Button, BufferWriter, BufferREader, SharedPreferences, Intent Attributes ArrayList<String> (sUrlTLE, alistaSat), String (“MyFile”, “TLE_all.xml”, “XSD_all.xml”, query), BufferWriter (xml, xsd), BufferReader (in), sat (sat) Table 40. searchActivity.java Object searchListaSatsSAXHandler.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Performs a search into the XML and find sat names that fits the string key words Methods Name Inputs Outputs Description getData - ArrayList<String> retrieves array with list of sat names found searchListaSatsHandler String - Constructor: it takes the query string parse InputStream Context - Performs the query. Search every node Superclasses RootElement, Element, defaultHandler Attributes ArrayList<String> (listaNombres), String (searchString) Table 41. searchListaSatsSAXHandler.java Rodrigo Santos Álvarez 39
6. Design System Analysis ZATDROID – Technical Manual Object listaTipoSat2.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Second menu of satellite types Methods Name Inputs Outputs Description onCreate Bundle - Set Layout Retrieves SahredPrefereces “TipoSatGeneral” layoutCode width, height typeSelected LinearLayout Creates adjustable Layout Components Selects the subtypes according to input type iconsLine button format param. LinearLayout Defines one line with two icons in a linearLayout breadCrumbs width, height typeSelected LinearLayout Sets BreadCrumbs buttons at the top of the screen scaleButtonText width, height p, text XScale calculate text width size to fit into box onClick View - calls saveData and saveData_openList saveData iTipoGuardado View int retrieves tipoEspecifico: subtype picked savaData_openList elegido - stores tipoEspecifico SharedPreferences opens listaSats.java Superclasses Activity, View.onClickListener, LinearLayout, ScrollView, Drawable, Button, Paint, SharedPreferences, Intent Attributes Buttons (bLast30, bSpaceStations, b100Brightest, bBreadCrumbs, bBreadCrumbs2, bBreadCrumbsEnd), String (“MyFile”, sNombrelistaelegida), ArrayString<String> Table 42. listaTipoSat2.java Object listaSats.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description search by type activity manager and shows name list Methods Name Inputs Outputs Description onCreate Bundle - Retrieves tipoEspecifico from SharedPref Set Layout calls seleccionarUrlTLE Creates Progress bar & Executes MiTarea onListItemClick listView,View position, id - Stores sharedPreferences “SatElegido” runs satElegidoSAXHandler to search into XML for date from sat picked Creates a “sat” Object with data from TLE Calls MenuOpciones.java 40 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 6. Design System Analysis scaleButtonText width, height p, text XScale calculate text width size to fit into box breadCrumbs width, height iSpecificType LinearLayout Sets BreadCrumbs buttons at the top of the screen according to iSepecificType breadCrumbsButton format variables Button sets format of breadCrumbs buttons mostrarAlerta Title 2 messages - show an alertDialog setButtonNames iType, select String returns SepecificType or GeneralType to set names of the icons buscarSatsEnXML - ArrayList<String> Calls listaSatsSAXHandler. Using SAX parses XML and retrieves all sat names. seleccionarUrlTLE type String loads URL from celestrack with txt files according to type escribirXML BufferWriter BufferReader - reads txt files from URL in celestrack.com parses txt and writes XML file escribirXSD BufferWriter - writes XSD Sheme MiTarea (CLASS) Asyntask that performs in background txt download and XML file creation. XML is created with all sats from TLEs txt file. calls “buscarSatsEnXML” and saves names for the listView Superclasses listActivity, SAXParserFactory, SAXParser, XMLReader, ProgressDialog, Resources, LinearLayout, ScrollView, Button, BufferWriter, BufferREader, SharedPreferences, Intent Attributes ArrayList<String> (alistaSat), String (sUrlTLE, “MyFile”, “TLE.xml”, “XSD.xml”, query), sat (sat) Table 43. listaSats.java Object ListaSatsSAXHandler.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Performs a search into the XML and find sat names Methods Name Inputs Outputs Description getData - ArrayList<String> retrieves array with list of sat names found parse InputStream Context - Performs the query. Search every node Superclasses RootElement, Element, defaultHandler Attributes ArrayList<String> (listaNombres) Table 44. listaSatsSAXHandler.java Object satElegidoSAXHandler.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Performs a search into XML, find sat parameters, creates a sat object Methods Name Inputs Outputs Description getData - sat retrieves sat object with TLE parameters of the sat picked Rodrigo Santos Álvarez 41
6. Design System Analysis ZATDROID – Technical Manual satElegidoSAXHandler String - Constructor: it takes the sat name parse InputStream Context - retrieves sateElegido from SharePref Performs the query. Search every node Superclasses RootElement, Element, defaultHandler Attributes String (satElegido) Table 45. satElegidoSAXHandler.java Object sat.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Object with all data of the satellite picked Methods Name Inputs Outputs Description sat - - Constructor sat(…) parameters - Constructor: it takes the parameters get… - attribute retrieves a certain attribute set… value - sets a certain attribute value sat(…) Parcel - parcelling part copyData sat - copies data to another sat object showLog - - writes object content to logCat writeToparcel Parcel, int - parcelling part Superclasses Parcelable Attributes name, number, inclination, raan, eccentricity, argumentPerigee, meanAnomly, meanMotion, epochYear, epoch, epochC, epochN, epochJD, meanMotionDerivate, bstarDragTerm, epehemeridesType, encontrad, r1, r2, r3, rdot1, rdot2, rdot3, lat, lon, az, ele, alt, range Table 46. sat.java Object menuOpciones.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Menu with the two functionalities Methods Name Inputs Outputs Description onCreate Bundle - Set Layout Retrieves SahredPref“TipoSatEspecifico” indentificarBotones - - Identify buttons layout layoutCode width, height typeSelected LinearLayout Creates adjustable Layout Components Selects subtypes according to input type iconsLine button format param. LinearLayout Defines one line with two icons in a linearLayout breadCrumbs width, height iSpecificType LinearLayout Sets BreadCrumbs buttons at the top breadCrumbs2 width, height LinearLayout Sets BreadCrumbs 2nd line with name breadCrumbsButton format variables Button sets format of breadCrumbs buttons setButtonNames iType, select String returns SepecificType or GenralType to set names of the icons 42 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 6. Design System Analysis scaleButtonText width, height p, text XScale calculate text width size to fit into box onClick View - calls ARintro when AR button is pressed (previous ProgressDialog created) calls MapActivity if Map button clicked. Superclasses Activity, View.onClickListener, LinearLayout, ProgressDialog, SharedPreferences, Intent Attributes Buttons (R, Map), sat, ProgresDialog Table 47. menuOpciones.java Object MapsActivity.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Google Maps functionality Methods Name Inputs Outputs Description onCreate Bundle - Set Layout Retrieves at object calculates current time calls calculationsSatPOS.class to calculate position creates layer list ,add compass and MapOverlay class Superclasses MapActivity, MyLocationOverlay, MapView, MapsController, Dundle, Calendar, GeoPoint, MapOverlay Attributes MyLocationOverlay (Compass), MapView (map) Table 48. MapsActivity.java Object MapsOverlay.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Google Maps layer class Methods Name Inputs Outputs Description MapOverlay sat - Constructor: set current time calls method trajectory for the first time create Geopoint with sat position trajectory sat double[] Calculates sat trajectory calling CalculationsSatPOS 20 positions predicted (1 per minute, 10 past, 10 future) & creates array draw Canvas, MapView, boolean Boolean log refreshes view instantly updates trajectory (1 second delay) draws sat icon and updates its geoPoint draw text info box Superclasses com.google.android.maps.Overlay, Calendar Attributes CalculationsTime, sat, double[] (trajectpoints) Table 49. MapsOverlay.java Rodrigo Santos Álvarez 43
6. Design System Analysis ZATDROID – Technical Manual Object ARIntro.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description First Augmented reality manager Methods Name Inputs Outputs Description onCreate Bundle - retrieves sat object calls DevicePositionProvider for sat position: lat, lon, alt calls CalculationsSatTRACK for sat orientation (azimuth, elevation) if ele<0, calculate next overhead pas and show message calls ARCameraActivityOverlay showAlert Title 2 messages - show an alertDialog Superclasses Activity, Calendar, AlertDialog Attributes double (latitude, longitude, altitude), sat Table 50. ARIntro.java Object ARCameraActivityOverlay.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description AR View Manager Methods Name Inputs Outputs Description onCreate Bundle - Create Camera, Sensors, renders, surfaceViews and two TextViews Set Layout with previous layers getCameraInstance - Camera starts camera onSensorChanged SensorEvent - refreshed Sensors values getRotationMatrix and Orientation Vector from device Calculates device azimuth and elevation and send them to the renders update textView with device info showAlert Title 2 messages - show an alertDialog onStop - - unregisters Sensor Listeners Superclasses SensorManager, Sensor, FrameLayout, Camera, SensorEvent, AlertDialog Attributes Camera, ARCameraPreview_Overlay, AROurSurfaceOverlaySat, AROurSurfaceOverlayCruz, AROurSurfaceOverlayFlecha, SensorManager, Sensor, float[] (several), DevicePositionProvider, ARGLRenderOverlayMovSat, ARGLRenderOverlayMovCruz, ARGLRenderOverlayMovFlecha Table 51. ARCameraActivityOverlay.java 44 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 6. Design System Analysis Object CalculationsOrbitSDP4.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description implements SDP4 NORAD method Methods Name Inputs Outputs Description resetStaticVars - - configures variables getOrbit tsince, sat CalculationsVarGlobal sat calculates position and velocity with SDP4. It uses CalculationsVarSDP4, CalculationsOrbitSDP4_Deep Superclasses - Attributes - Table 67. CalcualtionsOrbitSDP4.java Object CalculationsOrbitSDP4_Deep.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description implements SDP4 NORAD method variables Methods Name Inputs Outputs Description deepCalc int, Vriables Variables SDP4 configures variables SDP4 Superclasses - Attributes - Table 68. CalcualtionsOrbitSDP4_Deep.java Object CalculationsVarSDP4.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Variables used in SDP4 Methods Name Inputs Outputs Description get… - value get values from variable set… value - set value for a variable copyData CalculationsVarSDP4 - copy object showlog - - show content in logCat Superclasses - Attributes SDP4 variables Table 69. CalcualtionsVarSDP4.java Object CalculationVarGlobal.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Variables used in SDP4 and SGP4 Methods Name Inputs Outputs Description get… - value get values from variable set… value - set value for a variable copyData CalculationsVarGlobal - copy object showlog - - show content in logCat Superclasses - Attributes SDP4 and SGP4 variables Table 70. CalcualtionsVarGlobal.java Rodrigo Santos Álvarez 51
6. Design System Analysis ZATDROID – Technical Manual Object CalculationsTime.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Methods used to transform time formats Methods Name Inputs Outputs Description julian year, month, day double conventional to julian date Julian_date_of_year year doble Julian date of year Julia_date_of_epoch epoch, epochYear double Julian date of (epoch in NORAD format) DOY year, month, day int day of year Fraction_of_day hour, min, sec double fraction of a day Julian_date Calendar double Calendar type to Julian date getCalendarFromJD jd Calendar julian Date to Calendar ThetaG_JD double double Greenwich mean sidereal time from Julian date thetaG epoch, epochYear double Greenwich mean sidereal time from NORAD date sat_Eclipsed vector, vector, depth int calculates sat eclipse status and depth test - int carries out tests of every method Attributes CalculationMaths Table 71. CalcualtionsTime.java Object CalculationMaths.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Mathematical functions Methods Name Inputs Outputs Description FMod2p double double calculates 0-2 angle FixAngle double double calculates 0-2 angle Frac double double returns fractional part Round double int returns argument rounded to nearest integer Int double double floor integer Test - int carries out tests of every Attributes CalculationMaths Table 72. CalcualtionsMaths.java Object k.java Version V1.0 – 15/08/2013 Author Rodrigo Santos Álvarez Description Mathematical constants Table 73. k.java Object visibleSats.java Description Calculates list of visible sats (ele>0). This class is not implemented. It lasts 35 minutes and it is out of requirements It gets a list of sat names that can be tracked (ele>0) from device location. Table 74. visibleSats.java 52 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 6. Design System Analysis 6.6. BEHAVIOR MODEL 6.6.1. USE CASES DIAGRAM Figure 14. Use Cases Diagram This diagram is repeated, but it is considered important to introduce next diagrams. Rodrigo Santos Álvarez 53
6. Design System Analysis ZATDROID – Technical Manual 6.6.2. SEQUENCE DIAGRAMS Only the most representative diagrams are shown. Figure 15. Sequence Diagram 01: Creating sat JAVA Object from XML 54 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 6. Design System Analysis Figure 16. Sequence Diagram 02: UC-01: Download Satellite list (search by name) Rodrigo Santos Álvarez 55
6. Design System Analysis ZATDROID – Technical Manual Figure 17. Sequence Diagram 03: UC-03: GOOGLE MAPS View 56 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 6. Design System Analysis Figure 18. Sequence Diagram 04: UC-05: Augmented Reality View (I) Rodrigo Santos Álvarez 57
6. Design System Analysis ZATDROID – Technical Manual Figure 19. Sequence Diagram 05: UC-05: Augmented Reality View (II) 58 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 6. Design System Analysis 6.7. SUMMARY CLASSES DIAGRAMS General Classes Diagram Satellite Explorer Classes Diagram Augmented Reality classes Diagram GOOGLE MAPS Classes Diagram OBJECT TYPE intro listaTipoSats searchActivity MiTarea searchListaSatsSAXHandler listaTipoSat2 listaSats listaSatsSAXHandler satElegidoSAXHandler sat MenuOpciones MapsActivity MapOverlay ARIntro ARCameraActivityOverlay ARCameraPreview_Overlay AROurSurfaceOverlaySat AROurSurfaceOverlayFlecha ARSurfaceOverlayCruz ARGLRenderOverlayMovSat ARGLRenderOverlayMovCruz ARGLRenderOverlayMovFlecha ARGLSat ARGLFlecha ARGLCruz Vector DevicePostionProvider CalculationsSatPOS CalculationsSatTRACK CalculationsTime CalculationsMaths CalculationsOrbit CalculationsOrbitSDP4 CalculationsOrbitSGP4 CalculationsOrbitSDP4_Deep CalculationsVarGlobal CalculationsVarSDP4 CalculationsMaths k visibleSats SEQUENCE DIAGRAM Creating sat JAVA Object from XML UC-01: Download Satellite list (search by name) UC-03: GOOGLE MAPS View UC-05: Augmented Reality View (I) UC-05: Augmented Reality View (II) DEPLOYMENT DIAGRAM Deployment Diagram PACKAGE DIAGRAM Packages Diagram Table 75. Design summary Rodrigo Santos Álvarez 59
7. User Interface Design ZATDROID – Technical Manual 7. USER INTERFACE DESIGN 7.1. GUI REQUIREMENTS Once the design of the back-end has been determined, it is now time for the graphical user interface. As it is the door of the whole application to the user, it is really essential that it fits some requirements. There are brilliant apps in the market whose GUI is not as expected. Therefore, it is not successful. Moreover, nowadays GUI´s importance is increasing as we live in a visual world expecting immediate results. ZatDroid GUI is required to fit some expectations: • Friendly, beautiful, attractive and colourful. • Multilanguage support: English and Spanish. Automatically selected with default device language. • Icon based: icons must be the way to navigate and must be representative. • BreadCrumbs buttons: indicate the selections picked, where is the user within the app and allow navigating backwards • ListViews for long lists • Progress bars shown when a process is taking some time, e.g., downloading. • Support different device screen sizes. • Delay between screen must be less than 3 seconds. 7.2. SCENARIOS In order to clearly describe the processes running under every screen, some scenarios are going to be defined. Although the class diagrams and descriptions has clarify the flow, it is considered really helpful to explain the flow following the user experience. Sequence diagrams could have been created, but an example seemed too long and complicated to understand, so a brief description is considered more appropriate. These Scenarios will be defined taking into account Figure 20 Figure 20. Scenarios 60 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 7. User Interface Design 3b (right screen) listaSats.java in its onCreate method retrieves tipoSatEspecifico from SharedPreferences and select the URL from the txt file in celestrak.com via method seleccionarUrlTLE according to tipoSatElegido. It also starts the progress bar. Then the Asynctask “MiTarea”is created: • Reads txt file from celestrak.com and writes one xml file following format rules previously detailed and also the XSD Scheme. Both files are stored in the internal memory. • Updates progress bar while the process is being carried out. • Searches into the XML for all the sat names invoking ListaSatsSAXHandler which is in charge of managing the search. It extends defaultHandler and uses SAX ElementRoot and Element to go through all nodes and store all sat name. A listArray is created with all these sat names • MiTarea finishes and the progress bar disappears. Go to Scenario 5. This process lasts less than the other option because it reads only one txt file from celestrack.com, not all of them and fits with the requirements. onClick: This screens disappear automatically. It is not clickable. Rodrigo Santos Álvarez 67
7. User Interface Design ZATDROID – Technical Manual 7.2.7. SCENARIO 5: SATELLITE NAMES LIST General Description: ListView showing satellite names according to previous selections. Figure 27. Scenario 5: Satellite names list onCreate: Coming from searchActivity.java (left screen, scenario 3a) or listaSats.java (right screen, scenario 3b): • ListView is created, lista_sats.xml layout complemented with code layout for BreadCrumbs • BreadCrumbs at the top supporting English and Spanish. Here it can be seen the only one difference between screens. If coming from scenario 3a, the complete address is not shown, as there has not been any type-based selection. So BreadCrumbs only allows to navigate home. onClick: • BreadCrumbs Buttons: navigate backwards. • onListItemclick: the name is saved in SharedPreferences as “satElegido”. • The system searches into the XML for the sat picked. satElegidoSAXHandler which is in charge of managing the search. It extends defaultHandler and uses SAX ElementRoot and Element to go through all nodes and store the information only from the sat picked. A “sat” Java object is created with all these parameters. Sat is declared as Parcelable, so that it can be accessed from every class. • Go to Scenario 6. 68 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 7. User Interface Design 7.2.8. SCENARIO 6: FUNCTIONALITIES MAIN MENU General Description: options menu Figure 28. Scenario 6: Functionalities main menu onCreate: • Layout menu_apps.xml • BreadCrumbs at the top supporting English and Spanish. (as shown in images) It retrieves “satElegido” and “tipoSatEspecifico” from SharedPreferences to show the complete route of selections. • Icons represents the two functionalities. (English and Spanish version is displayed)) Buttons are created with XML resources setting states changing colours when clicked and modifying visual characteristics. The images are real screenshots. onClick: • Sat parcelable is retrieved. • BreadCrumbs buttons: navigate backwards • Top button: calls mapsActivity.java opening GOOGLE MAPS view. Go to Scenario 7. • Bottom button: calls ARIntro.java starting the augmented reality view. While the view is loading, a dialog spinnerstyle pops up. (Figure 27a.). Go to Scenario 8. Figure 28a. Scenario 6: loading spinner dialog Rodrigo Santos Álvarez 69
7. User Interface Design ZATDROID – Technical Manual 7.2.9. SCENARIO 7: Google Maps VIEW General Description: GOOGLE MAPS View Figure 29. Scenario 7: Google Maps View onCreate: • Layout “map” provided by GOOGLE MAPS. Some layers overlays the MapView • It retrieves parcelable “sat” with TLE information of the picked satellite • CalculationsTime object is created to modify time format • CalculationsSatPOS is performed and sat Java object is completed with latitude, longitude and altitude of the satellite. These calculations will be detailed as their implementation in section 8 • Geopoint with latitude and longitude of the sat is created and map is centred onto this point • List of overlays is defined: o Compass is added to the view as a new layer o MapView GOOGLE class is added as another layer. This class contains the GOOGLE MAPS information. MapView class: A first trajectory line is drawn: 10 GeoPoints for the past 10 minutes and 10 GeoPoints for predicted 10 minutes are calculated thanks to CalculationsSatPOS which gives latitude , longitude and altitude, known time and sat object. These GeoPoints are joined with a line using Path object and there it is the trajectory. Then method “draw” is refreshing the view instantly with all these objects: o Geopoint of the sat, together with an icon using BitMap and Canvas. o Trajectory, recalculating and redrawing it. It is limited to a 1 second refresh because the calculations are too complex and the line could deform. This is why a little delay can be notice when moving zooming or translating the map o Canvas.drawText shows text with name, latitude longitude and altitude of the satellite at the top left corner of the screen. onClick: this screen is not clickable. The back Button from ANDROID closes this view and comes back to Scenario 6 70 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 7. User Interface Design 7.2.10. SCENARIO 8a: NEXT OVERHEAD PASS General description: In case satellite elevation is less than 0 (under the horizon) a message with next overhead pass is shown. Figure 30. Scenario 8a: Next overhead pass onCreate: • ARIntro.java is called • It retrieves parcelable “sat” with TLE information of the picked satellite • DevicePositionProvider is called for latitude, longitude and altitude from device. It uses LocationManager, GPS, Network and web Service GOOGLE MAPS elevation if necessary. • CalculationsTime modifies format date. • Orbital Mechanics is developed by CalculationsSatTRACK method, where knowing sat object, device position and current time it calculates elevation and azimuth of the satellite from the place where the device is located. • Just in case sat elevation is lower than 0, the satellite is under the horizon, and the message of figure 29 gives information about it. Moreover, calculations inside a loop are developed increasing the current date and time, until the method knows when it will be the next overhead pass. This is also added to the message. onClick: • Next scenario is reached automatically when ok button is pressed: ARCameraActivityOverlay.java is started. Rodrigo Santos Álvarez 71
7. User Interface Design ZATDROID – Technical Manual 7.2.11. SCENARIO 8b: AUGMENTD REALITY VIEW General description: Augmented reality view positioning satellite in the sky. Figure 31. Scenario 8b: augmented Reality view onCreate: ARCameraActivityOverlay is started and manages all the process to create the complete view. • Implements SensorEventListener, so it is update every time a sensor changes. • It retrieves parcelable “sat” with TLE information of the picked satellite • The Camera SurfaceView is created (ARCameraPreview_Overlay.java) where the camera is started. • Now layers are managed with OPENGL. Each layer has a GLSurfaceView, a render and an object. • 3 GLSurfacesViews are also created as layer on top of the Camera view: o AROurSurfaceOverlaySat: draw the icon and uses sat Render. o AROurSurfaceOverlayCruz: draw central square and uses crus Render. o AROurSurfaceOverlayFlecha: draw arrow indicating the location of the sat. Uses fleche render. • These GLSurfaceViews uses Renders created also in ARCameraActivityOverlay. o ARGLRenderOverlayMovSat: It creates ARGLSat object which sets the geometrics of the Sat. Receive gravity vector, azimuth and elevation of device and smooth the values to make the view more stable GL10 object is created onDrawFrame method, updated instantly, manages OPENGL camera with GLU.gluLookAt changing vectors between coordinate systems, draws the icon when orientation from device and sat matches or is near (percentage calculation) and configure screen OPENGL view limits. o ARGLRenderOverlayMovCruz: similar to previous render, but with the central square. It changes colour when orientation from device and sat matches exactly. The sat icon is inside the square. It creates ARGLCruz object. o ARGLRenderOverlayMovFlecha: similar with the arrow. It indicates the direction in which the sat can be found. It helps the user to rotate the device in the right way. It disappears when orientation from device and sat matches in a certain percentage. It creates ARGLFlecha object. 72 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 7. User Interface Design • DevicePositionProvider gives the position of the satellite, taking advantage of GPS, network, location manager and, if necessary, web service GOOGLE MAPS Elevation with Http classes of ANDROID. • Sensors accelerometer, magnetic and gravity are created. • 2 TextViews with information of sat orientation and device orientation are created and added on top of the view. • onSensorChanged method keeps the values updated. This method is executed whenever a sensor changes. o RotationMatrix with information of the coordinate system axis of the device is retrieved and then used to calculate the elevation and azimuth of the device in real time. o TextViews of the device is updated. o Device elevation and azimuth are passed to the renders. Onclick: this screen is not clickable. The back Button from ANDROID closes this view and comes back to Scenario 6 Rodrigo Santos Álvarez 73
8. Orbital Mechanics ZATDROID – Technical Manual 8. ORBITAL MECHANICS This project makes sense since it involves a lot of knowledge in orbital mechanics. This section aims to be an introduction of the complex calculations used, as well as some general concepts concerning satellites. Taking advantage of the introduction in the final year project report section 6, some more detailed information is given below. 8.1. COORD. SYST., NEWTON`S & KEPLER`S LAWS. KEPLERIAN ELEMENTS. All this information has been already introduced in project report. Taking all that concepts in mind, and playing with the formulas. It an be demonstrated that once the keplerian elements are known for a orbit, position and velocity can be calculated given a current time and a known initial condition. Figure 32 shows the process and formulas that are used in the process to calculate position and velocity vectors out of keplerian elements. Detailed process with equations can be found in [2] Figure 32. Diagram for orbit prediction with Newton´s equations. 74 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 8. Orbital Mechanics Needless to say that this is a theoretical development that could be right in ideal conditions, based on the assumption that the motion of the satellite is a result of the gravitational attractions between two bodies. So it is clear that new and improved models need to be developed. 8.2. NORAD ORBIT PROPAGATION MODELS SpaceTrack Report 3 [4] developed for the first time in 1980 the complete models to face orbits prediction and there is no better source to explain what they did: “NORAD maintains general perturbation element sets on all resident space objects. These element sets are periodically refined so as to maintain a reasonable prediction capability on all space objects. In turn, these element sets are provided to users. The purpose is to provide the user with a means of propagating these element sets in time to obtain position & velocity space object” “The most important point to be noted is that not just any prediction model will suffice. The NORAD element sets are mean values obtained by removing periodic variations in a particular way. In order to obtain good predictions, these periodic variations must be reconstructed (by the prediction model) in exactly the same way they were removed by NORAD. Hence, inputting NORAD element sets into a different model (even though the model may be more accurate or even a numerical integrator) will result in degraded predictions. The NORAD element sets must be used with one of the models described in this report in order to retain maximum prediction accuracy” 8.2.1. NORAD TLES Two Line Element Sets TLEs are the files containing the element sets daily updated by NORAD. With this information and studying the models, the position and velocity of any object in space can be retrieved. Although format of TLEs has already been explained, figure 33 review it: Figure 33. TLEs explanation Rodrigo Santos Álvarez 75
8. Orbital Mechanics ZATDROID – Technical Manual These data can be used together with SGP models to obtain accurate propagation of the orbit. • First line contains identification data sets and perturbation influences by geopotential (The Earth is not an sphere) and the drag forces. • The Second line provides with the keplerian elements expect for the semimajor axis, that can be determined easily. These TLEs are provided at the moment by Celestrak.com, which was created and is maintained by Dr. T.S. Kelso, recognized worldwide as an expert in the area of satellite tracking and orbit determination. Regularly sought out for advice and counsel by NASA, European Space Agency (ESA), Russian Space Institute, US and AF Space Command, and many universities and commercial space organizations. TLEs are txt files classified into several files by satellite types. There is a fixed URL for every satellite type, e.g., http://celestrak.com/NORAD/elements/weather.txt for weather satellites. ZATDROID implements lists that matches the type required with its URL and then a download module (UC-01) is executed. 8.2.2. NORAD PROPAGATIONS MODELS SGP4/SPD4 Five mathematical models for prediction of satellite position and velocity are available: [4] • SGP (Simplified General Propagation) was developed by Hilton & Kuhlman (1966) and is used for near-Earth satellites. This model uses a simplification of the work of Kozai (1959) for its gravitational model and it takes the drag effect on mean motion as linear in time. This assumption dictates a quadratic variation of mean anomaly with time. The drag effect on eccentricity is modelled in such a way that perigee height remains constant. • SGP4 (Simplified General Propagation version 4) was developed by Ken Cranford in 1970 (see Lane and Hoots 1979) and is used for near-Earth satellites. This model was obtained by simplification of the more extensive analytical theory of Lane and Cranford (1969) which uses the solution of Brouwer (1959) for its gravitational model and a power density function for its atmospheric model (see Lane, et al. 1962). • SDP4 (Simplified General Deep Space Perturbation model version 4) is an extension of SGP4 to be used for deep-space satellites. The deep-space equations were developed by Hujsak (1979) and model the gravitational effects of the moon and sun as well as certain sectoral and tesseral Earth harmonics which are of particular importance for half-day and one-day period orbits.” In order to describe such disturbance forces, here it is a brief overview to them: [2] SGP: • Perturbations due to Geopotential The Earth is not spherical, in fact it has a bulge at the equator, is flattened at the poles and is slightly pear-shaped. This leads to perturbations in all Keplerian elements. The second order deformation of the Earth considers the fact that it is slightly flattened. • Perturbations due to the Sun and the Moon The Sun and the Moon causes periodic variations in all Keplerian elements, but secular perturbations only to the right ascension of ascending node and the argument of perigee. These perturbations have their minima for the same inclinations, i, as the non spherical Earth perturbations and become larger for higher altitude orbits. 76 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 9. Breakthrough Design Features 9.5. BREADCRUMBS NAVIGATION BUTTONS In every screen at the top the user can find some buttons as indicated in figure 8. These so-called BreadCrumbs functions are: • To be helpful as they provide information of the satellite type picked during the process of several screens. All types are shown so that the user, at first sight, remembers the types and name of the satellite picked. • To allow the user to navigate through the previous screens, changing the type picked, just by clicking on one of the buttons of the breadcrumbs. The layouts affected are created programmatically, not with XML. This is another example where layouts defined with code allow to add some more functionalities than with XML. Figure 36. BreadCrumbs Examples can be seen in the code. They are too large to bring examples to this document. 9.6. GOOGLE SEARCH ACTIVITY The first screen gives the opportunity to select searching a satellite by it type or launching a search by some key words. See Figure 9. This last functionality uses GOOGLE Search Activity from Android. The button calls onSearchRequested method and the GOOGLE interface is launched. It opens a dialog with a keyboard where you can write key words to find a satellite. It also supports voice search. It opens searchActivity and calls onNewIntent method, then handleIntent, where the string is retrieved and starts the process with doSearch method. Figure 37. GOOGLE Search & progress bar CELESTRAK provides txt files with TLEs classified by type. To be able to perform the search in all satellite files provided by CELESTRAK, ZATDROID needs to download all files, merge them together in one file and then search. This process lasts some seconds, it is encoded inside an Asynctask and a progress bar is shown to the user. private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); this.query = query; doSearch(query); } } private void doSearch(String queryStr) { ... } } Rodrigo Santos Álvarez 83
9. Breakthrough Design Features ZATDROID – Technical Manual 9.7. DEVICE LOCATION PROVIDER Latitude, longitude and altitude of the device must be known whenever a prediction for the location of the satellite in the sky is intended to do. Besides knowing the satellite georeference, also device coordinates are essential. With the help of [12] ZATDROID implements a customized LocationListener to retrieve latitude and longitude coordinates: • Checks that Network or GPS is enabled. If not, it shows a message to the user requiring at least one connection. • Firstly retrieves location from Network provider. It is quicker and usually devices enables network but not always GPS. • Secondly, if GPS is enabled, as it is more precise, uses it to get a more accurate location. Finally, altitude is also required. • If GPS is enabled, it is easy. GPS gives it together with latitude and longitude. • Otherwise, a web service is called using a httpRequest. There are two possibilities based on 3D maps of the Earth: [13] o USGS Elevation Query Web Service: [14] o GOOGLE MAPS Elevation API Web Service: [15] ZATDROID implements GOOGLE MAPS Elevation API Web Service, although there is no big difference between them, advantages or disadvantages. • Retrieve latitude and longitude from GPS and/or Network: public Location getLocation() { try { locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE); // getting GPS status isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); // getting network status isNetworkEnabled = locationManager.isProviderEnabled(LocMngr.NETWORK_PROVIDER); if (!isGPSEnabled && !isNetworkEnabled) { // no network provider is enabled } else { this.canGetLocation = true; // First get location from Network Provider if (isNetworkEnabled) { locationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER,MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this); if (locationManager != null) { location = locationManager.getLastKnownLocation(LtnMngr.NETWORK_PROVIDER); if (location != null) { latitude = location.getLatitude(); longitude = location.getLongitude(); } } } 84 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 9. Breakthrough Design Features // if GPS Enabled get lat/long using GPS Services if (isGPSEnabled) { if (location == null) { locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this); if (locationManager != null) { location = locationManager.getLastKnownLocation(LocatMar.GPS_PROVIDER); if (location != null) { latitude = location.getLatitude(); longitude = location.getLongitude(); } } } } } • Connecting to Web service GOOGLE MAPS elevation: // Write the url for the request HttpClient httpClient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); String url = "http://maps.googleapis.com/maps/api/elevation/" + "xml?locations=" + String.valueOf(latitude) + "," + String.valueOf(longitude) + "&sensor=true"; HttpGet httpGet = new HttpGet(url); // Process the answer HttpResponse response = httpClient.execute(httpGet, localContext); HttpEntity entity = response.getEntity(); 9.8. SENSORS MANAGEMENT Method mSensorManager provides access to all sensors installed in the device. Three sensors are to be used by ZATDROID: • Accelerometer: measures the acceleration applied to the device that gives the orientation. • Magnetic Field: magnetic vector is provided device coordinate system. • Gravity: Gravity vector is given in device coordinate system. Vectors need a reference coordinate system and as the device is moving and rotating, the transformation matrix is also necessary. Two methods inside mSensorManager (getRotationMatrix and getOrientation) give information about the orientation and coordinate system of the device and the transformation matrix. onSensorChanged is where all changes in the measurements are noticed and sent to the code. • Declaring Sensors: private SensorManager mSensorManager; private Sensor mAccelerometer, mMagnetic, mGravity; mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mMagnetic = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); mGravity = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY); mSensorManager.registerListener(this, mMagnetic,SensorManager.SENSOR_DELAY_UI); mSensorManager.registerListener(this, mAccelerometer, 300000); mSensorManager.registerListener(this, mGravity, SensorManager.SENSOR_DELAY_UI); Rodrigo Santos Álvarez 85
9. Breakthrough Design Features ZATDROID – Technical Manual • Retrieveing measurements: public void onSensorChanged(SensorEvent event) { // TODO Auto-generated method stub switch (event.sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: System.arraycopy(event.values, 0, vGrav, 0, 3); break; case Sensor.TYPE_MAGNETIC_FIELD: System.arraycopy(event.values, 0, vMag, 0, 3); break; case Sensor.TYPE_GRAVITY: System.arraycopy(event.values, 0, vGravSensorGrav, 0, 3); break; } • Rotation Matrix and Orientation vector: mSensorManager.getRotationMatrix(vR, vI, vGrav, vMag); mSensorManager.getOrientation(vR, vOrient); 9.9. SMOOTH MOVEMENTS FILTER [16] The augmented reality functionality requires to retrieve device orientation in real time. This information is used to locate the satellite icon on the screen when the user is rotating the device searching the right orientation (azimuth & elevation). Then, icon is moving through the screen. This movement depends on the accuracy, updating time and speed of rotating the device. One method has been implemented to smooth the movement of the icon on the screen: filterSmoothMovements. It takes two factors into account: • SmoothFactorCompass: so that the small jumps do not disturb • SmoothThresholdCompass: minimum distance so that the icon jumps private double filterSmoothMovements(double oldValue, double newValue) { //Degrees /* The easing float that defines how smooth the movement will be *(1 is no smoothing and 0 is never updating, my default is 0.5). *We will call it SmoothFactorCompass. * The threshold in which the distance is big enough to turn immediately * (0 is jump always, 360 is never jumping, my default is 30). * We will call it SmoothThresholdCompass */ double SmoothFactorCompass = .4; //factor so that the small jumps do not disturb double SmoothThresholdCompass = 30.0; // minimum distance so that the icon jumps if (Math.abs(newValue - oldValue) < 180) { if (Math.abs(newValue - oldValue) > SmoothThresholdCompass) { temp = newValue; } else { temp = oldValue + SmoothFactorCompass * (newValue - oldValue); } } else { if (360.0 - Math.abs(newValue - oldValue) > SmoothThresholdCompass) { temp = newValue; } else { if (oldValue > newValue) { temp = (oldValue + SmoothFactorCompass * ((360 + newValue - oldValue) % 360) + 360) % 360; } else { temp = (oldValue - SmoothFactorCompass * ((360 - newValue + oldValue) % 360) + 360) % 360; } } } return temp; 86 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 9. Breakthrough Design Features 9.10. MIGRATION OF SGP4 CODE FROM FORTRAN / C TO JAVA FOR ANDROID Document [4] stated the definition of the methods to calculate the propagation of the orbits taking into account perturbations due to disturbance forces. This was in 1980 in FORTRAN language. A new revision was developed in 2006 in C [6] Some other reviews and improvements have been implemented but the heart still remains. ZATDROID implements the code from 1980 with some modifications (not all) from 2006 migrated to JAVA for ANDROID. 9.11. AUGMENTED REALITY VIEW: LAYERS OVER CAMERA VIEW. Augmented Reality views means to be able to merge the camera view with some other artificial layers with digital information and let both worlds interchange information and interact with each other. This has been achieved thanks to the GLSurfaceView and SurfaceView classes and then overlapping them with addViews. All these layouts have been created programmatically, as already explained before to increase customization. ZATDROID implements 6 layers at the same time: (Figure 10) 1) The camera view, as usual: ARCameraPreview_Overlay (SurfaceView) 2) A rectangle in the centre that changes colour when device orientation is directly pointing at the satellite in the sky. a. AROurSurfaceOverlayCruz (GLSurfaceView) b. ARGLRenderOverlayMovCruz (Renderer) c. ARGLCruz: class object 3) An arrow indicating the direction of the satellite to rotate the device a. AROurSurfaceOverlayFlecha (GLSurfaceView) b. ARGLRenderOverlayMovFlecha (Renderer) c. ARGLFlecha: class object 4) An icon symbolizing the satellite in the right azimuth and elevation. a. AROurSurfaceOverlaySat (GLSurfaceView) b. ARGLRenderOverlayMovSat (Renderer) c. ARGLSat: class object 5) TextView with the name and orientation (azimuth and elevation) of the satellite 6) TextView with elevation and azimuth of the device updated in real time. Figure 38. Augmented reality view Rodrigo Santos Álvarez 87
9. Breakthrough Design Features ZATDROID – Technical Manual 9.12. OPENGL USAGE When implemented AR View, it was complicated to visualize the icon of the sat only when the device was pointing at the direction of the satellite. OPENGL has been used to rotate the virtual camera that shows the icon at the same time as the device camera is rotated by the user. • GLU.gluLookAt and GL10.glFrustumf control the focus, position and movements of the virtual camera. • GL10 class manages all other OPENGL requirements. • As explained before, the moving coordinate systems made the vectors transformations really complicated. Complex matrixes were used. • The geometry of the arrow and rectangle was easy, but the icon was inside a rectangle and was always moving, so updating the geometry of the icon really increased the difficulty. 9.13. GOOGLE MAPS VIEW As one of the two main functionalities, locating the satellite icon in the GOOGLE MAPS in real time with latitude and longitude is exciting. These maps have the same appearance as the maps you see in your computer, but here you can customize to show whatever you want to (Figure 10) • MapActivity is the class extended in ZATDROID. Newer versions of ANDROID has deprecated MapView object and replaced it with GoogleMap object. The heart is similar but other complements are improved. For this app, MapView fits all requirements. • com.google.android.maps.Overlay is the layer where all the information is added and shown onto the map. • A canvas let the program add the satellite icon as a bitmap together with the geoPoint represented by the latitude and longitude of the satellite. • Also in this canvas a drawPath object allows to draw a trajectory line. This trajectory represents the orbit in its last 20 minutes and its predicted 20 coming minutes, all calculated iterating the propagating models. • And the last layer is the textView with name, latitude and longitude of the satellite updated in real time. The satellite icon is updated almost instantly. The refreshing delay for the trajectory is one second though, that is, the trajectory stays old when zooming or moving the map. It was tested to update the trajectory several times per second so that the visual appearance was smoother, but the high amount of calculations, made it not possible for the program. If the user ever sees a satellite at high altitudes (30.000 Km) and the trajectory is not drawn, it is not a bug. The satellite follows a geostationary orbit and therefore it is fixed. Actually, it is rotating with the Earth. For an inhabitant it is always in same position, same latitude and longitude. Figure 39. GOOGLE MAPS View 88 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 9. Breakthrough Design Features 9.14. XML/XSD MANAGEMENT The TLEs downloaded from CELESTRAK is provided in txt format as described in appendix 1. One of the objectives of this project was to learn XML language. Therefore, the data management in ZATDROID was in XML. So TLEs are transformed into XML. The XML format is shown in appendix 2. The way to create XML from the txt is done manually, by parsing txt NORAD format and then writing XML tags and content. The files are storaged in the internal memory, as explained before in this section. protected void escribirXML(BufferedWriter xml, BufferedReader in) { ... • Read txt from URL: while (continuar) { // //Read txt file and parse it ////////////// linea1 = new StringBuilder(aux); // //// Erase spaces after the name while (linea1.toString().endsWith(" ")) { linea1.delete(linea1.toString().length() - 1, linea1.toString().length()); } // & simbol give an error in the name. Erase it. if (linea1.toString().contains("&") ){ linea1.deleteCharAt((linea1.toString().indexOf("&"))); } // second line try { linea2 = in.readLine(); // read the whole line linea2 = linea2.trim().replaceAll(" +", " "); // Leave only one space splitLinea2 = linea2.split(" "); // parse it // Third line linea3 = in.readLine(); // read the whole line linea3 = linea3.trim().replaceAll(" +", " "); // Leave only one space splitLinea3 = linea3.split(" "); // parse it } catch (IOException e1) { e1.printStackTrace(); } • Write XML: xml.write(INI + sat); xml.newLine(); xml.write(INI + info); xml.newLine(); xml.write(INI + name + linea1.toString() + END + name); xml.newLine(); xml.write(INI + number + splitLinea2[1] + END + number); xml.newLine(); xml.write(END + info); xml.newLine(); xml.write(INI + keplerianElements); ... Rodrigo Santos Álvarez 89
9. Breakthrough Design Features ZATDROID – Technical Manual 9.15. SAX MANAGEMENT SAX (Simple API for XML) and DOM (Document Object Model) are the two methods to deal with XML data in ANDROID. A brief description is now given: [17] SAX: • Parses node by node • Doesn’t store the XML in memory • We can´t insert or delete a node • SAX is an event based parser • SAX is a Simple API for XML • Doesn’t preserve comments • SAX generally runs faster than DOM DOM: • Stores XML document into memory before processing • Occupies more memory • We can insert or delete nodes • Traverse in any direction. • DOM is a tree model parser • Document Object Model (DOM) API • Preserves comments ZATDROID is: • Dealing with big documents • Not inserting nodes, just reading • Intending not to use a lot of memory • Not reading the whole document, just the node required. • Not needing to store the whole document and creating the DOM tree. So SAX was decided to be the method for the searches into XML. ZATDROID looks into the XML for the satellite picked by the user and read all the information of this certain satellite to create afterwards a “sat” JAVA object. Element and ElementRoot are used to navigate through the nodes of the XML and then checking conditions and saving data. In this case, it goes through all nodes, search “name” Element and retrieve the value of all of the nodes in a list of arrays. public class listaSatsSAXHandler extends DefaultHandler { private ArrayList<String> ListaNombres = new ArrayList<String>(); public ArrayList<String> getData() { return ListaNombres; } public void parse(InputStream is) { String NAMESPACE = "http://www.w3schools.com"; RootElement root = new RootElement(NAMESPACE, "TLE"); // Just Name is read to show in the list Element E_sat = root.getChild(NAMESPACE, "sat"); Element E_info = E_sat.getChild(NAMESPACE, "info"); Element E_name = E_info.getChild(NAMESPACE, "name"); E_name.setEndTextElementListener(new EndTextElementListener() { Public void end(String body) { // body is the label informations ListaNombres.add(body); } }); try { Xml.parse(is, Xml.Encoding.UTF_8, root.getContentHandler()); } catch (SAXException e) { Log.e("SAX XML", "sax xml.parse ", e); } } 90 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 10. Testing and Validating 10. TESTING AND VALIDATING • Mathematics functions have a method test which check them • Time functions, preparing date format (JD, NORAD, calendar) for the NORAD models have also a test method inside CalcualtionsTime.class where all functions are checked. • One extra app has been developed to implement tests: • App Creation: activities management o Sensors Management o RotationMatrix and Orientation vector. This study of the coordinate system transformations, between device coordinate system and Earth Coordinate system has been really difficult and a lot of time has been invested on understanding the meaning of these values. o Augmented Reality view, overlaying camera view with TextViews, geometry. o OPENGL geometry creation and virtual camera management: 2D and 3D. o Device position provider examples; checking data with internet web sites retrieving latitude, longitude and altitude of the location. o Device orientation: checking with compass and experiment manually. • And finally, orbital mechanics: results in terms of latitude, longitude, altitude, azimuth and elevation, as well as position and velocity of the satellites, are the final values to be checked. o GPREDICT [1] is a free software application that gives all these values. This software is considered to be reliable. As free software, source code in C language can be downloaded and it contains two tests (test_001.c and test_002.c). These files consist of satellite TLE data, a date and time and their SPG4/SPD4 orbit prediction position and velocity vectors. These same tests have been performed with ZatDroid and after some reviews, the code has been tested against GPREDICT successfully. listaSats.class contains test code against GPREDICT. o AIAA 2006-6753 paper [6] provides the code for SGP4/SDP4 in C, Pascal and FORTRAN. ZATDROID has also been tested against this paper. o Spacetrack Report #3 [4] also gives test modules that has been checked. • Web sites tracking satellites can also provide these data: [18], [19] Rodrigo Santos Álvarez 91
11. List of References ZATDROID – Technical Manual 11. LIST OF REFERENCES [1] Csete, A. (2009). GPREDICT: Free, Real-Time Satellite Tracking and Orbit Prediction Softtware. Retrieved from http://gpredict.oz9aec.net/ [2] Daum, P. (2005). VIS SAT: A Satellite Footprint Visualization Tool (Master Thesis). Lancaster University. [3] Grzegorczyk , M. (2013). SATFINDER. Retrieved from http://esys.com.pl/satfinder [4] Hoots, Felix R., & Roehrich, R. L. (1980). Spacetrack Report #3: Models for Propagation of the NORAD Element Sets. Colorado Springs, CO: U.S. Air Force Aerospace Defense Command. [5] SATELLITE AR. (2011). ANALYTICAL GRAPHICS, INC. RETRIEVED FROM HTTP://SPACEDATA.AGI.COM/MOBILEAPPS/ABOUT.HTM [6] Vallado, D. A., Crawford, P., Hujsak, R., & Kelso, T. S. (2006). Revisiting spacetrack report #3. In Collection of Technical Papers - AIAA/AAS Astrodynamics Specialist Conference, 2006 (Vol. 3, pp. 1984–2071). (AIAA-2006-6753) [7] Videotutorials YOUTUBE, stackoverflow.com [8] WIKIPEDIA.COM [9] http://www.developerphil.com/parcelable-vs-serializable/ [10] developer.android.com/ [11] http://stackoverflow.com/questions/5092591/what-are-the-differencesamong-internal-storage-external-storage-sd-card-and-r [12] http://www.androidhive.info/2012/07/android-gps-location-managertutorial/ [13] http://stackoverflow.com/questions/1995998/android-get-altitude-bylongitude-and-latitude [14] http://gisdata.usgs.gov/xmlwebservices2/elevation_service.asmx [15] https://developers.google.com/maps/documentation/elevation [16] http://stackoverflow.com/questions/4699417/android-compassorientation-on-unreliable-low-pass-filter [17] http://stackoverflow.com/questions/12140851/sax-vs-dom-in-android [18] http://www.n2yo.com/ [19] http://www.isstracker.com/ 92 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 13. Appendices Rodrigo Santos Álvarez 99
13. Appendices ZATDROID – Technical Manual SDP4: (Simplified General Deep Space Perturbation model version 4) [4] 100 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 13. Appendices Rodrigo Santos Álvarez 101
13. Appendices ZATDROID – Technical Manual 102 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 13. Appendices Rodrigo Santos Álvarez 103
13. Appendices ZATDROID – Technical Manual 104 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 13. Appendices Rodrigo Santos Álvarez 105
13. Appendices ZATDROID – Technical Manual CONSTANTS DEFINITION 106 Rodrigo Santos Álvarez
ZATDROID – Technical Manual 13. Appendices ABBREVIATIONS Rodrigo Santos Álvarez 107
USER MANUAL ZATDROID Satellite Tracking and Augmented Reality App for ANDROID