NextFTC
Current NextFTC v2 modules, robot structure, triggers, and command model
Overview
NextFTC is an open-source library for code. The current documentation covers NextFTC v2, a Kotlin-first library with interoperability. Its modules cover robot lifecycle and command bindings (robot), hardware wrappers (hardware), and control theory (control). Check which major version your project uses before copying an example: v1 code is not interchangeable with v2.
Version note
This page describes v2. Do not mix it with older v1 examples such as NextFTCOpMode, CommandManager, NextBindings, setStart, or setUpdate. The official docs warn that keeping v1 dependencies alongside v2 can cause duplicate-class build errors.
Installation
Checked 14 October 2026: published v2 modules 0.2.1 remain the latest release. The development branch is 0.3.0-SNAPSHOT; its later -stop and field-centric changes are not part of 0.2.1. This guide uses the published artifacts.
In TeamCode/build.gradle, add the modules you use and the Dairy Maven repository for hardware or robot:
repositories {
maven { url 'https://repo.dairy.foundation/releases' }
}
dependencies {
implementation 'dev.nextftc.v2:control:0.2.1'
implementation 'dev.nextftc.v2:hardware:0.2.1'
implementation 'dev.nextftc.v2:robot:0.2.1'
}You can use control or hardware by itself. Read the official installation page for the current requirements and migration status before changing an existing v1 project.
Modules and lifecycle
NextRobotlists the robot'sMechanisminstances. NextFTC discovers exactly oneNextRobotimplementation at runtime and supplies it to each .Mechanismgroups hardware owned by one part of the robot and can define commands that require that .NextOpModeis the base for registered OpModes. Annotate it with@NextTeleop,@NextAutonomous, or@NextUtility.- Commands in the robot module use Ivy, Pedro Pathing's command library. NextFTC v2 does not provide its own separate command framework.
- Triggers poll buttons and conditions and schedule or cancel commands. NextFTC advances triggers and the scheduler during the OpMode loop; you do not call a
BindingManager.update()loop yourself.
Claw example
These examples use NextFTC v2 modules 0.2.1. Save the Java classes in separate Claw.java, Robot.java, and ClawPractice.java files, all in the same package. For example, put package org.firstinspires.ftc.teamcode; before the imports in each file. Use the matching .kt filenames for Kotlin.
This example makes one button close a claw. This example assumes you have installed the robot and hardware modules, added the claw to your configuration as clawServo, and selected a robot profile that includes the servo.
Claw commands
Create one Mechanism that owns the servo. An action describes what should happen; it moves the servo only when a trigger schedules it. The positions are practice values that you must tune for your linkage.
import com.pedropathing.ivy.Command;
import dev.nextftc.hardware.actuators.NextServo;
import dev.nextftc.robot.Mechanism;
public class Claw implements Mechanism {
private final NextServo servo = new NextServo("clawServo");
public Command open() {
return instant(() -> servo.setPosition(0.2));
}
public Command close() {
return instant(() -> servo.setPosition(0.8));
}
}import dev.nextftc.hardware.actuators.NextServo
import dev.nextftc.robot.Mechanism
class Claw : Mechanism {
private val servo = NextServo("clawServo")
fun open() = instant { servo.position = 0.2 }
fun close() = instant { servo.position = 0.8 }
}The string clawServo must match the configured device name. instant makes a command that runs its action once and then finishes.
Robot configuration
NextRobot is the shared place where NextFTC finds the mechanisms. Add the claw to mechanisms; otherwise the OpMode will not receive it through the robot object.
import java.util.Collections;
import java.util.Set;
import dev.nextftc.robot.Mechanism;
import dev.nextftc.robot.NextRobot;
public class Robot implements NextRobot {
private final Claw claw = new Claw();
@Override
public Set<Mechanism> getMechanisms() {
return Collections.singleton(claw);
}
public Claw getClaw() {
return claw;
}
}import dev.nextftc.robot.NextRobot
class Robot : NextRobot {
val claw = Claw()
override val mechanisms = setOf(claw)
}NextFTC discovers one public NextRobot implementation at runtime and supplies that instance to each NextOpMode. You do not create a second Robot inside the OpMode.
Button binding
Now the OpMode can use the shared claw. onTrue schedules close() once when the A button changes from released to pressed.
import dev.nextftc.robot.opmode.NextOpMode;
import dev.nextftc.robot.opmode.NextTeleop;
import dev.nextftc.robot.triggers.CommandGamepad;
@NextTeleop(name = "Claw Practice")
public class ClawPractice extends NextOpMode {
public ClawPractice(Robot robot) {
super(robot);
CommandGamepad driver = new CommandGamepad(gamepad1);
driver.a().onTrue(robot.getClaw().close());
}
}import dev.nextftc.robot.opmode.NextOpMode
import dev.nextftc.robot.opmode.NextTeleop
import dev.nextftc.robot.triggers.CommandGamepad
@NextTeleop(name = "Claw Practice")
class ClawPractice(private val robot: Robot) : NextOpMode(robot) {
override fun start() {
val driver = CommandGamepad(gamepad1)
driver.a.onTrue(robot.claw.close())
}
}NextFTC checks the trigger and advances the command during the OpMode loop. You do not add a separate scheduler-update loop. Check the version-specific mechanism, NextOpMode, and trigger examples for full package imports and current Java/Kotlin signatures.
Testing
- Check that the servo name in the Robot Controller configuration is exactly
clawServo. - With the robot lifted or the claw disconnected from anything it could pinch, select the OpMode and press .
- Press PLAY and tap A. The servo should move once to the close position.
- If nothing happens, check that you included
clawinmechanisms, that the class has the required annotation and constructor, and that you installed compatible v2 dependencies.
The positions 0.2 and 0.8 are examples, not safe or correct positions for every claw. Start with low-risk values and tune them for your linkage.
Module APIs
A CommandGamepad wraps an FTC Gamepad. Buttons expose Triggers such as onTrue (schedule on a rising edge) and whileTrue (schedule on the rising edge and cancel on the falling edge). A command that finishes while the button remains held is not automatically rescheduled. Stick axes and analog triggers expose range values and threshold helpers. Bind commands in the OpMode lifecycle and let NextFTC poll them.
The hardware module wraps FTC SDK devices and resolves them lazily. Device wrappers can be created from a configured name or a hub/port. The control module is usable on its own and includes feedback controllers, feedforward, filters, motion profiles, geometry, and typed units. Start with the official hardware and control references before adding a controller to a robot.
Java support
NextFTC is written in Kotlin but designed for Java interoperability. The official docs include Java and Kotlin tabs for core examples; use those examples instead of translating Kotlin syntax by guesswork. Confirm annotations, constructor visibility, and generated Kotlin property accessors for your selected version.
Team fit
NextFTC can help when a team wants shared mechanisms, scheduled commands, reusable controls, or its hardware/control wrappers. It adds dependencies and concepts, so a small project may be easier to understand with the FTC SDK alone. Compare the actual APIs and maintenance needs with alternatives before adopting it.