This is where the code that we will use for competitions will be stored
When setting up your environment, we recommend the usage of the Anaconda package manager alongside the PyCharm IDE and GitHub Desktop!
Firstly, we will need to install Python 3.11, you can install it from the Anaconda Package Manager or directly from python.org
Once you have installed Python onto your computer you will want to install RobotPy! To do this, we will need to open a command prompt tab with Python in the path variables of the terminal (How To With Anaconda + How To With Local Python). Once the terminal is open, execute the following code:
python -m pip install robotpy[all]
This will install the Python library named robotpy, the library FRC teams have been using since 2010 without any problems!
Now that we have installed robotpy, we need to install OpenCV and numpy. The following terminal command will install OpenCV:
python -m pip install opencv-python
The following terminal command will install numpy (using pip):
python -m pip install numpy
The following terminal command will install numpy (using anaconda):
conda install numpy
You can find the instructions on how to deploy code in Python to the robot here.
Note: Make sure that you run
robotpy syncbefore you deploy code. If this command doesn't work, trypython -m robotpy sync.
To download the code, do not download the ZIP file. Download (Github Desktop)(https://docs.github.com/en/desktop/installing-and-authenticating-to-github-desktop/installing-github-desktop) and clone the repository by clicking "Open with Github Desktop":

There are 5 easy steps to contributing!
- Find an issue to fix
- Clone the repository to your local machine using Github Desktop
- Create a branch of the repository to make your commits to
- Create a pull request to merge with the main branch and have your code reviewed by others
- Delete your branch. We don't want dead limbs on our repository tree
Here is the link to a nice tool to visualize how the branch structure works: https://learngitbranching.js.org/
When choosing an issue, make sure to read the tags and try to fufill the critical and milestone tasks first!
To ensure quality of code, we have a set of guidelines for adding new examples to the project. These guidelines are not strictly enforced, but we do ask that you follow them when submitting pull requests with new examples. This will make the review process easier for everyone involved.
- New code must run, either on the robot or the simulator provided by RobotPy
- Format your code with black (Note: Not required on pull-request drafts and branches in times of stress but, all code must be formatted before being merged into the main branch)
- Every variable not calculated by the robot must be within a Network Table v4 value
- All code is stored in the
srcfolder - We put all of our code into
robot.pyunless you are running a vision file or any code that needs to be in a different file - We use the Command Framework
- We always comment our code so that if a person from a different team sector was reading it, they would be able to read it
Main.pyis never needed, it is the same aswpilib.run(MyRobot)robot.pymust have#!/usr/bin/env python3at the beginning of the file until the end of time (or python releases version 4)- Include the license at the beginning of every file except
robot.py. The filerobot.pymust start with the line#!/usr/bin/env python3followed by the license! - Don't ever check in files for your IDE (.vscode, .idea, etc)
- Filenames should always be all lowercase
- Function names are camelCase
- Class names start with a capital letter
- Class method names are camelCase
- Class member variables such as
m_nameshould beself.namein Python - Protected/private methods/members can optionally be prefixed with
_ - The file
robot.pyis lowercase
class MyRobot(wpilib.TimedRobot):
def robotInit(self):
"""
This function is called upon program startup and
should be used for any initialization code.
"""
# --- Define NetworkTables ---
# --- Define Drive System ---
# --- Define Acuators and Manipulators ---
# --- Define Sensors ---
# --- Define Drive Kinematics and Odometry ---
# --- Define Vision ---
# --- Define Acuator and Manipulator PID ---
# --- Define Other Variables ---
# --- Define LEDs and Pretty Stuff ---
# --- Update NetworkTables ---
...class MyRobot(wpilib.TimedRobot):
...
def teleopInit(self):
"""This function is called once each time the robot enters teleoperated mode."""
# --- Set Local Variables ---
# --- Reset Local Timer ---
# --- Reset Sensors ---
# --- Update NetworkTables ---
...class MyRobot(wpilib.TimedRobot):
...
def teleopPeriodic(self):
"""This function is called periodically during teleoperated mode."""
# --- Update Variables ---
# --- Read Sensors ---
# --- Update Motor Values ---
# --- Update Vital Systems ---
# --- Update Other Systems ---
# --- Report Telemetry to NetworkTables ---
...class MyRobot(wpilib.TimedRobot):
...
def autonomousInit(self):
"""This function is run once each time the robot enters autonomous mode."""
# --- Set Local Variables ---
# --- Update NetworkTables ---
# --- Reset Local Timer ---
# --- Reset Sensors ---
# --- Update NetworkTables ---
...class MyRobot(wpilib.TimedRobot):
...
def autonomousPeriodic(self):
"""This function is called periodically during autonomous."""
# --- Update Variables ---
# --- Read Sensors ---
# --- Update Motor Values ---
# --- Update Vital Systems ---
# --- Update Other Systems ---
# --- Report Telemetry to NetworkTables ---
...