Skip to main content

Overview

tip

You can check out our codebase in TeamCode to see how the Scheduler is used in actual code & how it's used with other parts of Blacksmith

The majority code is in Kotlin, but many/most of the concepts remain the same.

Read the docs still though.

What is the Scheduler API?

It's a small library that streamlines the creation of both your autos and especially your TeleOps!

It's provided functionality makes your code easier to create, read, and maintain. 😮😮😮🤯😮

✨ Creating TeleOps (ᵃⁿᵈ ᵃᵘᵗᵒˢ ᵒᶠᶜ) has never been easier! ✨

that literally answered nothing.

Let's take a look at some bog-standard TeleOp code:

@TeleOp
public class NotCoolTeleOp extends OpMode {
@Override
public void init() {
// Initialize hardware
}

@Override
public void loop() {
// Loop code
}

// ...300 billion lines later...

private boolean gamepad2aPreviousState = //...;

private void checkIfShouldDoSomething() {
if (gamepad2.a && !gamepad2aPreviousState) { // Messy and ugly and ew 🤮
claw.intake();
} else if (!gamepad2.a && gamepad2aPreviousState) { // Ugly unreadable signal edge detectors
claw.close();
} // Can't tell if the driver does this or the codriver at the quick glance
gamepad1aPreviousState = //...;
} // ugh imperative hell
}

Now the same TelpOp after receiving the Scheduler (and BlackOp treatment:

@TeleOp
public class CoolTeleOp extends BlackOp {
@EvalOnGo(method = "getReforgedGamepad2")
private ReforgedGamepad codriver;

@Override
public void go() {
describeControls(); // Abstracting it to a method for readability

Scheduler.launchOnStart(this, () -> {
// Any extra code to run every loop
});
}

private void describeControls() {
codriver.a.onRise(claw::intake); // Simple and easy to read
codriver.a.onFall(claw::close); // Complexity is abstracted away
}
}

As you can see, it dramatically improves code quality and readability, and makes it easier to develop and maintain—after all, you no longer have to deal with basic boilerplate logic.

🚀 Instead of telling the code exactly what to do, you just tell it what you want!

Practical examples:

Confused?

Uh, what are those weird symbols?

The Scheduler API does require some medium-level knowledge of Java, but it's really not too hard to learn. You just need to have fairly surface level knowledge of lambdas and how to use an annotation and such to use this API.

Check out the FAQ page for some learning resources.

(I'm assuming if you're using Kotlin, you're already familiar with such higher level concepts)

What is BlackOp?

You don't need to use this, you can use LinearOpMode if you'd like, but it's our own extension to the LinearOpMode which provides some extra functionality for a more seamless developer experience. Check out this for more info.

what is @CreateOnGo/createOnGo?

A very nice part of BlackOp. There's a @CreateOnGo equivalent for Java too!

Wth is a ReforgedGamepad or codriver.a.onRise??

Read on, it's described in the docs in a little bit. Or click here.