WPILibC++ 2024.3.2
frc::RobotBase Class Referenceabstract

Implement a Robot Program framework. More...

#include <frc/RobotBase.h>

Inheritance diagram for frc::RobotBase:
frc::IterativeRobotBase frc::TimedRobot frc::TimesliceRobot

Public Member Functions

bool IsEnabled () const
 Determine if the Robot is currently enabled. More...
 
bool IsDisabled () const
 Determine if the Robot is currently disabled. More...
 
bool IsAutonomous () const
 Determine if the robot is currently in Autonomous mode. More...
 
bool IsAutonomousEnabled () const
 Determine if the robot is currently in Autonomous mode and enabled. More...
 
bool IsTeleop () const
 Determine if the robot is currently in Operator Control mode. More...
 
bool IsTeleopEnabled () const
 Determine if the robot is current in Operator Control mode and enabled. More...
 
bool IsTest () const
 Determine if the robot is currently in Test mode. More...
 
bool IsTestEnabled () const
 Determine if the robot is current in Test mode and enabled. More...
 
virtual void StartCompetition ()=0
 Start the main robot code. More...
 
virtual void EndCompetition ()=0
 Ends the main loop in StartCompetition(). More...
 
 RobotBase ()
 Constructor for a generic robot program. More...
 
virtual ~RobotBase ()=default
 

Static Public Member Functions

static std::thread::id GetThreadId ()
 Returns the main thread ID. More...
 
static RuntimeType GetRuntimeType ()
 Get the current runtime type. More...
 
static constexpr bool IsReal ()
 Get if the robot is real. More...
 
static constexpr bool IsSimulation ()
 Get if the robot is a simulation. More...
 

Protected Member Functions

 RobotBase (RobotBase &&)=default
 
RobotBaseoperator= (RobotBase &&)=default
 

Static Protected Attributes

static std::thread::id m_threadId
 

Detailed Description

Implement a Robot Program framework.

The RobotBase class is intended to be subclassed to create a robot program. The user must implement StartCompetition() which will be called once and is not expected to exit. The user must also implement EndCompetition(), which signals to the code in StartCompetition() that it should exit.

It is not recommended to subclass this class directly - instead subclass IterativeRobotBase or TimedRobot.

Constructor & Destructor Documentation

◆ RobotBase() [1/2]

frc::RobotBase::RobotBase ( )

Constructor for a generic robot program.

User code can be placed in the constructor that runs before the Autonomous or Operator Control period starts. The constructor will run to completion before Autonomous is entered.

This must be used to ensure that the communications code starts. In the future it would be nice to put this code into it's own task that loads on boot so ensure that it runs.

◆ ~RobotBase()

virtual frc::RobotBase::~RobotBase ( )
virtualdefault

◆ RobotBase() [2/2]

frc::RobotBase::RobotBase ( RobotBase &&  )
protecteddefault

Member Function Documentation

◆ EndCompetition()

virtual void frc::RobotBase::EndCompetition ( )
pure virtual

Ends the main loop in StartCompetition().

Implemented in frc::TimedRobot.

◆ GetRuntimeType()

static RuntimeType frc::RobotBase::GetRuntimeType ( )
static

Get the current runtime type.

Returns
Current runtime type.

◆ GetThreadId()

static std::thread::id frc::RobotBase::GetThreadId ( )
static

Returns the main thread ID.

Returns
The main thread ID.

◆ IsAutonomous()

bool frc::RobotBase::IsAutonomous ( ) const

Determine if the robot is currently in Autonomous mode.

Returns
True if the robot is currently operating Autonomously as determined by the Driver Station.

◆ IsAutonomousEnabled()

bool frc::RobotBase::IsAutonomousEnabled ( ) const

Determine if the robot is currently in Autonomous mode and enabled.

Returns
True if the robot us currently operating Autonomously while enabled as determined by the Driver Station.

◆ IsDisabled()

bool frc::RobotBase::IsDisabled ( ) const

Determine if the Robot is currently disabled.

Returns
True if the Robot is currently disabled by the Driver Station.

◆ IsEnabled()

bool frc::RobotBase::IsEnabled ( ) const

Determine if the Robot is currently enabled.

Returns
True if the Robot is currently enabled by the Driver Station.

◆ IsReal()

static constexpr bool frc::RobotBase::IsReal ( )
inlinestaticconstexpr

Get if the robot is real.

Returns
If the robot is running in the real world.

◆ IsSimulation()

static constexpr bool frc::RobotBase::IsSimulation ( )
inlinestaticconstexpr

Get if the robot is a simulation.

Returns
If the robot is running in simulation.

◆ IsTeleop()

bool frc::RobotBase::IsTeleop ( ) const

Determine if the robot is currently in Operator Control mode.

Returns
True if the robot is currently operating in Tele-Op mode as determined by the Driver Station.

◆ IsTeleopEnabled()

bool frc::RobotBase::IsTeleopEnabled ( ) const

Determine if the robot is current in Operator Control mode and enabled.

Returns
True if the robot is currently operating in Tele-Op mode while enabled as determined by the Driver Station.

◆ IsTest()

bool frc::RobotBase::IsTest ( ) const

Determine if the robot is currently in Test mode.

Returns
True if the robot is currently running in Test mode as determined by the Driver Station.

◆ IsTestEnabled()

bool frc::RobotBase::IsTestEnabled ( ) const

Determine if the robot is current in Test mode and enabled.

Returns
True if the robot is currently operating in Test mode while enabled as determined by the Driver Station.

◆ operator=()

RobotBase & frc::RobotBase::operator= ( RobotBase &&  )
protecteddefault

◆ StartCompetition()

virtual void frc::RobotBase::StartCompetition ( )
pure virtual

Start the main robot code.

This function will be called once and should not exit until signalled by EndCompetition()

Implemented in frc::TimedRobot.

Member Data Documentation

◆ m_threadId

std::thread::id frc::RobotBase::m_threadId
staticprotected

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