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

A wrapper around Driver Station control word. More...

#include <wpi/hal/DriverStationTypes.hpp>

Public Member Functions

 ControlWord ()=default
 Default constructor.
 ControlWord (int64_t opModeHash, RobotMode robotMode, bool enabled, bool eStop, bool fmsAttached, bool dsAttached)
 Constructs from state values.
 ControlWord (HAL_ControlWord word)
 Constructs from the native HAL value.
 ControlWord (const ControlWord &)=default
ControlWordoperator= (const ControlWord &)=default
void Update (int64_t opModeHash, RobotMode robotMode, bool enabled, bool eStop, bool fmsAttached, bool dsAttached)
 Updates from state values.
void Update (HAL_ControlWord word)
 Updates from the native HAL value.
bool IsEnabled () const
 Check if the DS has enabled the robot.
RobotMode GetRobotMode () const
 Gets the current robot mode.
int64_t GetOpModeId () const
 Gets the current opmode ID.
void SetOpModeId (int64_t id)
 Sets the opmode ID.
bool IsEStopped () const
 Check if the robot is e-stopped.
bool IsFMSAttached () const
 Is the driver station attached to a Field Management System?
bool IsDSAttached () const
 Check if the DS is attached.
bool IsAutonomous () const
 Check if the DS is commanding autonomous mode.
bool IsAutonomousEnabled () const
 Check if the DS is commanding autonomous mode and if it has enabled the robot.
bool IsTeleop () const
 Check if the DS is commanding teleop mode.
bool IsTeleopEnabled () const
 Check if the DS is commanding teleop mode and if it has enabled the robot.
bool IsTest () const
 Check if the DS is commanding test mode.
bool IsTestEnabled () const
 Check if the DS is commanding test mode and if it has enabled the robot.
HAL_ControlWord GetValue () const
 Get the HAL raw value.

Detailed Description

A wrapper around Driver Station control word.

Constructor & Destructor Documentation

◆ ControlWord() [1/4]

wpi::hal::ControlWord::ControlWord ( )
default

Default constructor.

◆ ControlWord() [2/4]

wpi::hal::ControlWord::ControlWord ( int64_t opModeHash,
RobotMode robotMode,
bool enabled,
bool eStop,
bool fmsAttached,
bool dsAttached )
inline

Constructs from state values.

Parameters
opModeHashopmode hash
robotModerobot mode
enabledenabled
eStopemergency stopped
fmsAttachedFMS attached
dsAttachedDS attached

◆ ControlWord() [3/4]

wpi::hal::ControlWord::ControlWord ( HAL_ControlWord word)
inlineexplicit

Constructs from the native HAL value.

Parameters
wordvalue

◆ ControlWord() [4/4]

wpi::hal::ControlWord::ControlWord ( const ControlWord & )
default

Member Function Documentation

◆ GetOpModeId()

int64_t wpi::hal::ControlWord::GetOpModeId ( ) const
inline

Gets the current opmode ID.

Returns
opmode

◆ GetRobotMode()

RobotMode wpi::hal::ControlWord::GetRobotMode ( ) const
inline

Gets the current robot mode.

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

Returns
robot mode

◆ GetValue()

HAL_ControlWord wpi::hal::ControlWord::GetValue ( ) const
inline

Get the HAL raw value.

Returns
Control word value

◆ IsAutonomous()

bool wpi::hal::ControlWord::IsAutonomous ( ) const
inline

Check if the DS is commanding autonomous mode.

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

◆ IsAutonomousEnabled()

bool wpi::hal::ControlWord::IsAutonomousEnabled ( ) const
inline

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.

◆ IsDSAttached()

bool wpi::hal::ControlWord::IsDSAttached ( ) const
inline

Check if the DS is attached.

Returns
True if the DS is connected to the robot

◆ IsEnabled()

bool wpi::hal::ControlWord::IsEnabled ( ) const
inline

Check if the DS has enabled the robot.

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

◆ IsEStopped()

bool wpi::hal::ControlWord::IsEStopped ( ) const
inline

Check if the robot is e-stopped.

Returns
True if the robot is e-stopped

◆ IsFMSAttached()

bool wpi::hal::ControlWord::IsFMSAttached ( ) const
inline

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

◆ IsTeleop()

bool wpi::hal::ControlWord::IsTeleop ( ) const
inline

Check if the DS is commanding teleop mode.

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

◆ IsTeleopEnabled()

bool wpi::hal::ControlWord::IsTeleopEnabled ( ) const
inline

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.

◆ IsTest()

bool wpi::hal::ControlWord::IsTest ( ) const
inline

Check if the DS is commanding test mode.

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

◆ IsTestEnabled()

bool wpi::hal::ControlWord::IsTestEnabled ( ) const
inline

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

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

◆ operator=()

ControlWord & wpi::hal::ControlWord::operator= ( const ControlWord & )
default

◆ SetOpModeId()

void wpi::hal::ControlWord::SetOpModeId ( int64_t id)
inline

Sets the opmode ID.

Parameters
idopmode ID

◆ Update() [1/2]

void wpi::hal::ControlWord::Update ( HAL_ControlWord word)
inline

Updates from the native HAL value.

Parameters
wordvalue

◆ Update() [2/2]

void wpi::hal::ControlWord::Update ( int64_t opModeHash,
RobotMode robotMode,
bool enabled,
bool eStop,
bool fmsAttached,
bool dsAttached )
inline

Updates from state values.

Parameters
opModeHashopmode hash
robotModerobot mode
enabledenabled
eStopemergency stopped
fmsAttachedFMS attached
dsAttachedDS attached

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