Team Color Identification

Hello all,

As far as I understand, we should receive an indicator of what team we’re on from the competition port on the Driver’s Station. Does anyone know how to access this in our programming code or if this is even possible? (we’re using c++)

Thanks,
Sarah

Edit: I found it, but I will leave this posted as a refference for other teams. The Driver Station class contains an enumerated variable called “Alliance” with the values kRed, kBlue, and kInvalid.

You can get your team color by using the DriverStation class:


DriverStation ds;

if(ds.GetAlliance() == DriverStation::kRed)
  // do something
else if(ds.GetAlliance() == DriverStation::kBlue)
  // do something else
else
  // WPI lib is broken as usual

Anyone know a way to trick the robot into thinking it is on red or blue for testing purposes?

~DtD

I wouldn’t play with the competition port at all, I would just say use a switch, and see if receiving it from the DS actually works at competition :wink:

if you know about classes, create a simple class
(this probably has bugs in it, but illustrates the point)

class FakeDriverStation :private DriverStation
{
Alliance GetAlliance(){return DriverStation::kRed;}
};

//Code 
//more code
//DriverStation DS;//make sure to uncomment this 
FakeDriverStation DS;//and comment this before competition
switch(DS.GetAlliance())
{
...

as an example