Skip to content

Android v1.4 GPS location data collection

zaven edited this page Aug 13, 2020 · 8 revisions

Motivation

Currently we capture a single GPS coordinate during photo capture. A GPS accuracy of x meters only means that there is a 66% likelihood that the actual location is within x meters of the coordinate that was received. Sometimes a GPS coordinate therefore can be far off. To help mitigate this problem, we would like to capture much more GPS data, including both many GPS coordinates at the actual tree, as well as track data while the user moves around. Track data allows use to better understand the relative position between trees, even though additional GPS inaccuracies will still be present.

To further refine our approach, we also want to collect additional data, including the compass heading and gyroscope orientation during image capture. These are hints during image analysis. Additionally, Android supports a step counter provider. We would like to capture the number of steps counted between each tree capture.

GPS Capture Implementation

When a user has the application in the foreground we want to be capturing GPS coordinates constantly - latitude, longitude, accuracy, and GPS timestamp. All of this data will be sent to the cloud.

All data points collected between the time a user taps 'add tree' to begin capturing a tree and time when they finish capturing the photo (but not the completed capture) will be tagged with the UUID of the tree. This UUID will be uploaded with the GPS data to link coordinates captured to the tree captured.

Additionally, we will implement a convergence parameter that must be satisfied between tapping 'add tree' and allowing the user to capture an image. The user will see a spinner graphic while waiting for the convergence parameter. The convergence parameter will be the greater of the latitude and longitude standard deviations of a set number of most recent GPS coordinates since beginning image capture. A configurable maximum value convergence parameter will be assigned. If this maximum value is not passed within a configurable convergence timeout since beginning tree capture, image capture will be allowed anyway.

GPS Capture Configurations

GPS capture will be configurable. At first this configuration can happen via gradle build settings, but ideally a locked screen in the app would be implemented to allow the adjustment of configurable parameters. Configurable parameters are as follows

  1. Speed of GPS capture during track collection (between tree captures). Default: 1 second.
  2. Speed of GPS capture during tree capture. Default: 1 second
  3. Convergence parameter maximum value. Default: TBD ... to be calculated by GPS team
  4. Convergence timeout: Default 60s

Additional Data Capture

Step Counter

The step counter (not step detector) is described here: https://developer.android.com/guide/topics/sensors/sensors_motion. Since the step counter has a latency of 10s, we should capture the step counter output AFTER the image is capture (since the user will have had to wait for GPS convergence, giving the step counter time to catch up). The single output number should saved to the tree record and uploaded. Additionally, the step counter output from the previous tree captured should be subtracted from the step counter output for the current tree, and this value should be saved as delta_steps in the current tree record.

Gyroscope and Compass Heading

These position sensors are also described here: https://developer.android.com/guide/topics/sensors/sensors_position. We want to capture all components of the geomagnetic rotation position, and also use the methods described to compute and save the device's orientation. These values should be captured or computed at the moment the image is captured (when the image capture button is pressed or immediately afterward).

Data Upload

GPS Track data will be uploaded to S3 in a similar fashion to how tree and planter data is current uploaded. The JSON format is as: { locations: [ { 'latitude' : <float>, 'longitude' : <float>, 'accuracy' : <float>, 'timestamp' : <integer>, 'tree_uuid' : <string> }, .... ] }

Additional fields added to tree capture for steps and device orientation can be added to the existing tree_attributes array for adding experimental fields to a tree capture. Using tree_attributes avoids requiring us to immediately implementat database changes in the mobile device and the cloud.