Skip to content

Latest commit

 

History

History
89 lines (73 loc) · 5.04 KB

README_1_STARTING.md

File metadata and controls

89 lines (73 loc) · 5.04 KB

Setting up a VSCode Development Environment

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.

Get Set Up With Git

TODO

  1. Git Team100/all24 repo checked out.

Get VSCode + WPILib Set Up

TODO

  1. You might need to install Java manually to get autocomplete etc?

Getting VSCode Workspace Working

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.

Building the RoboRIO Code

Use the WPI extensions to run the gradlew build:

  1. Press CTRL + SHIFT + P to get the VSCode Command Mode.
  2. Search for Build Robot Code
  3. Select swerve100 when it asks.
  4. 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?

Simulating the RoboRIO

Use the WPI extensions to kick off the Simulator. Good overall instructions are available here.

  1. Press CTRL + SHIFT + P to get the VSCode Command Mode.
  2. Search for Simulate Robot Code
  3. Select swerve100 when it asks.
  4. It will ask you what simulations to run. Make sure Sim GUI is selected, and nothing else.
  5. You should get the robot simulation GUI, which looks like this: Simulation GUI
  6. Make sure you can debug your code in simulation.
    1. If you aren't familiar with debugging in VSCode, read this: TODO.
    2. Set a debug breakpoint on:
      public void robotPeriodic() 
    3. The simulation should trip your debugger since it calls this function every few ms. Then you are ready to go!

Using the Simulator

  1. 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 Field View.
    1. If you don't see the Field view widget/option, make sure your Robot code is running flawlessly (and no breakpoints were hit).
    2. Learn more about using the Field widget here.
  2. Try to drive the Robot. You will need to setup your Keyboard as a Joystick if you haven't yet.
    1. Click and drag Keyboard 0 to Joystick[0] like this: Drag Keyboard.
    2. Select Teleoperated from the Robot State widget.
    3. You should be able to use the A-W-S-D keys to move in 2 dimensions (Axis 0 and Axis 1).
    4. You should be able to use the E-R keys to rotate the robot (Axis 2).
  3. Try to put the Robot in autonomous mode. This will cause it to execute known trajectories.
    1. First, let's get debugging working by increasing the Log Level.
      1. Go to Network Tables > SmartDashboard > Log Level. Alt text
      2. Select TRACE level, which should be the maximum
    2. Click on Autonomous in the Robot State widget.
    3. The robot should start driving around, with these ugly trajectories drawn: Alt text
    4. 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: Alt text

Deploying to the RoboRIO

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.

  1. Ask a mentor for a RoboRIO you can use and get their help to power it up. The green light should come on.
  2. Connect the RoboRIO to your laptop with a USB cable, like these photos:
  3. Click the "W" button (or go to the search) in VSCode and find WPILIB: Deploy Robot Code
    1. deploy
  4. Select swerve100 and then watch the build happen in the terminal. You should get BUILD SUCCESSFUL and the RioLog should pop up on the right after the build.
    1. rio_log

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