Skip to content

OHS-Robotics/SpartobotsAcademy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SpartobotsAcademy

This respository contains resources for learning programming, geared towards programming a FRC robot.

Read below for more information, instructions on how to play with these lessons on your own PC, setting up your PC to be able to develop Java code, and more

Table of Contents

Your Programming Environment

Unfortunately, there are a few necessary steps that you need to take before you can actually run any code. It's sort of just a fact of life when it comes to programming. However, following the guides below should be able to get you up and running with zero prior knowledge required.

Specifically, the following things are required:

  • An installation of the JDK
    • Specifically, we use version 17, as that is what WPILib has been built on since 2023
  • An installation of Visual Studio Code
    • Can either be Vanilla VS Code or the WPILib flavor, as discussed below

And the following things are technically optional but recommended:

  • A Github Account that is a member of the Spartobots github organization
  • Github Desktop installed on your PC

Important notes about Java and programming in general

  • Setting up your programming environment so that you can actually run some code can be one of the most frustrating steps to learning programming.
    • With this readme guide, and with these lessons, we aim to give a very functional knowledge to get you writing and understanding robot code quickly
    • We may not explain all the nuances of how exactly the entire environment works together, but with the following instructions, you should be able to get your computer set up to be able to use the lessons in this repository and hit the ground running.
  • You may see a lot of what look like just "extra" files in the lesson folders. Don't worry too much about them
    • Some of these files may have been auto-generated by build system and may indeed by unnecessary for our purposes, but we've decided to just leave them there so that if you were to generate your own project, it would look very similar to what you see in these lessons
  • Some of these lessons are designed to run only locally on your own machine, and some are designed to run only remotely on the robo rio of a robot.
    • The earlier lessons which teach more general programming concepts, which aren't specific to an FRC robot, are designed so that you can run them locally, so that you can edit them and re run them very quickly.
    • The later lessons that deal with programming on a robo rio specifically, you will not be able to run locally on your machine
      • The exception to this is that you can run most robot code in a simulator that is packaged with WPIlib. If you're interested in this, see the WPIlib documentation about it here
    • Although a project that is set up to be run locally may not be able to run on the robo rio will not be able to be downloaded to a robo rio, fundamentally, the Java code within that project is still code that you could put within a robo rio project. It is simply the build system that is included in that project that changes where and how you are able to deploy that code (e.g. you can still write your own classes, functions, loops, etc. in a robo rio project, the same as in a regular java project. It's just the "supporting" files included in each lesson/project that determine on what type of computer they are designed to be run (robo rio vs. a windows PC))

Notes on setting up your environment for FRC Development

  • All java programming (which is the language team 4687 chooses to use) is done within a text editor/Integrated Development Environment (IDE) called Visual Studio Code (VS Code).
    • For FRC specifically, we install an instance of VS Code that stands by itself (doesn't overwrite or interfere with any other instances of VS Code already installed on the computer, including other instances from past FRC seasons)
    • This is simply a regular VS Code installation that has been pre-packaged and pre-configured with a bunch of useful tools for developing FRC code.
      • Things like making it easy to install code packages that let you work with common FRC components like Spark Max's and the Laser Distance Sensor, and tools that allow you to download your code to the roborio with one or two clicks
  • Choose whether you'd like to install just standard, "vanilla" VS Code, or the current FRC Season's version of VS Code
    • If you do not plan to actually develop any robot code and only wish to learn some java, you can simply go here to download VS Code.
      • This would be the quickest and easiest way to get started with these lessons
      • If you choose to do this and later decide that you would like to write code for a robot, that's ok. You can always go install any version of WPIlib VS Code and it will not interfere with any other instance of VS Code you already have installed
    • However if you plan to write code that you can download to a robo rio, or even if you think you might, we would recommend that you download and install the latest FRC Season's WPILib VS Code (steps found here)
      • This will take more time (an hour or so depending on your internet speed)
      • This will involve the installation of more tools than just VS Code (it will include the driver station, which you use to control the robot during a match or testing, and other FRC-Specific applications)

Now for the actual installation

Installing the JDK (Required)

In order to develop and run java code, you must have the Java Developer Kit (JDK) installed on your computer.

  1. Follow this link to download the JDK installer
  2. Run the installer and complete the installation, leaving all options as default
  3. That's it!

Installing Github Desktop (Technically Optional, but strongly recommended)

In order to download and run the lessons from this repository (and to be able to contribute to any code for the team in the future) you will want to install Github Desktop

  1. If you don't already have a github account, go to github.com and create an account
  2. (Not required to proceed but necessary to contribute to the team's code) Ask Zack (Or whoever the current owner of the repo is) to invite you to the Spartobots github organization
  3. All of our repositories are public, so even if you're not part of the organization, you can still view and clone (make a local copy of) the team's repositories
  4. Go to this link and download the latest version of Github Desktop
  5. Run the installer and complete the installation, leaving all fields as default
  6. Once you get to a page that says "Let's get started!" the installation is complete

For more information on how to actually use github to download and upload code, see the corresponding lesson in this repository

Installing Vanilla VS Code (Either this or WPILib VS Code is required)

  1. Go to this link and download the latest version of VS Code
  2. Run the installer that is downloaded
  3. Select all default options and complete the installation
  4. Launch VSC
  5. On the left hand side, click on the icon that looks like 4 little blocks
  6. Search for "java" and install the following extensions:
  7. "Java" (by Oracle Corporation)
  8. "Extension Pack for Java" (by Microsoft) (This will download a few extensions for you)
  9. Your installation of VSC should now be complete and ready to run code

Installing WPILib VS Code (Either this or the vanilla VS Code is required)

  1. This installation can take a little while (an hour or so) so be prepared
  2. Go to this link to find WPILib's instructions for setting up your development environment for FRC
  3. The guide found there will be better than whatever I could write here, so I will just leave it up to them
  4. You will have some choices as to what to download though, so here is exactly what you will need to know:
  5. We are a Java team
  6. You will need the FRC Game Tools
  7. You will need WPILib
  8. You will not need any python tools or the tools specifically for labview teams

How to download and use these lessons

There are two main ways you could download the lessons from this repository and run them

1. Cloning the Repository (Recommended)

Cloning a repository simply means making a local copy of it on your own machine. Here's how to clone this repository

  1. Go to this repository's github page (You're probably already here)
  2. Find the (probably green) button that says "Code"
  3. Click on it and select "Open with Github Desktop"
  4. It should open up the github desktop application (if you have it installed. If not, see above) with a clone repository dialog
  5. Select the folder on your computer into which you would like to clone the repo
  6. Once the repo has been cloned, you can check that folder and see that all of the repo's files have now been placed there

For more information on using github, see the corresponding lesson repo

2. Downloading the code as a zip file manually

If for some reason you don't want to install and use github to download the code (maybe you just are checking something out quick), follow these steps

  1. Go to this repository's github page (You're probably already here)
  2. Find the (probably green) button that says "Code"
  3. Click on it and select "Download Zip". A Zip file containing the entire repo will be downloaded
  4. Extract the zip file.
  5. See the section below on opening one of the lessons for instructions on how to do that

Opening one of this repository's lessons in VS Code

This repository's Lessons folder contains a bunch of sub folders, each of which is a separate lesson which are designed to be opened as a folder in VS Code.

As mentioned above, some lessons are designed to be run locally on your machine. These can be run in any version of VS Code (although if you have never run them before and have the WPILib version of VS Code, you may need to install the extensions mentioned in the VS Code Vanilla Installation instructions above). Others are designed to be run on the robo rio. These can be opened in any version of VS Code, but you will not be able to deploy the code to the rio without opening them in WPILib

  1. Open VS Code (or WPILib)
  2. If you alrady have some code or a folder open, close all of them for the purposes of these instructions (from the File menu)
  3. Go to File -> Open Folder
  4. Navigate to the lesson that you would like to open, and select the top-level folder for that lesson
  5. Click Select Folder
  6. With that folder now open, in the explorer on the left, navigate to app -> src -> main -> java -> App.java (or Main.java if it's a robo rio project)
  7. To run the code, either go to Run -> Start Debugging or press F5
  8. A window at the top of the screen may open. If it does, select "Java"
  9. The app should now compile, and a terminal should appear at the bottom of VS Code that shows some initialization and then perhaps some text like "Hello World!" (or whatever text the code is supposed to print)
  10. If this is your first time compiling and running a java project, it may take a bit for the java workspace to initialize. Just be patient and keep an eye on the status indicators on the bottom of the screen
  11. Also keep any eye out for any popups in the bottom right of VS Code that could let you know if you don't have some necessary extension or piece of software installed

Creating your own projects

If you want to start your own fresh project to be able to start from scratch yourself, that's great! Here's how you can do that, depending on whether you want a simple java project to run on your own machine, or a WPILib project you could deploy to a robo rio

Simple Java Project

  1. Open VS Code
  2. Press Ctrl+Shift+P to open the command pallette
  3. Start typing "java" and select "Java: Create Java Project..."
  4. Select Gradle for build tools
  5. Select the folder in which you would like to create the project
  6. Select "Groovy" for your DSL
  7. Press enter to accept the project name, or enter a new one
  8. After a little bit, you should see a popup in the bottom right of VS Code saying your project has been created. Go ahead and click "Open" to open it
  9. You can also manually open the project at a later time by going to File -> Open Folder and opening the folder in which you created the project

WPILib Project

  1. Open WPILib VS Code (required--cannot use vanilla VS Code for this)
  2. Press Ctrl+Shift+P to open the command pallette
  3. Start typing "WPILib" and select "WPILib: Create a new project"
  4. Press the button to select a project type
  5. Select Template
  6. Select Java
  7. Select Command Robot
  8. Click "Select a new project folder" and navigate to and select the folder you'd like to place this project in
  9. Give the project a name
  10. Decide whether you want to create a new folder with the name you just gave or just place all the project files directly in the folder you alread selected
  11. Enter your team number (4687)
  12. Check enable desktop support (this allows the code to be run in the simulator)
  13. Click Generate Project
  14. A dialog should pop up asking if you'd like to open your newly created project. Click one of the "yes" options
  15. The source code for your robot can then be found in src -> java. The program starts execution in the function "Main" in the class "Main.java", but most of the code you write, when you are learning, will likely go within Robot.java. If you know enough to put your code elsewhere, then go right ahead!
  16. You can deploy your code to a robo rio by connecting to it (either connecting to it's wifi network, a USB Cable, or an Ethernet Cable), then doing one of the following:
  17. Pressing Ctrl+Shift+P then typing WPILib and selecting "WPILib: Deploy Robot Code"
  18. Clicking the WPILib logo in the top right of VS Code and "WPILib: Deploy Robot Code"
  19. Pressing Shift+F5
  20. If your code doesn't have any errors and you're connected to the robo rio, you should see an output in the terminal window that slowly progresses then tells you it was successful
  21. In order to actually control the robot, you must open the driver's station application separately, connect a controller, and switch the mode to Teleoperated and Enabled

About

Resources for learning programming, geared towards programming a FRC robot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages