Skip to content
Joe Thompson - FTC Coach edited this page Oct 3, 2021 · 15 revisions

Introduction

This wiki provides an introduction to the basic commands and procedures required to make a robot go. The primary reference source for most of the information here is the WPI FRC documentation wiki. The WPI documentation covers most aspects of robot design and build, but we will focus on software here.

The information presented here assumes that you have a basic familiarity with Java and git SCM. If you aren't familiar with these things, don't worry. Some of the information here may not make sense to you, but we'll help you get through it.

Getting Started

Development System Requirements

Creating software for an FRC robot requires the installation of a few software packages on a Windows system:

The WPI documentation has detailed step-by-step instructions for installing these software packages (except for git) starting here. You will also need to install some vendor-specific libraries, but we'll discuss those later.

The WPI libraries include a specially-configured version of Visual Studio Code. If you already have VS Code installed on your machine, it is important that you use the special WPI configuration for working with FRC code and the robot. The installation routine will place an icon for this and a local copy of the WPI documentation on your desktop.

Cloning the Robot-Go repository

> git clone https://github.com/FRC8592/Robot-Go.git

We're going to all work on our own branch so that we don't overwrite each other's code. After cloning the repository, change into the new directory and create a personal branch:

> git checkout -b <my name>

The git checkout command is used to switch among branches. The -b option tells git to create a new branch.

All of our software efforts will make use of git Source Control Management (SCM). Using an SCM like git has many advantages:

  • Our code is shared with the team. Anyone can see our code and anyone can modify our code. It can be downloaded anywhere. A useful collary is that our code is inherently backed up on github. If something happens to our laptop, we don't lose any work.
  • Our software can be modified in private branches. This let's multiple people make changes to the code without interfering with each other. Modified code is merged to the main branch only after it is tested and ready to share.
  • Git lets us tag our code to identify and retrieve an important version. For example, we may want to tag the code we take to a competition so that we know exactly what is on the robot.

Creating a new robot project

We're going to create a new, blank project skeleton.

Making the Robot Go!

We're going to start off by creating a robot program that will drive the robot like a tank. The left and right sides of the robot will be controlled by independent joysticks and the result will emulate the way a tank with treads drives. Once we have our basic tank drive working, we'll add additional features.

In order to do this we only need to know two things: how to read control values from a joystick and how to write control values to a motor. Once we know how to do these two things, it's relatively easy to expand our knowledge to things like reading sensors (e.g. a color or distance sensor) and operating the motor in more sophisticated modes (e.g. constant velocity or constant position mode.

A note on software design

We can place a lot of requirements on the design of new software. For example, "The software shall follow good object-oriented programming methodologies" or "The software shall meet ISO 26262 and MISRA standards for software safety". Here are my top three requirements, in order of priority:

  1. The software shall perform its intended function
  2. The software shall be understandable and maintainable
  3. The software shall be efficient for its task

Some quick pointers specific to the WPI robot code

  1. All of our classes start with package frc.robot;
  2. Import any external classes needed
  3. Creating objects belongs in an init method
  4. Repetitive operations below in a periodic method

Basic robot functions

Basic smart dashboard instrumentation

Debugging robot code can be tricky. The Smart Dashboard can be used to view internal variables

import import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; SmartDashboard.putNumber("Left Power", leftPower);