![]() |
WPILibC++ 2027.0.0-alpha-5
|
An opmode structure for periodic operation. More...
#include <wpi/opmode/PeriodicOpMode.hpp>
Public Member Functions | |
| ~PeriodicOpMode () override=default | |
| void | DisabledPeriodic () override |
| Called periodically while the opmode is selected on the DS (robot is disabled). | |
| void | Start () override |
| Called a single time when the robot transitions from disabled to enabled. | |
| void | Periodic () override |
| Called periodically while the robot is enabled. | |
| void | End () override |
| Called a single time when the robot transitions from enabled to disabled, or just before Close() is called if a different opmode is selected while the robot is enabled. | |
| std::vector< wpi::internal::PeriodicPriorityQueue::Callback > | GetCallbacks () override |
| Returns the set of additional periodic callbacks registered via AddPeriodic(). | |
| void | AddPeriodic (std::function< void()> callback, wpi::units::second_t period) |
| Add a callback to run at a specific period. | |
| void | AddPeriodic (std::function< void()> callback, wpi::units::second_t period, wpi::units::second_t offset) |
| Add a callback to run at a specific period with a starting time offset. | |
| Public Member Functions inherited from wpi::OpMode | |
| virtual | ~OpMode ()=default |
| The object is destroyed when the opmode is no longer selected on the DS or after an enabled run ends. | |
Protected Member Functions | |
| PeriodicOpMode () | |
| Constructor. | |
An opmode structure for periodic operation.
This base class implements a loop that runs one or more functions periodically (on a set time interval aka loop period). The primary periodic callback function is the abstract Periodic() function. Additional periodic callbacks with different intervals can be added using the AddPeriodic() set of functions.
Lifecycle:
|
protected |
Constructor.
|
overridedefault |
|
inline |
Add a callback to run at a specific period.
This is scheduled on the same Notifier as Periodic(), so Periodic() 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. |
| void wpi::PeriodicOpMode::AddPeriodic | ( | std::function< void()> | callback, |
| wpi::units::second_t | period, | ||
| wpi::units::second_t | offset ) |
Add a callback to run at a specific period with a starting time offset.
This is scheduled on the same Notifier as Periodic(), so Periodic() 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. |
|
inlineoverridevirtual |
Called periodically while the opmode is selected on the DS (robot is disabled).
Reimplemented from wpi::OpMode.
|
inlineoverridevirtual |
Called a single time when the robot transitions from enabled to disabled, or just before Close() is called if a different opmode is selected while the robot is enabled.
Reimplemented from wpi::OpMode.
|
inlineoverridevirtual |
Returns the set of additional periodic callbacks registered via AddPeriodic().
These are executed by the robot framework while the opmode is enabled, in addition to the primary Periodic() callback.
Reimplemented from wpi::OpMode.
|
inlineoverridevirtual |
Called periodically while the robot is enabled.
The framework calls this at OpModeRobot's configured loop period.
Reimplemented from wpi::OpMode.
|
inlineoverridevirtual |
Called a single time when the robot transitions from disabled to enabled.
This is called prior to Periodic() being called.
Reimplemented from wpi::OpMode.