Skip to content

NextRobot

Your NextRobot implementation lists the mechanisms on your robot. Write one, and every NextOpMode gets the same instance of it. You never call its constructor and you never register it anywhere.

interface NextRobot {
fun periodic() {}
val mechanisms: Set<Mechanism> get() = emptySet()
}

Every Mechanism on your robot. NextFTC calls periodic() on each one every loop, and schedules each one’s default command at start. A mechanism left out of this set gets neither.

Called once per loop, before any of your mechanisms’ periodic() methods. Use it for robot-wide logic that doesn’t belong to any single mechanism.

class MyRobot : NextRobot {
val claw = Claw()
val arm = Arm()
override val mechanisms = setOf(claw, arm)
}

NextFTC scans the classpath at runtime to find your NextRobot. Give your class a public no-arg constructor, which is what we recommend in both Kotlin and Java, and it gets picked up and passed to your NextOpModes. Write exactly one implementation. Zero or two or more, and NextFTC throws instead of guessing which one you meant. See robot project structure for the rest of the rules.