Help with C robot example

As a mentor I’d like to set up to help our team learn the C development platform. I’ve followed the instructions but have no Default Robot Main Program.

Can you help me with what I might have missed?

My guess would be you are missing the Workbench Update. The “Getting Started with the 2012 FRC Control System” (the instructions I assume you are following) has a link to where to find it on page 3.

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…
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.

You drive forward for 5 seconds.

When do you stop?

In my experience using the C++ library (C without the wrappers), all outputs completely stop once you’re outside the code blocks. The methods are called once in simple robot when it detects it’s changed to autonomous or operator control, and control of the robot is enabled during your code blocks.

I’ll have to double check this, but either the robot drives forward for 5 seconds, then stops at the end because the autonomous program has ended, or… if it still detects autonomous, it’ll just keep on driving past the end of the block, until it detects a disable command or switching to operator control, at which point you could send new commands to the jaguars. I’ll have to recheck this today. The reason they’ve stopped before is probably a combination of below and the fact that I stop it only by disable commands.

Usually, in order to provide immediate control and switching, I simply enclose everything within the method in a while(IsAutonomous()) or while(IsOperatorControl()) loop with a Wait(.005) at the end, making sure the code runs fast and it’ll check every 5 ms to end everything.

Proper programming practice is to stop at the end of autonomous.

I believe that you will continue to drive forward until autonomous ends.

Err, I misread the original post, this isn’t asking about why there’s no main().

As to the OP, there isn’t a default main robot program, and never was, to my knowledge. When the updates are applied, what you’ll get instead are quite a few other templates, among them which includes the default factory image. This is the default program that is installed when the cRio is imaged, and you might want to start with that instead.

To apalrd, yes, I know. Laziness gets the best of us, and for a short example, I wrote a few commands to demonstrate where to put what.

I was simply missing the update that includes the programming framework. Thanks for the other suggestions as well.