Log in

View Full Version : Team Color Identification


legotech25
31-01-2009, 13:12
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.

Shinigami2057
31-01-2009, 13:18
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

DtD
31-01-2009, 14:33
Anyone know a way to trick the robot into thinking it is on red or blue for testing purposes?

~DtD

wt200999
31-01-2009, 16:13
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 ;)

byteit101
31-01-2009, 22:35
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