Setting up 2021 Programming tools - quasics/quasics-frc-sw-2015 GitHub Wiki

There's a series of things that need to be done in order to be able to get, modify, build, and deploy the code for the team's robot:

  • Get an account set up on GitHub (this site).
  • Install Visual Studio Code and the FRC development tools that are used to edit/build/deploy code for the robot, along with some libraries from hardware vendors to work with specific devices.
  • Install Subversion tools, which are used to access the team's source code repository.
  • Install the Visual Studio Code extensions to allow Subversion to be used within the GUI.
  • Check out an initial copy of the code for the project.
  • Open up the project in Visual Studio Code.
  • Build the code for the robot (e.g., after making changes).
  • Deploy the code to the robot.
  • (Optional) Install a "native" compiler, if you're working with a Romi device.

Some of these you should only need to do once (e.g., getting an account set up); others need to be done once per computer that you're going to use (e.g., installing various programs).

Phase 1: Getting a GitHub account set up

Instructions are here.

Note: This doesn't actually need to be finished until you're ready to make changes to the code, but it can take time (and people sometimes run into problems), so it's worth starting early. You can continue on with the rest of what's outlined below while you're waiting to get an "invitation to collaborate" with the team on GitHub.

Phase 2: Installing Visual Studio Code and the FRC development tools

To install the FRC development tools, follow the instructions here as appropriate for your platform (Windows, MacOS, or Linux).

In summary, you'll need to:

  1. Download the WPILib installer release for your operating system (here).
  2. On Windows or Mac machines, mount the disc image (.img or .dmg file) by double-clicking on it; on Linux machines, unpack the archive (.tar.gz) by double-clicking on it.
  3. Run the installer (WPILibInstaller).
  4. When asked about VS Code during the installation, pick the option to "Download VS Code for Single Install".
  5. On the "Select the items you'd like to install" page:
    • Our team doesn't generally require the "Java JDK/JRE" option (but it doesn't hurt to include it).
    • Unless there's multiple accounts using the computer to code for FIRST (e.g., the "coach" and "developer" accounts on the team laptops), you can likely get away with the "Install for this user" option.
  6. After the install finishes:
    • On Windows/Mac, you can right-click on the disc in your file browser and eject it, and then delete the disc image you downloaded.
    • On Linux, you can delete both the archive you downloaded and the unpacked version.

Important notes to supplement the directions from FIRST:

  • For Windows machines that will be set up as driver's stations, you should install the software for "programming-only" machines and also follow the directions for "Installing the FRC Game Tools".

Phase 2.1: Installing Rev Robotics libraries for Spark MAX

Directions for "online installation" are provided at in the C++ API documentation on the Rev Robotics site.

Note: Follow the "online installation" instructions, as this is the simplest way to do things for this library.

Phase 2.2: Installing Rev Robotics libraries for Color Sensor v3

  • Go to https://github.com/REVrobotics/Color-Sensor-v3/releases
  • Download the .ZIP file containing the latest release.
  • Unpack the .ZIP file
  • Open up a file browser, and look inside the folder the was extracted from the .ZIP file
  • Open up a second file browser, and look inside the "wpilib/2021" folder on your machine
    • On Windows, this should likely be in "c:\Users\Public\wpilib\2021".
    • On a Mac, this should be under "<your home directory>/wpilib/2021".
  • Copy the "vendordeps/REVColorSensorV3.json" file from the unpacked archive into the "wpilib/2021/vendordeps/" folder on your machine.
  • Copy the "maven/com/revrobotics" folder (and all of its contents) from the unpacked archive into the "wpilib/2021/maven/com/" folder on your machine.

Phase 2.3: Installing CTRE Phoenix Framework (for Victor SPX)

  • Go to CTRE's resource page here.
  • Click on the link for "Phoenix Framework Releases".
  • Download the latest version of the "CTRE Phoenix Framework Installer" for your machine.
    • For Windows, this may be a ".exe" file, which will automatically install the various components.
      • Run the installer
      • When asked to select the components to install, make sure that the "roboRio-FRC | C++/Java" option is selected. (None of the other optional components should be needed.)
    • On Mac/Linux, this will be a ".zip" archive.
      1. Extract the files from the archive (typically by double-clicking on it).
      2. Open a file browser (if needed), and navigate into the folder that was extracted from the archive.
      3. Open a second file browser and navigate to the "wpilib/2021" tool folder (typically in your home directory).
      4. Copy the files from the "<extractedFolder>/vendordeps/" folder from the archive into the "wpilib/2021/vendordeps/" folder.
      5. Copy the entire "<extractedFolder>/maven/com/ctre" folder (and its contents) from the archive into the "wpilib/2021/maven/com/" folder.
      6. Copy the all of the folders/files in the "<extractedFolder>/Robotbuilder/" folder from the archive into the "wpilib/2021/Robotbuilder/extensions/" folder.
        • Note: the "extensions" sub-folder may not exist initially within "wpilib/2021/Robotbuilder/". If this is the case, then create a new folder with that name (e.g., via "File | New folder", etc.), and then copy the folders/files over.

Phase 3: Installing Subversion tools to access the GitHub repository

