RobotPy MagicBot framework for Java

This is an implementation of the RobotPy MagicBot framework for Java. MagicBot is an opinionated framework for creating Python robot programs for the FIRST Robotics Competition. It is envisioned to be an easier to use and less verbose alternative to the WPILib Command framework.

If you’re not familiar with MagicBot, it’s pretty cool, and one of its features is the ability to create autonomous modes that look like this:

public class MyAutonomous extends AutonomousStateMachine {

  DriveTrain driveTrain;

  @TimedState(first=true, duration=2.5, nextState="rotate")
  public void driveForward(){
    driveTrain.move(-0.8, 0);
  @TimedState(duration=1.0, nextState="driveForwardAgain")
  public void rotate() {
    driveTrain.move(0, 0.5);
  public void driveForwardAgain() {
    driveTrain.move(-0.8, 0);

Play with it and let me know what you think! It’s not quite as full-featured as the python version of the framework, but most of the coolness is there.

Seems pretty cool! I’ll look into it when I have time.

So you’re telling me that this’ll replace the multi-hundred line switch statements? Count me in!


In fact, when (2014/robot/robot/src/common/ at master · frc1418/2014 · GitHub), one of the problems I was trying to solve was precisely this – and, you don’t have switch statements in python, so it’s even worse there.

I’ve added component magic injection to make things even simpler. Additionally, I’m now pushing jar files to which you can just copy to your ~/wpilib/user/java/lib directory and eclipse will pick it up automatically.