All our programming this year will be done through Java and VSCode. Additionally, we will be using Github and Git for version control. We will also be using some tools from other teams like AdvantageScope and Pathplanner.
- Download WPILib:
- Click on the link above and scroll to the bottom of the page
- Click on the file that has your operating system on it (Choose Windows32 for Windows users)
- Windows:
- Open your downloads folder
- Right-click the WPILib-Windows32 file
- Click on "Mount"
- Click on "This PC" in the left column
- Look for DVD Drive WPILib-Windows32 and double-click on it
- MacOS
- Go to downloads
- Double-click on installed file
- Windows:
- Double-click on WPILibInstaller
- Click on "Start"
- Select "Everything" and click "Install for this User"
- Click on "Download for this computer only"
- Click on Finish once it is complete
- If you are using a Mac follow the instructions below
- Drag VSCode Application from the folder that opened to your dock
- Then open it and follow this guide to finish setting up your VSCode
- If you are using a Mac follow the instructions below
- Download AdvantageScope:
- Click on the download for your operating system
- Windows
- Drag the file to your desktop
- MacOS
- Double-click on the file in your downloads
- Windows
- Once you have it successfully downloaded, open it
- Then open the Preferences Page and set
roboRIO address
to10.31.81.2
- Click on the download for your operating system
- Download PathPlanner:
- You can find PathPlanner on the Windows and Mac App Store, but it is also available on Github for direct download.
- Download Git:
- Follow this guide
- Make Folder:
- You will probably want to store all the programming files in a folder
- Navigate to your desktop and create a folder called "FRC"
- Sign up for GitHub:
NOTE: You can use your school email, but I highly recommend you use a personal one, as your GitHub can be used later on for college and even work.
- Click on this link to signup
Firstly, you have to bookmark this page. That page is a how-to guide for basically most things you will be confused about, while their explanations can be confusing, it is still very helpful.
Next, I highly recommend that everyone reads/skims through these pages, as it'll make the code make a lot more sense logically.
We are using 6328's AdvantageKit for logging. You can read this page for more details or you can just read the summary below.
AdvantageKit follows the rule of logging all inputs. This means that all interactions with hardware (motors, sensors, etc.) should be logged. This is done through 4 main layers:
- IO Layer
- This layer consists of all communication with motor controllers and sensors, which allows for everything to be replayed later on.
- This also has the advantage of allowing for different types of hardware and simulations to be easily swapped in.
- Control Layer
- This layer exists inside the subsystem, using the IO layer to control motors and read sensors. This layer should contain most of the processing of data and decision-making.
- This means that updated control logic can be changed and replayed with the same inputs for debugging.
- Public Interface
- These methods are used in subsystems for the rest of the robot code to interact with the subsystem.
- User Outputs:
- This layer allows for the user to log any extra data they want.
With your basic understanding of how the code functions now, your goal is to make some functioning auto paths. This will likely be very confusing, so don't be afraid to look things up.
- Fork this repository by clicking the button in the top right that says
Fork
- Clone this repository
- MacOS
- Press
CMD
+Space
and type inTerminal
then press enter - Type
cd Desktop/FRC
- Press
- Windows
- Search for
Git Bash
and open it - Type in
cd c:/Users/YOUR_USERNAME/Desktop/FRC
- Search for
- MacOS
- Go back to your fork on GitHub and click on the green
Code
button - Click on HTTPS and then copy the text in the box
- Type
git clone (paste what you copied)
There are 4 major steps in getting your code to work.
- Create methods in the Drive subsystem
- The method shells have been left in the class, all you have to do is figure out what to put in the methods
- Create commands, you will need these 2
- DriveResetPose - resets the robot pose and encoders
- DriveZero - drive at 0 volts
- Create paths (this is detailed in section below)
- Setup your auto in RobotContainer
- First Launch
- Open PathPlanner
- Click on
Open Robot Project
- Choose directory of
Programming Training
(Should be on your desktop in FRC folder)
- Future Launches
- Click on the
≡
button - Make sure the top left says ProgrammingTraining
- If it doesn't click
Switch Project
and choose your project directory
- Click on the
- Creating Paths
NOTE: Path are created in meters, make sure to do your unit conversions!
- Basic controls
- These paths will automatically be imported in to your robot code
- Using Paths
- Using Original Class:
- Using Wrapper Class:
- This class only requires
name
+reversed
variable, as it gets maxVel and maxAccel from the Constants file - Example:
Trajectory PATH = PathPlannerHelper.loadPath("5BallAuto", false);
- This class only requires
- Press the WPILib button in the top right of VSCode
- Type and select
Simulate Robot Code
- If your code builds, select
Sim GUI
and press Ok - You will now need to open AdvantageScope
- Click on
File
in the top left and selectConnect to Simulator
- You should see a red dot appear in the top right which indicates that you are connected to the simulator live
- Click on the Odometry tab and drag
/RealOutputs/Drive/Pose
toRobot
underPose Data
- Go back to the Simulator GUI and add your Auto Command Chooser to the GUI
- Then select your which auto to run from the
Auto Command
- Lastly you can select change the RobotState to
Autonomous
- You can now go back to AdvantageScope and view your auto run
If you have finished everything above and have a working simulated auto, you can attempt to make a DriveIOSparkMax
layer so that your auto can be run on the actual robot. All the constants you need are located in the Constants file.
As the final piece of training we will do, we are going to have competition based on who can complete the path below the fastest.