WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
wpi::RobotState Class Referencefinal

Provides access to robot state information from the Driver Station. More...

#include <wpi/driverstation/RobotState.hpp>

Public Member Functions

 RobotState ()=delete

Static Public Member Functions

static bool IsEnabled ()
 Check if the DS has enabled the robot.
static bool IsDisabled ()
 Check if the robot is disabled.
static bool IsEStopped ()
 Check if the robot is e-stopped.
static RobotMode GetRobotMode ()
 Gets the current robot mode.
static bool IsAutonomous ()
 Check if the DS is commanding autonomous mode.
static bool IsAutonomousEnabled ()
 Check if the DS is commanding autonomous mode and if it has enabled the robot.
static bool IsTeleop ()
 Check if the DS is commanding teleop mode.
static bool IsTeleopEnabled ()
 Check if the DS is commanding teleop mode and if it has enabled the robot.
static bool IsUtility ()
 Check if the DS is commanding utility mode.
static bool IsUtilityEnabled ()
 Check if the DS is commanding Utility mode and if it has enabled the robot.
static int64_t AddOpMode (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.
static int64_t AddOpMode (RobotMode mode, std::string_view name, std::string_view group={}, std::string_view description={})
 Adds an operating mode option.
static int64_t RemoveOpMode (RobotMode mode, std::string_view name)
 Removes an operating mode option.
static void PublishOpModes ()
 Publishes the operating mode options to the driver station.
static void ClearOpModes ()
 Clears all operating mode options and publishes an empty list to the driver station.
static int64_t GetOpModeId ()
 Gets the operating mode selected on the driver station.
static std::string GetOpMode ()
 Gets the operating mode selected on the driver station.
static bool IsOpMode (int64_t id)
 Check to see if the selected operating mode is a particular value.
static bool IsOpMode (std::string_view mode)
 Check to see if the selected operating mode is a particular value.
static bool IsDSAttached ()
 Check if the DS is attached.
static bool IsFMSAttached ()
 Is the driver station attached to a Field Management System?

Detailed Description

Provides access to robot state information from the Driver Station.

Constructor & Destructor Documentation

◆ RobotState()

wpi::RobotState::RobotState ( )
delete

Member Function Documentation

◆ AddOpMode() [1/2]

int64_t wpi::RobotState::AddOpMode ( RobotMode mode,
std::string_view name,
std::string_view group,
std::string_view description,
const wpi::util::Color & textColor,
const wpi::util::Color & backgroundColor )
inlinestatic

Adds an operating mode option.

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

Parameters
moderobot mode
namename of the operating mode
groupgroup of the operating mode
descriptiondescription of the operating mode
textColortext color
backgroundColorbackground color
Returns
unique ID used to later identify the operating mode; if a blank name is passed, 0 is returned; identical names for the same robot mode result in a 0 return value

◆ AddOpMode() [2/2]

int64_t wpi::RobotState::AddOpMode ( RobotMode mode,
std::string_view name,
std::string_view group = {},
std::string_view description = {} )
inlinestatic

Adds an operating mode option.

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

Parameters
moderobot mode
namename of the operating mode
groupgroup of the operating mode
descriptiondescription of the operating mode
Returns
unique ID used to later identify the operating mode; if a blank name is passed, 0 is returned; identical names for the same robot mode result in a 0 return value

◆ ClearOpModes()

void wpi::RobotState::ClearOpModes ( )
inlinestatic

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

◆ GetOpMode()

std::string wpi::RobotState::GetOpMode ( )
inlinestatic

Gets the operating mode selected on the driver station.

Note this does not mean the robot is enabled; use IsEnabled() for that. In a match, this will indicate the operating mode selected for auto before the match starts (i.e., while the robot is disabled in auto mode); after the auto period ends, this will change to reflect the operating mode selected for teleop.

Returns
Operating mode string; may return a string not in the list of options, so callers should be prepared to handle that case

◆ GetOpModeId()

int64_t wpi::RobotState::GetOpModeId ( )
inlinestatic

Gets the operating mode selected on the driver station.

Note this does not mean the robot is enabled; use IsEnabled() for that. In a match, this will indicate the operating mode selected for auto before the match starts (i.e., while the robot is disabled in auto mode); after the auto period ends, this will change to reflect the operating mode selected for teleop.

Returns
the unique ID provided by the AddOpMode() function; may return 0 or a unique ID not added, so callers should be prepared to handle that case

◆ GetRobotMode()

RobotMode wpi::RobotState::GetRobotMode ( )
inlinestatic

Gets the current robot mode.

Note that this does not indicate whether the robot is enabled or disabled.

Returns
robot mode

◆ IsAutonomous()

bool wpi::RobotState::IsAutonomous ( )
inlinestatic

Check if the DS is commanding autonomous mode.

Returns
True if the robot is being commanded to be in autonomous mode

◆ IsAutonomousEnabled()

bool wpi::RobotState::IsAutonomousEnabled ( )
inlinestatic

Check if the DS is commanding autonomous mode and if it has enabled the robot.

Returns
True if the robot is being commanded to be in autonomous mode and enabled.

◆ IsDisabled()

bool wpi::RobotState::IsDisabled ( )
inlinestatic

Check if the robot is disabled.

Returns
True if the robot is explicitly disabled or the DS is not connected

◆ IsDSAttached()

bool wpi::RobotState::IsDSAttached ( )
inlinestatic

Check if the DS is attached.

Returns
True if the DS is connected to the robot

◆ IsEnabled()

bool wpi::RobotState::IsEnabled ( )
inlinestatic

Check if the DS has enabled the robot.

Returns
True if the robot is enabled and the DS is connected

◆ IsEStopped()

bool wpi::RobotState::IsEStopped ( )
inlinestatic

Check if the robot is e-stopped.

Returns
True if the robot is e-stopped

◆ IsFMSAttached()

bool wpi::RobotState::IsFMSAttached ( )
inlinestatic

Is the driver station attached to a Field Management System?

Returns
True if the robot is competing on a field being controlled by a Field Management System

◆ IsOpMode() [1/2]

bool wpi::RobotState::IsOpMode ( int64_t id)
inlinestatic

Check to see if the selected operating mode is a particular value.

Note this does not mean the robot is enabled; use IsEnabled() for that.

Parameters
idoperating mode unique ID
Returns
True if that mode is the current mode

◆ IsOpMode() [2/2]

bool wpi::RobotState::IsOpMode ( std::string_view mode)
inlinestatic

Check to see if the selected operating mode is a particular value.

Note this does not mean the robot is enabled; use IsEnabled() for that.

Parameters
modeoperating mode
Returns
True if that mode is the current mode

◆ IsTeleop()

bool wpi::RobotState::IsTeleop ( )
inlinestatic

Check if the DS is commanding teleop mode.

Returns
True if the robot is being commanded to be in teleop mode

◆ IsTeleopEnabled()

bool wpi::RobotState::IsTeleopEnabled ( )
inlinestatic

Check if the DS is commanding teleop mode and if it has enabled the robot.

Returns
True if the robot is being commanded to be in teleop mode and enabled.

◆ IsUtility()

bool wpi::RobotState::IsUtility ( )
inlinestatic

Check if the DS is commanding utility mode.

Returns
True if the robot is being commanded to be in utility mode

◆ IsUtilityEnabled()

bool wpi::RobotState::IsUtilityEnabled ( )
inlinestatic

Check if the DS is commanding Utility mode and if it has enabled the robot.

Returns
True if the robot is being commanded to be in Utility mode and enabled.

◆ PublishOpModes()

void wpi::RobotState::PublishOpModes ( )
inlinestatic

Publishes the operating mode options to the driver station.

◆ RemoveOpMode()

int64_t wpi::RobotState::RemoveOpMode ( RobotMode mode,
std::string_view name )
inlinestatic

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
Returns
unique ID for the opmode, or 0 if not found

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