This template makes it easy to organize FTC code and allows for the Autonomous and TeleOp periods to share code.

Overview

FTC Code Organizer

This template created by team 19458 Equilibrium.exe makes it easy to keep your code organized and allows the Autonomous and TeleOp periods to share code.

Overview

Each subsystem has its own class that handles all motors, servos, and sensors for that subsystem. Instances of these classes are stored in the Robot class, so creating an instance of the Robot class is all that's needed during initialization. Since these classes are the same for all OpModes, they can all use the same methods.

Setup

The easiest way to use the template is to fork this repository. If your team already has the SDK installed, you can manually download the robot package into the teamcode directory, and add the following line to the dependencies section of TeamCode/build.gradle:

implementation 'com.google.guava:guava:31.1-android'

Creating Subsystems

Each subsystem is its own object stored in the Robot class. To create a subsystem, put this starter code into a new class in the robot package:

package org.firstinspires.ftc.teamcode.robot;

public class Example extends Subsystem{
    //instance variables here
    
    public Example() {
        super();
        //constructor code here
    }
    
    @Override
    public void manualControl() {
        //teleop code here
    }
    
    //other methods here
}

Replace Example with the name of the subsystem (and file name), then implement code where the comments tell you to. You will also need to add the subsystem to the Robot class. You can do this by adding the following line to the end of the constructor:

subsystems.putInstance(Example.class, new Example());

Again, replace Example with the name of the subsystem.

To call a method from a subsystem in your OpMode, just use this line below and pass in the class for the subsystem:

((Example) (robot.getSubsystem(Example.class).get())).example();

If you want, you can also add this method to the Robot class to call it more easily using Robot.getExample():

public Example getExample() {
    return (Example) (getSubsystem(Example.class).get());
}

Autonomous

You can start your autonomous program with this starter code:

@Autonomous
public class Auto extends LinearOpMode {
    private Robot robot;

    @Override
    public void runOpMode() throws InterruptedException {
        robot = new Robot(hardwareMap, telemetry, true, Alliance.BLUE, gamepad1, gamepad2, this);

        waitForStart();

        //auto path here
    }
}

TeleOp

All teleop code should be written in the manualControl() methods of subsystems, and the fullManualControl() method in the Robot class. Gamepads should only be called from the Controls class. Because of this, your teleop code can be as simple as this:

@TeleOp
public class Teleop extends LinearOpMode {
    private Robot robot;

    @Override
    public void runOpMode() throws InterruptedException {
        robot = new Robot(hardwareMap, telemetry, false, Subsystem.alliance, gamepad1, gamepad2, this);

        waitForStart();

        while (opModeIsActive()) {
            robot.fullManualControl();
        }
    }
}

Help

If you have any trouble using the template on your robot, feel free to open a GitHub issue.

You might also like...

A React Native Template for installing a working ClojureScript, Krell, and Storybook environment

A React Native Template for ClojureScript, Krell, and Storybook Getting Started npx react-native init YourProjectName --template react-native-template

Dec 23, 2022

A Java-based template project for the FastJ Game Engine.

A Java-based template project for the FastJ Game Engine.

FastJ Java Template Program Requirements Java 16 JDK Basic understanding of Java Initial Setup Download the Template You have a few options for gettin

May 15, 2022

The shortest possible maven template / quickstarter for Java 16

The shortest possible Java 16 maven quickstarter The shortest possible Apache Maven template for Java 16 usage git clone https://github.com/AdamBien/j

Nov 8, 2021

Spring Cloud Netflix Hystrix Dashboard template resolution vulnerability CVE-2021-22053

CVE-2021-22053: Spring Cloud Netflix Hystrix Dashboard template resolution vulnerability Severity High Vendor Spring by VMware Description Application

Dec 16, 2022

Template to speed up your development in React Native projects.

React Native SpaceShip I created this template with the purpose of leaving the development environment already configured for use. 🚀 How to use it in

Mar 23, 2022

With this template, you are ste to deploy your application to Heroku

Template for deployment With this template, you are ste to deploy your application to Heroku. I´m using a Spring backend, React JS Frontend with Mongo

Jun 23, 2022

A Spigot latest maven starter template.

NAME One sentence to describe your plugin. Introduction Describe your plugin clearly. Features Feature 1 Dependencies Commands /command Command functi

Jul 1, 2022

A template repository for new extensions.

SAP CX Template The sapcxtemplate extension improves ... FEATURE DESCRIPTION COPY-TEXT INTRODUCTION How to activate and use COPY-TEXT ACTIVATION / SET

Dec 15, 2022

JavaFX or Swing + jpackage + Maven template project for generating native desktop applications.

Java + Maven + GitHub Actions = Native Desktop Apps JavaFX or Swing + jpackage + Maven template project for generating native desktop applications. Go

Dec 24, 2022
Owner
FTC 19458 Equilibrium.exe
FTC 19458 Equilibrium.exe
An example FTC project using Road Runner.

Road Runner Quickstart An example FTC project using Road Runner. Note: Road Runner is in alpha and many of its APIs are incubating. Installation For m

McCaskey Robotics 1 Mar 25, 2022
Simple Minecraft mod that makes it easy to put horses in boats.

HorseInBoat What does this mod do? This mod makes it much easier to put horses into boats. This mod also changes the hitbox of horses in boats, this i

null 8 Dec 20, 2022
Share food-Android- - Food donation coded in native android with firebase, google maps api and php server xampp

share_food-Android- Instructions: 1. Create a firebase account and link it with the project via google-services.json. 2. This project also uses a XAMP

Abubakar 3 Dec 28, 2021
Calef - CalEF (Calendar Entry Formatter) : Select an entry in Android-Kalender and send/share the entry's content as human readable text.

CalEF (Calendar Entry Formatter) Select an entry in Android-Kalender and send/share the entry's content as human readable text. Usually calendar entri

k3b 6 Aug 17, 2022
A blog recipes API for you to share and search for food recipes

A blog recipes API for you to share and search for food recipes

java dojo 3 Apr 15, 2022
Library that makes it possible to read, edit and write CSV files

AdaptiveTableLayout Welcome the new CSV Library AdaptiveTableLayout for Android by Cleveroad Pay your attention to our new library that makes it possi

Cleveroad 1.9k Jan 6, 2023
This is a Velocity plugin that makes it possible to host a modern forge server behind a Velocity proxy!

Ambassador This is a Velocity plugin that makes it possible to host a modern forge server behind a Velocity proxy! Unlike other solutions, this plugin

Adrian Bergqvist 31 Dec 28, 2022
UniFi Proxy makes it possible to integrate third-party hardware into UniFi Protect

UniFi Proxy UniFi Proxy makes it possible to integrate third-party hardware into UniFi Protect. For testing purposes only, it is recommended to purcha

Jan Heil 8 Dec 27, 2022
A boilerplate project designed to work as a template for new microservices and help you get in touch with various useful concepts.

Microservice Reference Project This project is inspired by the idea to quickly create a production ready project with all the required infrastructure

Innovation & Tech 4 Dec 17, 2022
This project archetype is a template for creating a fully functional MVC web application using Hibernate, JSTL and Bootstrap

This project archetype is a template for creating a fully functional MVC web application using Hibernate, JSTL and Bootstrap. It has an automatic database creation, auto initial load of the data, with different variety of users. It also has a checkstyle to check the proper coding of your project immediately right after you enter the code.

null 90 Oct 21, 2022