0

The bracket is located after int main (). This is for VEX robotics. I'm using VexCode V5 to program the Robot. This is C++. This code is to allow the robot to drive forward and backward, and also side ways using the specific kind of wheels needed. If I'm not mistaken that names of those wheels are mecanum wheels.

{
 Motor1.spin(forward);
 Motor2.spin(forward);
 Motor3.spin(forward);
 Motor4.spin(forward);

 int main ()
 {
  while(true)
   {
     // REMEMBER:
     // m1(x, y) = y + x
     // m2(x, y) = y - x
     // m3(x, y) = y + x
     // m4(x, y) = y - x

     // motor[Front_Left] = 1
     // motor[Front_Right] = 2
     // motor[Back_Right] = 3
     // motor[Back_Left] = 4

     // vexRT[Ch1] = Left/Right
     // vexRT[Ch2] = Up/Down
     // vexRT[Btn5U] = Counter-Clockwise
     // vexRT[Btn6U] Clockwise

     motor[Front_Left] = vexRT[Ch2] + vexRT[Ch1];
     motor[Front_Right] = vexRT[Ch2] - vexRT[Ch1];
     motor[Back_Right] = vexRT[Ch2] + vexRT[Ch1];
     motor[Back_Left] = vexRT[Ch2] - vexRT[Ch1];

     if (vexRT[Btn5U] == 1) {
       // rotate counter clockwise
       motor[Front_Left] = -127;
       motor[Front_Right] = 127;
       motor[Back_Right] = 127;
       motor[Back_Left] = -127;
       wait1Msec(50);
       motor[Front_Left] = motor[Front_Right] = motor[Back_Right] = motor[Back_Left] = 0;
     }
     if (vexRT[Btn6U] == 1) {
       //rotate clockwise
       motor[Front_Left] = 127;
       motor[Front_Right] = -127;
       motor[Back_Right] = -127;
       motor[Back_Left] = 127;
       wait1Msec(50);
       motor[Front_Left] = motor[Front_Right] = motor[Back_Right] = motor[Back_Left] = 0;
     }
   } //END OF WHILE LOOP
 } //END OF TASK MAIN
}
  • 2
    You seem to define the `main` function inside another function. Nested functions (functions defined inside other functions) are not allowed. – Some programmer dude Jun 30 '22 at 12:53
  • 1
    What is the code that begins with `{` and ends with `Motor4.spin(forward);` ? – drescherjm Jun 30 '22 at 12:54
  • Also, VEX is a completely separate language, loosely based on C with some C++ ideas thrown in (according to [the `vex` tag info](https://stackoverflow.com/tags/vex/info)). So which programming language are you really using? VEX or C++? – Some programmer dude Jun 30 '22 at 13:01
  • You should refer to a [good C++ book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) for this completely trivial error. You're trying to define `main` inside another function. – Jason Jun 30 '22 at 13:24

0 Answers0