Library for FTC teams allowing quick changes to TeamCode files to speed up the software development process.
The fast load works through a combination of an Android Gradle plugin and a small Android library included in the FtcRobotController app. The Gradle plugin creates a streamlined build process for TeamCode classes. The result of this build process is a slim bundle containing only TeamCode classes which is a few hundred KB opposed to the full FtcRobotController APK which is ~50MB. This small bundle allows for sub-second installs. Finally, the Android library contains a custom classloader to reload the TeamCode classes from this bundle which eliminates the need for restarting the FtcRobotController app.
The result of these optimizations is, in our testing, a 70-90% reduction in deploy times depending on development computer. Note that the majority of install time will now be the Gradle build as the actual install and reload takes approximately 4 seconds will little variance.
- Changes through fast load will NOT be reloaded after a robot power cycle (Control Hub being turned off and back on causing the FtcRobotController app to reboot) so a TeamCode install must be preformed for changes to become permanent.
- Fast Load is NOT compatible with OnBotJava. The library uses part of the OnBotJava mechanism for classloading, so once a fast load is run OnBotJava will not work until the app is restarted.
In the TeamCode build.gradle file located at TeamCode/build.gradle
insert the listed lines to add the fast load
plugin and library as dependencies to your
project.
Here is a reference adding these
items to the default FtcRobotController v8.2 TeamCode build.gradle, if you copy this file be sure to replace {version} with the latest version of the dependencies listed below or in the title of this gist.
- by default a
buildscript
block is not included. if this is the case add the following before theapply
section at the top of the filebuildscript { }
- inside the
buildscript
block addrepositories
anddependencies
blocks if they do not yet existrepositories { }
dependencies { }
- in
buildscript.repositories
addmavenCentral()
- in
buildscript.repositories
addmaven { url = 'https://www.matthewo.tech/maven/' }
- in
buildscript.dependencies
addclasspath 'org.team11260:fast-load-plugin:0.1.2'
- now at the end of the
apply
section after lines that look likeapply from ...
putapply plugin: 'org.team11260.fast-load-plugin'
- the
repositories
block (not to be confused withbuildscripts.repositories
) does not exist by default in this file, if it doesn't addrepositories { }
- inside at the end of the
repositories
block addmaven { url = 'https://www.matthewo.tech/maven/' }
- inside at the end of the
dependencies
block (should exist in the base FtcRobotController) addimplementation 'org.team11260:fast-load:0.1.2'
- finally, run a Gradle sync in Android Studio to pull in the new dependencies
ADB is required for the fast load process. Wireless ADB has the most testing and was the focus in development but wired ADB is also compatible.
A standard TeamCode install must be run after the Installation steps have been completed before the fast load will work. To run a fast load use the Gradle tasks tool window (at the top of the right sidebar in Android Studio by default). There are two ways of running the task for the first time:
-
To run from the Execute Gradle Task menu open from the Gradle tool window.
Type in
reloadFastLoad
and hit enter to run. -
You can also run the task by navigating to
{project name}.TeamCode.Tasks.install
.Finally, run
reloadFastLoad
by double-clicking on it.
When this Gradle task has completed successfully the fast load is finished. After running this task for the first time you can choose between fast load (reloadFastLoad) and standard (TeamCode) installs from the Run Configuration selector.
- The library does not modify the SDK, but does use reflection to edit private fields only when a fast load is preformed.
- All modifications to Op Mode registrations should properly be reflected on the Driver Station after a fast load.
- For teams which use FTC Dashboard, it will not properly handle Op Mode registration changes or Configuration Variable editing with a fast load. If you modify Op Mode registration name, class name, or enabled status a robot restart or TeamCode download should be preformed to refresh Op Mode registration.
The following are speed benchmarks from the computers used by the 11260 software team.
Times are an average of 3 runs from beginning the Gradle build until the robot is ready to run. For a TeamCode install
ready to run is the Control Hub lights turning green indicating the robot is ready to run. For a fast load when
the reloadFastLoad
task completes the robot is ready to run.
First, an initial run of the given Gradle task was used to warm up the Gradle cache. The benchmark runs then occurred after changing the string name of a single Op Mode which would force an incremental build to best match the standard software development workflow.
All tests were completed using wireless ADB.
Results:
- 2021 Apple MacBook Pro, M1 Max, 64GB unified memory
- Team11260 CRI codebase (includes Java and Kotlin classes)
- TeamCode install + app startup: 58s
- fast load: 7s
- 88% faster
- FTCRobotController v8.2 (containing a single Java
Op Mode)
- TeamCode install + app startup: 53s
- fast load: 5s
- 91% faster
- Team11260 CRI codebase (includes Java and Kotlin classes)
- 2018 Dell XPS 13 9365, Intel i7-7Y75, 16GB ram
- Team11260 CRI codebase (includes Java and Kotlin classes)
- TeamCode install + app startup: 89s
- fast load: 27s
- 70% faster
- FTCRobotController v8.2 (containing a single Java Op Mode)
- TeamCode install + app startup: 78s
- fast load: 18s
- 77% faster
- Team11260 CRI codebase (includes Java and Kotlin classes)
Note that in general faster computers will have a higher percentage increase in download speed as the fast load cuts the majority of time out of the installation and reload process.
- v0.1.2
- Fixed bug where Op Modes containing method references may not appear after a fast load (thanks to FTC discord user @thesimg for reporting).
- Fixed bug where removed or renamed classes cause a non-fatal error.
- Minor speed improvement thanks to reduced exceptional control flow and logging.
- v0.1.1
- Updated dependencies for SDK v9.0 compatibility.
- Enhanced Gradle task exception handling to give more specific errors and remedies.
- v0.1
- Initial release.
FTC Team 21430 BroomBots here, FTC fast load was the first thing that we installed into our Center Stage repo. Right out of the gate our software changes had already been installed on our control hub before we even touched the driver station! This tool will save my team SO MUCH TIME and let us focus on the more important things like programming our autonomous and not staring at slow progress bars. On behalf of the BroomBots, we thank the creator of this tool for making it possible to have a functioning robot by our first scrimmage in 3 weeks. Thank you :)