![]() |
WPILibC++ 2025.3.2
|
TimedRobot implements the IterativeRobotBase robot program framework. More...
#include <frc/TimedRobot.h>
Public Member Functions | |
| void | StartCompetition () override |
| Provide an alternate "main loop" via StartCompetition(). | |
| void | EndCompetition () override |
| Ends the main loop in StartCompetition(). | |
| TimedRobot (units::second_t period=kDefaultPeriod) | |
| Constructor for TimedRobot. | |
| TimedRobot (TimedRobot &&)=default | |
| TimedRobot & | operator= (TimedRobot &&)=default |
| ~TimedRobot () override | |
| uint64_t | GetLoopStartTime () |
| Return the system clock time in micrseconds for the start of the current periodic loop. | |
| void | AddPeriodic (std::function< void()> callback, units::second_t period, units::second_t offset=0_s) |
| Add a callback to run at a specific period with a starting time offset. | |
Public Member Functions inherited from frc::IterativeRobotBase | |
| virtual void | RobotInit () |
| Robot-wide initialization code should go here. | |
| virtual void | DriverStationConnected () |
| Code that needs to know the DS state should go here. | |
| virtual void | SimulationInit () |
| Robot-wide simulation initialization code should go here. | |
| virtual void | DisabledInit () |
| Initialization code for disabled mode should go here. | |
| virtual void | AutonomousInit () |
| Initialization code for autonomous mode should go here. | |
| virtual void | TeleopInit () |
| Initialization code for teleop mode should go here. | |
| virtual void | TestInit () |
| Initialization code for test mode should go here. | |
| virtual void | RobotPeriodic () |
| Periodic code for all modes should go here. | |
| virtual void | SimulationPeriodic () |
| Periodic simulation code should go here. | |
| virtual void | DisabledPeriodic () |
| Periodic code for disabled mode should go here. | |
| virtual void | AutonomousPeriodic () |
| Periodic code for autonomous mode should go here. | |
| virtual void | TeleopPeriodic () |
| Periodic code for teleop mode should go here. | |
| virtual void | TestPeriodic () |
| Periodic code for test mode should go here. | |
| virtual void | DisabledExit () |
| Exit code for disabled mode should go here. | |
| virtual void | AutonomousExit () |
| Exit code for autonomous mode should go here. | |
| virtual void | TeleopExit () |
| Exit code for teleop mode should go here. | |
| virtual void | TestExit () |
| Exit code for test mode should go here. | |
| void | SetNetworkTablesFlushEnabled (bool enabled) |
| Enables or disables flushing NetworkTables every loop iteration. | |
| void | EnableLiveWindowInTest (bool testLW) |
| Sets whether LiveWindow operation is enabled during test mode. | |
| bool | IsLiveWindowEnabledInTest () |
| Whether LiveWindow operation is enabled during test mode. | |
| units::second_t | GetPeriod () const |
| Gets time period between calls to Periodic() functions. | |
| void | PrintWatchdogEpochs () |
| Prints list of epochs added so far and their times. | |
| IterativeRobotBase (units::second_t period) | |
| Constructor for IterativeRobotBase. | |
| ~IterativeRobotBase () override=default | |
Public Member Functions inherited from frc::RobotBase | |
| bool | IsEnabled () const |
| Determine if the Robot is currently enabled. | |
| bool | IsDisabled () const |
| Determine if the Robot is currently disabled. | |
| bool | IsAutonomous () const |
| Determine if the robot is currently in Autonomous mode. | |
| bool | IsAutonomousEnabled () const |
| Determine if the robot is currently in Autonomous mode and enabled. | |
| bool | IsTeleop () const |
| Determine if the robot is currently in Operator Control mode. | |
| bool | IsTeleopEnabled () const |
| Determine if the robot is current in Operator Control mode and enabled. | |
| bool | IsTest () const |
| Determine if the robot is currently in Test mode. | |
| bool | IsTestEnabled () const |
| Determine if the robot is current in Test mode and enabled. | |
| RobotBase () | |
| Constructor for a generic robot program. | |
| virtual | ~RobotBase ()=default |
Static Public Attributes | |
| static constexpr auto | kDefaultPeriod = 20_ms |
| Default loop period. | |
Additional Inherited Members | |
Static Public Member Functions inherited from frc::RobotBase | |
| static std::thread::id | GetThreadId () |
| Returns the main thread ID. | |
| static RuntimeType | GetRuntimeType () |
| Get the current runtime type. | |
| static constexpr bool | IsReal () |
| Get if the robot is real. | |
| static constexpr bool | IsSimulation () |
| Get if the robot is a simulation. | |
Protected Member Functions inherited from frc::IterativeRobotBase | |
| IterativeRobotBase (IterativeRobotBase &&)=default | |
| IterativeRobotBase & | operator= (IterativeRobotBase &&)=default |
| void | LoopFunc () |
| Loop function. | |
Protected Member Functions inherited from frc::RobotBase | |
| RobotBase (RobotBase &&)=default | |
| RobotBase & | operator= (RobotBase &&)=default |
Protected Attributes inherited from frc::RobotBase | |
| NT_Listener | connListenerHandle |
| bool | m_dashboardDetected = false |
Static Protected Attributes inherited from frc::RobotBase | |
| static std::thread::id | m_threadId |
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.
|
explicit |
Constructor for TimedRobot.
| period | Period. |
|
default |
|
override |
| void frc::TimedRobot::AddPeriodic | ( | std::function< void()> | callback, |
| units::second_t | period, | ||
| units::second_t | offset = 0_s ) |
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.
| callback | The callback to run. |
| period | The period at which to run the callback. |
| offset | The offset from the common starting time. This is useful for scheduling a callback in a different timeslot relative to TimedRobot. |
|
overridevirtual |
Ends the main loop in StartCompetition().
Implements frc::RobotBase.
| uint64_t frc::TimedRobot::GetLoopStartTime | ( | ) |
Return the system clock time in micrseconds for the start of the current periodic loop.
This is in the same time base as Timer.GetFPGATimestamp(), but is stable through a loop. It is updated at the beginning of every periodic callback (including the normal periodic loop).
|
default |
|
overridevirtual |
Provide an alternate "main loop" via StartCompetition().
Implements frc::RobotBase.
|
staticconstexpr |
Default loop period.