Step 4: Write and Drive¶
04
Write and Drive
Step 4 of 4
Deploy a drivetrain program to Systemcore, test the controller and drive motors, and verify that disabling the robot stops the motors.
Use the programming environment and language you set up in Step 2. Start with the example for your hardware and test with the drive wheels off the floor.
Note
FRC KitBot example code will be available after the 2027 kickoff.
Step 3 is complete
Driver Station communication is green
Your controller is connected to the driver computer
The drivetrain is securely supported with every wheel off the floor
People, tools, hair, and loose clothing are clear of moving parts
Someone is ready to turn off robot power
Part 1: Choose Your Walkthrough
The detailed FRC VS Code walkthrough covers project creation through the first drive test. Blocks has a project-creation guide; its deployment walkthrough and the OnBot, LabVIEW, and FTC walkthroughs are still being completed. Use the path that matches your programming environment and hardware.
Create a project, configure the motor controllers, and deploy using the full drivetrain walkthrough. C++ uses desktop development only.
Start with a drivetrain sample in the Blocks editor. Choose the sample for your hardware, make an editable copy, and check its configuration. More drivetrain examples for Blocks are coming soon.
Open the editor hosted by Systemcore. The detailed project-creation and deployment walkthroughs are still being completed.
Use the LabVIEW environment you selected in Step 2. The Systemcore project-creation and deployment walkthroughs for both environments are still being completed.
Part 2: Create and Configure Your Project
Start with a working drivetrain example, then match it to your robot’s motor controllers and wiring.
Open WPILib VS Code and open the WPILib command palette. Select Create a new project.
Choose Example, then Next. Select your language and the Getting Started project base.
Choose a project folder and name, and enter the team number shown on Systemcore. Leave desktop support unchecked for this example, as described in the full walkthrough.
Review the settings, select Create Project, then open the new project in VS Code. For C++, accept the prompt to refresh C++ configurations.
Expected result: the project appears in the file explorer and you can open its Robot source file. The Getting Started example provides the robot program structure and drivetrain code.
Create a folder for your robot project and open it in VS Code.
Open a terminal in that folder. On Windows, run
py -3 -m robotpy init. On macOS or Linux, runpython3 -m robotpy init.Open the generated
robot.py. Use the complete Python drivetrain example in the walkthrough to fill in the Robot class and configure the hardware.
Expected result: the folder contains robot.py and
pyproject.toml. The first contains your robot code; the second
lists its Python dependencies.
The full drivetrain walkthrough includes screenshots, complete code, and motor-controller-specific configurations. Use its complete example when adapting the project to your hardware.
For Blocks, follow Starting a Drivetrain Project in Blocks to make an editable copy of a drivetrain sample. Check the sample’s hardware before using it.
For OnBot or LabVIEW, use the environment you selected in Step 2. The Systemcore project-creation instructions are still being completed; the VS Code walkthrough does not describe these editors.
Before deploying any drivetrain project:
Set the project team number to match Systemcore.
Check each motor controller’s type and port or CAN ID against the wiring.
Check which controller axes the example uses to drive and turn.
Add the vendor libraries required by the motor controllers in your example.
Install and update the vendor libraries used by a VS Code project. Add dependencies each time you create or import a project.
Note
Using an A301 with Motioncore? Keep its firmware and REVLib versions
compatible, and identify the Motioncore channel with CANBusMap rather
than a raw integer. Motioncore channel D0 is not the same bus as Systemcore
bus 0. See the current A301 testing guide
for the required version pair and channel examples.
Understand How the Robot Drives
Open the Robot class and trace the path from controller input to motor output:
The program creates the motor-controller objects, a
Gamepadon port 0, and aDifferentialDriveonce when the robot starts. The motor objects identify the PWM ports or CAN IDs connected to your drivetrain.During teleop,
teleopPeriodic(TeleopPeriodicin C++) reads the controller axes repeatedly. One input requests forward or backward motion; the other requests a turn.DifferentialDrivecombines those inputs into left and right motor outputs. The motor-controller objects send the outputs to the hardware.
Find the motor ports or CAN IDs in your example and compare them with the wiring. The PWM example uses ports 0 and 1; the vendor examples use CAN IDs 1 and 2. Keep the objects outside the periodic method so they are not recreated on every iteration.
Follow the example’s motor-inversion setup so both drivetrain sides move the robot in the same direction for a forward request. You will check that direction with the wheels off the floor during the first drive test.
Expected result: you can identify the controller input, the left and right motor assignments, and the drive call in your program before deploying it.
Part 3: Deploy and Confirm Robot Code Is Running
Keep the robot disabled and its drive wheels supported off the floor.
Power on Systemcore and connect the computer using the USB or robot-network path you checked in Step 3. Confirm Driver Station communication before deploying.
Save your program and deploy using the command for your language:
Java / C++: open the WPILib command palette in VS Code and select Deploy Robot Code.
Python on Windows: run
py -3 -m robotpy deployin the project folder.Python on macOS / Linux: run
python3 -m robotpy deployin the project folder.
Watch the build and deploy output. If it reports an error, fix that error before continuing. A successful build alone does not confirm that the program reached the robot.
Check Driver Station for both robot communication and robot code running. Leave the robot disabled until you complete the checks in Part 4.
Expected result: deployment reports success, and Driver Station reports communication and robot code. If code is missing, inspect the deploy output and Driver Station log before trying to enable.
For OnBot or LabVIEW, deploy from your selected editor. The detailed Systemcore deployment walkthroughs for these paths are still being completed.
FRC Driver Station and controller checks, followed by the first teleop test.
Part 4: Test, Disable, and Check the Result
First test: robot safely elevated with every drive wheel off the floor
All team members clear of moving parts
Driver Station shows communication and robot code running
Joystick connected and recognized in DS
Driver Station reports a plausible robot battery voltage
Open FRC Driver Station
Select TeleOperated mode
Announce that the robot is about to enable, then click Enable
Apply a small forward input, then release it
Confirm both sides turn in the expected direction and stop on release
Apply a small turn input, then release it
Click Disable or press Enter before approaching the robot
The detailed Systemcore driver-software and first-drive walkthroughs are still being completed. Check the FTC overview for available instructions before proceeding with a powered test.
Warning
FRC Driver Station: the Space bar triggers Emergency Stop; it is not the ordinary disable shortcut. An emergency-stopped robot must be rebooted before it can be enabled again.
Tip
Something not working? See Troubleshooting.
Check That You Can Continue
For the FRC drive test, confirm each result before putting the robot on the floor:
The expected controller input operates the expected motor or drivetrain side.
Forward and turn directions match the example’s intended controls.
Releasing the controls stops the drive motors.
Disabling the robot stops the drive motors.
If any check fails, disable the robot before changing its code or wiring. Use the drivetrain walkthrough and troubleshooting guide to resolve the problem, then repeat the test with the wheels off the floor.
✓ First drive test complete.
Use the Command-Based framework to organize code for more mechanisms, path planning for autonomous, and simulation to test code without hardware.