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

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

#include <wpi/driverstation/MatchState.hpp>

Public Member Functions

 MatchState ()=delete

Static Public Member Functions

static wpi::units::second_t GetMatchTime ()
 Return the approximate match time.
static std::optional< AllianceGetAlliance ()
 Get the current alliance from the FMS.
static std::optional< int > GetLocation ()
 Return the driver station location from the FMS.
static int GetReplayNumber ()
 Returns the number of times the current match has been replayed from the FMS.
static int GetMatchNumber ()
 Returns the match number provided by the FMS.
static MatchType GetMatchType ()
 Returns the type of match being played provided by the FMS.
static std::string GetEventName ()
 Returns the name of the competition event provided by the FMS.
static std::optional< std::string > GetGameData ()
 Returns the game specific message provided by the FMS.

Detailed Description

Provides access to match state information from the Driver Station.

Constructor & Destructor Documentation

◆ MatchState()

wpi::MatchState::MatchState ( )
delete

Member Function Documentation

◆ GetAlliance()

std::optional< Alliance > wpi::MatchState::GetAlliance ( )
inlinestatic

Get the current alliance from the FMS.

If the FMS is not connected, it is set from the team alliance setting on the driver station.

Returns
The alliance (red or blue) or an empty optional if the alliance is invalid

◆ GetEventName()

std::string wpi::MatchState::GetEventName ( )
inlinestatic

Returns the name of the competition event provided by the FMS.

Returns
A string containing the event name

◆ GetGameData()

std::optional< std::string > wpi::MatchState::GetGameData ( )
inlinestatic

Returns the game specific message provided by the FMS.

If the FMS is not connected, it is set from the game data setting on the driver station.

Returns
A string containing the game specific message.

◆ GetLocation()

std::optional< int > wpi::MatchState::GetLocation ( )
inlinestatic

Return the driver station location from the FMS.

If the FMS is not connected, it is set from the team alliance setting on the driver station.

This could return 1, 2, or 3.

Returns
The location of the driver station (1-3, 0 for invalid)

◆ GetMatchNumber()

int wpi::MatchState::GetMatchNumber ( )
inlinestatic

Returns the match number provided by the FMS.

Returns
The number of the match

◆ GetMatchTime()

wpi::units::second_t wpi::MatchState::GetMatchTime ( )
inlinestatic

Return the approximate match time.

The FMS does not send an official match time to the robots, but does send an approximate match time. The value will count down the time remaining in the current period (auto or teleop). Warning: This is not an official time (so it cannot be used to dispute ref calls or guarantee that a function will trigger before the match ends).

When connected to the real field, this number only changes in full integer increments, and always counts down.

When the DS is in practice mode, this number is a floating point number, and counts down.

When the DS is in teleop or autonomous mode, this number returns -1.0.

Simulation matches DS behavior without an FMS connected.

Returns
Time remaining in current match period (auto or teleop) in seconds

◆ GetMatchType()

MatchType wpi::MatchState::GetMatchType ( )
inlinestatic

Returns the type of match being played provided by the FMS.

Returns
The match type enum (kNone, kPractice, kQualification, kElimination)

◆ GetReplayNumber()

int wpi::MatchState::GetReplayNumber ( )
inlinestatic

Returns the number of times the current match has been replayed from the FMS.

Returns
The number of replays

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