FIRST Robotics FRC is a high school robotics program. This repository contains the code used in the Southfield High School Team 94 (Retrojays) robot for the year 2024.
- Python 3.11: This codebase uses Python 3.11
- robotpy: Be sure to follow the robotpy instructions for the latest robotPy setup. This is largely handled by installing the project as mentioned below.
It is highly recommended that you use a python environment manager with python to help as the version of python required by pyfrc changes year over year.
- pyenv is useful for managing multiple python versions on your computer: NOTE your python version and pip
version/dependencies are highly correlated
- The most sane method for installing pyenv is using the pyenv installer
- If you are more confident, you can use
brew install pyenv
for macOS and Homebrew - On windows, you can use
scoop install pyenv
with Scoop as the closest thing to Homebrew (if you have the misfortune to be using Windows and possibly follow this page for more instructions on supporting different python versions
- If you are more confident, you can use
- The most sane method for installing pyenv is using the pyenv installer
- pipenv is useful for dependency management for this project as well
- `` to create a python 3.11 environment for this project
python -m pip install .
to setup this project in the created virtualenvpipenv shell
to enter the environment for this projectpip install tox
to install tox in the environmenttox
after that to run the tests
IDEs like Pycharm also support pipenv.
It is very important that you have updated pip to the latest version. You can do so with the command below:
# Confirm your python version in python 3
python --version
Good luck!
The robot can be reached over ethernet or local usb connection.
With the robot connected to your laptop over USB, your best bet is to attempt to connect with
# lvuser is the user where robot code is deployed, the `94` here is as programmed when flashing the roborio
ssh lvuser@roborio-94-frc.local
If you know the IP of the robot, it can be accessed at:
# note IP assignment is done dynamically through DHCP, so this IP address may
# not always be true
ssh lvuser@169.254.171.191
These steps are useful for confirming connectivity to the robot before attempting to deploy.
Robotpy provides useful commands to copy/install all .py files in the src/
folder to the robot.
RobotPy has some great robot code deployment instructions and automation.
To deploy code after being connected
python src/robot.py deploy --netconsole
-
Make sure, you have
tox
installed:pipenv install -r requirements.txt pipenv shell
-
Run the projects tests:
tox
tox
is running python src/robot.py coverage test
from RobotPy Unit Testing
If you would like to run the tests without coverage, you can execute
python src/robot.py test
And individual tests can be run by passing pytest arguments to the test
option of the pyfrc test command
python src/robot.py test -- ./tests/test_oi.py
It is often useful to test the vision processing code independently of the robot code. Especially since the
robotpy cscore SPECIFICALLY STATES THAT YOU MUST NOT IMPORT wpilib
IN VISION CODE OR VICE VERSA
Use the handy commands below to run vision code locally on your laptop
python -m cscore src/vision/vision.py:start_camera
TODO setup GitHub actions for the robot code. Examples are provided directly from the wpilib docs, setting up CI for robot code
To be soothing to your mind, the project attempts to make python/PEP formatting not an issue. Given you think you are ready to commit your code changes. Just run:
black --check .
To show which files black will reformat.
black --diff .
Shows the changes black will make, and then:
black .
will let the reformatting goodness happen. Black comes with the pipenv install -e .
of the project.