WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
MatchState.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <optional>
8#include <string>
9
13
14namespace wpi {
15
16/**
17 * Provides access to match state information from the Driver Station.
18 */
19class MatchState final {
20 public:
21 MatchState() = delete;
22
23 /**
24 * Return the approximate match time. The FMS does not send an official match
25 * time to the robots, but does send an approximate match time. The value will
26 * count down the time remaining in the current period (auto or teleop).
27 * Warning: This is not an official time (so it cannot be used to dispute ref
28 * calls or guarantee that a function will trigger before the match ends).
29 *
30 * When connected to the real field, this number only changes in full integer
31 * increments, and always counts down.
32 *
33 * When the DS is in practice mode, this number is a floating point number,
34 * and counts down.
35 *
36 * When the DS is in teleop or autonomous mode, this number returns -1.0.
37 *
38 * Simulation matches DS behavior without an FMS connected.
39 *
40 * @return Time remaining in current match period (auto or teleop) in seconds
41 */
42 static wpi::units::second_t GetMatchTime() {
44 }
45
46 /**
47 * Get the current alliance from the FMS.
48 *
49 * If the FMS is not connected, it is set from the team alliance setting on
50 * the driver station.
51 *
52 * @return The alliance (red or blue) or an empty optional if the alliance is
53 * invalid
54 */
55 static std::optional<Alliance> GetAlliance() {
57 }
58
59 /**
60 * Return the driver station location from the FMS.
61 *
62 * If the FMS is not connected, it is set from the team alliance setting on
63 * the driver station.
64 *
65 * This could return 1, 2, or 3.
66 *
67 * @return The location of the driver station (1-3, 0 for invalid)
68 */
69 static std::optional<int> GetLocation() {
71 }
72
73 /**
74 * Returns the number of times the current match has been replayed from the
75 * FMS.
76 *
77 * @return The number of replays
78 */
82
83 /**
84 * Returns the match number provided by the FMS.
85 *
86 * @return The number of the match
87 */
91
92 /**
93 * Returns the type of match being played provided by the FMS.
94 *
95 * @return The match type enum (kNone, kPractice, kQualification,
96 * kElimination)
97 */
101
102 /**
103 * Returns the name of the competition event provided by the FMS.
104 *
105 * @return A string containing the event name
106 */
107 static std::string GetEventName() {
109 }
110
111 /**
112 * Returns the game specific message provided by the FMS.
113 *
114 * If the FMS is not connected, it is set from the game data setting on the
115 * driver station.
116 *
117 * @return A string containing the game specific message.
118 */
119 static std::optional<std::string> GetGameData() {
121 }
122};
123
124} // namespace wpi
static int GetReplayNumber()
Returns the number of times the current match has been replayed from the FMS.
Definition MatchState.hpp:79
static wpi::units::second_t GetMatchTime()
Return the approximate match time.
Definition MatchState.hpp:42
static std::string GetEventName()
Returns the name of the competition event provided by the FMS.
Definition MatchState.hpp:107
static std::optional< Alliance > GetAlliance()
Get the current alliance from the FMS.
Definition MatchState.hpp:55
static int GetMatchNumber()
Returns the match number provided by the FMS.
Definition MatchState.hpp:88
static MatchType GetMatchType()
Returns the type of match being played provided by the FMS.
Definition MatchState.hpp:98
static std::optional< int > GetLocation()
Return the driver station location from the FMS.
Definition MatchState.hpp:69
static std::optional< std::string > GetGameData()
Returns the game specific message provided by the FMS.
Definition MatchState.hpp:119
MatchState()=delete
static std::string GetEventName()
Returns the name of the competition event provided by the FMS.
static int GetReplayNumber()
Returns the number of times the current match has been replayed from the FMS.
static std::optional< std::string > GetGameData()
Returns the game specific message provided by the FMS.
static int GetMatchNumber()
Returns the match number provided by the FMS.
static std::optional< int > GetLocation()
Return the driver station location from the FMS.
static wpi::units::second_t GetMatchTime()
Return the approximate match time.
static std::optional< Alliance > GetAlliance()
Get the current alliance from the FMS.
static MatchType GetMatchType()
Returns the type of match being played provided by the FMS.
Definition CvSource.hpp:15
MatchType
The type of robot match that the robot is part of.
Definition MatchType.hpp:12