mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpilib] DriverStation: Change alliance station to use optional (#5229)
Many teams have issues trying to read the DS too early. By switching to an optional, we cause teams to check 2 things. Either 1) they explicitly check, and their code is correct, or 2) they just read .value() and their code reboots in a loop. However, because the DS will eventually connect, this 2nd case is ok, and should theoretically be undetectable on the field.
This commit is contained in:
@@ -129,6 +129,17 @@ TEST(DriverStationTest, AllianceStationId) {
|
||||
|
||||
auto cb = DriverStationSim::RegisterAllianceStationIdCallback(
|
||||
callback.GetCallback(), false);
|
||||
|
||||
// Unknown
|
||||
allianceStation = HAL_AllianceStationID_kUnknown;
|
||||
DriverStationSim::SetAllianceStationId(allianceStation);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId());
|
||||
EXPECT_FALSE(DriverStation::GetAlliance().has_value());
|
||||
EXPECT_FALSE(DriverStation::GetLocation().has_value());
|
||||
EXPECT_TRUE(callback.WasTriggered());
|
||||
EXPECT_EQ(allianceStation, callback.GetLastValue());
|
||||
|
||||
// B1
|
||||
allianceStation = HAL_AllianceStationID_kBlue1;
|
||||
DriverStationSim::SetAllianceStationId(allianceStation);
|
||||
|
||||
Reference in New Issue
Block a user