This template provides a partially completed WPILib Java project for a differential (tank-style) drive robot.
Programmers are expected to fill in the missing code to
-
Set up the Drive Subsystem
a. Set up motor controllers
b. Bind the motors to arcade drive controls
-
Set up an Arcade Drive command
-
Bind a command to a joystick controller
Finally, you should be able to simulate the robot movement on both a 2D field and a 3D field. The remainder of the document is a guide to how to get your simulation running.
Once you’ve filled in the required code, you can run the robot in simulation using the WPILib extension:
- Open the Command Palette in VS Code:
Ctrl+Shift+P(Windows) /Cmd+Shift+P(Mac). - Select
WPILib: Simulate Robot Code. - Choose the option: Sim GUI.
AdvantageScope is used to visualize and interact with the simulated robot.
- Launch AdvantageScope.
- Go to File > Connect to Simulator — this connects to the simulation running from WPILib.
- In AS, switch to the "Odometry" tab at the top.
- In the left sidebar, locate the data key named
MyPose. - Drag
MyPoseinto the “Poses” section at the bottom — the robot should now appear on the 2D field.
To control the robot simulation:
- In AS, open the "Robot Simulation" window (usually on the right or bottom).
- Under Joysticks, find the
Joysticks[0]slot. - Drag Keyboard 0 into
Joysticks[0](unless you have a physical controller connected).Joysticks[0],[1], etc., represent the slots used in your robot code (e.g.,new Joystick(0)).- Binding
Keyboard 0simulates a gamepad using your keyboard.
- Under Robot State, click “Teleoperated” to enable the robot.
W= Drive ForwardS= Drive BackwardA= Rotate Counter-Clockwise (left)D= Rotate Clockwise (right)
To simulate the robot in a 3D environment:
- In AdvantageScope, switch to the "3D Field" UI (select from the top tab bar).
- Click on the field model selector, and choose "Kitbot 2025".
- Your simulated robot should now appear and move around on a 3D model of the FRC field!