Example Projects - captainsoccer/BasicMotor GitHub Wiki
Using the Example Projects
The BasicMotor library includes ready-to-run example projects to help you get started quickly.
These projects show how to implement common robot mechanisms using BasicMotor, and can be adapted to your own robot by changing a few settings.
Currently available examples:
swerve_example
– Basic swerve drive setup using BasicMotor.tank_example
– Tank drive control using BasicMotor.flywheel_example
– Simple flywheel shooter example with configurable speed control.
1. Downloading the Examples
Each example project is available as its own downloadable zip file in the Releases page.
- Go to the Releases page.
- Find the example you want:
swerve_example.zip
tank_example.zip
flywheel_example.zip
- Download the desired zip file.
- Extract the zip file to a convenient location on your computer — you will now have a ready-to-import WPILib project folder.
2. Importing into WPILib VS Code
Each example is a full WPILib project. To open one:
- Launch WPILib VS Code.
- Go to File → Open Folder.
- Navigate to the folder you extracted from the zip file.
- Select the example project folder.
- Wait for WPILib to build and index the project.
3. Setting Your Team Number
Before using an example with your robot, update the team number:
- Open WPILib VS Code.
- Press
Ctrl + Shift + P
(Windows/Linux) orCmd + Shift + P
(Mac) to open the Command Palette. - Search for
WPILib: Set Team Number
. - Enter your FRC team number.
- WPILib will update the project to match your team.
4. Changing the Constants
Each example includes a constants file for setting CAN IDs, gear ratios, PID gains, speed limits, and other configuration values.
Locate the corresponding constants file for the example you are using and update:
- CAN IDs to match your wiring
- Gear ratios
- PID gains for tuning
- Inversions if motors spin in the wrong direction
- Sensor settings if using encoders or other feedback devices
5. Example-Specific Details
flywheel_example
- Default hardware: Uses a TalonFX motor.
- Where to change motor type:
FlywheelIOBasic.java
- Where constants are stored:
FlywheelConstants.java
tank_example
- Default hardware: Uses SparkMAX motors.
- Where to change motor type:
TankIOBasic.java
- Where constants and motor config are stored:
TankConstants.java
swerve_example
- Default hardware:
- Drive motor: TalonFX
- Steer motor: SparkMAX
- Absolute encoder: CANcoder
- Where to change motor types:
SwerveModuleIOBasic.java
- Where constants are stored:
DriveTrainConstants.java
(overall drivetrain settings)SwerveModuleConstants.java
(per-module settings)