0% found this document useful (0 votes)
11 views

Lesson 24 Programming Refresher

The document provides an introduction to REV Programming using visual programming blocks that simplify coding by allowing users to drag and drop preset code. It explains how to connect to the Control Hub, configure hardware, create operational modes (OP Modes), and program motors, including using gamepads for control. The guide emphasizes the importance of saving configurations and offers step-by-step instructions for setting up and programming robots.

Uploaded by

luchartley123
Copyright
© © All Rights Reserved
Available Formats
Download as KEY, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Lesson 24 Programming Refresher

The document provides an introduction to REV Programming using visual programming blocks that simplify coding by allowing users to drag and drop preset code. It explains how to connect to the Control Hub, configure hardware, create operational modes (OP Modes), and program motors, including using gamepads for control. The guide emphasizes the importance of saving configurations and offers step-by-step instructions for setting up and programming robots.

Uploaded by

luchartley123
Copyright
© © All Rights Reserved
Available Formats
Download as KEY, PDF, TXT or read online on Scribd
You are on page 1/ 18

Introduction to REV Programming

Blocks
Blocks are a visual programming tool that is run through a web browser
Each “block” is made up of a preset piece of code that can be dragged and dropped

Blocks simplifies the programming process by building in certain assumptions to each


block so the programmer doesn’t need to clarify all of the details that would be required
for other languages

There is an option in the Blocks programming tool to show the written Java code that
makes up each block
This is a powerful tool for learning programming
How to Start “Blocks”

Follow along as we go through this process and raise


your hands with any questions!

1. Go to Wi-Fi Settings, on a Windows 10 Computer, by clicking on the Wifi symbol.


2. Once the list of available Wifi networks in the vicinity is displayed, select the network that
matches the name of your Control Hub.
3. Enter the password that you set when setting up your Control System
4. Once connected, open Google Chrome
5. Type in the following IP Address: http://192.168.43.1:8080
6. At the top of the Robot Controller Console Page, there should be 3 menu options:
Blocks, OnBot Java, and Manage. Choose Blocks .
OP Modes

Operational Modes (OP Modes) are computer


programs that are used to customize or control the
behavior of a robot
For our robots, the Control Hub will run the OP
Modes
There are 2 types of OP Modes:
Autonomous (robot controlled)
Teleoperation (driver controlled)
Autonomous Modes run on the left drop down
Runs for 30 seconds unless manually stopped
Teleop Modes run on the right drop down
Runs forever until manually stopped
Configuration

Configuration is the process of telling the Control


Hub what sensors and motors are plugged into
what ports
The Control Hubs knows what ports are available,
but needs to be told what is plugged in

The user needs to go through a process called


Hardware Mapping, which involves creating a
Configuration File and Hardware Map within an
OP Mode
Configuration

The Configuration File is created using the


Driver Station app by clicking the three dots
in the top right (see image)
The User must give each motor/sensor a
unique name and assign it to a port
Blocks simplifies the Hardware Mapping
process by automatically referencing
external hardware after it’s first referenced
within a program
Other languages have more complex
processes which will be covered later
Configuration with Pictures!

1. Click “Configure 2. Click “New” 3. Click “Control Hub Portal” 4. Click “Control Hub”
Robot”
Configuration with Pictures! (Continued)

You’re now on the Hardware Screen where you can configure Motors, Servos,
and Sensors
The process for configuring all devices is similar:
Specify what you want to configure (Motors, Servos, Digital Devices, etc.)
Specify what type of device is on each port
Give each device a unique name
Configuration with Pictures! (Continued)
Saving your Configuration File

Once your Configuration File is


done, save it by clicking “Done”
twice, and then click “Save”
Next, give your configuration a name
Once complete, you’ll have the
option to Edit, Activate, or Delete
your Configuration
Hit the back button to return to the
Driver Station
Creating an OP Mode
Click on “Create New OP Mode in
the top left of the Robot Controller
Console

Name your OP Mode and optionally


use a sample code to start with
Sample code can give you a big
head start when trying to
program something quickly
Start with the BasicOpMode
sample code when starting out
OP Mode Interface

1. Save Op Mode - Click this button to save an op


mode to the robot. It is important to save the op
mode any time you stop working on a code, so
that progress is not lost.
2. TeleOp/Autonomous - This section of blocks
allows users to change between the two types
of op modes: 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.
Programming Essentials

The sample code seen to the right


is the BasicOpMode which includes
all the necessary components for a
working OP mode
“Comment” Blocks

Comment Blocks are useful for


making programs easier to work
with

Comment Blocks are used by


Programmers to explain a
section of code
“Call” Blocks

The Call block will tell all of the blocks below it to wait until the start command is
given on the Driver Station
Any Blocks above the Call block will start right when the OP Mode is first selected
Placing Blocks above the Call block is typically used for defining variables
Programming Motors

To program a motor, you must follow the path below to find the motor block
Once selected, you can click the drop down menu to determine what motor
you’d like to use

Add the motor block to the “While Loop”


as shown in the image on the right
Programming Motors with a Gamepad

To Program a motor to be controlled


by a Gamepad, navigate to the
Gamepad block

Replace the “1” from the previous


code example with your Gamepad
block

If you want to reverse the direction


that the joystick moves the motor,
navigate to the “Math” tab and insert
a minus sign as shown
Programming Summary:
1. Start Blocks on your Computer
2. Configure your robot through the Driver Station
App
a. Make sure to add all devices with unique names
3. Save and title your configuration file
4. Create a new OP Mode on your computer/Robot
Controller while selecting the BasicOpMode
sample code
5. Drag Motor blocks into the “While Loop” of the
sample code and set them to be controlled by
gamepads

You might also like