129 Seamon Rd., Farmington, ME 04938, USA
(207) 578-2202
contact@bluecrew6153.org

Getting Started with FRC Programming in Python

Getting Started with FRC Programming in Python

Welcome to the programming team on The Blue Crew. This is a guide to programming our robot using Python. This step-by-step guide will teach you how to get all of the developer tools setup on your computer in order to program the robot. This tutorial assumes that you are running a Mac computer. Linux machines should follow most of the steps below.

The Terminal

The first step to programming the robot is the terminal. For those of you who know what the terminal is and how to use it, may skip this section.

The terminal is very powerful. It allows you to execute precise commands on your computer. You should be able to either search spotlight (cmd+space) for it or find it in

/Applications/Utilities/Terminal.app

Get used to using the terminal because this will be one of two primary tools used throughout the season.

Installing the Software

In order to get our development environment setup, we will need to install a few pieces of software. If you are using a district machine, don’t worry, all of these commands don’t require admin access.

Homebrew

Homebrew is an extremely popular third-party package manager for macOS. Homebrew will allow us to install a modern version of python on your Mac. Copy and paste the following commands into a terminal window:

cd ~/
git clone https://github.com/mxcl/homebrew.git
echo "export PATH=\${HOME}/homebrew/bin:\${PATH}" >> .bash_profile
brew update

If on Mac it prompts you to install the Command Line Developer Tools, click yes and the agree. Run the commands above again.

Close terminal (cmd+q) and open it again. You can install tree just to test that it’s working.

brew install tree

Python 3

Python 3 is version 3 of the Python programming language. This is the version of Python that we will be using with the robot. Copy and paste the following commands into a terminal window:

brew install python3

This will take a while, up to an hour.

To check that it is installed and working, type:

python3 -V

RobotPy (PyFRC)

RobotPy is the library that allows our code to interface with the robot hardware. PyFRC is a suite of libraries that allow us to not only control the robot, but also implement vision processing and much more. Copy and paste the following commands into a terminal window:

pip3 install pyfrc

Visual Studio Code

This is the IDE (integrated development environment) of choice for our team. It is fast, and has excellent syntax highlighting support for Python 3. Click here to download it. Once downloaded, run the Visual Studio Code.app file to run it.

Developing the Code

There are three main types of robot code design: iterative, command, and MagicBot. Our team prefers the MagicBot design because it is Python-specific and allow us to write our code in a more Pythonic way. For information of how to program using the RobotPy library, click here for the documentation.

Writing the Code

Every year, skeleton code is used to start the design of the code. You can clone the code using Git by using the command below:

git clone https://github.com/BlueCrewRobotics/BareBonesRobot.git

To learn more about using Git, please refer to our guidelines here. In short, the only Git commands that you will need to know are as follows:

Git Add

git add -A

 

Git Commit

git commit -m "This is where you put what you updated"

 

Git Push

git push

 

These three Git commands push your code to the Git repository for safe-keeping. This is essential to keep loss of code to a minimum.

 

Deploying the Code

In order to deploy your code, cd into your directory with the robot.py file and enter the following into a terminal window:

python3 robot.py deploy

No Comments

Add your comment