diff --git a/Sinister/SlothLoad.mdx b/Sinister/SlothLoad.mdx new file mode 100644 index 0000000..acaf07d --- /dev/null +++ b/Sinister/SlothLoad.mdx @@ -0,0 +1,265 @@ +--- +title: "SlothLoad" +--- + + +Sloth is a Sinister runtime that enables the use of Sinister's classpath scanning and dynamic loading capabilities on the android FTC platform. + + +Like fastload, Sloth is built for hot reloading your teamcode, which allows for very fast iteration of code. + + +# Features: + + +- Sloth is much faster than fastload. fastload advertises ~7 seconds upload time, Sloth should be 2 seconds or less. +- Sloth will keep changes across restarts and power cycles of the robot. +- `@Pinned` can be put on classes to prevent dynamically changing it, or any subclasses of it. +- Sloth is built on a more capable runtime, that supports Dairy, and has shims for all of the SDK, meaning that all SDK classpath scanning is performed dynamically. +- This includes device drivers, like the GoBilda PinPoint that are uploaded alongside a team's code. +- Sloth has a drop-in replacement of Dashboard that replaces some internal mechanisms of Dashboard to use Sloth and Sinister equivalents. This fork fully supports dynamic uploading for Configuration and OpModes. +- Not hacked onto the OnBotJava system, so doesn't break that +- Sloth only processes the change in code when your OpMode ends, which means its safe to run Sloth while running other code + + +1. Sloth will only dynamically hot reload classes in the `org.firsinspires.ftc.teamcode` package, and subpackages. +2. It is possible to upload code that compiles, but does not work when hot reloaded due to: + - Installing or changing libraries. + - Changing files that are not hot reloaded. + - Changing `@Pinned` on files. Be careful to ensure that you make changes that will be changed, and if make changes that will not, that you perform a full install in order to propagate them. + + +# Installation: + + + + IF YOU HAVE USED THE PEDRO QUICKSTART, PLEASE MOVE YOUR FILES TO THE `org.firstinspires.ftc.teamcode` PACKAGE. THE SECOND MOST COMMON ERROR I SEE IS USING THE PEDRO QUICKSTART. THEY WILL NOT FIX THIS ISSUE. + + + + + If you are using Dairy, skip to the Dairy Core Heading. If you are using Dashboard, check out the Dashboard heading. + + + +## Sloth Library + + +Add the dairy releases repository to your `TeamCode` `build.gradle`, above the dependencies block + + +```gradle +repositories { + maven { + url = "https://repo.dairy.foundation/releases" + } +} +``` + + +then add sloth to the `dependencies` block: + + +```gradle +dependencies { + implementation("dev.frozenmilk.sinister:Sloth:0.2.1") +} +``` + + +## Dairy Core + + + + To use this release of Sloth with Dairy you need to install a snapshot version of Dairy's Core + + + +Add the dairy releases and snapshots repository to your `TeamCode` `build.gradle`, above the `dependencies` block + + +```gradle +repositories { + maven { + url = "https://repo.dairy.foundation/releases" + } + maven { + url = "https://repo.dairy.foundation/snapshots" + } +} +``` + + +then add core to the `dependencies` block: + + +```gradle +dependencies { + implementation("dev.frozenmilk.dairy:Core:2.2.1") +} +``` + + + + You do not need to install Sloth as well, and if you currently have any installations of either "`dev.frozenmilk.dairy:Util`" or "`dev.frozenmilk:Sinister`" then you need to remove those, this Core version will provide the correct versions of these libraries. + + + +Now install the load plugin + + +# Load Plugin + + +add this to the top of your `TeamCode` `build.gradle` + + +```gradle +buildscript { + repositories { + mavenCentral() + maven { + url "https://repo.dairy.foundation/releases" + } + } + dependencies { + classpath "dev.frozenmilk:Load:0.2.1" + } +} +``` + + +add this after the apply lines in the same file + + +```gradle +// there should be 2 or 3 more lines that start with apply here +apply plugin: 'dev.frozenmilk.sinister.sloth.load' +``` + + +sync and download onto your robot via standard install + + +now add the gradle tasks + + + + If you use dashboard, install that now, then setup the gradle tasks + + + +## Dashboard + + +add the dairy releases repository to your TeamCode build.gradle, above the dependencies block (if you already have it, no need to do so again) + + +```gradle +repositories { + maven { + url = "https://repo.dairy.foundation/releases" + } +} +``` + + +then add dashboard to the dependencies block: + + +```gradle +dependencies { + implementation("com.acmerobotics.slothboard:dashboard:0.2.1+0.4.16") +} +``` + + + + if you use a library that imports dashboard via a implementation or api dependency, ask the library maintainers to consider changing it to compileOnly or change the implementation like so: + + + +```gradle +implementation("com.pedropathing:pedro:1.0.8") { + exclude group: "com.acmerobotics.dashboard" +} +``` + + +or + + +```gradle +implementation("com.acmerobotics.roadrunner:ftc:0.1.21") { + exclude group: "com.acmerobotics.dashboard" +} +implementation ("com.acmerobotics.roadrunner:actions:1.0.1"){ + exclude group: "com.acmerobotics.dashboard" +} +``` + + + + Both Pedro and RR require this. Pedro and RR version numbers may not be up to date. + + + +# Gradle Tasks + + +edit configurations: + + +![Edit Configurations Pn](/images/edit_configurations.png) + + +add new configuration: + + +![Add New Configuration Pn](/images/add_new_configuration.png) + + +select gradle: + + +![Add New Gradle Configuration Pn](/images/add_new_gradle_configuration.png) + + +add `deploySloth` and save it: + + +![Add Deploy Sloth Task Pn](/images/add_deploySloth_task.png) + + + + Android studio will not auto complete the names of these tasks, just write it and it will work. + + + +edit TeamCode configuration: + + +![Edit Team Code Configuration Pn](/images/edit_TeamCode_configuration.png) + + +add new gradle task: + + +![Run Gradle Task Pn](/images/run_gradle_task.png) + + +add `removeSlothRemote`:\ +![Add Remove Sloth Remote Task Pn](/images/add_removeSlothRemote_task.png) + + + + type `:TeamCode` into the `Gradle Project` box to get the right contents, do not copy mine. + + + +put `removeSlothRemote` first and save:\ +![Ensure Order Pn](/images/ensure_order.png) + + +Run the deploySloth task you just added to deploy the code. + diff --git a/images/add_deploySloth_task.png b/images/add_deploySloth_task.png new file mode 100644 index 0000000..ad83ac5 Binary files /dev/null and b/images/add_deploySloth_task.png differ diff --git a/images/add_new_configuration.png b/images/add_new_configuration.png new file mode 100644 index 0000000..4db2163 Binary files /dev/null and b/images/add_new_configuration.png differ diff --git a/images/add_new_gradle_configuration.png b/images/add_new_gradle_configuration.png new file mode 100644 index 0000000..eb20689 Binary files /dev/null and b/images/add_new_gradle_configuration.png differ diff --git a/images/add_removeSlothRemote_task.png b/images/add_removeSlothRemote_task.png new file mode 100644 index 0000000..2e1c331 Binary files /dev/null and b/images/add_removeSlothRemote_task.png differ diff --git a/images/edit_TeamCode_configuration.png b/images/edit_TeamCode_configuration.png new file mode 100644 index 0000000..7ce19fb Binary files /dev/null and b/images/edit_TeamCode_configuration.png differ diff --git a/images/edit_configurations.png b/images/edit_configurations.png new file mode 100644 index 0000000..31a932d Binary files /dev/null and b/images/edit_configurations.png differ diff --git a/images/ensure_order.png b/images/ensure_order.png new file mode 100644 index 0000000..a4dc7ac Binary files /dev/null and b/images/ensure_order.png differ diff --git a/images/run_gradle_task.png b/images/run_gradle_task.png new file mode 100644 index 0000000..9f37119 Binary files /dev/null and b/images/run_gradle_task.png differ diff --git a/mint.json b/mint.json index 2898e6f..61db0db 100644 --- a/mint.json +++ b/mint.json @@ -124,6 +124,12 @@ "Sinister/overview" ] }, + { + "group": "Sloth Load", + "pages": [ + "Sinister/SlothLoad" + ] + }, { "group": "AppHooks", "pages": [ @@ -230,3 +236,4 @@ "github": "https://github.com/Dairy-Foundation/docs" } } +