Java 0: Introduction

From Deep Blue Robotics Wiki
Revision as of 03:07, 20 August 2016 by Eliu (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

What is Robot Programming?

Robot Programming is the process of writing the software that controls the robot. Each year’s game challenge usually contains two parts, autonomous (auto) and teleoperated (teleop). During teleop, the robot is controlled by human drivers, so the software has to connect the driver station controls with actual robot actions. While some of these actions are fairly simple, such as activating a piston, others can be more complicated, like tilting a shooter to a precise angle. During auto, the robot has no drivers, so it must be completely controlled by software. This often requires even more complex functionality, such as machine vision or PID control.

Java

The robot’s code runs on an onboard processor called the RoboRIO, which is connected to the driver station computer by a wireless bridge. The RoboRIO supports three programming languages: LabView, C++, and Java. Our team decided to use Java, because it is both powerful and easy to use. Java is a general-purpose text-based language with a huge number of applications, so any Java skills that you learn here will be very useful outside of robotics as well.

WPILib

FIRST provides us with a useful code library called WPILib (after Worcester Polytechnic Institute) that takes care of low-level functionality, like reading encoder values or communicating with speed controllers. This frees the programming team to focus on higher level program logic during build season.

The Programming Process

There are three main stages of writing a program: design, implementation, and testing.

Design

When working on a complicated project (like robot code), the first step is to determine the general structure of your program. At the beginning of each build season, the programmers divide up the robot into separate subsystems, each with its own actuators and sensors. We then decide what commands the robot will need to execute and figure out which subsystems will be required for each command. Finally, we design the operator interface, i.e. which commands are assigned to which joysticks and buttons on the driver station.

Implementation

The next step is to actually write the code for all of the commands and subsystems in the design. For example, let's say the design calls for an Auto-Aim command that will automatically aim the shooter at the goal. The implementation of that command would require identifying the target using the camera, determining how far away it is, calculating the ideal parabolic trajectory for the game piece to travel, and rotating the shooter to the correct angle and elevation within a very small margin of error.

Testing

Once the code has been written, the final step is to test it out. There will inevitably be some bugs in your code, so testing is necessary to find and eliminate those bugs before the actual competition. Testing is also the time for any calibration and tuning that needs to be done. While there are some parts of the code that can be tested on a practice board or an old robot, the most important test of the code is on the actual robot. Unfortunately, the robot is usually finished near the very end of build season, so testing needs to be done as quickly as possible.


Next Lesson: Java Basics