Skip to content

jthftc/ftc-teamcode

Repository files navigation

FTC TeamCode Repository 🤖

Website Twitter Follow Instagram Follow

Getting Started With Java

To start off with, you are going to need to download the current FTC SDK from the Official First Technology Challenge Github page. This will include a .zip file that includes all of the base structures that your team is going to need in order to develop a functional Java program.

Next, your going to need to either setup an OnBotJava or Andriod Studio environment for editing and compiling your Java projects. The links in the previous sentence will bring you to the respective tutorials provided by First Robotics.

Developing an OpMode:

Basic Template

To begin creating your first java program, open up your /teamcode folder within your FTC SDK and create a new file named main.java. Next copy and paste the following template into this new java file. This template includes basic imports, class syntax, and the init()/loop() in which will help define our robot objectives during the TeleOp period.

package org.firstinspires.ftc.teamcode; //This may change depending on where this file is stored

import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp; 
import com.qualcomm.robotcore.hardware.DcMotor; //Needed for Motor Control
import com.qualcomm.robotcore.hardware.DcMotorEx; //Needed for Motor Control
import com.qualcomm.robotcore.hardware.Servo; //Needed for Servo Control
import com.qualcomm.robotcore.util.ElapsedTime;

@TeleOp(name="main", group="Opmode") //Name & group of OpMode within the Driver Station Phone
@Disabled //Remove when finished and ready for testing

public class main extends OpMode {

    @Override
    public void init() {
      //Initialization Code
    }
    
    @Override
    public void loop() {
      //Loop Code
    }

}

Initializing Motors

Controlling Motors

Initializing Servos

Controlling Servos

Exporting OpMode

Adjusting OpMode Based Upon Drivetrain


Connect with us:

javathehutts.org javathehutts | Facebook javathehutts | Twitter javathehutts | Instagram javathehutts | YouTube javathehutts | Reddit