From 1511Wookiee
Revision as of 11:30, 30 June 2022 by Heydowns (talk | contribs) (→‎Initial Setup: Checking Out)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Programming Sub-pages and Links

FRC and WPILib References

Quite Useful Things to Remember

Camera Server Port is 1181

Color sensor proximity reading ranges from 0-2048, the higher the value the closer the surface. A reading of ~300 or greater is enough for a reliable color read

Using SVN

SVN works, in essence, by tracking changes made to the robot code. A "master" copy is kept on the server, and you work off a local copy that you have "checked out" from the server. You make changes, add new features, etc. then you send the changes back to the server (commit).

All team laptops have an SVN client already installed called Tortoise SVN. This works using context (right-click) menus in Windows Explorer. Tortoise SVN has an in-depth guide on how to use it here, but the following sections are short versions of how to use it for programming on the team.

Initial Setup: Checking Out

To get the initial copy of the robot code for this year on to the laptop you are working on, you will "check out" the project from the SVN server:

  1. Open Windows Explorer on your laptop
  2. Browse to a location on the computer to keep your working code - the desktop, the Documents folder, or a the top level of the C drive are all good locations. You may wish to make a folder with your name on it to make it clear to other users of that laptop that this is your working copy!
  3. In the Explorer window, right-click to open the context menu
  4. Choose "SVN Checkout...." from the menu
  5. In the new window that opens, you need to enter this year's SVN URL (look for that on the 2022 build season programming page!) into the box labelled URL of repository. Keep all other options on this screen as-is and hit "OK"
  6. You will be prompted for username and password. Enter your SVN username and password, then hit OK. Because the laptops are shared, you should make sure that "Save Authentication" is unchecked!
  7. You should now have a new folder named "thunderbotYEAR'". This is your new working copy of the robot code and is the folder you will open up in VSCode.

Updating Your Local Copy

"Updating" will fetch changes made by other people on the team from the server and merge them into your local working copy of the code. You should try to do this at the start of a meeting/work session or whenever you need to pick up the work done by others so your local copy does not fall too far out of sync with the "master" copy on the server. You also need to do this before you can send your changes to the server (commit).

This process does not delete or overwrite any local changes you have made!

  1. Open Windows Explorer and browse to the folder where your local working copy is on the laptop.
  2. Right-click the top-level (thunderbotYYYY) folder
  3. Choose "SVN Update" from the menu
  4. Enter your username/password for SVN (make sure that "Save Authentication" is unchecked!)
  5. If all goes well, you will have an updated local copy with all changes made by others. If someone else was working on the same file(s) as you have local changes, it is possible you will get what is known as a "conflict". This will need to be resolved before you proceed with any additional changes or committing.

Resolving Conflicts

Sometimes when you update there will be changes others have done that "conflict" with changes you have made or new stuff you have done locally and your update will result in conflicts.

  1. The conflicted files will be marked in Windows Explorer with special icons and also listed in the output of your Update. They will also likely cause VSCode "build" to fail.
  2. Open the conflicted source code files in VSCode and "resolve" the conflicts. The areas with conflicts will be marked directly in the file and look something like this:
    <<<<<<< .mine
    int x = 0;
    if (y > 10)
    x += 1511;
    int x = 1;
    if (y < 0)
    x -= 1511;
    >>>>>>> .r7
  3. You can see here that you have two versions of code, separated by special markers. Your version of the changes is between <<<<< and ==== and marked "mine". The changes someone else made to that same area of the code are between ==== and >>>>> and marked with the SVN revision they were made.
  4. You will need edit the file to "resolve" the conflict; edit the code to be what the end result should be -- this could be deleting the other person's changes entirely, abandoning/deleting your changes and leaving the other person's changes in place, or some combination of the two. Once it looks as it should, remove the special marking lines.
  5. Repeat that process for all "conflicted" sections of the file and for any other "conflicted" files.
  6. Once you have fixed the conflicts, you need to tell SVN you have done so. Open Windows Explorer to your project folder and browse down to the location of the conflicted file(s) in the project. Select the conflicted file(s), right click, choose Tortoise SVN, then choose "Resolve".

Committing Your Changes to the Server

Once you have completed a good amount of new code, you will want to "commit" it to send it to the server and so that others can access your changes.

  1. Verify your code builds properly (use the normal VSCode build process)
  2. Have a programming mentor review your changes!
  3. Open Windows Explorer and browse to your project location. Right-click your changed file(s) or the top-level project directory (thunderbotYYYY) and choose "SVN Commit" from the menu.
  4. Enter a brief description of what you are changing! Examples: "initial new code to control shooter", "fixed motor spin direction on intake", etc.
  5. Hit OK
  6. Enter your username/password for SVN (make sure that "Save Authentication" is unchecked!)

Preseason Software Installation

Here are instruction and download links if you want to install the software to your own computer:

    1. Install WPILib - Instructions and Download Link
    2. Install CTRE Phoenix Libraries Download Link
    3. If you are just doing programming you can skip this step! This step is only needed if you want the Driver Station Software: install FRC Game Tools using these instructions.

Programming Preseason


  • Lesson 1: Make a motor run
  • Lesson 2: Control motor direction using a gamepad
  • Lesson 3: Using Digital sensors to limit range of motion
  • Lesson 4: Controlling motor output speed
  • Lesson 5: Control motor based on an encoder