Blocks — Visual drag-and-drop in your browser. Easiest way to start. This is what the course slideshows use.
OnBot Java — Text-based code. Same concepts, written as Java. Expand the "Level Up" section when you're ready.
Start with Blocks. Java is in a collapsible section at the bottom of each chapter.
When using Blocks or OnBot Java there are two primary ways to access the Robot Controller App on the Control Hub for programming.
The first way is through the REV Hardware Client (RHC), the same software you use to update the Control and Driver Hub! This application makes it easy to navigate, manage, update, and program with the Control Hub. Additionally, the RHC allows for programming while connected via USB or Wi-Fi. However, the REV Hardware Client is currently only available for Windows.
As an alternate option, the Robot Controller App can be accessed via Wi-Fi allowing programming through a web browser. This is the perfect option for those using Chromebooks or who may have restrictions on installing applications.
Download the latest version of the REV Hardware Client and install on a Windows PC.
Step 1: Power on the Control Hub, by plugging the 12V Slim Battery (REV-31-1302) into the XT30 connector labeled "BATTERY" on the Control Hub.
Step 2: The Control Hub is ready to connect with a PC when the LED turns green. Note: the light blinks blue every ~5 seconds to indicate that the Control Hub is healthy.
Step 3: Plug the Control Hub into the PC using a USB-A to USB-C Cable (REV-11-1232)
Start up the REV Hardware Client. Once the hub is fully connected it will show up on the front page of the UI under the Hardware Tab. Select the Control Hub.
After selecting the Connected Hardware the Update tab will pop up. Select the Program and Manage tab. This will take you to the Robot Controller Console built into the REV Hardware Client.
Once in the Robot Controller Console, the homepage of the console will appear. You will see the option for "Blocks" and "OnBot Java" along the top tool bar. "Manage" provides access to changing the Control Hub's network settings!
[SUCCESS] When using a Chromebook or Macbook with a Control Hub follow the steps below.
With the Control Hub powered, access the Wi-Fi network selector. For Windows 10 devices, click the Wi-Fi Network icon in the lower right corner of the desktop.
Look for the Wi-Fi that matches the naming protocol of the device.
Once you have found the target network in the list, click on it to select it then press connect.
Provide the network password (in this example "password") and press "Next" to continue.
Once a wireless connection is established, the status is displayed in the wireless settings for the device.
[DANGER] When connected to the Control Hub, the connected device will not have access to the Internet. It only has direct access to the Control Hub.
Open a web browser (Chrome, Firefox, Internet Explorer) and navigate to "192.168.43.1:8080" through the address bar.
Before we can truly dive into programming our robot we need to help our robot's brain, the Control Hub, to know what is connected to it. Through the configuration process we can tell the Control Hub which port sensors, motors, servos, and any other connected devices can be found.
This is one of the most important steps to always complete BEFORE you can start programming!
While every REV Control Hub is the same, the robots being controlled are each unique. Each Control Hub has the same number of input and output ports for motors, sensors and cameras, but, how you may utilize these ports varies from system to system. For instance, a Color Sensor V3 may be plugged in to I2C Bus 1 on one person's Hub, but another might use the same bus to host a 2m Distance Sensor.
While the Control Hub may know there is a device attached to a port, it doesn't instinctively know which information needs to be transferred back for use in an OpMode. To help our robot out we need to complete a process called hardware mapping. Generally, this is a two step process that includes creating our configuration file using the Driver Hub and calling the hardware map within our OpMode.
When using Blocks, this second step is handled by the SDK itself. Once you've created your configuration file on the Driver Hub your robot's devices are ready to use and you will see their names in the dropdown menus of related blocks.
The configuration file is a readable file created by the user through the Driver Station Application. When creating a configuration file users are required to assign each device to a port, select the type of device it is from options provided by the SDK, and give it a unique name.
It's important to name each device something recognizable and distinguishable!
Once a configuration file is saved or activated the robot will restart. This restart is so the SDK can read the file, determine what devices are present, and add the devices to the hardwareMap class.
Step 1: Select the menu in the top right corner of the Driver Station app. Then select Configure Robot.
Step 2: In the Available configurations page, select New.
Step 3: In the USB Devices in configuration page select the Control Hub Portal.
Note: If you have an Expansion Hub connected it will appear as an Expansion Hub Portal.
[DANGER] Pressing 'Scan' on an existing configuration may result in the already named devices being erased. A new configuration file is needed when adding a camera or Expansion Hub.
Step 4: Within the Hub Portal select the device you want to configure. In this use case, select the Control Hub.
Note: If you have an Expansion Hub connected to a Control Hub, the Expansion Hub will also appear as a configurable device in the portal.
Step 5: This will bring you to the configuration page. From here you can configure motors, servos and sensors that you are using.
Note: The way that Digital and Analog devices are configured versus how I2C devices are configured differ significantly. This is because each physical I2C port is a different bus that can host multiple different sensors.
The following section will show how to configure components that will be used in the Test Bed. The hardware type and names have been chosen in consideration for the Hello World lesson plan.
Step 1: Select Motors.
Step 2: The Motor page will allow you to configure all four motor ports on the Hub. On Port 0 open the drop down menu and select REV Robotics Core Hex Motor.
Note: In your configuration file you should configure the motor ports to the type of motor you are using.
Step 3: Name the motor test_motor. Select done.
Note: Remember when naming hardware in the configuration file that the REV Control System is Case Sensitive.
Step 1: Select Servos.
Step 2: The Servo page will allow you to configure all six servo ports on the Hub. On Port 0 open the drop down menu and select Servo.
Note: REV Servos can be configured as a Servo or a Continuous Rotation Servo. The type of device a servo is configured as should correspond with the mode the sensor is in.
Step 3: Name the servo test_servo. Select done.
Note: Remember when naming hardware in the configuration file that the REV Control System is Case Sensitive.
Step 1: Select Digital Devices.
Step 2: The Digital Devices page will allow you to configure all eight digital ports on the Hub. On Port 1 open the d
[... guide continues at REV docs ...]
While our robot is able to do a lot autonomously, more often than not we need, or want, to input commands using a gamepad. There is a wide variety of gamepads that are compatible with the Driver Hub. For this tutorial we will be focusing on a generic PS4 controller, such as the REV USB PS4 Compatible Gamepad, or an Etpark Wired Controller.
All buttons on a gamepad can be programmed to a specific task or behavior. Let's take a look at the breakdown of each button, their associated block name, and the type of data they output:
| PS4 Controllers | Generic USB Gamepad | Data Type |
|---|---|---|
| Cross | a | Boolean |
| Circle | b | Boolean |
| Triangle | y | Boolean |
| Square | x | Boolean |
| Dpad Up | Dpad Up | Boolean |
| Dpad Down | Dpad Down | Boolean |
| Dpad Left | Dpad Left | Boolean |
| Dpad Right | Dpad Right | Boolean |
| Left Bumper | Left Bumper | Boolean |
| Right Bumper | Right Bumper | Boolean |
| Left Trigger | Left Trigger | Float |
| Right Trigger | Right Trigger | Float |
| PS | Home | Boolean |
| Options | Start/Options | Boolean |
| Share | Back/Share | Boolean |
| Left Stick Button | Left Stick Button | Boolean |
| Left Stick X Axis | Left Stick X Axis | Float |
| Left Stick Y Axis | Left Stick Y Axis | Float |
| Right Stick Button | Right Stick Button | Boolean |
| Right Stick X Axis | Right Stick X Axis | Float |
| Right Stick Y Axis | Right Stick Y Axis | Float |
The gamepad outputs two types of data back to the Control Hub to be used within the program:
Boolean data has two possible values: True and False. These two values can also be represented by On and Off or 1 and 0.
The buttons, bumpers, and triggers on the gamepad provide boolean data to our robot! For example, a button that is not pressed will return a value of False (or 0) and a button that is pressed will return the value True (or 1).
Float data is a number that can include decimal places and positive or negative values.
On the gamepad, the float data returned will be between 1 and -1 for the joystick's position on each axis. Some examples of possible values are 0.44, 0, -0.29, or -1.