Setting up an Opmode - ThorGuy/NOTN_2018-19 GitHub Wiki

Opmodes

Opmodes, or Operating Modes, are the programs that run the robot. In order for the phone app to recognize a program as an opmode, it first needs to be located in ftc_app-master\TeamCode\src\main\java\org\firstinspires\ftc\teamcode.

There are two types of OpModes: One for the Autonomous period and one for the Driver-Controlled period.

Autonomous

To use the autonomous, import import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode and add the following line before the class: @LinearOpMode(name="Autonomous", group="Linear Opmode")

Have the main class extend LinearOpmode, and add a function public void runOpMode() This method will run from start to end when you hit the Init button on the app, so if you want something to wait for the Start button to be pressed, add waitForStart(); before it. If you want the program to stop when the Stop button is pressed, you will need to test to see if it's pressed using the method opModeIsActive(), which will return false when the button is pressed.

Driver-Controlled

To use the Driver-Controlled, import import com.qualcomm.robotcore.eventloop.opmode.OpMode and com.qualcomm.robotcore.eventloop.opmode.TeleOp. Then add the following line before the main class: @TeleOp(name="Autonomous", group="Linear Opmode")

Have the main class extend Opmode, and add the functions public void init() and public void loop(). The init method will run from start to end when the Init button is pressed, and the loop method will be run repeatedly after the Start button is pressed, and before the Stop button is pressed.

~~~~~~~~~~~~~~~~

Next, we will go over Reading Input