Programming Quick Start

Getting Eclipse and WPILib
Check out the WPILib Screensteps for your year (this website has the 2016 directions) to learn how to download and correctly configure the Eclipse development environment.

If Eclipse is already installed, skip that part of the tutorial and move on to the WPILib installation section.

Integrating JSON.Simple (and Other External Libraries)

 * 1) Grab the .zip archive from here and extract it to some directory (make sure to remember where!).
 * 2) In Eclipse, on the top toolbar, go to Window -> Preferences. Next, expand the Java section, and then the Build Path section. Finally, choose User Libraries.
 * 3) Press New to create a new library. Call it "JSON.simple" (without the quotes. Actually, any name works, but make it memorable). Press Okay.
 * 4) Make sure that the library you just created is highlighted. Press Add External JARS, navigate to the JSON jar, and press Okay. The library is now set up. We just have to add it to your project now.
 * 5) Exit out of the prefences window. At the top of the Eclipse window, go to Project -> Properties.
 * 6) Choose Java Build Path in the sidebar.
 * 7) On the right hand side of the window, choose Add Library. Pick the library which your just created, and press Okay.
 * 8) Exit out of the properties window, and your project should now be completely able to handle JSON.

Setting up EGit (Git Integration)

 * 1) Open Eclipse and, at the top, navigate to Help -> Install New Software.
 * 2) Type "http://download.eclipse.org/egit/updates" into the dialog box. Press Add and wait.
 * 3) Select all of the checkboxes and press Next a bunch of times.
 * 4) Restart Eclipse, and EGit should be up and running.

Compilation
To compile the code, make sure you are connected to the robot. Then just press the green arrow and choose WPILib Java Deploy. The code should then push to the robot. See build.properties and build.xml to see more about the compilation process.

Starting a Project -- Singularity Style
WPILib has their own tutorials for starting basic robot projects, but this is how we do it here on the Saline Singularity.

Creating the Project
* NOTE: In future years it might make sense to switch to a Command-Based Robot, but in 2016 we still used the Iterative Robot scheme.
 * 1) In Eclipse, navigate to File -> New -> Other
 * 2) Under WPILib Java Robot Development, select "Robot Java Project" and then click Next.
 * 3) Name the new project (our naming convention is "FRC[year]") and choose the Iterative Robot* radio button. Then click Finish.

Adding the Singularity Libraries
Our team has been developing our own libraries to extend WPILib's functionality since the 2015 season. The libraries streamline the robot coding process by providing many classes and methods that are useful to our team every year, such as the SingularityDrive class that extends the basic RobotDrive class. The libraries are developed each year at the same time as the robot code, with the distinction between the two being that the robot code is for code unique to that year's game and the libraries are for code that is applicable to future years' games as well.

Adding the Project to Git and GitHub

 * 1) First we must create the repository on GitHub. Go to the SalineSingularityFRC GitHub page and create click the "New Repository" button. Name it "FRC[year]", add a description, and make it private if possible. Then click "Create Repository"
 * 2) Copy the URI (the link under "Quick setup") to your clipboard. Leave the window open in case you need to copy it again later.
 * 3) Create an empty folder on your PC for the local repository (probably in the git folder)
 * 4) Right-click on the project in Eclipse and navigate to Team -> Share Project...
 * 5) Press the "Create..." button, then navigate to the folder you created, then click "Finish"
 * 6) Click "Finish" on this menu
 * 7) Now it's time for the initial commit. Right click on the project in Eclipse and navigate to Team -> Commit. Type "initial commit" into the commit message, and then click "Commit and Push"
 * 8) A window will appear and prompt you to configure a remote repository. The remote repository will be set up through GitHub. Paste the URI from step 2 in the "URI" prompt in the "Location" box. Sign in with your GitHub ID* in the "Authentification" box. Then click "Next >"
 * 9) Finally, click "Next >" and then "Finish."

* The account must have the correct privileges on the Saline Singularity GitHub)

Importing the Project on Another Computer (from Github)

 * 1) Navigate to File -> Import
 * 2) In the folder Git, choose Projects from Git and click "Next"
 * 3) Choose Clone URI and click "Next"
 * 4) Enter your GitHub credentials under "Authentfication" and copy-paste the URI from GitHub into the URI box. Then hit "Finish"

Running Code
For more about the build process, refer to Build.properties and build.xml.
 * 1) Make sure you are connected to the robot's wifi network.
 * 2) Click the green "run" button in Eclipse and select WPILib Java Deploy. Alternatively, right-click in the Robot.java file and select Run As -> WPILib Java Deploy
 * 3) Wait for the build-and-push process* to (hopefully) complete. You'll know it is complete when the console displays "BUILD SUCCESSFUL". If the console displays "BUILD FAILED," refer to BUILD FAILED.
 * 4) The code will run automatically on the robot once it is pushed. On the driver dashboard, you should see a green light next to "Robot code". If not, restart the robot. (If that doesn't solve the problem, refer to the Errors database on this wiki).
 * 5) Select teleop, automomouns, test, or practice mode in Driver Station, then click the green "Enable" button!