[wpilib] Publish AllianceStationID (#8856)

Glass now internally uses the AllianceStationID enum, but the two
separate topics remain for simple use cases. The Invalid alliance is now
published as Red, Station 0, instead of 3.

Fixes #6488 and fixes #8725.
This commit is contained in:
Gold856
2026-07-02 02:07:51 -04:00
committed by GitHub
parent 9dabcb99f3
commit 5a06b81673
4 changed files with 28 additions and 24 deletions

View File

@@ -107,6 +107,8 @@ struct MatchDataSender {
true};
MatchDataSenderEntry<wpi::nt::IntegerTopic> station{table, "StationNumber",
1};
MatchDataSenderEntry<wpi::nt::IntegerTopic> allianceStation{
table, "AllianceStationID", 0};
wpi::nt::StructPublisher<wpi::hal::ControlWord> controlWord;
wpi::nt::StringPublisher opMode;
wpi::hal::ControlWord prevControlWord;
@@ -931,10 +933,14 @@ void SendMatchData() {
isRedAlliance = true;
stationNumber = 2;
break;
default:
case HAL_ALLIANCE_STATION_RED_3:
isRedAlliance = true;
stationNumber = 3;
break;
default:
isRedAlliance = true;
stationNumber = 0;
break;
}
HAL_MatchInfo tmpDataStore;
@@ -944,14 +950,15 @@ void SendMatchData() {
HAL_GetGameData(&tmpGameData);
auto& inst = GetInstance();
inst.matchDataSender.alliance.Set(isRedAlliance);
inst.matchDataSender.station.Set(stationNumber);
inst.matchDataSender.eventName.Set(tmpDataStore.eventName);
inst.matchDataSender.gameData.Set(
std::string(reinterpret_cast<char*>(tmpGameData.gameData)));
inst.matchDataSender.matchNumber.Set(tmpDataStore.matchNumber);
inst.matchDataSender.replayNumber.Set(tmpDataStore.replayNumber);
inst.matchDataSender.matchType.Set(static_cast<int>(tmpDataStore.matchType));
inst.matchDataSender.alliance.Set(isRedAlliance);
inst.matchDataSender.station.Set(stationNumber);
inst.matchDataSender.allianceStation.Set(alliance);
hal::ControlWord ctlWord = hal::GetControlWord();
if (ctlWord != inst.matchDataSender.prevControlWord) {