WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::OpModeRobotBase Class Reference

OpModeRobotBase is the non-templated base class for OpModeRobot. More...

#include <wpi/framework/OpModeRobot.hpp>

Inheritance diagram for wpi::OpModeRobotBase:
wpi::RobotBase wpi::OpModeRobot< Derived >

Public Types

using OpModeFactory = std::function<std::unique_ptr<OpMode>()>

Public Member Functions

void StartCompetition () override
 Provide an alternate "main loop" via StartCompetition().
void EndCompetition () override
 Ends the main loop in StartCompetition().
 OpModeRobotBase ()=default
 Constructor.
 OpModeRobotBase (OpModeRobotBase &&)=delete
OpModeRobotBaseoperator= (OpModeRobotBase &&)=delete
virtual void DriverStationConnected ()
 Function called exactly once after the DS is connected.
virtual void NonePeriodic ()
 Function called periodically anytime when no opmode is selected, including when the Driver Station is disconnected.
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.
Public Member Functions inherited from wpi::RobotBase
 RobotBase ()
 Constructor for a generic robot program.
virtual ~RobotBase ()=default

Additional Inherited Members

Static Public Member Functions inherited from wpi::RobotBase
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 IsTest ()
 Determine if the robot is currently in Test mode.
static bool IsTestEnabled ()
 Determine if the robot is current in Test 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.
Protected Member Functions inherited from wpi::RobotBase
 RobotBase (RobotBase &&)=default
RobotBaseoperator= (RobotBase &&)=default
Protected Attributes inherited from wpi::RobotBase
NT_Listener connListenerHandle
Static Protected Attributes inherited from wpi::RobotBase
static std::thread::id m_threadId

Detailed Description

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.

Member Typedef Documentation

◆ OpModeFactory

using wpi::OpModeRobotBase::OpModeFactory = std::function<std::unique_ptr<OpMode>()>

Constructor & Destructor Documentation

◆ OpModeRobotBase() [1/2]

wpi::OpModeRobotBase::OpModeRobotBase ( )
default

Constructor.

◆ OpModeRobotBase() [2/2]

wpi::OpModeRobotBase::OpModeRobotBase ( OpModeRobotBase && )
delete

Member Function Documentation

◆ AddOpModeFactory() [1/2]

void wpi::OpModeRobotBase::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.

It's necessary to call PublishOpModes() to make the added modes visible to the driver station.

Parameters
factoryfactory function
moderobot mode
namename of the operating mode
groupgroup of the operating mode
descriptiondescription of the operating mode
textColortext color
backgroundColorbackground 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
factoryfactory function
moderobot mode
namename of the operating mode
groupgroup of the operating mode
descriptiondescription of the operating mode

◆ ClearOpModes()

void wpi::OpModeRobotBase::ClearOpModes ( )

Clears all operating mode options and publishes an empty list to the driver station.

◆ DriverStationConnected()

virtual void wpi::OpModeRobotBase::DriverStationConnected ( )
inlinevirtual

Function called exactly once after the DS is connected.

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

Ends the main loop in StartCompetition().

Implements wpi::RobotBase.

◆ NonePeriodic()

virtual void wpi::OpModeRobotBase::NonePeriodic ( )
inlinevirtual

Function called periodically anytime when no opmode is selected, including when the Driver Station is disconnected.

◆ operator=()

OpModeRobotBase & wpi::OpModeRobotBase::operator= ( OpModeRobotBase && )
delete

◆ 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
moderobot mode
namename of the operating mode

◆ StartCompetition()

void wpi::OpModeRobotBase::StartCompetition ( )
overridevirtual

Provide an alternate "main loop" via StartCompetition().

Implements wpi::RobotBase.


The documentation for this class was generated from the following file: