Team 1288 Initial Python Code release


This is the first year team 1288 is using python for our robot. Here is our initial code going into the competition.

We only scratched the surface of what we can do with python and hope to greatly improve our coding process in the years to come! (4.2 KB) (4.2 KB)


First off, congrats. Python is a great language choice since it’s so easy to use.

I went through your code because it is always fun to see how teams do stuff differently, and I noticed a few things.

self.cameraFour = wpilib.USBCamera(b'cam3')

Did you mean to put b’cam3’?

Also, the code for gyro rotation seems awfully long. 1418 did this last year and the way we did it was

angleOffset = target_angle - self.return_gyro_angle()
if angleOffset < -1 or angleOffset > 1:
	self.rotation = angleOffset * self.angle_constant
	self.rotation = max(min(0.5, self.rotation), -0.5)

self.angle_constant was used to keep the rotation speed low. It was .04. The max(min()) code keeps the rotation in between -.5 and .5 as an extra safety precaution. Then we just pass self.rotation into the mecanum drive method to rotate.

Either now while you’re waiting for competition or during the offseason rewrite your code. It is a great way to learn, as you often think of a better way to do something. Also, look at other python teams and their code from previous years.

PS: Don’t forget to add yourselves to the 2015 RobotPy Roll Call


You guys aren’t using github are you?


Good stuff! Glad to see more people making use of python :slight_smile:

You might find that your autonomous state machines will be easier to create/read/adjust if you use the StatefulAutonomous stuff in robotpy-wpilib-utilities.