Android (FTC)

android2

NOTE:  The 2019 Version of the navX-Micro Android Library for FTC has currently been tested with the FTC “ftc_app” library for the 2019 season, and has been verified to operate correctly with the REV Expansion and Control Hubs.

The navx_ftc Android software library supports access to navX-Model devices via the I2C communication interface.  Several example programs are provided, demonstrating how to use a navX-Model device in a FTC-based robot control application.

To use the library, you can download the latest build of the libraries, or you can checkout the source code with Git.  To learn more about the library, online help is available.

Getting Started

Before getting started, ensure you have installed Android Studio and the indicated Android Studio Project components linked to on the FIRST Tech Challenge Programming Resources page.

Several sample Java Robot Applications are provided.  After running the setup program included in the latest build, the libraries and samples will be installed to the following location:

<HomeDirectory>\navx-micro\android

For example, if your user name is Robot, the directory name will be C:\Users\Robot\navx-micro\android.

Within this directory, the “examples” sub-directory contains several example programs.  Select the example you wish to start with and copy it into your project as follows:

  • Copy one or more of the example navX-Model “op modes” files from the <HomeDirectory>\navx-micro\android\examples directory into your project’s “TeamCode” top-level directory. (i.e., org.firstinspires.ftc.teamcode).

Next, several configuration changes must be made in order that the Android Studio ftc_app-based project can locate the navx_ftc library:

  • Modify any of the op mode example files to change the following line near the top of the file to match the “Device name” given to the I2C port on the REV Expansion or Control Hub to which you have connected the navX-Model device.  By default, the Device name is “navx”.
    navx_device = AHRS.getInstance(hardwareMap.get(NavxMicroNavigationSensor.class, "navx"), AHRS.DeviceDataType.kProcessedData);

    See FTC Robot Installation for details on configuring the Device name.

  • Modify your robot application’s (the “TeamCode” project) build.release.gradle file repository list to add a reference the directory where the navx_ftc library is installed:
    repositories {
        flatDir {
            dirs 'libs', 'C:\\Users\\Robot\\navx-micro\\android\\libs'
        }
    }
  • Again in the same build.release.gradle file, add the navx_ftc library to the list of libraries the ftc_app will link to – by adding this line near the bottom of the gradle build file, in the dependencies section:
    dependencies {
      ...
         compile (name:'navx_ftc-release', ext:'aar')
    }

Linux/MacOS distribution

For developers on Linux and Mac OS platforms, the latest non-Windows build is also available.  Please note that this build does not contain any of the navX2-Micro tools, but does contain the RoboRIO and Android libraries.

This distribution is packaged as a .zip file; unzip the file and follow the instructions in the readme.txt file in the top-level directory.

Once you have installed the Android libraries onto your computer, use the instructions in the Getting Started section above to use the library.  However, you will need to replace “C:\Users\Robot\navx-micro” in several places shown above with the corresponding path on Linux/MacOS where you installed the Android libraries, including the “repositories” section of the build.release.gradle file:

repositories { 
    flatDir { 
        dirs 'libs','/Users/Robot/navx-micro/android/libs' 
    }
}