[SUCCESS] The examples and screenshots for this tutorial are completed using a Windows computer, however the Control Hub can be programmed using a Chromebook or a Macbook.
This tutorial serves as an introduction to the REV Control System, teaching basics of configuration, programming, and utilizing sensors, motors, and servos -- extending beyond the traditional "Hello World" programming exercise.
Two major sections:
Three programming options exist: Blocks (Basic), OnBot Java (Intermediate), and Android Studio (Advanced).
A drag-and-drop programming tool available directly through the Control Hub, similar to Scratch-based languages used in FIRST LEGO League. It caters to users with minimal programming experience through preset code snippets. Users can view underlying Java syntax using a "Show Java" button.
A text-based programming tool based on a modified version of Java. Suits programmers with basic to advanced Java skills. It provides access to complicated SDK library elements like the hardwareMap class, which remain hidden in Blocks.
An advanced IDE for Android app development used by professional developers. Recommended only for users with extensive Java experience, offering enhanced editing and debugging features plus third-party library access. Requires dedicated laptop installation.
Users select between Blocks or OnBot Java to begin the Hello Robot tutorial.
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.
To start, in the REV Hardware Client, select the "Program and Manage" menu tab. In the upper left-hand corner there is a "Create New OpMode" button, click it.
Clicking the "Create New OpMode" button will open a new window to name and, if applicable, select a sample template for a program. For this guide use the default "BasicOpMode" sample and name the OpMode HelloRobot_TeleOp.
Once the OpMode has been named click 'OK' to proceed forward.
Creating an OpMode will open up the main Blocks programming page. Before moving on to programming, take some time to learn and understand the following key components of Blocks:
1. Save OpMode - Click this button to save an OpMode to the robot. It is important to save the OpMode any time you stop working on a code, so that progress is not lost. Blocks does not have an autosave feature!
2. TeleOp/Autonomous - This section of blocks allows users to change between the two types of OpMode: teleop and autonomous.
3. Categorized Blocks - This section of the screen is where the programming blocks are categorized and accessible. For instance, clicking Logic will open access to programming blocks like if/else statements.
4. Programming Space - This space is where blocks are added to build programs. Blocks not currently in the use may be dragged off to the side to be clicked back in later or deleted.
5. Greeting Message - This intro information message may appear when creating a new, empty OpMode. Clicking the ? icon will close this message.
[DANGER] Remember a configuration needs to be completed first before programming! Some blocks or dropdown menus may be hidden from the side menu until a configuration is made active.
Blocks includes a nifty tool to view how our code would appear if converted to Java. You can click the button on the far right side to open or close this viewer.
While this feature is designed to aid in the transition between programming platforms, some edits may be required for the Java code to properly compile if added to an OnBot Java OpMode.
Creating an OpMode requires selecting a clear and unique name to help locate the program later or communicate with teammates driving the robot.
Programming follows established naming conventions for variables, classes, and functions. OpModes resemble classes as program-code templates, so their naming convention capitalizes the first letter of every word.
The REV Hardware Client interface includes five key elements:
1. Create New OpMode - A plus sign button that opens a window for creating a new OpMode
2. Project Browser Pane - Displays all Java project files on the Robot Controller
3. Source Code Editing Pane - The main code editing area
4. Message Pane - Provides information on code build success or failure and error locations
5. Build Everything - Builds ALL .java files on a Robot Controller
To temporarily disable an OpMode, right-click the filename and select "Disable / Comment." OpModes can be reenabled the same way.
For Hello Robot tutorial, use these settings:
"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! The intended configuration file should be active before creating an OpMode using this feature.
For Hello Robot tutorial in 10.3:
In the 10.3 version, samples and blank templates are separated for easier navigation. To use sample code, change "File Type" to "Example OpMode," then select the desired sample from the dropdown.