FTC Core
  • Introduction
  • Getting Started
    • ⚙️Configuring FTC Core
Powered by GitBook
On this page
  • Overview
  • Preparing Your Program
  • Creating a Config
  1. Getting Started

Configuring FTC Core

Overview

One of FTC Core's key strengths is that it minimizes the amount of unnecessary code teams need to write before they can get their robot up and running; however, to achieve this, FTC Core needs to be configured.

Currently, FTC Core only supports 4-wheel holonomic drives (for most teams, X-Drive or Mecanum). We understand that this eliminates many robots and we are actively working on developing options for teams that do not employ holonomic drives on their robots.

Before we can begin configuring FTC Core, it is useful to understand how FTC Core works from a high level. There are three main components that compose FTC Core and act as the library's foundation. These components are:

  • Config - Supplied to the hardware manager and describes the physical configuration of the robot.

  • HardwareManager - Initializes robot hardware from information in the config and dynamically adjusts which parts of FTC Core to activate for the most streamlined experience. Acts as a central hub for teams and internal modules to access robot hardware.

  • Pipeline - Where teams specify autonomous instructions (More on that later)

Preparing Your Program

Before we begin configuring FTC Core to run on your robot, it is useful for teams to lay out their program to support expansion and promote accessibility, especially when changes need to be made down the road.

There is no "correct" way of setting up your project. More knowledgeable teams may skip this step and lay out their program as needed.

To get started, install FTC-Core if you haven't already. If you're stuck installing FTC-Core, please refer to the installation instructions on the previous page.

First, let's organize the folder structure of our program. We're going to create two packages (folders) in our TeamCode module:

  • opmodes - The folder that will hold all of our opmodes, including our tele-op program.

  • actions - The folder that will hold all of our specialized actions for running our own code (raising lifts, closing claws, extending sliders, etc.)

Refer to the guide below if you are unfamiliar with adding packages to the TeamCode package using Android Studio:

Navigate to the teamcode package under the TeamCode module. This is where we will place our program.

We're creating two packages. The first package we'll create is our "opmodes" package which will hold all of our OpModes. The same process can be repeated for adding an "actions" package.

You should end up with a very basic project structure that looks like this:

Next, we'll create a simple linear OpMode to write our code in. This OpMode should only be used for the purposes of this guide and learning how FTC Core works. When it comes to creating an autonomous program that will be used in competition, it is useful to create multiple OpModes, one for each position the robot might start in.

We'll use the opmodes package to hold our example linear OpMode.

To create this OpMode, all we need to do is create a new Java class and annotate that class with an @Autonomous. Annotating the class is necessary to show up on the driver station. This class will extend the LinearOpMode class, meaning that when it is run, the code will only run once.

Once the class is created, implement the runOpMode function. This is where all of our code for this OpMode will lie (and thankfully, it's not much!)

Creating the Example OpMode

Your class should look something like this:

package org.firstinspires.ftc.teamcode.opmodes;

import com.chsrobotics.ftccore.hardware.HardwareManager;
import com.chsrobotics.ftccore.hardware.config.Config;
import com.chsrobotics.ftccore.pipeline.Pipeline;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;

@Autonomous
public class ExampleAutonomousOpMode extends LinearOpMode {


    @Override
    public void runOpMode() throws InterruptedException {
       
    }
}

Creating a Config

A Config class allows teams to describe their robot's physical attributes, including the drive motors, accessory motors for lifts, etc., servos, webcams, odometry pods, and more. Usually, configs are created in the OpMode for accessibility; however, there is nothing stopping you from creating one Config to use across all of your OpModes. For this guide, we will be setting up a simple Config that enables the robot to navigate the field. A more detailed list of Config options will be in the table below.

Under the runOpMode function in our example, we'll create a Config class. The Config class uses the Java builder pattern, a factory pattern that allows for constructing heavy, complex classes. Each configuration option under the Builder is a constructor that allows for optional robot configuration settings.

Some settings, like entering drive motor information, imu information, setOpMode, and odometry/dead reckoning wheel properties, aren't optional and are critical to the function of FTC Core; however, since they are apart of the builder pattern, they will not result in a compilation error if they are not considered.

If FTC Core does not work, ensure these configuration options are specified.

For this example, we are aiming to get our robot to navigate the field. More advanced features will be described later. The code below describes how to configure your robot for simple field navigation. Rather than using odometry pods, we will simply be using the encoders on our four drive motors. The .setOdometryWheelProperties constructor can be used for both odometry pods or drive motor localization.

package org.firstinspires.ftc.teamcode.opmodes;

import com.chsrobotics.ftccore.hardware.HardwareManager;
import com.chsrobotics.ftccore.hardware.config.Config;
import com.chsrobotics.ftccore.pipeline.Pipeline;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;

@Autonomous
public class ExampleAutonomousOpMode extends LinearOpMode {


    @Override
    public void runOpMode() throws InterruptedException {
        Config config = new Config.Builder()
                .setDriveMotors("m0", "m1", "m2", "m3")
                .setOdometryWheelProperties(537.7f, 96, 0, 0)
                .useDegrees(true)
                .setMotorDirection(DcMotorSimple.Direction.FORWARD)
                .setIMU("imu")
                .setOpMode(this)
                .setPIDCoefficients(RobotConstants.linear, RobotConstants.rotation)
                .build();
    }
}


PreviousIntroduction

Last updated 2 years ago

Create a Java Class

Name the class

Add annotations and implementations.

⚙️