There's a couple of different options here, depending on the operating system you're using.

  • If you're working on Microsoft Windows, the easiest tool set to use is probably TortoiseSVN; see directions here.
  • If you're working on a Mac or Linux machine, it may be simplest to install the command-line tools for these environments. (They're also available for Windows.) You can largely use them from within the Visual Studio Code via some extensions (covered below).
    • Mac tools installs are covered in a lot of places, including here. If you need help with the part that talks about "edit[ing] your .profile", please talk to Mr. Healy.
    • Linux tools installs are covered in a lot of places, including here. (We assume that if you're using Linux, you'll know the basics of using a terminal window; if not, please talk to Mr. Healy.)

Phase 4: Installing Visual Studio Code extensions for Subversion use

Instructions are here.

Phase 5: Checking out the code for the robot

Phase 6: Opening up the project in Visual Studio Code

  1. Start Visual Studio Code (VSC).
    • If you're on Windows, the installer will typically have put a shortcut to this on your desktop, and you can just double-click that.
    • On a Mac, there will usually be a shortcut added to the system dock.
  2. Select "Open Folder..." from the "File" menu, browse into the project folder that you checked out and want to work in, and click on the "Select Folder" button.
    • VSC will update the UI to show the folder's contents, and will building its idea of how everything works. Be patient, as this can take a little while.
    • Among other things, a panel will open up, showing that it's "Executing task: gradlew generateVsCodeConfig" and other stuff (such as "Starting Daemon").
    • Keep being patient.
  3. A number of warnings and other indications may pop up periodically, such as "Intellisense configurations might have been updated. Refresh them now?" Feel free to say "Yes" when these appear. (You may then be prompted to restart something: feel free to say "Yes" to this, too.)
    • Eventually, you should see a "BUILD SUCCESSFUL" message in green letters. This isn't actually telling you that it's built the code to be deployed on the robot, it's just finished building the configuration files that VSC uses to do that. But it's a good sign.
    • If you see an error message that you don't understand, come find Mr. Healy or a more experienced coder, and they'll help you out.

Phase 7: Building code for the robot

  1. Start Visual Studio Code (VSC) and open the desired project for the robot.
  2. Open the "command window" by either hitting <Ctrl+Shift+P>, or by clicking on the WPILib icon (looks like a "W" in a red hexagon) on the top of the window.
  3. Pick the "WPILib: Build Robot Code" command to compile the robot code.
    • Be patient while the code builds.
    • When the build finishes, you should see a "BUILD SUCCESSFUL" message in green letters.

Phase 8: Deploying code on the robot

Instructions are here

Phase 9: Installing a "native" compiler

This phase is only needed if you're going to work with one of the Romi devices, which simulate real FRC hardware by running the robot code you write on your computer, and sending information back-and-forth with the Romi while the program is running.

To do that, you'll need a "native" compiler to be installed for your computer (i.e., one that can compile C++ code for Windows/Mac/whatever, rather than the one that is used to compile code to run on the RoboRio). For Windows, this would be Visual Studio 2019 (which is very different from VS Code), while macOS requires Xcode, and Linux (Ubuntu) requires the build-essential package.

For Windows:

  1. Go to Microsoft's web site for Visual Studio (their compiler platform), and download/run the installer for "Visual Studio Community Edition".
    • Note: It should be possible to just use the "Build Tools for Visual Studio", which is a much smaller download/install. The functional difference between the two is that the "Build Tools" are just a compiler and libraries that you need to compile code to run on Windows, while the "Visual Studio Community Edition" comes with a bunch of other stuff (editor, debugger, etc.) that aren't useful in working with the Romi devices or other FIRST code. However, it looks like a base install of the Build Tools doesn't quite work "out of the box" with the Romi set up in VSC. (We're looking into this, to see if we can simplify things.)
  2. Once the installer brings up a list of different "Workloads" and other options to be installed, select the "Desktop development with C++" option, and then press the "Install" button on the lower-right corner of the screen.
  3. The installation of the C++ tools will begin.
    • You may want to uncheck the option to "Start after installation", since you won't be using the full-blown Visual Studio environment to work with the Romi; instead, the FRC stuff for Visual Studio Code will automatically use the compiler, etc., in the background on your behalf.
  4. Once the installation process has completed, you may close the installer program window.

On a Mac:

  1. Run the "Terminal" program (found in your "Applications" folder, under "Utilities")
  2. At the prompt in the window it opens, run the command "clang --version" to check if the compiler is installed.
  3. If it reports an error (e.g., can't find the "clang" program, etc.), then run the command "xcode-select --install" to run the installer for the Xcode compiler tools for MacOS.

On Linux:

  1. Open a Terminal window.
  2. At the prompt, run "gcc -v" to check if the compiler is installed.
  3. If the compiler isn't installed, first run "sudo apt-get update" to update your machine's list of available programs, and then run "sudo apt-get install build-essential gdb" to install the compiler/debugger you'll need.

The following content still needs to be updated for 2021. Proceed with extreme caution....

Important notes to supplement the directions from FIRST:

  • Depending on the parts being used on the robot, additional software components may be required and can be obtained from here. As of mid-February, it looks like you'll need to install at least:
    • the C++ API for the Spark controllers (can be done via "online install" process)
    • the C++ API for the Rev Robotics Color Sensor V3 (can be done via "online install" process)
    • the CTRE Phoenix Framework for the Victor SPX controllers (documented in Phase 2.1, below)

Not yet, but soon (this summer):

  • Password-based access to the repository will be shut down; we'll need to update this doc to include instructions on how to create "Personal Access Tokens" on GitHub, which are then used in place of a password with SVN tools. (Passwords will still work on the web site/wiki.)
⚠️ **GitHub.com Fallback** ⚠️