OpModeRobotBase is the non-templated base class for OpModeRobot.
More...
#include <wpi/framework/OpModeRobot.hpp>
|
| void | StartCompetition () override |
| | Provide an alternate "main loop" via StartCompetition().
|
| void | EndCompetition () override |
| | Ends the main loop in StartCompetition().
|
| | OpModeRobotBase (wpi::units::second_t period) |
| | Constructor.
|
| | OpModeRobotBase () |
| | Constructor for an OpModeRobot with a default loop time of 0.02 seconds.
|
| | OpModeRobotBase (OpModeRobotBase &&)=delete |
| OpModeRobotBase & | operator= (OpModeRobotBase &&)=delete |
| virtual void | DriverStationConnected () |
| | Code that needs to know the DS state should go here.
|
| virtual void | RobotPeriodic () |
| | Function called periodically every loop, regardless of enabled state or OpMode selection.
|
| virtual void | SimulationInit () |
| | Function called once during robot initialization in simulation.
|
| virtual void | SimulationPeriodic () |
| | Function called periodically in simulation.
|
| virtual void | DisabledInit () |
| | Function called once when the robot becomes disabled.
|
| virtual void | DisabledPeriodic () |
| | Function called periodically while the robot is disabled.
|
| virtual void | DisabledExit () |
| | Function called once when the robot exits disabled state.
|
| virtual void | NonePeriodic () |
| | Function called periodically anytime when no opmode is selected, including when the Driver Station is disconnected.
|
| void | AddPeriodic (std::function< void()> callback, wpi::units::second_t period) |
| | Add a callback to run at a specific period.
|
| wpi::units::microsecond_t | GetLoopStartTime () const |
| | Return the system clock time in microseconds for the start of the current periodic loop.
|
| void | AddOpModeFactory (OpModeFactory factory, RobotMode mode, std::string_view name, std::string_view group, std::string_view description, const wpi::util::Color &textColor, const wpi::util::Color &backgroundColor) |
| | Adds an operating mode option using a factory function that creates the opmode.
|
| void | AddOpModeFactory (OpModeFactory factory, RobotMode mode, std::string_view name, std::string_view group={}, std::string_view description={}) |
| | Adds an operating mode option using a factory function that creates the opmode.
|
| void | RemoveOpMode (RobotMode mode, std::string_view name) |
| | Removes an operating mode option.
|
| void | PublishOpModes () |
| | Publishes the operating mode options to the driver station.
|
| void | ClearOpModes () |
| | Clears all operating mode options and publishes an empty list to the driver station.
|
| | RobotBase () |
| | Constructor for a generic robot program.
|
| virtual | ~RobotBase ()=default |
|
| static bool | IsEnabled () |
| | Determine if the Robot is currently enabled.
|
| static bool | IsDisabled () |
| | Determine if the Robot is currently disabled.
|
| static bool | IsAutonomous () |
| | Determine if the robot is currently in Autonomous mode.
|
| static bool | IsAutonomousEnabled () |
| | Determine if the robot is currently in Autonomous mode and enabled.
|
| static bool | IsTeleop () |
| | Determine if the robot is currently in Operator Control mode.
|
| static bool | IsTeleopEnabled () |
| | Determine if the robot is current in Operator Control mode and enabled.
|
| static bool | IsUtility () |
| | Determine if the robot is currently in Utility mode.
|
| static bool | IsUtilityEnabled () |
| | Determine if the robot is currently in Utility mode and enabled.
|
| static int64_t | GetOpModeId () |
| | Gets the currently selected operating mode of the driver station.
|
| static std::string | GetOpMode () |
| | Gets the currently selected operating mode of the driver station.
|
| 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.
|
| NT_Listener | connListenerHandle |
| static std::thread::id | m_threadId |
OpModeRobotBase is the non-templated base class for OpModeRobot.
Users should generally prefer using OpModeRobot instead of this class.
Opmodes are constructed when selected on the driver station, and destroyed when the robot is disabled after being enabled or a different opmode is selected. When no opmode is selected, NonePeriodic() is called. The DriverStationConnected() function is called the first time the driver station connects to the robot.
◆ OpModeFactory
◆ OpModeRobotBase() [1/3]
| wpi::OpModeRobotBase::OpModeRobotBase |
( |
wpi::units::second_t | period | ) |
|
|
explicit |
Constructor.
- Parameters
-
| period | The period of the robot loop function. |
◆ OpModeRobotBase() [2/3]
| wpi::OpModeRobotBase::OpModeRobotBase |
( |
| ) |
|
|
explicit |
Constructor for an OpModeRobot with a default loop time of 0.02 seconds.
◆ OpModeRobotBase() [3/3]
| wpi::OpModeRobotBase::OpModeRobotBase |
( |
OpModeRobotBase && | | ) |
|
|
delete |
◆ AddOpModeFactory() [1/2]
Adds an operating mode option using a factory function that creates the opmode.
It's necessary to call PublishOpModes() to make the added modes visible to the driver station.
- Parameters
-
| factory | factory function |
| mode | robot mode |
| name | name of the operating mode |
| group | group of the operating mode |
| description | description of the operating mode |
| textColor | text color |
| backgroundColor | background color |
◆ AddOpModeFactory() [2/2]
| void wpi::OpModeRobotBase::AddOpModeFactory |
( |
OpModeFactory | factory, |
|
|
RobotMode | mode, |
|
|
std::string_view | name, |
|
|
std::string_view | group = {}, |
|
|
std::string_view | description = {} ) |
Adds an operating mode option using a factory function that creates the opmode.
It's necessary to call PublishOpModes() to make the added modes visible to the driver station.
- Parameters
-
| factory | factory function |
| mode | robot mode |
| name | name of the operating mode |
| group | group of the operating mode |
| description | description of the operating mode |
◆ AddPeriodic()
| void wpi::OpModeRobotBase::AddPeriodic |
( |
std::function< void()> | callback, |
|
|
wpi::units::second_t | period ) |
Add a callback to run at a specific period.
- Parameters
-
| callback | The callback to run. |
| period | The period at which to run the callback. |
◆ ClearOpModes()
| void wpi::OpModeRobotBase::ClearOpModes |
( |
| ) |
|
Clears all operating mode options and publishes an empty list to the driver station.
◆ DisabledExit()
| virtual void wpi::OpModeRobotBase::DisabledExit |
( |
| ) |
|
|
inlinevirtual |
Function called once when the robot exits disabled state.
◆ DisabledInit()
| virtual void wpi::OpModeRobotBase::DisabledInit |
( |
| ) |
|
|
inlinevirtual |
Function called once when the robot becomes disabled.
◆ DisabledPeriodic()
| virtual void wpi::OpModeRobotBase::DisabledPeriodic |
( |
| ) |
|
|
inlinevirtual |
Function called periodically while the robot is disabled.
◆ DriverStationConnected()
| virtual void wpi::OpModeRobotBase::DriverStationConnected |
( |
| ) |
|
|
inlinevirtual |
Code that needs to know the DS state should go here.
Users should override this method for initialization that needs to occur after the DS is connected, such as needing the alliance information.
◆ EndCompetition()
| void wpi::OpModeRobotBase::EndCompetition |
( |
| ) |
|
|
overridevirtual |
◆ GetLoopStartTime()
| wpi::units::microsecond_t wpi::OpModeRobotBase::GetLoopStartTime |
( |
| ) |
const |
|
inline |
Return the system clock time in microseconds for the start of the current periodic loop.
This is in the same time base as Timer.getMonotonicTimeStamp(), but is stable through a loop. It is updated at the beginning of every periodic callback (including the normal periodic loop).
- Returns
- Robot running time in microseconds, as of the start of the current periodic function.
◆ LoopFunc()
| void wpi::OpModeRobotBase::LoopFunc |
( |
| ) |
|
|
protected |
Main robot loop function.
Handles disabled state logic.
◆ NonePeriodic()
| virtual void wpi::OpModeRobotBase::NonePeriodic |
( |
| ) |
|
|
inlinevirtual |
Function called periodically anytime when no opmode is selected, including when the Driver Station is disconnected.
◆ operator=()
◆ PublishOpModes()
| void wpi::OpModeRobotBase::PublishOpModes |
( |
| ) |
|
Publishes the operating mode options to the driver station.
◆ RemoveOpMode()
| void wpi::OpModeRobotBase::RemoveOpMode |
( |
RobotMode | mode, |
|
|
std::string_view | name ) |
Removes an operating mode option.
It's necessary to call PublishOpModes() to make the removed mode no longer visible to the driver station.
- Parameters
-
| mode | robot mode |
| name | name of the operating mode |
◆ RobotPeriodic()
| virtual void wpi::OpModeRobotBase::RobotPeriodic |
( |
| ) |
|
|
inlinevirtual |
Function called periodically every loop, regardless of enabled state or OpMode selection.
◆ SimulationInit()
| virtual void wpi::OpModeRobotBase::SimulationInit |
( |
| ) |
|
|
inlinevirtual |
Function called once during robot initialization in simulation.
◆ SimulationPeriodic()
| virtual void wpi::OpModeRobotBase::SimulationPeriodic |
( |
| ) |
|
|
inlinevirtual |
Function called periodically in simulation.
◆ StartCompetition()
| void wpi::OpModeRobotBase::StartCompetition |
( |
| ) |
|
|
overridevirtual |
◆ DEFAULT_PERIOD
| auto wpi::OpModeRobotBase::DEFAULT_PERIOD = 20_ms |
|
staticconstexpr |
The documentation for this class was generated from the following file: