Competition functions giving problems

So after adjusting some code for my bot the competition function declaration is giving me a problem. I’ve coded a drive train, and an arm lift with 4 motors on the drive and 2 on the arm so far. We have a competition tomorrow so any help asap would be appreciated!

Welcome to the forum @Aero !

We’re going to need a little more information to help you.

What exactly is the error that is being given? What does it say if you hover over the red highlight?

We made need more of your code.

You shouldn’t be modifying the main function for competition template. Like ever. Why were you changing it?

This is the original for reference:

// Main will set up the competition functions and callbacks.
int main() {
  // Set up callbacks for autonomous and driver control periods.

  // Run the pre-autonomous function.

  // Prevent main from exiting with an infinite loop.
  while (true) {
    wait(100, msec);

Thanks for the warm welcome!

So the error given is “Function definition is not allowed here”

As for why it was changed, I don’t know. The code was from our previous year’s bot program which was coded by someone else.

I just changed it back to the original competition function and it is still giving me the error.

I’ve also made a document of the code, which I can link if you’d like.

Yeah. Probably need that to do any further troubleshooting

Alrighty, here you go

Huh. Interesting.

It looks like whoever programmed this before was doing some printing inside of the main function. Probably not too bad, assuming it worked.

It appears that you don’t know exactly what you are doing with this code. Maybe I’m wrong, but you don’t seem to have the best understanding of it (Granted, I don’t have the best understanding of it either, it’s not my code). It may be better for you to just start with the blank Competition Template and use that.

As for the error, you (or whoever was programming) forgot a curly braces in driver control. There was apparently nothing wrong with main, so you could switch it back to the cool feedback code if you wanted. End of Driver should look like this:

} else {
 GoalLift.setMaxTorque(0, percent);
 wait(0.05, sec);
 wait(0.05, sec);
// End this else statement, which you did not do in your code
// ........................................................................
wait(20, msec); // Sleep the task for a short amount of time to
              // prevent wasted resources.
// These will now end the infinite loop and the usercontrol function respectively. 

Yeah, definitely. I just copied what you put and it seemed to work, had to delete the print screen stuff though because it was all marked as errors. Where would a good place for that part of the code to go?

Inside the while(true) loop that is in main.

1 Like

Ok, just did that.

Thank you so much for your help, been a real life saver.

You = Gigachad GIF - Gigachad Chad - Discover & Share GIFs

does the code work now? I still see some issues.

yeah, its working now.

I think in your usercontrol function you miss “}”. Maybe you already fixed it. You need to test the code by field control or VEXnet Competition Switch.