diff --git a/examples/stage1/solutions/ctre/src/main/java/first/robot/opmode/MyAuto.java b/examples/stage1/solutions/ctre/src/main/java/first/robot/opmode/MyAuto.java index 0e2ce26..f6f01c7 100644 --- a/examples/stage1/solutions/ctre/src/main/java/first/robot/opmode/MyAuto.java +++ b/examples/stage1/solutions/ctre/src/main/java/first/robot/opmode/MyAuto.java @@ -22,6 +22,7 @@ public MyAuto(Robot robot) { @Override public void start() { + /* Called once when the robot is enabled. */ autoTimer.restart(); // Reset the timer to zero at the start of auto } diff --git a/examples/stage1/solutions/rev/src/main/java/first/robot/Robot.java b/examples/stage1/solutions/rev/src/main/java/first/robot/Robot.java index 65dcdd6..f87db4c 100644 --- a/examples/stage1/solutions/rev/src/main/java/first/robot/Robot.java +++ b/examples/stage1/solutions/rev/src/main/java/first/robot/Robot.java @@ -17,6 +17,13 @@ import org.wpilib.hardware.imu.OnboardIMU; import org.wpilib.hardware.imu.OnboardIMU.MountOrientation; +/** + * The methods in this class are called automatically as described in the OpModeRobot documentation. + * OpMode classes anywhere in the package (or sub-packages) where this class is located are + * automatically registered to display in the Driver Station. If you change the name of this class + * or the package after creating this project, you must also update the Main.java file in the + * project. + */ public class Robot extends OpModeRobot { private SparkMax leftLeader = new SparkMax(0, 0, MotorType.kBrushless); @@ -37,8 +44,11 @@ public class Robot extends OpModeRobot { public final DifferentialDrive drivetrain = new DifferentialDrive(leftLeader::setThrottle, rightLeader::setThrottle); + /** + * This function is run when the robot is first started up and should be used for any + * initialization code. + */ public Robot() { - var leftConfig = new SparkMaxConfig().inverted(true); leftLeader.configure( leftConfig, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters); diff --git a/examples/stage1/solutions/rev/src/main/java/first/robot/opmode/MyAuto.java b/examples/stage1/solutions/rev/src/main/java/first/robot/opmode/MyAuto.java index 826a695..0e09bf7 100644 --- a/examples/stage1/solutions/rev/src/main/java/first/robot/opmode/MyAuto.java +++ b/examples/stage1/solutions/rev/src/main/java/first/robot/opmode/MyAuto.java @@ -15,18 +15,26 @@ public class MyAuto extends PeriodicOpMode { private final Robot robot; private Timer timer = new Timer(); + /** The Robot instance is passed into the opmode via the constructor. */ public MyAuto(Robot robot) { this.robot = robot; } @Override public void start() { - timer.restart(); + /* Called once when the robot is enabled. */ + timer.restart(); // Reset the timer to zero at the start of auto } + /* + * This method runs periodically, using the same period as the Robot instance. + * + * Additional periodic methods may be configured with addPeriodic(), + * which can have periods that differ from the main Robot instance. + */ @Override public void periodic() { - if (timer.hasElapsed(4)) { + if (timer.hasElapsed(4)) { // Drive for 4 seconds after the start of auto robot.drivetrain.arcadeDrive(0.0, 0.0); // Stop the robot after 4 seconds } else { robot.drivetrain.arcadeDrive(0.5, 0.0); // Drive forward at half speed with no rotation diff --git a/examples/stage1/solutions/rev/src/main/java/first/robot/opmode/MyTeleop.java b/examples/stage1/solutions/rev/src/main/java/first/robot/opmode/MyTeleop.java index 09fd6ab..94ec0e2 100644 --- a/examples/stage1/solutions/rev/src/main/java/first/robot/opmode/MyTeleop.java +++ b/examples/stage1/solutions/rev/src/main/java/first/robot/opmode/MyTeleop.java @@ -15,12 +15,14 @@ public class MyTeleop extends PeriodicOpMode { private final Robot robot; private final NiDsXboxController xboxController = new NiDsXboxController(0); + /** The Robot instance is passed into the opmode via the constructor. */ public MyTeleop(Robot robot) { this.robot = robot; } @Override public void periodic() { + /* Called periodically (set time interval) while the robot is enabled. */ robot.drivetrain.arcadeDrive(-xboxController.getLeftY(), xboxController.getRightX()); if (xboxController.getRightBumperButton()) { diff --git a/examples/stage1/templates/ctre/src/main/java/first/robot/opmode/MyAuto.java b/examples/stage1/templates/ctre/src/main/java/first/robot/opmode/MyAuto.java index e73f0c2..6d12a12 100644 --- a/examples/stage1/templates/ctre/src/main/java/first/robot/opmode/MyAuto.java +++ b/examples/stage1/templates/ctre/src/main/java/first/robot/opmode/MyAuto.java @@ -19,7 +19,9 @@ public MyAuto(Robot robot) { } @Override - public void start() {} + public void start() { + /* Called once when the robot is enabled. */ + } /* * This method runs periodically, using the same period as the Robot instance. diff --git a/examples/stage1/templates/rev/src/main/java/first/robot/Robot.java b/examples/stage1/templates/rev/src/main/java/first/robot/Robot.java index e52755b..d014eeb 100644 --- a/examples/stage1/templates/rev/src/main/java/first/robot/Robot.java +++ b/examples/stage1/templates/rev/src/main/java/first/robot/Robot.java @@ -7,8 +7,19 @@ import org.wpilib.framework.OpModeRobot; +/** + * The methods in this class are called automatically as described in the OpModeRobot documentation. + * OpMode classes anywhere in the package (or sub-packages) where this class is located are + * automatically registered to display in the Driver Station. If you change the name of this class + * or the package after creating this project, you must also update the Main.java file in the + * project. + */ public class Robot extends OpModeRobot { + /** + * This function is run when the robot is first started up and should be used for any + * initialization code. + */ public Robot() {} @Override diff --git a/examples/stage1/templates/rev/src/main/java/first/robot/opmode/MyAuto.java b/examples/stage1/templates/rev/src/main/java/first/robot/opmode/MyAuto.java index 5bd8791..6d12a12 100644 --- a/examples/stage1/templates/rev/src/main/java/first/robot/opmode/MyAuto.java +++ b/examples/stage1/templates/rev/src/main/java/first/robot/opmode/MyAuto.java @@ -13,13 +13,22 @@ public class MyAuto extends PeriodicOpMode { private final Robot robot; + /** The Robot instance is passed into the opmode via the constructor. */ public MyAuto(Robot robot) { this.robot = robot; } @Override - public void start() {} + public void start() { + /* Called once when the robot is enabled. */ + } + /* + * This method runs periodically, using the same period as the Robot instance. + * + * Additional periodic methods may be configured with addPeriodic(), + * which can have periods that differ from the main Robot instance. + */ @Override public void periodic() {} } diff --git a/examples/stage1/templates/rev/src/main/java/first/robot/opmode/MyTeleop.java b/examples/stage1/templates/rev/src/main/java/first/robot/opmode/MyTeleop.java index 312336a..e2dcd61 100644 --- a/examples/stage1/templates/rev/src/main/java/first/robot/opmode/MyTeleop.java +++ b/examples/stage1/templates/rev/src/main/java/first/robot/opmode/MyTeleop.java @@ -13,10 +13,13 @@ public class MyTeleop extends PeriodicOpMode { private final Robot robot; + /** The Robot instance is passed into the opmode via the constructor. */ public MyTeleop(Robot robot) { this.robot = robot; } @Override - public void periodic() {} + public void periodic() { + /* Called periodically (set time interval) while the robot is enabled. */ + } }