Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   detecting your own alliance(C++) (http://www.chiefdelphi.com/forums/showthread.php?t=71141)

Red Mage 06-01-2009 21:10

Re: detecting your own alliance(C++)
 
If only just to take rad pictures.

virtuald 07-01-2009 00:01

Re: detecting your own alliance(C++)
 
Quote:

Originally Posted by daltore (Post 793283)
Basically, constructor is the equivalent of Initialize() or IO_Initialization() of the PIC version of WPILib, except I think it runs more than once.

A constructor is a standard C++ language feature, and constructor only gets called once per created object, and only when the object is instantiated (for example, if you do a "new ObjectName()" then a new object is created and a constructor is called.. of course there are other ways to create an object also).

If you examine WPILib, the START_ROBOT_CLASS macro passes startRobotTask() a function that creates an object of your RobotBase derived class. Once it starts the robot task, it creates your object. This is only done once (or at least, only when FRC_UserProgram_StartupLibraryInit() is called).

Strictly speaking, FRC_UserProgram_StartupLibraryInit (also defined in the START_ROBOT_CLASS macro) is more like Initialize() or IO_Initialization()... but of course it gets called before your task is created and its probably not a particularly great idea to use it. :)

Shalmezad 11-01-2009 17:13

Re: detecting your own alliance(C++)
 
Inside the WPI library, look in the driverstation.cpp file.
Inside there, you'll find that there is a function to tell you what alliance you are on (also, there is one that will tell you what station you're plugged into, 1,2, or 3)

Quote:

DriverStation::Alliance DriverStation::GetAlliance()
{
if (m_controlData->dsID_Alliance == 'R') return kRed;
if (m_controlData->dsID_Alliance == 'B') return kBlue;
wpi_assert(false);
return kInvalid;
}
Have fun :cool:


All times are GMT -5. The time now is 13:41.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi