================== Basic Auto ================== .. contents:: :local: :depth: 2 ---- Basic Auto ----------------------- We will create a simple autonomous routine that moves our robot off the starting line, thereby scoring the autonomous points. The strategy is to activate the motors so they run for 3 seconds at 60% speed. Let's begin with our `Timed Skeleton (Advanced)` project. Type the relevant lines within the `autonomousPeriodic()` function: .. code:: java :number-lines: @Override public void autonomousPeriodic() { double time = Timer.getFPGATimestamp(); if (time - startTime < 3) { leftMotor1.set(0.6); leftMotor2.set(0.6); rightMotor1.set(-0.6); rightMotor2.set(-0.6); } else { leftMotor1.set(0); leftMotor2.set(0); rightMotor1.set(0); rightMotor2.set(0); } } However, this code will not work as intended. This is because the `Timer.getFPGATimestamp()` function returns the number of seconds elapsed *since the robot was powered on*. To accurately measure the time elapsed since the start of the autonomous period, we need to modify our code as follows: .. code:: java :number-lines: public class Robot extends TimedRobot { private double startTime; @Override public void autonomousInit() { startTime = Timer.getFPGATimestamp(); } @Override public void autonomousPeriodic() { double time = Timer.getFPGATimestamp(); System.out.println(time - startTime); if (time - startTime < 3) { leftMotor1.set(0.6); leftMotor2.set(0.6); rightMotor1.set(-0.6); rightMotor2.set(-0.6); } else { leftMotor1.set(0); leftMotor2.set(0); rightMotor1.set(0); rightMotor2.set(0); } } } See more ----------------------- - FRC 0 to Autonomous: #1 Arcade drive + auto-line (YouTube)