Skip to content

nicholas-karr/ftc-hotpatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ftc-hotpatch

Update FTC OpModes on the fly

  • Debug running OpModes while updating them
  • Deploy app changes without rebooting

Installation

  1. Clone this repo into a folder adjacent to your FtcRobotController folder.
~/dev$ ls
FtcRobotController
~/dev$ git clone https://github.com/VCInventerman/ftc-hotpatch.git
Cloning into 'ftc-hotpatch'...
Unpacking objects: 100% (43/43), 21.48 KiB | 39.00 KiB/s, done.
~/dev$ ls
FtcRobotController  ftc-hotpatch
~/dev$
  1. Copy the .run folder from this repo to FtcRobotController. This installs the script that deploys hotpatches.
~/dev$ cp -r ftc-hotpatch/.run FtcRobotController/
  1. Include this repo's source code to your gradle project.
~/dev$ echo "android { sourceSets { main { java { srcDirs('../../ftc-hotpatch/src/') } } } }" >> FtcRobotController/FtcRobotController/build.gradle
  1. Open the FtcRobotController project in Android Studio. Open FtcOpModeRegister in the folder below. Screenshot
  2. Edit FtcOpModeRegister
// Copy this line directly below the other lines starting with "import"
import com.karrmedia.ftchotpatch.SupervisedClassManager;

// Copy this line directly below the line starting with "public void register"
SupervisedClassManager.init(manager);
  1. Modify an existing OpMode to be hotpatchable
    • Add the following under existing import statements
    import com.karrmedia.ftchotpatch.SupervisedOpMode;
    import com.karrmedia.ftchotpatch.Supervised;
    
    • Change the @TeleOp or @Autonomous annotation to @Supervised, and inherit from SupervisedOpMode instead of LinearOpMode or OpMode
    - @TeleOp(name="Basic OpMode", group="Iterative Opmode")
    + @Supervised(name="Basic OpMode", group="Iterative Opmode", autonomous=false)
    - public class BasicOmniOpMode extends LinearOpMode {
    + public class BasicOmniOpMode extends SupervisedOpMode {
    • Patch existing methods to loop
    - public void runOpMode() {
    + public void init() {
    - waitForStart();
    + }
    + 
    + public void start() {
    - while (opModeIsActive()) {
    + }
    +
    + public void loop() {
      ...
    - }

Usage

  1. Perform a normal run in debug or release mode. Screenshot
  2. Launch the opmode you want to use.
  3. Modify some of its code.
  4. Change the current configuration to DeployHotpatch, then press Run/F5. This will preserve your current debugging session. Screenshot
  5. Wait a bit until the new code is compiled and applied

About

Update FTC OpModes on the fly

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages