(VIDEOS) FIRST Robotics in Python - from Absolute Zero and example code

Are you new to programming but still want to write effective code for FRC?
Are you a coder for FRC robotics having trouble with Java?

It’s 2024 and switching from Java to Python has become easier than ever (and internship job market wants students with Python too).

This series of step-by-step videos can be used to train new FRC developers in Python.
Middle school or high school (we see good results in both cases).

For every video there are simple code examples that work on real robots.

Major FRC part makers started offering both Java and Python support, and we want to support your team too:

  • if you post questions under the YouTube videos, one of our students or mentors will answer, and if our answer doesn’t work immediately, at least one of our mentors is open to do WhatsApp video calls.

All you need to do is to get started!


P.S. Not 100% convinced yet?
Example of defining maximum speed in robot Constants class:

  • Java

    public static double MaxSpeed = 2.0;

  • Python

    MAX_SPEED = 2.0

(in other words, if professionals sometimes have trouble remembering where to put static, public and final, why should students suffer for no reason? let’s try Python!)

Free course link = FIRST Robotics in Python - from Absolute Zero LINK

More Questions and Feedback ? Send DM here

PS Thanks to GENE PANOV - linkedin

5 Likes

Sorry if this is the wrong place to ask, but what are the benefits of switching over from Java to Python besides code readability / general ease of writing Python? I use Python a lot primarily for data processing @ NASA and have been working with it for years now, but I always default to Java for robotics because Python is a little slow and it seems like the Python FRC software ecosystem isn’t fleshed out enough to make the switch worthwhile, especially considering the amount of open-source projects for FRC that are written in Java/C++.

3 Likes

Having mentored both python and java teams, I haven’t noticed any core usability differences between the two. Historically, python felt nicer because it had better simulation than Java but now that’s a wash.

Right now, the 2 libraries missing OSS libraries in Python are AdvantageKit and YAGSL. YAGSL for swerve is the big one, most teams just translate a team’s working swerve code from java to python; Most teams I see don’t use the replay part of AKit so that’s a wash in my book.

Speedwise, the robot defaults to a 50hz update loop which all 3 languages can hit pretty easily unless you’re really pushing it. The breakdown I’ll give is 0.5% of teams would benefit moving from Java to c++. 5% of teams would benefit moving from python to java.

2 Likes

If you really wanted to flex python, you could code some vision/object tracking. While there are good COTS solutions it’s still a good project.

Very good question @Swerve!
If I understood correctly, you have four separate concerns, let me try to answer each.

1. COMPUTER SPEED

Quiz: imagine three hypothetical robots

  • a C++ robot that takes 2ms per decision,
  • a Java robot that takes 4ms per decision,
  • a Python robot that takes 6ms per decision,

which of these robots will run faster in a real FRC game?

Answer: in practice all three robots will run equally fast, because WPILib artificially slows them all down to 50 decisions per second.
(and when RoboRIO is replaced with a faster computer, these decision times will shrink and will matter even less than now).

And yes, if you want go above 50 decisions per second, you absolutely can do what team 971 did: they don’t use WPILib. But then how come team 321 was pretty comfortable with WPILib and 50 decisions/sec and still was one of the winners this year?

2. SPEED OF DEVELOPING NEW FEATURES

Three provoking questions:

  • did your team ran out of time before they could implement a 6-note auto this year?
  • would the result be better if they had a chance to onboard more new developers sooner?
  • and would all the graduating students later thank their mentors for making them more internship-ready in today’s job market?

If you answered “yes” to any of the above… then maybe click on our videos to see if Python can help your team next year too!

3. AMOUNT OF SUPPORT AND EXAMPLES TODAY

It is 2024 now and things have changed since the beginning of RobotPy project – take a look at the long list of RobotPy examples available now:

RobotPy examples

, can you think of something important that is not covered yet?

If it looks interesting, maybe get some step-by-step practice with our videos and this will empower you to copy and paste any of the real RobotPy examples from this list above!

(kudos to all the RobotPy volunteers who have put it together over the past ~10 years)

4. AMOUNT OF SUPPORT AND EXAMPLES IN THE NEXT FEW MONTHS

The next step-by-step videos we are going to post are:

  • aiming to shoot at an AprilTag using a camera,
  • finding and picking up a gamepiece using an object detection camera (we already covered a half of this in video 8),
  • full-field localization using multiple cameras.

And I am available for video calls over WhatsApp if something isn’t working for you – I will later have a chance to put such feedback and Q&A into videos directly.

Please plan your next moves with this in mind.

1 Like

Great question @jedgar6 ! Please take a look at super simple object tracking in our video 8.
And we will add a more advanced version with aiming and shooting soon.

Short summary: challenge accepted – please see an example of realtime object tracking from Python here :wink:
(and you can uncomment the usage of YOLOv8 or replace it with YOLOv11 too).

That said, there is actually no good reason to do object tracking on RoboRIO in 2024 without leveraging a GPU or a TPU
(Why not connect a Limelight to your RoboRIO network instead? Or connect a Pi/Radxa with PhotonVision? No extra coding required in either case – your main robot program will simply receive the coordinates, confidence and type of detected object, just like it’s receiving the encoder and other sensor readings over CAN already)

sorry my comment was more directed towards @Swerve

1 Like