2020 赛季 Game Data (赛场信息包) 相关细节

In the 2020 FIRST® Robotics Competition game, the Position Control objective requires alliances to select a specific color transmitted to them when specific pre-requisites have been met. The field will transmit the selected color to teams using Game Data. This page details the timing and structure of the sent data and provides examples of how to access it in the three supported programming languages.

2020赛季赛场信息包

发送时间

Color assignment data is sent to both alliances simultaneously once the first alliance in a match has reached Capacity on Stage 3 of the Shield Generator (see the Game Manual for more complete details). Between the beginning of the match and this point, the Game Data will be an empty string.

信息格式

The selected color for an alliance will be provided as a single character representing the color (i.e. ‘R’ = red, ‘G’ = green, ‘B’ = blue, ‘Y’ = yellow). This color indicates the color that must be placed underneath the Control Panel’s color sensor in order to complete the Position Control objective (see the Game Manual for information about the location of the Control Panel sensor).

Accessing the Data

The data is accessed using the Game Data methods or VIs in each language. Below are descriptions and examples of how to access the data from each of the three languages. As the data is provided to the Robot during the Teleop period, teams will likely want to query the data in Teleop periodic code, or trigger reading it off a button press or other action after they have reached Stage 3 capacity.

C++/Java

In C++ and Java the Game Data is accessed by using the GetGameSpecificMessage method of the DriverStation class. Teams likely want to query the data in a Teleop method such as Teleop Periodic in order to receive the data after it is sent during the match. Make sure to handle the case where the data is an empty string as this is what the data will be until the criteria are reached to enable Position Control for either alliance.

import edu.wpi.first.wpilibj.DriverStation;

String gameData;
gameData = DriverStation.getInstance().getGameSpecificMessage();
if(gameData.length() > 0)
{
  switch (gameData.charAt(0))
  {
    case 'B' :
      //Blue case code
      break;
    case 'G' :
      //Green case code
      break;
    case 'R' :
      //Red case code
      break;
    case 'Y' :
      //Yellow case code
      break;
    default :
      //This is corrupt data
      break;
  }
} else {
  //Code for no data received yet
}

LabVIEW

The Game Data in LabVIEW is accessed from the Game Specific Data VI. This VI can be found in the WPI Robotics Library -> Driver Station palette.

LabVIEW teams will likely want to query the data in the Teleop or PeriodicTasks VIs and may choose to gate the query behind a button press or other action. The code below reads the data and then uses a case structure to react differently to each of the 5 possible cases (empty, or any of the 4 letters).

Making a decision what to do about the game data received using a case structure.

测试赛场信息

你可以在没有FMS的情况下,使用Driver Station测试比赛特定的数据代码。单击Driver Station的设置选项卡,然后在比赛数据文本字段中输入所需的测试字符串。数据将在以下两种情况之一传输给机器人:在遥控操作模式下启用机器人,或当DS在练习赛中到达比赛结束时间时(时间可在“设置”选项卡上配置)。建议使用“实践”功能运行至少一次,以验证代码在完整比赛流程中是否能正常运行。

Game Data text box on the Driver Station.