Robot Project Structure
NextFTC enforces no package layout at all.
It finds your NextRobot and NextOpMode classes
by scanning the classpath at runtime, using the Sinister scanning library from Sloth,
so where you put them in your project doesn’t matter.
What does matter is what makes a class visible to that scan.
How NextRobot is discovered
Section titled “How NextRobot is discovered”NextFTC looks for a class implementing NextRobot that is:
public,- not abstract,
- not annotated
@Disabled, and - either has a public no-arg constructor or, in Kotlin, is a singleton
object.
We recommend the no-arg constructor. It works identically in Kotlin and Java.
Exactly one class should qualify. If none does, or if two do, NextFTC throws on startup with a message saying which case it hit, instead of picking one at random.
How NextOpModes are discovered
Section titled “How NextOpModes are discovered”NextFTC registers every public, non-abstract, non-@Disabled subclass of NextOpMode that carries
@NextTeleop, @NextAutonomous, or @NextUtility.
You never call an SDK registration method.
To build the OpMode, NextFTC looks for two constructors in order:
- One that takes a single parameter of your
NextRobottype, or a supertype of it. NextFTC passes the robot instance in. - Failing that, a public no-arg constructor.
That first rule is why the usual OpMode looks like this:
class MyTeleop(robot: MyRobot) : NextOpMode(robot)Suggested layout
Section titled “Suggested layout”None of this is required, so organize the code however your team likes. This is the one we use, and it holds up once you have a dozen OpModes:
Directoryorg.firstinspires.ftc.teamcode
- Robot.java
Directorymechanisms
- Arm.java
- Intake.java
Directoryopmodes
Directoryauto
- CloseAuto.java
- FarAuto.java
Directoryteleop
- OneDriverTeleop.java
See also
Section titled “See also”NextRobotfor declaring your robot and its mechanisms.NextOpModefor writing OpModes and for what the registration annotations accept.