Home

Awesome

pyrobottraining

This is a repository that can be used as a tool to teach you about programming an FRC robot using python and the RobotPy WPILib libraries.

Note: If you aren't very familiar with python programming, you may want to complete pybasictraining first, which will teach you the basics of programming in python.

Preparation

Install the requirements

One of the really useful things about python is that you can write code that behaves the same regardless of which platform you're running it on. As such, the challenges should function the same regardless of whether you're using Windows or OSX or Linux. However, each platform will require slightly different steps to install the necessary requirements.

OSX/Linux

You need to have the following things installed:

Windows

You need to have the following things installed:

Get the code

You need to clone this git repository somewhere on your computer. You can use eclipse to do this, or open up a terminal and run the following:

git clone https://github.com/robotpy/pyrobottraining.git

About the challenges

In the challenges section, each bullet point is a challenge you must complete. The name of the challenge is listed first, followed by the description of the challenge.

All of the challenges will involve adding code to robot.py, which is a file that could potentially be used to control a real FRC robot. You can also run your code using the pyfrc robot simulator.

Please keep in mind that there are generally many different ways you can get the challenge tests to pass, but typically each test is a simple step that builds upon the knowledge/things done in previous tests. You are encouraged to complete the tests in order.

Testing to see if you beat the challenges

The challenges currently need to be run in the terminal/command line. This means you need to open up a terminal or cmd and change directories to wherever you checked out the code.

There are two ways to run the challenges. If you think your code can beat ALL of the challenges, then you can run the tests the same way that you will run tests when you write real robot code (because this IS real robot code):

OSX/Linux: ./robot.py test
Windows:   py robot.py test

However, running all the challenges can be a bit confusing and give you a lot of errors that you don't care about when concentrating on beating the current challenge. To run a single challenge, do this instead:

OSX/Linux: ./run_single.sh CHALLENGE
Windows    run_single.bat CHALLENGE

So for example, to run challenge v1 on OSX or Linux, you would do this:

./run_single.sh v1

Whereas on Windows you would do this:

run_single.bat v1

Should be simple enough!

Documentation

Before you start creating code for the challenges, you may find it useful to read through the following resources:

Challenges

basics

At all times your robot code must pass all basic pyfrc tests, which ensure that your robot can pass through all modes without crashing. Additionally, you must document all methods and classes with docstrings.

The basic tests will only run when running all other tests, and not when running single tests.

initialization

When initializing motors and sensors in your robot code, you should do it in the robotInit method. These challenges will ask you to create a robotInit method, and create various objects in it. You may find it convenient to add additional initialization code to robotInit for other challenges.

Motor control

These challenges will require you to create code that executes when the robot is actually running -- in the teleopPeriodic method.

Simple state machines

Autonomous mode

TODO