Package edu.wpi.first.wpilibj
Class TimedRobot
java.lang.Object
edu.wpi.first.wpilibj.RobotBase
edu.wpi.first.wpilibj.IterativeRobotBase
edu.wpi.first.wpilibj.TimedRobot
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
TimesliceRobot
public class TimedRobot extends IterativeRobotBase
TimedRobot implements the IterativeRobotBase robot program framework.
The TimedRobot class is intended to be subclassed by a user creating a robot program.
periodic() functions from the base class are called on an interval by a Notifier instance.
-
Field Summary
Fields Modifier and Type Field Description static doublekDefaultPeriod -
Constructor Summary
Constructors Modifier Constructor Description protectedTimedRobot()Constructor for TimedRobot.protectedTimedRobot(double period)Constructor for TimedRobot. -
Method Summary
Modifier and Type Method Description voidaddPeriodic(Runnable callback, double periodSeconds)Add a callback to run at a specific period.voidaddPeriodic(Runnable callback, double periodSeconds, double offsetSeconds)Add a callback to run at a specific period with a starting time offset.voidendCompetition()Ends the main loop in startCompetition().protected voidfinalize()voidstartCompetition()Provide an alternate "main loop" via startCompetition().Methods inherited from class edu.wpi.first.wpilibj.IterativeRobotBase
autonomousExit, autonomousInit, autonomousPeriodic, disabledExit, disabledInit, disabledPeriodic, getPeriod, loopFunc, robotInit, robotPeriodic, setNetworkTablesFlushEnabled, simulationInit, simulationPeriodic, teleopExit, teleopInit, teleopPeriodic, testExit, testInit, testPeriodicMethods inherited from class edu.wpi.first.wpilibj.RobotBase
close, getBooleanProperty, getMainThreadId, getRuntimeType, isAutonomous, isAutonomousEnabled, isDisabled, isEnabled, isNewDataAvailable, isOperatorControl, isOperatorControlEnabled, isReal, isSimulation, isTeleop, isTeleopEnabled, isTest, startRobot, suppressExitWarning
-
Field Details
-
kDefaultPeriod
- See Also:
- Constant Field Values
-
-
Constructor Details
-
TimedRobot
protected TimedRobot()Constructor for TimedRobot. -
TimedRobot
Constructor for TimedRobot.- Parameters:
period- Period in seconds.
-
-
Method Details
-
finalize
-
startCompetition
Provide an alternate "main loop" via startCompetition().- Specified by:
startCompetitionin classIterativeRobotBase
-
endCompetition
Ends the main loop in startCompetition().- Specified by:
endCompetitionin classRobotBase
-
addPeriodic
Add a callback to run at a specific period.This is scheduled on TimedRobot's Notifier, so TimedRobot and the callback run synchronously. Interactions between them are thread-safe.
- Parameters:
callback- The callback to run.periodSeconds- The period at which to run the callback in seconds.
-
addPeriodic
Add a callback to run at a specific period with a starting time offset.This is scheduled on TimedRobot's Notifier, so TimedRobot and the callback run synchronously. Interactions between them are thread-safe.
- Parameters:
callback- The callback to run.periodSeconds- The period at which to run the callback in seconds.offsetSeconds- The offset from the common starting time in seconds. This is useful for scheduling a callback in a different timeslot relative to TimedRobot.
-