[wpilib] Update RobotBase documentation (NFC) (#5320)

This commit is contained in:
Ryan Blue
2023-05-13 00:29:39 -04:00
committed by GitHub
parent 218cfea16b
commit 7a90475eec
2 changed files with 28 additions and 18 deletions

View File

@@ -29,11 +29,13 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Supplier;
/**
* Implement a Robot Program framework. The RobotBase class is intended to be subclassed by a user
* creating a robot program. Overridden autonomous() and operatorControl() methods are called at the
* appropriate time as the match proceeds. In the current implementation, the Autonomous code will
* run to completion before the OperatorControl code could start. In the future the Autonomous code
* might be spawned as a task, then killed at the end of the Autonomous period.
* Implement a Robot Program framework. The RobotBase class is intended to be subclassed to create a
* robot program. The user must implement {@link #startCompetition()}, which will be called once and
* is not expected to exit. The user must also implement {@link #endCompetition()}, which signals to
* the code in {@link #startCompetition()} that it should exit.
*
* <p>It is not recommended to subclass this class directly - instead subclass IterativeRobotBase or
* TimedRobot.
*/
public abstract class RobotBase implements AutoCloseable {
/** The ID of the main Java thread. */
@@ -138,9 +140,9 @@ public abstract class RobotBase implements AutoCloseable {
}
/**
* Constructor for a generic robot program. User code should be placed in the constructor that
* runs before the Autonomous or Operator Control period starts. The constructor will run to
* completion before Autonomous is entered.
* Constructor for a generic robot program. User code can be placed in the constructor that runs
* before the Autonomous or Operator Control period starts. The constructor will run to completion
* before Autonomous is entered.
*
* <p>This must be used to ensure that the communications code starts. In the future it would be
* nice to put this code into its own task that loads on boot so ensure that it runs.
@@ -288,10 +290,13 @@ public abstract class RobotBase implements AutoCloseable {
return DriverStation.isTeleopEnabled();
}
/** Provide an alternate "main loop" via startCompetition(). */
/**
* Start the main robot code. This function will be called once and should not exit until
* signalled by {@link #endCompetition()}
*/
public abstract void startCompetition();
/** Ends the main loop in startCompetition(). */
/** Ends the main loop in {@link #startCompetition()}. */
public abstract void endCompetition();
private static final ReentrantLock m_runMutex = new ReentrantLock();