Hello Robot - Introduction to Programming

Hello Robot - Choosing Your Path

In almost every programming class, the first lesson taught is some variation of the Hello World code. Hello World, often a one to two line segment of code, displays the line Hello World when the code is built and run. Though this code may seem like a very simple introduction to programming, it introduces several crucial concepts in programming. Hello World is the first lesson many students get in the logic of programming, as well as, language specific syntax. But, most importantly, the simplicity of Hello World allows it to be a testing point for the system used to execute the code.

Though it is possible to display Hello World or Hello Robot on an Android Device in the REV Control System, it doesn't serve quite the same purpose. In order to properly consider syntax, logic, and testing in the REV Control System; consideration has to be paid to a multitude of system elements like actuators and sensors. For that reason the Hello World lesson has been edited into Hello Robot.

By the end of this guide users should understand how to configure their robot and test their robot mechanisms. The following outline walks through the flow and goals of this section. Choose the path that best fits your needs.

If you are new to programming or the REV Control System we recommend that you follow through the whole guide to learn how to properly utilize the system.

Section

Sub Section

Goals

Introduction

There are three programming tools for the REV Control System. Learn about the benefits of each option and choose the best option to fit your needs. Section also includes instructions on how to access the option you choose.

What are Op Modes? Learn about the different types of Op Modes in the REV Control System

Configuration

What is Configuration and why should you configure before you begin to program?

Learn how to configure commonly used hardware like motors, servos, and sensors.

Understand and solve the common errors that occur when configuring and mapping hardware.

Test Bed: Introduction

Why creating a test bed of actuators and sensors can help with programming. This test bed, or something equivalent, will be used in following sections.

Learn why is one of the most important aspects of Software Development and how it differs from troubleshooting.

Test Bed: Blocks

Focuses on how to navigate the Blocks interface and create an op mode.

Breaks down the structure and key elelments needed for an op mode, as well as some of the essential components of Blocks and programming logic.

How to code servos and motors. This section walks through the basic logic of coding actuators, controlling actuators with a gamepad, and using telemetry.

How to code a digital device. The section focuses on the basic logic of coding a digital device, like a REV Touch Sensor.

Test Bed: OnBot Java

Focuses on how to navigate the OnBot Java interface and create an op mode.

Breaks down the structure and key elelments needed for an op mode, as well as some of the essential components of Java.

How to code servos and motors. This section walks through the basic logic of coding actuators, controlling actuators with a gamepad, and using telemetry.

How to code a digital device. The section focuses on the basic logic of coding a digital device, like a REV Touch Sensor.

Robot Control

Introduces a potential robot to work with as well as the configuration file used in the following sections.

Differences between differential and omnidirectional drivetrains and their affect on teleoperated control types.

Robot Navigation: Blocks

What to consider when programming drivetrain motors and how to apply this to an arcade style teleoperated control.

Learn how to use the concept of elapsed time to create time controlled autonomous programs.

Learn how to use encoders to create more consistent autonomous pathing.

Robot Navigation: OnBot Java

What to consider when programming drivetrain motors and how to apply this to an arcade style teleoperated control.

Learn how to use the concept of elapsed time to create time controlled autonomous programs.

Learn how to use encoders to create more consistent autonomous pathing.

Arm Control: Blocks

Introduction to coding an arm for teleoperated control and working with a limit switch

Using motor encoders to move an arm to a specific position, such as from 45 degrees to 90 degrees.

Working with the basics of arm control, motor encoder, and limit switches to control the range of motion for an arm.

Arm Control: OnBot Java

Introduction to coding an arm for teleoperated control and working with a limit switch

Using motor encoders to move an arm to a specific position, such as from 45 degrees to 90 degrees.

Working with the basics of arm control, motor encoder, and limit switches to control the range of motion for an arm.

Programming Tools

Choosing the appropriate programming tool or language is one of the most crucial decisions a user can make. In the REV Control System there are three programming tools to choose from: Blocks, OnBot Java, and Android Studio. Each tool comes with different benefits and difficulty levels.

Basic

Intermediate

Advanced

Blocks

Onbot Java

Android Studio

The programming tools for the Software Development Kit (SDK) were chosen as a means of giving users the ability to choose among alternatives, but also as a means of allowing users to naturally move from basic to advanced programming. A user can reasonably start with Blocks and build their way up to Android Studio. In fact, this is often our suggestion to rookie users. Android Studio is a very powerful tool but, as you are learning the basics of programming, has the potential to be a hindrance rather than a help.

Review the following sections to learn about each programming tool and the benefits that come with it. Once you are done reviewing make an educated choice about what tool will work best for you!

Blocks

The Blocks Programming Tool is a visual, programming tool that lets programmers uses a web browser to create, edit and save their op modes. Blocks, like other scratch based programming tools, is a collection of preset code snippets that users can drag-and-drop into the appropriate code line.

