Skip to content
CrocoDocs
Starter GuideProgrammingEngineeringDesignPortfolio
Documentation

Introduction

IntroductionBIOBUZZ game overview

Getting started

Getting startedBlocksOnBot JavaAndroid StudioYour first OpModeJava basicsMotors and servosNonblocking codeDebugging robot code

Control systems

Control systemsJoystick mappingField-centric mecanum drivePID controlFeedforwardFlywheel velocity controlSystem identificationMotion profilingKalman filterLow-pass filter

Autonomous

AutonomousTimed and encoder movementOdometryLocalization troubleshootingMotion planningReliable autonomous sequencesPure PursuitSensor fusionAuto to TeleOp handoff

Season topics

Season topicsProjectile mathematicsTurret aimingShooting on the move

Code practices

Code practicesNaming conventionsCode organizationLoop timing and bulk readsFormattingComments and documentationTeam collaboration

Libraries

LibrariesNextFTCFTCLibSolversLibPedro PathingRoad RunnerFTC DashboardMercurial v2Mercurial v1PanelsSloth

Community software

Community softwareBlaze FTCOpenLoopHive Vision

Sensors and vision

Vision overviewVision basicsLimelight 3A
Starter Guide
Engineering
Design
Portfolio
Appearance

Code organization

Keep an FTC project easy to navigate as the robot grows

TeamCode

In the official Android Studio project, your team's files belong under:

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/

One working in that folder is enough to begin. You do not need separate classes for every on day one.

As the grows, group related files in packages. For example:

teamcode/
├── MainTeleOp.java       ← reads gamepads
├── PracticeAuto.java     ← runs an autonomous routine
└── mechanisms/
    └── Arm.java          ← handles the arm motor

The diagram is a possible team layout, not an extra folder structure required by the SDK. A file in mechanisms/ needs a matching package declaration, such as package org.firstinspires.ftc.teamcode.mechanisms;.

File responsibilities

The OpMode should decide when an action happens. A class can decide how to control its hardware. For example, the OpMode reads a button and asks the arm to move; the arm class owns the motor and its power limit.

Here is a small mechanism class. Save it as mechanisms/Arm.java:

package org.firstinspires.ftc.teamcode.mechanisms;

import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.HardwareMap;

public class Arm {
    private final DcMotor motor;

    public Arm(HardwareMap hardwareMap) {
        motor = hardwareMap.get(DcMotor.class, "arm_motor");
    }

    public void move(double requestedPower) {
        double safePower = Math.max(-0.25, Math.min(0.25, requestedPower));
        motor.setPower(safePower);
    }
}

Inside an OpMode in the teamcode package, import Arm, construct it before waitForStart(), then call arm.move(...) in the active loop. This is a pattern for separating jobs; it still needs the usual OpMode setup and a matching arm_motor configuration.

When to split files

Move code into a new method or class when you can give it a clear name and use it without copying the same logic. Examples:

  • A stopDrive() method makes a safety action easy to find.
  • An Arm class can keep arm limits together when several OpModes use the arm.
  • A RobotConfig class can hold shared, measured constants such as counts per revolution.

Keep -specific scoring decisions in the or match logic, so a reusable motor helper does not silently depend on one game.

Review

Can a new teammate find the code that controls a motor in under a minute? Can they see where its configuration name and power limit live? If yes, the structure is doing its job. Build after moving files; package and import mistakes show up immediately.

Next steps

Use naming conventions to make the files readable and comments to explain decisions that names cannot show.

Sources

  • FTC Android Studio project

Naming conventions

Pick names that tell a teammate what each part of the code means

Loop timing and bulk reads

Measure the control loop, refresh cached inputs, and reduce hardware traffic before adding threads

On this page

TeamCodeFile responsibilitiesWhen to split filesReviewNext stepsSources