Tetrix

Hardware Mapping

Two more preparatory topics and then we can write some code!

A key function of the FTC SDK, and of any robotics API, is to provide software access to the physical hardware of a robot. A way must be provided to allow programmers to identify, in software, hardware devices on the robot so that they can write programs that interact with that hardware. On the Tetrix/REV platform, this is called hardware mapping.

The FTC SDK Library

The FTC SDK Library is a library of classes that allow your programs to access and control all aspects of the Tetrix robot control system and the hardware devices attached to it. This library is the API for the control system and robot hardware. The library is included in the FTC SDK. You can access the library with the following import statement in an OpMode class:

Linear OpModes

The Linear OpMode is much simpler than the regular OpMode. You extend LinearOpMode and there is only one method to override: runOpMode(). This method is called after the Init button is pressed on the DS. So how do you separate initialization from actually starting the program running? You use the waitForStart() method inherited from the base LinearOpMode class.
 

Regular OpModes

The regular OpMode type that you would write extends the OpMode class in the FTC SDK. To add functionality, your code will override one or more of the following methods that exist in the base OpMode class:

  • init()
  • init_loop()
  • start()
  • stop()
  • loop()

These methods are called at the appropriate time in response to button presses on the driver station (DS).

Start Programming

Now its time to get more familiar with OnBot or Android Studio and writing OpModes. All of the code samples in this curriculum will work in either OnBot or AS.

OpMode Basics

The term OpMode or Operational Mode (also Op Mode and opmode) refers to a class located within the FTC SDK (robot controller app source code). You create this class to add your code to the controller app. Your code is really just a part of the controller app, with the rest of the app supplied by the FTC source code. We don't modify that other part of the code, we just create the custom robot behavior we want by adding our own OpModes. Here is a quick video overview of OpModes.

Getting Started

This course will not delve into Tetrix/REV hardware details or discuss how to build the physical robot. It is assumed you will learn about these topics elsewhere. The code exercises for this unit can be run on the classic example robot "pushbot", build instructions here.

Introduction

This lesson is the first in the "off ramp" unit for Tetrix/REV programmers. This unit contains a detailed exploration of writing Java programs for the control system used on Tetrix/REV based robots. Don't forget to complete the rest of the Java curriculum starting with Unit 12.

We have been learning a lot about the Java programming language. Now its time to explore how we actually write, compile and deploy Java programs to the robotics control system.

Packages and Imports in Detail

A real project, even robotics projects, can end up having many classes. You will likely need to use classes in libraries provided by FIRST or others. Finding the classes you need, controlling access to them and naming conflicts between your classes and library classes would be a problem. You may also want to organize a group of your classes into a library that can be reused with other projects or other robotics teams. Packages give us a way to group together related classes in a unique naming scheme and reference them from other classes.

More on Objects

Now we are going to look at some aspects of using objects in your code.

Pages