Autonomous help


We are still developing code and have a question about this year’s autonomous. We are planning to teleop during autonomous, but aren’t sure how to do that. Do we need to copy our teleop code into the autonomous section, or will it simply skip autonomous if nothing is there.


You need to put your teleop code into autonomous


Thanks. That’s what I figured, but wasn’t sure.


You do not need to copy the code. Just put it in a common method that both call or call the teleop methods (init and periodic) from the autonomous methods.

I hope this helps,


If you are using Command-based robots, the scheduler can be run from autonomous, and that will include scheduling of your default commands.

If you are relying on the periodic methods to execute your code, I would expand what @Waz said and create a matchPeriodic() method that is directly called by both teleopPeriodic() as well as autonomousPeriodic(). That way all of your code will be equally run from both sides.


We are still learning Java. How would we do that? We are not using command based.


In your autonomousInit call teleopInit();


  public void autonomousInit() {

and in autonomousPeriodic call teleopPeriodic();

  public void autonomousPeriodic() {


Thanks! So that will make everything in teleop init and periodic run during autonomous?


Yep, every time autonInit() is called (once) it will call teleopInit()
and every time autonPeriodic() is called (many many times) it will call teleopPeriodic()


Hopefully this does not confuse you more, but there is a method you can call that will run your code in autonomous and teleop. It’s called robotPeriodic() and it’s part of the Iterative Robot Base class(and inherited into the timedRobot class if you wanted to know). Here is the link to the API doc with it(shows you all the methods in ItertiveRobotBase). Pasting your code into this loop should run the same stuff in both teleop and autonomous. Hope this helps!!