Static Modifier

Normally, class members (variables and methods) are accessed via an instance reference. Leaving methods aside for the moment, this is because class variables exist separately for each instance of a class (created with the new keyword). If you have a variable x in a class and create two instances of the class, each instance will have its own x variable, access to which is by the instance reference. You also access methods via the instance reference. Here is an example:

Controlling access to members of a class

You have seen the access control modifier public used extensively in our Java examples. The access control modifier is applied to classes and class members (variables and methods) and determines what access code in other classes have to the class members.


We have seen how we can extend a class to have additional fields and methods and build a more specialized object. But what if we want to change the behavior of one of the superclass methods? we can do this with Overriding.


In our first unit on objects we learned how objects can encapsulate fields and methods creating a custom data type we can use to model the actual objects in the problem we are trying to solve. These objects make it easy to describe and work with our data and facilitate reuse of code. In this unit we are going to explore some of the more powerful features of Java's object oriented design.

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/FTC 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.