This guide will walk you through how to set up your computer to make code changes and push them to the RoboRio. You should make sure all of these instructions work before you spend a lot of time changing any code to know that your end-to-end testing loop with a robot will work.
TODO
- Git
Team100/all24
repo checked out.
TODO
- You might need to install Java manually to get autocomplete etc?
In VSCode, go to File > Open Folder
and select the swerve100
folder.
When you open the swerve100 project, VS Code should show a message in the bottom-right corner suggesting that you open the "workspace" instead, which includes lib:
When you have VS Code correctly set up, the Explorer view should contain two top-level folders: "swerve100" and "lib":
TODO.Use the WPI extensions to run the gradlew
build:
- Press
CTRL + SHIFT + P
to get the VSCode Command Mode. - Search for
Build Robot Code
- Select
swerve100
when it asks. - A terminal should pop up that runs the build. If successful, you will see this:
BUILD SUCCESSFUL in 2s`` 6 actionable tasks: 1 executed, 5 up-to-date Watched directory hierarchies: [C:\Users\Engineering Student\src\all24\comp\swerve100]
TODO: what if the build is not successful?
Use the WPI extensions to kick off the Simulator. Good overall instructions are available here.
- Press
CTRL + SHIFT + P
to get the VSCode Command Mode. - Search for
Simulate Robot Code
- Select
swerve100
when it asks. - It will ask you what simulations to run. Make sure
Sim GUI
is selected, and nothing else. - You should get the robot simulation GUI, which looks like this:
- Make sure you can debug your code in simulation.
- If you aren't familiar with debugging in VSCode, read this: TODO.
- Set a debug breakpoint on:
public void robotPeriodic()
- The simulation should trip your debugger since it calls this function every few ms. Then you are ready to go!
- Make sure you have the Field view available. This will allow you to "drive" the robot virtually. If you don't, go to
Network Tables > Field
.- If you don't see the Field view widget/option, make sure your Robot code is running flawlessly (and no breakpoints were hit).
- Learn more about using the Field widget here.
- Try to drive the Robot. You will need to setup your Keyboard as a Joystick if you haven't yet.
- Try to put the Robot in autonomous mode. This will cause it to execute known trajectories.
- First, let's get debugging working by increasing the Log Level.
- Click on
Autonomous
in theRobot State
widget. - The robot should start driving around, with these ugly trajectories drawn:
- Click the Hamburger Menu in the top-right of the field window, select Trajectory, and turn off the Arrows. You should get a nicer one like this:
Once you have your code compiling locally there is one more step before you start changing things: making sure you can deploy to a RoboRIO.
- Ask a mentor for a RoboRIO you can use and get their help to power it up. The green light should come on.
- Connect the RoboRIO to your laptop with a USB cable, like these photos:
- Click the "W" button (or go to the search) in VSCode and find
WPILIB: Deploy Robot Code
- Select
swerve100
and then watch the build happen in the terminal. You should getBUILD SUCCESSFUL
and the RioLog should pop up on the right after the build.
You are (hopefully!) getting a bunch of errors because we just deployed "production" code to a test RoboRIO, so it can't find motors, devices, etc. That's good! Move forward to the next step, controlling your first motor