mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
[wpilib] Update RobotBase documentation (NFC) (#5320)
This commit is contained in:
@@ -115,14 +115,14 @@ int StartRobot() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement a Robot Program framework.
|
||||
* Implement a Robot Program framework. The RobotBase class is intended to be
|
||||
* subclassed to create a robot program. The user must implement
|
||||
* StartCompetition() which will be called once and is not expected to exit. The
|
||||
* user must also implement EndCompetition(), which signals to the code in
|
||||
* StartCompetition() that it should exit.
|
||||
*
|
||||
* 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.
|
||||
* It is not recommended to subclass this class directly - instead subclass
|
||||
* IterativeRobotBase or TimedRobot.
|
||||
*/
|
||||
class RobotBase {
|
||||
public:
|
||||
@@ -193,8 +193,13 @@ class RobotBase {
|
||||
*/
|
||||
static std::thread::id GetThreadId();
|
||||
|
||||
/**
|
||||
* Start the main robot code. This function will be called once and should not
|
||||
* exit until signalled by EndCompetition()
|
||||
*/
|
||||
virtual void StartCompetition() = 0;
|
||||
|
||||
/** Ends the main loop in StartCompetition(). */
|
||||
virtual void EndCompetition() = 0;
|
||||
|
||||
/**
|
||||
@@ -229,7 +234,7 @@ class RobotBase {
|
||||
/**
|
||||
* Constructor for a generic robot program.
|
||||
*
|
||||
* User code should be placed in the constructor that runs before the
|
||||
* 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.
|
||||
*
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user