Creating an OpMode - OnBot
The time has come to create our first OpMode. We want to make sure to choose a clear and unique name each time we make a program. This will help us to find it again later or to communicate with teammates who may also be driving the robot.
In the programming world, there are common naming conventions that have been established to denote variables, classes, functions, etc. OpModes share some similarities to classes, a program-code-template. Thus the naming convention for OpModes tends to follow the naming convention for classes, which has the first letter of every word is capitalized.
While there are standardized naming conventions in programming, at the end of the day you will want to pick something that makes sense to YOU or your team. This might include having your name, team name, a school class period, or similar in your name.
Your OpMode name should not be the same as a created variable name.
To start, let's take a look at the OnBot Java layout in the REV Hardware Client:
Create New OpMode - The plus sign button opens up a window to create a new OpMode.
Project Browser Pane - This pane shows all the Java project files on the Robot Controller.
Source Code Editing Pane - This is the main code editing area
Message Pane - This pane provides information on the success or failure of code builds, as well as where to check for errors after attemping a build
Build Everything - Builds ALL of the .java files on a Robot Controller.
Selecting to "Build Everything" will attempt to compile ALL your OnBot Java files. Errors may appear for incomplete or test files along with the active file.
To temporarily disable an OpMode, right click the file name and select "Disable / Comment":
OpModes may be reenable the same way!
Select the Create New OpMode button. This will open the New File window.
There are a lot of things we can modify while setting up our OpMode, such as the name, sample in use, and kind of OpMode. For Hello Robot, use the following settings for reference:
![](https://docs.revrobotics.com/~gitbook/image?url=https%3A%2F%2F1359443677-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FUOOiQ4S2QcMWmVoSmeQ8%252Fuploads%252FhAwxxfuraTFqe2sCx79U%252Fimage.png%3Falt%3Dmedia%26token%3D8d06ea8d-3143-4a8c-a9e6-941019fbabe8&width=768&dpr=4&quality=100&sign=7df8ac86&sv=1)
File Name: HelloRobot_TeleOp
Sample: BlankLinearOpMode
OpMode Type: TeleOp
Setup for Configured Hardware: on
Setup Code for Configured Hardware is an incredibly useful tool that allows for OnBot to help create the hardwareMap based on the current active configuration!
Your intended configuration file should be active BEFORE creating an OpMode using this feature.
![](https://docs.revrobotics.com/~gitbook/image?url=https%3A%2F%2F1359443677-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FUOOiQ4S2QcMWmVoSmeQ8%252Fuploads%252Fi7HMrEgBVwEJoTp9GhfH%252Fimage.png%3Falt%3Dmedia%26token%3Df058c20c-dfd9-49d3-b095-29857dd5174a&width=768&dpr=4&quality=100&sign=98dfe364&sv=1)
Once the proper settings have been choose, select "OK" to create the OpMode!
Last updated