MATLAB: Android GPS block for Android OS resolution

androidgpssimulink coder

I'm using the Location Sensor block from the Simulink Support Package for Android Devices to get GPS data from my device. Why does the spatial resolution seem to update less frequently than other GPS apps on my phone?

Best Answer

GPS updates are conditioned on the following distance and time thresholds.
1) MIN_DISTANCE_CHANGE_FOR_UPDATES - The minimum distance between updates. This value is set to 10 meters.
2) MIN_TIME_BW_UPDATES - the minimum time between updates. This value is set to 1 minute.
The GPS location will update when the change in distance at least minDistance is observed _and _a duration of minTime has passed. These values can be changed after the app has been generated. They can't be set in Simulink. See the following page for more information.
First, deploy the model to hardware in Simulink. Once this is complete, you need to edit the app's source code in Android Studio.
Follow steps 1 through 10 given on the following page.
CAUTION: The documentation asks not to update Gradle because the Simulink Support Package for Android Devices requires specific versions of Gradle and SDK tools to guarantee the supported features.
I found that Android Studio required an updated version of Gradle in order to build the app. The version that shipped with the hardware support package was no longer supported. To fix this, I went to the following link and and downloaded v3.3.
This will download a folder named "gradle-3.3-all". Go into this folder and copy the directory "gradle-3.3".
There should be a folder named "gradle-android.instrset" on your MATLAB path. Copy the "gradle-3.3" folder into this directory. On my machine, this directory is located at C:\ProgramData\MATLAB\SupportPackages\R2016b\3P.instrset\gradle-android.instrset.
Next, continue to step 11 on the "Import Project into Google Android Studio" instructions. After pasting the Gradle directory into Android Studio, edit the Gradle path so that it points to the directory that you just copied. The end of the path in the "Gradle home" field should now read ".../gradle-android.instrset/gradle-3.3".
Now edit the GPS update parameters. Select the "Project" tab on the left hand side of the Android Studio window. Navigate to <app name> -> java -> com.example.<app name> -> GPSHandler. Double-click on GPSHandler.
Set the time and distance thresholds MIN_DISTANCE_CHANGE_FOR_UPDATES and MIN_TIME_BW_UPDATES to the desired values.
Complete steps 12 through 18 to deploy the modified app.