This website will generate all the code
snippets you will need to get off the
ground fast!
This help page has interactive snippets that you
can change on the fly and copy into your file for easy use,
as well as many explanations on how to use different features.
Opmodes are the way that you can make code appear on the robot.
They are defined the same way as normal classes, but with a few extras.
They follow a simple template that goes like this:
public class OpModeName extends OperationMode implements TeleOperation { @Override public void contruct() { } @Override public void run() { } }Opmode Name:
Hardware is the way that you can interact with the robot's physical features.
Hardware is the term for things like motors, gamepads, servos, and sensors.
Hardware devices can be interacted with using the HardwareGetter class.
Note that some hardware must be initialized before it can be used.
Hardware uses a system which I call "Requests". Requests have a two-part system.
First, a request must actually be created, then you can call that request. Requests can
be used in any part of the script, and some advantages will be explained later.
Devices.motor0.setPower(1.0); // Set the power of the motor
Devices.motor0.setOperation(OperationType); // Set the operation type of the motor
counts_per_inch = (counts_per_rev * gear_ratio) / (wheel_diameter * PI)
GENERIC BUTTONS dpadUp dpadDown dpadLeft dpadRight leftStickSutton rightStickButton leftBumper rightBumper GENERIC AXES leftTrigger rightTrigger leftStickX leftStickY rightStickX rightStickY XBOX-ONLY BUTTONS a b x y back start guide PLAYSTATION-ONLY BUTTONS circle cross square triangle share options touchpad touchpadFinger1 touchpadFinger2 ps PLAYSTATION-ONLY AXES touchpadFinger1X touchpadFinger1Y touchpadFinger2X touchpadFinger2YNote that some of those buttons, are axes, rather than buttons. Axes will return a value between -1 and 1, with the exception of the touchpad of the playstation controller, which we never use. Buttons will return a boolean value. To use the gamepad, look at the code snippet below:
Devices.controller1.getDpadUp();
public class OpModeName extends EmulatedOpMode implements TeleOperation { @Override public void contruct() { } @Override public void run() { } }Opmode Name:
Sometimes, you might want to connect to the robot wirelessly to connect to ADB, view the Dashboard, push code to the bot, etc.
This is possible in 2 ways:
The REV Hardware Client is useful for management of hardware. If you don't have it already—and you run Windows—you should install it even if you don't plan to use its wireless functions so you can still manage hardware. It is necessary for at least one computer to have this installed because the Control Hub's operating system and firmware must be updated every season.
With that out of the way, using the REV Hardware Client to connect to the robot wirelessly is simple.
You may have noticed that you can't access the internet using the REV Hardware Client to wirelessly communicate with the robot as you're on the robot's wifi network. There are two ways to solve this.
ipconfig
, and view the IP of the default gateway for the second adapter.
route -p ADD 192.168.43.0 MASK 255.255.255.0 192.168.1.X METRIC 1