Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
265 changes: 265 additions & 0 deletions Sinister/SlothLoad.mdx
Original file line number Diff line number Diff line change
@@ -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:


<Note>
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.
</Note>


<Info>
If you are using Dairy, skip to the Dairy Core Heading. If you are using Dashboard, check out the Dashboard heading.
</Info>


## 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


<Info>
To use this release of Sloth with Dairy you need to install a snapshot version of Dairy's Core
</Info>


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")
}
```


<Note>
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.
</Note>


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


<Note>
If you use dashboard, install that now, then setup the gradle tasks
</Note>


## 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")
}
```


<Note>
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:
</Note>


```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"
}
```


<Info>
Both Pedro and RR require this. Pedro and RR version numbers may not be up to date.
</Info>


# 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)


<Note>
Android studio will not auto complete the names of these tasks, just write it and it will work.
</Note>


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)


<Note>
type `:TeamCode` into the `Gradle Project` box to get the right contents, do not copy mine.
</Note>


put `removeSlothRemote` first and save:\
![Ensure Order Pn](/images/ensure_order.png)


Run the deploySloth task you just added to deploy the code.

Binary file added images/add_deploySloth_task.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/add_new_configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/add_new_gradle_configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/add_removeSlothRemote_task.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/edit_TeamCode_configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/edit_configurations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ensure_order.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/run_gradle_task.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@
"Sinister/overview"
]
},
{
"group": "Sloth Load",
"pages": [
"Sinister/SlothLoad"
]
},
{
"group": "AppHooks",
"pages": [
Expand Down Expand Up @@ -230,3 +236,4 @@
"github": "https://github.com/Dairy-Foundation/docs"
}
}