View Single Post
  #3   Spotlight this post!  
Unread 09-01-2012, 11:37
theprgramerdude theprgramerdude is offline
WPI Freshman
AKA: Alex
FRC #2503 (Warrior Robotics)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Brainerd, Minnesota
Posts: 347
theprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud of
Re: Help with C robot example

As a quick question, why not develop using C++ instead?

For developing the robot programs, there's no main method because... I'm not entirely sure why, but when using C, the WPILibrary enables you to not have to worry about game state, and do things in something akin to the main() method. The system handles all the field management sysem interfacing and checking of all other systems, and so I guess using a main method to start the program would be counter-intuitive as you'd lose all that support if you took direct control of it.

In short, the system starts up on it's own with software provided by FIRST; by including WPILib, all you need to do is provide the initialization code, and the system will automatically call the functions autonomous() and operatorControl() for you when those periods are detected, all that's needed to be done for control is put the control code per period in each code block.

I.E I would initialize two jaguars, jag1 = new CJaguar(port) or something like that, jag2...
CAutonomous(){
jag1.set(power);
jag2.set(power);
Wait(5);
}
The autonomous method is automatically called by the system, and it'll run your commands. In this case, it'll set each jaguar to the power level, and drive for 5 seconds while the user program waits to resume.
__________________
Attending: MN Duluth Regional