FTC-OpMode-Tuner is an Android app that is installed on a 3rd (DS + RC + Other) Android device that allows variables and runtime behavior of an OpMode to be modified in REAL TIME.
- Tuning a turn-to-heading PID
- Tuning a maintain-heading PID
- Tuning the speed and PID params of RUN_WITH_ENCODER
- Tuning the speed and PID params of RUN_TO_POSITION
- Tuning encoder count values for autonomous movement or RUN_TO_POSITION
- Tuning servo positions
- Tuning intake motor speeds
- Tuning HSV thresholds for computer vision
- Tuning the sensitivity of a line-following algorithm
- Tuning distance sensor values for autonomous movement
- Tuning smooth power scalar algorithm in either autonomous or teleop
Really, the use cases are endless and are also dependant on how advanced your program is. This list is absolutely not exclusive; it is merely here to help you start thinking about how this tool can help you improve your program.
- Integers
- Doubles
- Strings
- Booleans
- Bytes (advanced)
- Button presses (advanced)
Note: the "advanced" data types can be enabled by going to Settings --> Advanced UI
The OpModeTuner app provides variables to your OpMode in a similar fashion to the HardwareMap
. That is, each Field (variable) is created with a unique tag which is later used to identify and retrieve it. To continue to the illustration of the HardwareMap
:
//HardwareMap
DcMotor motor = hardwareMap.dcMotor.get("someMotor");
//OpModeTuner
int somethingInteresting = getInt("var1");
This is 100% legal for use in competition. In fact, it falls under essentially the exact same rules as using Blocks or OBJ. Using it in your pit is perfectly fine. Just don't show up in the queue with it or try to use it in a match.
-
Download the Tuner app APK file from the Releases section. (Note: This will be uploaded to the Play Store for the first stable release)
-
Install the APK on a 3rd Android device of your choosing
-
Open your FTC SDK Android Studio project
-
Open the
build.common.gradle
file: -
Add
jcenter()
to therepositories
block at the bottom: -
Open the
build.gradle
file for the TeamCode module: -
At the bottom, add this:
dependencies { //NOTE: this (0.22) is the correct version, the below screenshot is outdated compile 'org.openftc:ftc-opmode-tuner-common:0.22' }
When you've done that, the bottom of the file should look like this:
-
Now perform a Gradle Sync:
-
Wait for Gradle to finish gradling
-
Congratulations! You are now ready to use the OpModeTuner!
-
Change your opmode to
extend
either:TunableOpMode
if you are currently extendingOpMode
TunableLinearOpMode
if you are currently extendingLinearOpMode
-
You can consult the JavaDoc for the methods that you can now call. For now though, just go ahead and add this to the main loop of your program:
telemetry.addData("test", getInt("var1")); telemetry.update();
-
Deploy your project to the RC phone
-
Connect the phone with the Tuner app to the Wi-Fi Direct network broadcast by the RC. READ: you must connect through the normal Wi-Fi settings screen, NOT through the Wi-Fi Direct screen! The password for the Wi-Fi network can be found in the About activity of the RC app.
-
If shorty after connecting Android shows a "WiFi has no internet" dialog like this:
Then you will need to tap on it, and do this:
-
Run the OpMode that you just modified, and open the Tuner app on your 3rd phone. If all goes well, this should appear on the RC screen:
If it does appear, then move on to step 7. If not, then you may need to determine the IP address of the RC phone and input it into the Settings of the Tuner app before it will connect. I'm fairly confident that
192.168.49.1
(the default) is always correct for Wi-Fi Direct group owners, but shrug you never know what an OEM might do.... -
In the Tuner app, select Load Config from the overflow menu:
-
Press the New button in the top left corner. READ: this is NOT creating a robot hardware configuration, it is something entirely different
-
You can call the configuration whatever you'd like, and then press OK:
-
Load the configuration that you just created:
-
Back on the main screen of the Tuner, press the Add Field FAB in the lower right hand corner:
-
Create a new integer Field with a tag of var1:
-
Now adjust the value of the Field using the slider:
If all goes well, you should see the number in the Telemetry Area of the DS changing as you move the slider
If you'd like to contribute to this project, then you will need to setup this repository locally as an Android Studio project. You can do this as follows:
-
In a directory of your choosing, run:
git clone https://github.com/OpenFTC/FTC-OpMode-Tuner.git
-
On the AS "Welcome" screen, choose Import project (Gradle, Eclipse ADT, etc.)
-
Navigate to the directory where you cloned this repository to, and select the root (FTC-OpMode-Tuner) folder.
-
Wait for Gradle to finish gradling.
-
You're now all set up!
Initial alpha release.