Blocks was created to cater to users who have little to no experience programming. Unlike OnBot Java or Android Studio, Blocks works to insulate and protect users from the complexities of the SDK. The Blocks interface accomplishes this by hiding, or abstracting, some of the more complex overhead the system requires, like calls to specific libraries or classes. The code snippets make those connections and assumptions for the user.

One of the other major benefits of Blocks are the built-in features that allow users to naturally transition from little to no programming knowledge to a basic understanding of Java. Blocks teaches users the logic of programming, while protecting them from syntax mistakes. As users gain more confidence and ability they can use the "Show Java" option. "Show Java" allows users to see the Java syntax that corresponds with each Block that is added to the code.

Summarization of Benefits

Hides complexities from the user allowing them to focus on learning the logic

Has an option to Show Java which allows users to see what the corresponding syntax would be in Java

Web-based interface - accessible on most devices

Saves directly to the robot

Just as powerful as OnBot Java

Accessing Blocks

This section assumes that you have already gone through the steps of setting up your REV Control System. For more information on how to setup your control system check out the Getting Started with the Control Hub guide.

This section also assumes that you have a JavaScript enabled web browser.

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

  2. Once the list of available Wi-Fi networks in the vicinity is displayed select the network that matches the name of your Wi-Fi access point.

  3. Enter the password that you set when setting up the Control System.

  4. Once connected, open a JavaScript enabled browser (FIRST recommends Google Chrome).

  5. Go to 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.

Passwords are case sensitive. If you do not remember your password, use the Hardware Client to check the Program and Manage section of the Robot Controller Console

OnBot Java

A text-based programming tool that lets programmers use a web browser to create, edit and save their Java op modes.

OnBot Java is great for programmers with basic to advanced Java skills who would like to write text-based op modes. OnBot Java shares some of insulative properties of Blocks, but gives users access to the more complicated elements of the SDK libraries.For instance, OnBot requires users to make calls to classes like the hardwareMap, which are hidden within the Blocks code snippets.

OnBot Java shares a web-based interface with the Blocks Programming tool. The web-based model is easy to access on most devices to make code change and reduces the need to have one set device for code changes.

Summarization of Benefits

Access to more complicated library classes for more advance programming

Reduces coding issues by hiding complex classes from the user

Allows users to learn Java in simplified interface

Web-based interface - accessible on most devices

Saves directly to the robot

Accessing OnBot Java

This section assumes you have already gone through the steps of setting up your REV Control System. For more information on how to setup your control system check out the Getting Started or Managing the Control System sections of the Control System Guide.

This section also assumes that you have a JavaScript enabled web browser.

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

  2. Once the list of available Wi-Fi networks in the vicinity is displayed select the network that matches the name of your Wi-Fi access point.

  3. Enter the password that you set when setting up the Control System.

  4. Once connected, open a JavaScript enabled browser (FIRST recommends Google Chrome).

  5. Go to 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 OnBot Java

Passwords are case sensitive. If you do not remember your password, use the Hardware Client to check the Program and Manage section of the Robot Controller Console

Android Studio

An advanced integrated development environment for creating Android apps. This tool is the same tool that professional Android app developers use. Android Studio is only recommended for advanced users who have extensive Java programming experience.

Android Studio allows programmer with an advanced understanding of Java a more powerful development environment to work in. It offers enhanced editing and debugging features not available with OnBot Java or Blocks. It also allows programmers the ability to work with 3rd Party libraries not included within the SDK. However, Android Studio is not a web-based software and will need a dedicated laptop to run on.

Summarization of Benefits

Access to more complicated library classes for more advance programming

Enhanced editing and debugging features

Enables access to 3rd Party Libraries

Accessing Android Studio

To learn about how to properly download and work with Android Studio please visit the FTC Wiki.

FIRST Global does not have support for Android Studio.

Op Modes

Op modes (or operational modes) are computer programs that are used to customize or specify the behavior of a robot. The Robot Controller, either the Control Hub (REV-31-1595) or an Android device paired with an Expansion Hub (REV-31-1153), stores and executes op modes. The Driver Station allows users to select from any of the op modes stored on the Robot Controller and initialize, start, or stop the op modes.

In the SDK there are two types of op modes: autonomous and teleoperation. Both types of op modes have initialization, start, and stop features on the Driver Station phone. Each feature corresponds with different types of code segments that will be discussed in detail in the programming tool specific Test Bed sections of this document.

The main difference between autonomous and teleoperation op modes is how they show up in the Driver Station application. Autonomous op modes show up in a drop down menu on the left side of the Driver Station application. The Driver Station assigns a 30 second timer to autonomous op modes. If the autonomous op mode is not manually stopped prior to the end of the 30 seconds the Driver Station will automatically stop the code. TeleOp op modes will appear in a drop down menu on the right side of the Driver Station application. These op modes will run until they are manually stopped.

It is also worth noting that in the SDK op modes can be linear op modes or iterative op modes. This guide focuses on Linear op modes, which execute code lines in a sequential order. In order to repeatedly call actions within in a linear op mode, a loop function must be used. This topic will be discussed in further detail as you follow along this guide.

Last updated