Project Creation
Overview
Use the WPILib project wizard in VS Code to generate a Timed Robot or Command Robot project. Timed Robot uses periodic methods in Robot.java. Command Robot adds folders for commands and subsystems.
Prerequisites
Before creating a project, ensure you have:
• Visual Studio Code installed
• WPILib extension installed in VS Code
• Your FRC team number ready
• A location on your computer where you want to save the project
Creating a Timed Robot Project
Timed Robot fits simpler robots and early lessons. The template ships with a Robot.java file that already defines the lifecycle methods.
Timed Robot Video Tutorial
Watch this video for a complete walkthrough of creating a Timed Robot project:
Step 1: Open Command Palette
Open VS Code. Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac) to open the Command Palette. This is where you access WPILib commands.
Step 2: Start Project Creation
In the Command Palette, type “WPILib: Create a new project” and select it from the dropdown. The New Project Creator window will open.
Step 3: Select Project Type
In the New Project Creator window, choose Template as the project type. This gives you access to pre-configured project templates.
Step 4: Choose Programming Language
Select your preferred programming language. Choose Java or C++ based on your team’s preference. Most teams use Java.
Step 5: Select Timed Robot Base Class
Select TimedRobot as the base class. This template provides control through a collection of init() and periodic() methods that are called by WPILib during specific robot states.
Step 6: Configure Project Details
Enter the following information:
• Team Number: Enter your FRC team number
• Project Location: Choose the folder where you want to save the project
• Project Name: Enter a descriptive name (e.g., “MantikTimedRobot”)
Step 7: Generate the Project
Click Generate Project to create the new robot project. VS Code will generate all necessary files and folders. Once complete, the project will open automatically in VS Code.
Step 8: Understanding the Project Structure
After creation, your Timed Robot project will have this structure:
Timed Robot Project Files
src/main/java/frc/robot/Robot.java- Main robot class with lifecycle methodssrc/main/java/frc/robot/Main.java- Entry point that starts the robot programbuild.gradle- Build configuration and dependencieswpilib.json- WPILib project configuration.vscode/- VS Code settings and launch configurations
Step 9: Understanding Robot.java
Open Robot.java to see the template structure. The Timed Robot template includes these lifecycle methods:
Timed Robot Lifecycle Methods
robotInit()- Runs once when the robot startsrobotPeriodic()- Runs repeatedly (every 20ms) regardless of modeautonomousInit()- Runs once when autonomous mode startsautonomousPeriodic()- Runs repeatedly during autonomous (every 20ms)teleopInit()- Runs once when teleoperated mode startsteleopPeriodic()- Runs repeatedly during teleoperated mode (every 20ms)disabledInit()- Runs once when robot is disableddisabledPeriodic()- Runs repeatedly when robot is disabled (every 20ms)testInit()- Runs once when test mode startstestPeriodic()- Runs repeatedly during test mode (every 20ms)
Creating a Command Robot Project
Command Robot organizes code into subsystems and commands. It still extends TimedRobot, but most logic lives outside Robot.java.
Command Robot Video Tutorial
Watch this video for a complete walkthrough of creating a Command Robot project:
Step 1: Open Command Palette
Open VS Code. Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac) to open the Command Palette.
Step 2: Start Project Creation
In the Command Palette, type “WPILib: Create a new project” and select it from the dropdown. The New Project Creator window will open.
Step 3: Select Project Type
In the New Project Creator window, choose Template as the project type.
Step 4: Choose Programming Language
Select your preferred programming language. Choose Java or C++ based on your team’s preference.
Step 5: Select Command Robot Base Class
Select Command Robot as the base class. This template includes a command-based structure with subsystems and commands.
Step 6: Configure Project Details
Enter the following information:
• Team Number: Enter your FRC team number
• Project Location: Choose the folder where you want to save the project
• Project Name: Enter a descriptive name (e.g., “MantikCommandRobot”)
Step 7: Generate the Project
Click Generate Project to create the new robot project. VS Code will generate all necessary files and folders. Once complete, the project will open automatically in VS Code.
Step 8: Understanding the Project Structure
After creation, your Command Robot project will have this structure:
Command Robot Project Files
src/main/java/frc/robot/Robot.java- Main robot classsrc/main/java/frc/robot/Main.java- Entry point that starts the robot programsrc/main/java/frc/robot/commands/- Folder for command classessrc/main/java/frc/robot/subsystems/- Folder for subsystem classesbuild.gradle- Build configuration and dependencieswpilib.json- WPILib project configuration.vscode/- VS Code settings and launch configurations
Step 9: Understanding Command Robot Architecture
The Command Robot template uses a different architecture:
Command Robot Components
- Subsystems: Represent physical parts of the robot (drivetrain, intake, shooter, etc.). Each subsystem manages its own hardware.
- Commands: Represent actions the robot can perform (drive forward, collect game piece, shoot, etc.). Commands use subsystems to perform actions.
- Robot.java: Sets up subsystems, creates command bindings, and schedules commands based on robot state.
- Command Scheduler: Automatically runs scheduled commands and manages their lifecycle.
Choosing Between Templates
Use Timed Robot for a first project or a small mechanism count. Use Command Robot when several mechanisms must run at once or you want reusable commands.
Next Steps
Set your team number in wpilib.json, then add hardware configuration and mechanism code.